linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: only inherit btrfs specific flags when creating files
@ 2011-09-27 15:02 Josef Bacik
  2011-09-28  0:59 ` Liu Bo
  0 siblings, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2011-09-27 15:02 UTC (permalink / raw)
  To: linux-btrfs

Xfstests 79 was failing because we were inheriting the S_APPEND flag when we
weren't supposed to.  There isn't any specific documentation on this so I'm
taking the test as the standard of how things work, and having S_APPEND set on a
directory doesn't mean that S_APPEND gets inherited by its children according to
this test.  So only inherit btrfs specific things.  This will let us set
compress/nocompress on specific directories and everything in the directories
will inherit this flag, same with nodatacow.  With this patch test 79 passes.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 fs/btrfs/ioctl.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 24fd75b..d2b53eb 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -117,7 +117,7 @@ void btrfs_update_iflags(struct inode *inode)
 /*
  * Inherit flags from the parent inode.
  *
- * Unlike extN we don't have any flags we don't want to inherit currently.
+ * Currently only the compression flags and the cow flags are inherited.
  */
 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
 {
@@ -128,12 +128,17 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
 
 	flags = BTRFS_I(dir)->flags;
 
-	if (S_ISREG(inode->i_mode))
-		flags &= ~BTRFS_INODE_DIRSYNC;
-	else if (!S_ISDIR(inode->i_mode))
-		flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
+	if (flags & BTRFS_INODE_NOCOMPRESS) {
+		BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
+		BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
+	} else if (flags & BTRFS_INODE_COMPRESS) {
+		BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
+		BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS;
+	}
+
+	if (flags & BTRFS_INODE_NODATACOW)
+		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
 
-	BTRFS_I(inode)->flags = flags;
 	btrfs_update_iflags(inode);
 }
 
-- 
1.7.5.2


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

* Re: [PATCH] Btrfs: only inherit btrfs specific flags when creating files
  2011-09-27 15:02 [PATCH] Btrfs: only inherit btrfs specific flags when creating files Josef Bacik
@ 2011-09-28  0:59 ` Liu Bo
  2011-09-28 12:26   ` Josef Bacik
  0 siblings, 1 reply; 4+ messages in thread
From: Liu Bo @ 2011-09-28  0:59 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-btrfs

On 09/27/2011 11:02 PM, Josef Bacik wrote:
> Xfstests 79 was failing because we were inheriting the S_APPEND flag when we
> weren't supposed to.  There isn't any specific documentation on this so I'm
> taking the test as the standard of how things work, and having S_APPEND set on a
> directory doesn't mean that S_APPEND gets inherited by its children according to
> this test.  So only inherit btrfs specific things.  This will let us set
> compress/nocompress on specific directories and everything in the directories
> will inherit this flag, same with nodatacow.  With this patch test 79 passes.
> Thanks,
> 

I've checked ext3&4, they have such comments:

/* Flags that should be inherited by new inodes from their parent. */
#define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
                           EXT3_SYNC_FL | EXT3_IMMUTABLE_FL | EXT3_APPEND_FL |\
                           EXT3_NODUMP_FL | EXT3_NOATIME_FL | EXT3_COMPRBLK_FL|\
                           EXT3_NOCOMPR_FL | EXT3_JOURNAL_DATA_FL |\
                           EXT3_NOTAIL_FL | EXT3_DIRSYNC_FL)

It shows EXT[3,4]_APPEND_FL should be inherited from their parent, is this the standard?


thanks,
liubo

> Signed-off-by: Josef Bacik <josef@redhat.com>
> ---
>  fs/btrfs/ioctl.c |   17 +++++++++++------
>  1 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 24fd75b..d2b53eb 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -117,7 +117,7 @@ void btrfs_update_iflags(struct inode *inode)
>  /*
>   * Inherit flags from the parent inode.
>   *
> - * Unlike extN we don't have any flags we don't want to inherit currently.
> + * Currently only the compression flags and the cow flags are inherited.
>   */
>  void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
>  {
> @@ -128,12 +128,17 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
>  
>  	flags = BTRFS_I(dir)->flags;
>  
> -	if (S_ISREG(inode->i_mode))
> -		flags &= ~BTRFS_INODE_DIRSYNC;
> -	else if (!S_ISDIR(inode->i_mode))
> -		flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
> +	if (flags & BTRFS_INODE_NOCOMPRESS) {
> +		BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
> +		BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
> +	} else if (flags & BTRFS_INODE_COMPRESS) {
> +		BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
> +		BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS;
> +	}
> +
> +	if (flags & BTRFS_INODE_NODATACOW)
> +		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
>  
> -	BTRFS_I(inode)->flags = flags;
>  	btrfs_update_iflags(inode);
>  }
>  


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

* Re: [PATCH] Btrfs: only inherit btrfs specific flags when creating files
  2011-09-28  0:59 ` Liu Bo
@ 2011-09-28 12:26   ` Josef Bacik
  2011-09-28 14:45     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2011-09-28 12:26 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On 09/27/2011 08:59 PM, Liu Bo wrote:
> On 09/27/2011 11:02 PM, Josef Bacik wrote:
>> Xfstests 79 was failing because we were inheriting the S_APPEND flag when we
>> weren't supposed to.  There isn't any specific documentation on this so I'm
>> taking the test as the standard of how things work, and having S_APPEND set on a
>> directory doesn't mean that S_APPEND gets inherited by its children according to
>> this test.  So only inherit btrfs specific things.  This will let us set
>> compress/nocompress on specific directories and everything in the directories
>> will inherit this flag, same with nodatacow.  With this patch test 79 passes.
>> Thanks,
>>
> 
> I've checked ext3&4, they have such comments:
> 
> /* Flags that should be inherited by new inodes from their parent. */
> #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
>                            EXT3_SYNC_FL | EXT3_IMMUTABLE_FL | EXT3_APPEND_FL |\
>                            EXT3_NODUMP_FL | EXT3_NOATIME_FL | EXT3_COMPRBLK_FL|\
>                            EXT3_NOCOMPR_FL | EXT3_JOURNAL_DATA_FL |\
>                            EXT3_NOTAIL_FL | EXT3_DIRSYNC_FL)
> 
> It shows EXT[3,4]_APPEND_FL should be inherited from their parent, is this the standard?
> 

I have no idea actually, it was just failing on xfstest 79 and when I
took out the inheritance thing it passed so I took the test to be the
standard, maybe we should open this up to a wider audience.  Thanks,

Josef

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

* Re: [PATCH] Btrfs: only inherit btrfs specific flags when creating files
  2011-09-28 12:26   ` Josef Bacik
@ 2011-09-28 14:45     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2011-09-28 14:45 UTC (permalink / raw)
  To: Josef Bacik; +Cc: Liu Bo, linux-btrfs

On Wed, Sep 28, 2011 at 08:26:09AM -0400, Josef Bacik wrote:
> > 
> > It shows EXT[3,4]_APPEND_FL should be inherited from their parent, is this the standard?
> > 
> 
> I have no idea actually, it was just failing on xfstest 79 and when I
> took out the inheritance thing it passed so I took the test to be the
> standard, maybe we should open this up to a wider audience.  Thanks,

We had a little discussion on this when Stefan Behrens made this
test generic, and the conclusion was that the other filesystems should
adopt the xfs behaviour.


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

end of thread, other threads:[~2011-09-28 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 15:02 [PATCH] Btrfs: only inherit btrfs specific flags when creating files Josef Bacik
2011-09-28  0:59 ` Liu Bo
2011-09-28 12:26   ` Josef Bacik
2011-09-28 14:45     ` Christoph Hellwig

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).