Extend FIEMAP to indicate shared extents
This adds a FIEMAP extent flag, FIEMAP_EXTENT_SHARED, to indicate extents that are shared by multiple files. The second patch makes use of the same in the OCFS2 file system to show such extents in the reflinked files.
Thanks
Sunil
PATCH 1/2 fiemap: Add new extent flag FIEMAP_EXTENT_SHARED
Patch adds flag FIEMAP_EXTENT_SHARED to denote extents that are shared with other inodes.
--- include/linux/fiemap.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/fiemap.h +2 -0
@@ -62,5 +62,7 @@ struct fiemap {#define FIEMAP_EXTENT_MERGED 0x00001000/* File does not natively * support extents. Result * merged for efficiency. */ +#define FIEMAP_EXTENT_SHARED 0x00002000/* Space shared with other +* files. */ #endif /* _LINUX_FIEMAP_H */
Signature · 1 line
1.6.0.4
Re: [Ocfs2-devel] [PATCH 1/2] fiemap: Add new extent flag FIEMAP_EXTENT_SHARED
Quoted 2 lines · Sunil Mushran
Patch adds flag
FIEMAP_EXTENT_SHAREDto denote extents that are shared with other inodes.
This looks pretty sane to me. Thanks Sunil.
Quoted 1 line
Signed-off-by Sunil Mushran <[email protected]>
--Mark
--
Mark Fasheh
Re: [Ocfs2-devel] [PATCH 1/2] fiemap: Add new extent flag FIEMAP_EXTENT_SHARED
Quoted 5 lines · Mark Fasheh
Quoted 2 lines · Sunil Mushran
Patch adds flag
FIEMAP_EXTENT_SHAREDto denote extents that are shared with other inodes.This looks pretty sane to me. Thanks Sunil.
It might be better to have a flag FIEMAP_EXTENT_NOT_SHARED.
Apps which need to know the data is not shared can't safely check !(flags & FIEMAP_EXTENT_SHARED) because of old kernels which don't set the flag.
-- Jamie
Re: [Ocfs2-devel] [PATCH 1/2] fiemap: Add new extent flag FIEMAP_EXTENT_SHARED
Quoted 5 lines · Jamie Lokier
It might be better to have a flag
FIEMAP_EXTENT_NOT_SHARED.Apps which need to know the data is not shared can't safely check !(flags &
FIEMAP_EXTENT_SHARED) because of old kernels which don't set the flag.
I'm probably not understanding your point. Won't the older kernels not set FIEMAP_EXTENT_NOT_SHARED too.
If this is important, we could always add this flag in the stable kernel trees. Both sharing of extents and fiemap are relatively new to the kernel.
Re: [Ocfs2-devel] [PATCH 1/2] fiemap: Add new extent flag FIEMAP_EXTENT_SHARED
Quoted 7 lines · Sunil Mushran
Quoted 5 lines · Jamie Lokier
It might be better to have a flag
FIEMAP_EXTENT_NOT_SHARED.Apps which need to know the data is not shared can't safely check !(flags &
FIEMAP_EXTENT_SHARED) because of old kernels which don't set the flag.
Quoted 5 lines
I'm probably not understanding your point. Won't the older kernels not set
FIEMAP_EXTENT_NOT_SHAREDtoo.If this is important, we could always add this flag in the stable kernel trees. Both sharing of extents and fiemap are relatively new to the kernel.
I think the concern is that we are going to be getting "wrong" data when using an old kernel, and the question is which type of error is safer. If the flag is FIEMAP_EXTENT_SHARED, then programs running against an old kernel may think that shared extents are not shared. If the flag is instead FIEMAP_EXTENT_NOT_SHARED, then the program may think an extent is shared when it is not.
The real question is which information is more important, to know that the extent is shared or if the extent definitely is not shared. I would think that having FIEMAP_EXTENT_SHARED is more consistent with the rest of the defined bits, particularly since the program couldn't actually do anything that relies completely on this data anyway since it could change at any moment. It's not like the results of a map are static.
Brad Boyer
flar at allandria.com
PATCH 2/2 ocfs2: Use FIEMAP_EXTENT_SHARED
In reply to Sunil MushranAdds FIEMAP_EXTENT_SHARED flag to refcounted extents.
--- fs/ocfs2/extent_map.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
fs/ocfs2/extent_map.c +2 -0
@@ -786,6 +786,8 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, fe_flags =0 ;if (rec.e_flags &OCFS2_EXT_UNWRITTEN ) fe_flags |=FIEMAP_EXTENT_UNWRITTEN ; +if (rec.e_flags &OCFS2_EXT_REFCOUNTED ) + fe_flags |=FIEMAP_EXTENT_SHARED ;if (is_last) fe_flags |=FIEMAP_EXTENT_LAST ; len_bytes = (u64 )le16_to_cpu (rec.e_leaf_clusters) << osb->s_clustersize_bits;
Signature · 1 line
1.6.0.4