Re: [PATCH 1/6] Btrfs: fix a bug of per-file nocow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 31, 2012 at 01:36:54PM +0800, Liu Bo wrote:
> The new created file should not only inherit the NODATACOW flag, but also
> honor NODATASUM flag, because we must do COW on a file extent with checksum.

I was not entierly correct when suggesting to move NODATASUM to
inherit_iflags. Se below.

> 
> Signed-off-by: Liu Bo <bo.li.liu@xxxxxxxxxx>
> ---
>  fs/btrfs/inode.c |    3 +--
>  fs/btrfs/ioctl.c |    3 ++-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index b2c3514..9bce6e9 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -4720,8 +4720,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
>  	if (S_ISREG(mode)) {

Originaly it applied to regular files only.

>  		if (btrfs_test_opt(root, NODATASUM))
>  			BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
> -		if (btrfs_test_opt(root, NODATACOW) ||
> -		    (BTRFS_I(dir)->flags & BTRFS_INODE_NODATACOW))
> +		if (btrfs_test_opt(root, NODATACOW))
>  			BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
>  	}
>  
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 00ddf22..7390b25 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -141,7 +141,8 @@ void btrfs_inherit_iflags(struct inode *inode, struct inode *dir)
>  	}
>  
>  	if (flags & BTRFS_INODE_NODATACOW)
> -		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;
> +		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW |
> +					 BTRFS_INODE_NODATASUM;

But now this will happen to:

* nodes (mknod)
* directories -- NODATASUM for a dir does nothing, but does not feel
  right
* symlinks -- same
* subvolume roots -- same, and even more confusing what it does

While the fix you suggested in

http://www.mail-archive.com/linux-btrfs@xxxxxxxxxxxxxxx/msg18292.html

is simple, I'm still inclined to keep all flag inheritance at one place,
so the fix I'm proposing is to do

>  	if (flags & BTRFS_INODE_NODATACOW)
>  		BTRFS_I(inode)->flags |= BTRFS_INODE_NODATACOW;

		if (S_ISREG(inode->i_mode))
			BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM;
	}

>  
>  	btrfs_update_iflags(inode);
>  }
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux