Skip to contentSkip to conversation

ocfs2: only return the shared extents if FIEMAP_FLAG_COW is set

RFC PATCH In review Jeff Liu 2 participants 2 messages Feb 20, 2013 – Mar 2, 2013

Subsystems (2)
lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

RFC PATCH 3/3 ocfs2: only return the shared extents if FIEMAP_FLAG_COW is set

Teach OCFS2 to be aware of FIEMAP_FLAG_COW - fill the extent map array with those extents that have OCFS2_EXT_REFCOUNTED in rec.re_flags.

Cc Alexander Viro <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Dave Chinner <[email protected]>
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Jan Kara <[email protected]>
Cc Chris Mason <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 fs/ocfs2/extent_map.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/extent_map.c +10 -1
index f487aa3..1eaae3f 100644
@@ -745,7 +745,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
 	return 0;
 }
 
-#define OCFS2_FIEMAP_FLAGS	(FIEMAP_FLAG_SYNC)
+#define OCFS2_FIEMAP_FLAGS	(FIEMAP_FLAG_SYNC | FIEMAP_FLAG_COW)
 
 int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		 u64 map_start, u64 map_len)
@@ -810,11 +810,20 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		phys_bytes = le64_to_cpu(rec.e_blkno) << osb->sb->s_blocksize_bits;
 		virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits;
 
+		/*
+		 * If the FIEMAP_FLAG_COW is set, fill the fiemap_extent array
+		 * with the extents in copy-on-write state only.
+		 */
+		if ((fieinfo->fi_flags & FIEMAP_FLAG_COW) &&
+		    !(fe_flags & FIEMAP_EXTENT_SHARED))
+			goto next_map;
+
 		ret = fiemap_fill_next_extent(fieinfo, virt_bytes, phys_bytes,
 					      len_bytes, fe_flags);
 		if (ret)
 			break;
 
+next_map:
 		cpos = le32_to_cpu(rec.e_cpos)+ le16_to_cpu(rec.e_leaf_clusters);
 	}
 
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

Discussing this on another thread, but officially I'll NAK this here.

Joel

Quoted 53 lines · Jeff Liu

Teach OCFS2 to be aware of FIEMAP_FLAG_COW - fill the extent map array with those extents that have OCFS2_EXT_REFCOUNTED in rec.re_flags.

Cc Alexander Viro <[email protected]>
Cc Andreas Dilger <[email protected]>
Cc Dave Chinner <[email protected]>
Cc Mark Fasheh <[email protected]>
Cc Joel Becker <[email protected]>
Cc Jan Kara <[email protected]>
Cc Chris Mason <[email protected]>
Cc Christoph Hellwig <[email protected]>
---
 fs/ocfs2/extent_map.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/extent_map.c +10 -1
index f487aa3..1eaae3f 100644
@@ -745,7 +745,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
 	return 0;
 }
 
-#define OCFS2_FIEMAP_FLAGS	(FIEMAP_FLAG_SYNC)
+#define OCFS2_FIEMAP_FLAGS	(FIEMAP_FLAG_SYNC | FIEMAP_FLAG_COW)
 
 int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		 u64 map_start, u64 map_len)
@@ -810,11 +810,20 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		phys_bytes = le64_to_cpu(rec.e_blkno) << osb->sb->s_blocksize_bits;
 		virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits;
 
+		/*
+		 * If the FIEMAP_FLAG_COW is set, fill the fiemap_extent array
+		 * with the extents in copy-on-write state only.
+		 */
+		if ((fieinfo->fi_flags & FIEMAP_FLAG_COW) &&
+		    !(fe_flags & FIEMAP_EXTENT_SHARED))
+			goto next_map;
+
 		ret = fiemap_fill_next_extent(fieinfo, virt_bytes, phys_bytes,
 					      len_bytes, fe_flags);
 		if (ret)
 			break;
 
+next_map:
 		cpos = le32_to_cpu(rec.e_cpos)+ le16_to_cpu(rec.e_leaf_clusters);
 	}
 
Signature · 1 line
1.7.9.5
Signature · 6 lines
Life's Little Instruction Book #306

	"Take a nap on Sunday afternoons."

			http://www.jlbec.org/
			jlbec at evilplan.org