[3/6] vfs: support FS_XFLAG_REFLINK and FS_XFLAG_COWEXTSIZE
diff mbox

Message ID 147216786073.525.16014208838990530622.stgit@birch.djwong.org
State Not Applicable
Headers show

Commit Message

Darrick J. Wong Aug. 25, 2016, 11:31 p.m. UTC
Introduce XFLAGs for the new XFS reflink inode flag and the CoW extent
size hint, and actually plumb the CoW extent size hint into the fsxattr
structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 include/uapi/linux/fs.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Sept. 5, 2016, 2:56 p.m. UTC | #1
On Thu, Aug 25, 2016 at 04:31:00PM -0700, Darrick J. Wong wrote:
> Introduce XFLAGs for the new XFS reflink inode flag and the CoW extent
> size hint, and actually plumb the CoW extent size hint into the fsxattr
> structure.

Just curious, but why would we even bother to expose the reflink flag
to userspace?
Darrick J. Wong Sept. 6, 2016, 7:15 p.m. UTC | #2
On Mon, Sep 05, 2016 at 07:56:22AM -0700, Christoph Hellwig wrote:
> On Thu, Aug 25, 2016 at 04:31:00PM -0700, Darrick J. Wong wrote:
> > Introduce XFLAGs for the new XFS reflink inode flag and the CoW extent
> > size hint, and actually plumb the CoW extent size hint into the fsxattr
> > structure.
> 
> Just curious, but why would we even bother to expose the reflink flag
> to userspace?

So far I've put the reflink flag to use in xfs_scrub to look for
obvious signs of brokenness such as extents that overlap or have the
shared flag set but the inode flag is off; and to skip various kinds
of checks that don't have to happen when blocks don't overlap.

I doubt there's much of a use for the flag outside of the XFS utilities.
For a while I pondered only exposing the fsxattr flag if the caller had
CAP_SYS_ADMIN (the level of priviledge required to run scrub) but
decided that I wouldn't change the existing interface like that unless
I had a really good reason.

--D
Christoph Hellwig Sept. 11, 2016, 12:58 p.m. UTC | #3
On Tue, Sep 06, 2016 at 12:15:15PM -0700, Darrick J. Wong wrote:
> So far I've put the reflink flag to use in xfs_scrub to look for
> obvious signs of brokenness such as extents that overlap or have the
> shared flag set but the inode flag is off; and to skip various kinds
> of checks that don't have to happen when blocks don't overlap.
> 
> I doubt there's much of a use for the flag outside of the XFS utilities.
> For a while I pondered only exposing the fsxattr flag if the caller had
> CAP_SYS_ADMIN (the level of priviledge required to run scrub) but
> decided that I wouldn't change the existing interface like that unless
> I had a really good reason.

I don't think CAP_SYS_ADMIN is nessecarily the right thing, but it's
still an XFS implementation detail which I don't think we should
pollute a flags API for normal user space applications with.
Darrick J. Wong Sept. 12, 2016, 7:12 p.m. UTC | #4
On Sun, Sep 11, 2016 at 05:58:08AM -0700, Christoph Hellwig wrote:
> On Tue, Sep 06, 2016 at 12:15:15PM -0700, Darrick J. Wong wrote:
> > So far I've put the reflink flag to use in xfs_scrub to look for
> > obvious signs of brokenness such as extents that overlap or have the
> > shared flag set but the inode flag is off; and to skip various kinds
> > of checks that don't have to happen when blocks don't overlap.
> > 
> > I doubt there's much of a use for the flag outside of the XFS utilities.
> > For a while I pondered only exposing the fsxattr flag if the caller had
> > CAP_SYS_ADMIN (the level of priviledge required to run scrub) but
> > decided that I wouldn't change the existing interface like that unless
> > I had a really good reason.
> 
> I don't think CAP_SYS_ADMIN is nessecarily the right thing, but it's
> still an XFS implementation detail which I don't think we should
> pollute a flags API for normal user space applications with.

I can work around it in xfs_scrub, so I'll give back the xflag bit for
reflink.

--D

Patch
diff mbox

diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 3b00f7c..fb371a5 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -157,7 +157,8 @@  struct fsxattr {
 	__u32		fsx_extsize;	/* extsize field value (get/set)*/
 	__u32		fsx_nextents;	/* nextents field value (get)	*/
 	__u32		fsx_projid;	/* project identifier (get/set) */
-	unsigned char	fsx_pad[12];
+	__u32		fsx_cowextsize;	/* CoW extsize field value (get/set)*/
+	unsigned char	fsx_pad[8];
 };
 
 /*
@@ -178,6 +179,8 @@  struct fsxattr {
 #define FS_XFLAG_NODEFRAG	0x00002000	/* do not defragment */
 #define FS_XFLAG_FILESTREAM	0x00004000	/* use filestream allocator */
 #define FS_XFLAG_DAX		0x00008000	/* use DAX for IO */
+#define FS_XFLAG_REFLINK	0x00010000	/* file is reflinked */
+#define FS_XFLAG_COWEXTSIZE	0x00020000	/* CoW extent size allocator hint */
 #define FS_XFLAG_HASATTR	0x80000000	/* no DIFLAG for this	*/
 
 /* the read-only stuff doesn't really belong here, but any other place is