Skip to contentSkip to conversation

ocfs2: fiemap support

PATCH In review Mark Fasheh 2 participants 3 messages May 25, 2008 – May 27, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/5 ocfs2: fiemap support

Plug ocfs2 into ->fiemap. Some portions of ocfs2_get_clusters() had to be refactored so that the extent cache can be skipped in favor of going directly to the on-disk records. This makes it easier for us to determine which extent is the last one in the btree. Also, I'm not sure we want to be caching fiemap lookups anyway as they're not directly related to data read/write.

---
 fs/ocfs2/alloc.c      |    9 --
 fs/ocfs2/alloc.h      |    9 ++
 fs/ocfs2/extent_map.c |  345 +++++++++++++++++++++++++++++++++++++++++--------
 fs/ocfs2/extent_map.h |    3 +
 fs/ocfs2/file.c       |    1 +
 5 files changed, 305 insertions(+), 62 deletions(-)
fs/ocfs2/alloc.c +0 -9
index 10bfb46..29ff57e 100644
@@ -990,15 +990,6 @@ out:
 }
 
 /*
- * This is only valid for leaf nodes, which are the only ones that can
- * have empty extents anyway.
- */
-static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec)
-{
-	return !rec->e_leaf_clusters;
-}
-
-/*
  * This function will discard the rightmost extent record.
  */
 static void ocfs2_shift_records_right(struct ocfs2_extent_list *el)
fs/ocfs2/alloc.h +9 -0
index 42ff94b..60cd3d5 100644
@@ -146,4 +146,13 @@ static inline unsigned int ocfs2_rec_clusters(struct ocfs2_extent_list *el,
 		return le16_to_cpu(rec->e_leaf_clusters);
 }
 
+/*
+ * This is only valid for leaf nodes, which are the only ones that can
+ * have empty extents anyway.
+ */
+static inline int ocfs2_is_empty_extent(struct ocfs2_extent_rec *rec)
+{
+	return !rec->e_leaf_clusters;
+}
+
 #endif /* OCFS2_ALLOC_H */
fs/ocfs2/extent_map.c +292 -53

408 lines not on this page · raw message

fs/ocfs2/extent_map.h +3 -0
index de91e3e..1b97490 100644
@@ -50,4 +50,7 @@ int ocfs2_get_clusters(struct inode *inode, u32 v_cluster, u32 *p_cluster,
 int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno,
 				u64 *ret_count, unsigned int *extent_flags);
 
+int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+		 u64 map_start, u64 map_len);
+
 #endif  /* _EXTENT_MAP_H */
fs/ocfs2/file.c +1 -0
index 57e0d30..e3ed5d7 100644
@@ -2228,6 +2228,7 @@ const struct inode_operations ocfs2_file_iops = {
 	.getattr	= ocfs2_getattr,
 	.permission	= ocfs2_permission,
 	.fallocate	= ocfs2_fallocate,
+	.fiemap		= ocfs2_fiemap,
 };
 
 const struct inode_operations ocfs2_special_file_iops = {
Signature · 1 line
1.5.4.1
#1 lore raw
Quoted 5 lines · Mark Fasheh
fs/ocfs2/extent_map.c +5 -0
+int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+		 u64 map_start, u64 map_len)
+{
+	int ret, is_last;
+	u32 mapping_end, cpos;

fs/ocfs2/extent_map.c int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, · line 695

Quoted 10 lines
fs/ocfs2/extent_map.c +10 -0
+	unsigned int hole_size;
+	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	u64 len_bytes, phys_bytes, virt_bytes;
+	struct buffer_head *di_bh = NULL;
+	struct ocfs2_extent_rec rec;
+
+	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
+		fieinfo->fi_flags = FIEMAP_FLAG_XATTR;
+		return -EBADR;
+	}

This actually needs to check for every flag it DOES understand, otherwise it would break as soon as a new flag is added, per my comment in the VFS patch email.

#define OCFS2_FIEMAP_FLAG_SUPP (FIEMAP_FLAG_NUM_EXTENTS | FIEMAP_FLAG_SYNC |\
				FIEMAP_FLAG_HSM_READ | FIEMAP_FLAG_LUN_ORDER)


	if (fieinfo->fi_flags & ~OCFS2_FIEMAP_FLAG_SUPP) {
		fieinfo->fi_flags &= ~OCFS_FIEMAP_FLAG_SUPP;
		return -EBADR;
	}

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

#2 lore raw
Quoted 12 lines · Andreas Dilger
Quoted 11 lines · Mark Fasheh
fs/ocfs2/extent_map.c +11 -0
+int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
+		 u64 map_start, u64 map_len)
+{
+	int ret, is_last;
+	u32 mapping_end, cpos;
+	unsigned int hole_size;
+	struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+	u64 len_bytes, phys_bytes, virt_bytes;
+	struct buffer_head *di_bh = NULL;
+	struct ocfs2_extent_rec rec;
+
Quoted 8 lines

fs/ocfs2/extent_map.c int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno, · line 695

Quoted 4 lines
fs/ocfs2/extent_map.c +4 -0
+	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
+		fieinfo->fi_flags = FIEMAP_FLAG_XATTR;
+		return -EBADR;
+	}

This actually needs to check for every flag it DOES understand, otherwise it would break as soon as a new flag is added, per my comment in the VFS patch email.

Yeah, the feature checks in the existing per-fs patches are lacking. This will be fixed in the next round.

	--Mark

--
Mark Fasheh