linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] make the feature checks in ->fallocate future proof
@ 2011-01-14 12:07 Christoph Hellwig
  2011-01-14 13:05 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2011-01-14 12:07 UTC (permalink / raw)
  To: viro, josef; +Cc: linux-fsdevel

Instead of various home grown checks that might need updates for new
flags just check for any bit outside the mask of the features supported
by the filesystem.  This makes the check future proof for any newly
added flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/fs/btrfs/inode.c
===================================================================
--- linux-2.6.orig/fs/btrfs/inode.c	2011-01-14 10:50:03.578004699 +0100
+++ linux-2.6/fs/btrfs/inode.c	2011-01-14 12:58:25.669254316 +0100
@@ -7116,7 +7116,7 @@ static long btrfs_fallocate(struct inode
 	alloc_end =  (offset + len + mask) & ~mask;
 
 	/* We only support the FALLOC_FL_KEEP_SIZE mode */
-	if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+	if (mode & ~FALLOC_FL_KEEP_SIZE)
 		return -EOPNOTSUPP;
 
 	/*
Index: linux-2.6/fs/ext4/extents.c
===================================================================
--- linux-2.6.orig/fs/ext4/extents.c	2011-01-14 10:50:03.549004630 +0100
+++ linux-2.6/fs/ext4/extents.c	2011-01-14 12:58:25.662254106 +0100
@@ -3645,7 +3645,7 @@ long ext4_fallocate(struct inode *inode,
 	unsigned int credits, blkbits = inode->i_blkbits;
 
 	/* We only support the FALLOC_FL_KEEP_SIZE mode */
-	if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+	if (mode & ~FALLOC_FL_KEEP_SIZE)
 		return -EOPNOTSUPP;
 
 	/*
Index: linux-2.6/fs/gfs2/ops_inode.c
===================================================================
--- linux-2.6.orig/fs/gfs2/ops_inode.c	2011-01-14 10:50:03.524003582 +0100
+++ linux-2.6/fs/gfs2/ops_inode.c	2011-01-14 12:58:25.695253687 +0100
@@ -1426,7 +1426,7 @@ static long gfs2_fallocate(struct inode
 	next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
 
 	/* We only support the FALLOC_FL_KEEP_SIZE mode */
-	if (mode && (mode != FALLOC_FL_KEEP_SIZE))
+	if (mode & ~FALLOC_FL_KEEP_SIZE)
 		return -EOPNOTSUPP;
 
 	offset = (offset >> sdp->sd_sb.sb_bsize_shift) <<
Index: linux-2.6/fs/ocfs2/file.c
===================================================================
--- linux-2.6.orig/fs/ocfs2/file.c	2011-01-14 10:50:03.492003442 +0100
+++ linux-2.6/fs/ocfs2/file.c	2011-01-14 12:58:25.687254176 +0100
@@ -1997,6 +1997,8 @@ static long ocfs2_fallocate(struct inode
 	int change_size = 1;
 	int cmd = OCFS2_IOC_RESVSP64;
 
+	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+		return -EOPNOTSUPP;
 	if (!ocfs2_writes_unwritten_extents(osb))
 		return -EOPNOTSUPP;
 
Index: linux-2.6/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_iops.c	2011-01-14 10:50:03.458004420 +0100
+++ linux-2.6/fs/xfs/linux-2.6/xfs_iops.c	2011-01-14 12:58:25.615254176 +0100
@@ -518,6 +518,9 @@ xfs_vn_fallocate(
 	xfs_inode_t	*ip = XFS_I(inode);
 	int		cmd = XFS_IOC_RESVSP;
 
+	if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE))
+		return -EOPNOTSUPP;
+
 	/* preallocation on directories not yet supported */
 	error = -ENODEV;
 	if (S_ISDIR(inode->i_mode))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] make the feature checks in ->fallocate future proof
  2011-01-14 12:07 [PATCH 1/2] make the feature checks in ->fallocate future proof Christoph Hellwig
@ 2011-01-14 13:05 ` Josef Bacik
  0 siblings, 0 replies; 2+ messages in thread
From: Josef Bacik @ 2011-01-14 13:05 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: viro, josef, linux-fsdevel

On Fri, Jan 14, 2011 at 01:07:30PM +0100, Christoph Hellwig wrote:
> Instead of various home grown checks that might need updates for new
> flags just check for any bit outside the mask of the features supported
> by the filesystem.  This makes the check future proof for any newly
> added flag.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 

Reviewed-by: Josef Bacik <josef@redhat.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-01-14 13:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-14 12:07 [PATCH 1/2] make the feature checks in ->fallocate future proof Christoph Hellwig
2011-01-14 13:05 ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).