linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] fs: remove FS_COW_FL
@ 2011-04-15  3:02 Li Zefan
  2011-04-15  3:03 ` [PATCH 2/3] Btrfs: fix FS_IOC_GETFLAGS ioctl Li Zefan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Li Zefan @ 2011-04-15  3:02 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, linux-fsdevel, LKML

FS_COW_FL and FS_NOCOW_FL were newly introduced to control per file
COW in btrfs, but FS_NOCOW_FL is sufficient.

The fact is we don't have corresponding BTRFS_INODE_COW flag.

COW is default, and FS_NOCOW_FL can be used to switch off COW for
a single file.

If we mount btrfs with nodatacow, a newly created file will be set with
the FS_NOCOW_FL flag. So to turn on COW for it, we can just clear the
FS_NOCOW_FL flag.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c   |   15 ++++++---------
 include/linux/fs.h |    1 -
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f580a3a..3240dd9 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -144,16 +144,13 @@ static int check_flags(unsigned int flags)
 	if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
 		      FS_NOATIME_FL | FS_NODUMP_FL | \
 		      FS_SYNC_FL | FS_DIRSYNC_FL | \
-		      FS_NOCOMP_FL | FS_COMPR_FL | \
-		      FS_NOCOW_FL | FS_COW_FL))
+		      FS_NOCOMP_FL | FS_COMPR_FL |
+		      FS_NOCOW_FL))
 		return -EOPNOTSUPP;
 
 	if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL))
 		return -EINVAL;
 
-	if ((flags & FS_NOCOW_FL) && (flags & FS_COW_FL))
-		return -EINVAL;
-
 	return 0;
 }
 
@@ -218,6 +215,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 		ip->flags |= BTRFS_INODE_DIRSYNC;
 	else
 		ip->flags &= ~BTRFS_INODE_DIRSYNC;
+	if (flags & FS_NOCOW_FL)
+		ip->flags |= BTRFS_INODE_NODATACOW;
+	else
+		ip->flags &= ~BTRFS_INODE_NODATACOW;
 
 	/*
 	 * The COMPRESS flag can only be changed by users, while the NOCOMPRESS
@@ -231,10 +232,6 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 		ip->flags |= BTRFS_INODE_COMPRESS;
 		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
 	}
-	if (flags & FS_NOCOW_FL)
-		ip->flags |= BTRFS_INODE_NODATACOW;
-	else if (flags & FS_COW_FL)
-		ip->flags &= ~BTRFS_INODE_NODATACOW;
 
 	trans = btrfs_join_transaction(root, 1);
 	BUG_ON(IS_ERR(trans));
diff --git a/include/linux/fs.h b/include/linux/fs.h
index de9dd81..56a4141 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -365,7 +365,6 @@ struct inodes_stat_t {
 #define FS_EXTENT_FL			0x00080000 /* Extents */
 #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
 #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
-#define FS_COW_FL			0x02000000 /* Cow file */
 #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
 
 #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */
-- 
1.7.3.1

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

* [PATCH 2/3] Btrfs: fix FS_IOC_GETFLAGS ioctl
  2011-04-15  3:02 [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
@ 2011-04-15  3:03 ` Li Zefan
  2011-04-15  3:03 ` [PATCH 3/3] Btrfs: fix FS_IOC_SETFLAGS ioctl Li Zefan
  2011-05-03  9:11 ` [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
  2 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2011-04-15  3:03 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, linux-fsdevel, LKML

As we've added per file compression/cow support.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 3240dd9..aeabf6b 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -81,6 +81,13 @@ static unsigned int btrfs_flags_to_ioctl(unsigned int flags)
 		iflags |= FS_NOATIME_FL;
 	if (flags & BTRFS_INODE_DIRSYNC)
 		iflags |= FS_DIRSYNC_FL;
+	if (flags & BTRFS_INODE_NODATACOW)
+		iflags |= FS_NOCOW_FL;
+
+	if ((flags & BTRFS_INODE_COMPRESS) && !(flags & BTRFS_INODE_NOCOMPRESS))
+		iflags |= FS_COMPR_FL;
+	else if (flags & BTRFS_INODE_NOCOMPRESS)
+		iflags |= FS_NOCOMP_FL;
 
 	return iflags;
 }
-- 
1.7.3.1

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

* [PATCH 3/3] Btrfs: fix FS_IOC_SETFLAGS ioctl
  2011-04-15  3:02 [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
  2011-04-15  3:03 ` [PATCH 2/3] Btrfs: fix FS_IOC_GETFLAGS ioctl Li Zefan
@ 2011-04-15  3:03 ` Li Zefan
  2011-05-03  9:11 ` [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
  2 siblings, 0 replies; 5+ messages in thread
From: Li Zefan @ 2011-04-15  3:03 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, linux-fsdevel, LKML

Steps to reproduce the bug:

  - Call FS_IOC_SETLFAGS ioctl with flags=FS_COMPR_FL
  - Call FS_IOC_SETFLAGS ioctl with flags=0
  - Call FS_IOC_GETFLAGS ioctl, and you'll see FS_COMPR_FL is still set!

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 fs/btrfs/ioctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index aeabf6b..3e7031d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -238,6 +238,8 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
 	} else if (flags & FS_COMPR_FL) {
 		ip->flags |= BTRFS_INODE_COMPRESS;
 		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
+	} else {
+		ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
 	}
 
 	trans = btrfs_join_transaction(root, 1);
-- 
1.7.3.1

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

* Re: [PATCH 1/3] fs: remove FS_COW_FL
  2011-04-15  3:02 [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
  2011-04-15  3:03 ` [PATCH 2/3] Btrfs: fix FS_IOC_GETFLAGS ioctl Li Zefan
  2011-04-15  3:03 ` [PATCH 3/3] Btrfs: fix FS_IOC_SETFLAGS ioctl Li Zefan
@ 2011-05-03  9:11 ` Li Zefan
  2011-05-03 11:20   ` Chris Mason
  2 siblings, 1 reply; 5+ messages in thread
From: Li Zefan @ 2011-05-03  9:11 UTC (permalink / raw)
  To: linux-btrfs@vger.kernel.org; +Cc: Chris Mason, linux-fsdevel, LKML

Any comments? If this patch is acceptable, it should be queued for .39?
since fs.h is exported to userspace.

Li Zefan wrote:
> FS_COW_FL and FS_NOCOW_FL were newly introduced to control per file
> COW in btrfs, but FS_NOCOW_FL is sufficient.
> 
> The fact is we don't have corresponding BTRFS_INODE_COW flag.
> 
> COW is default, and FS_NOCOW_FL can be used to switch off COW for
> a single file.
> 
> If we mount btrfs with nodatacow, a newly created file will be set with
> the FS_NOCOW_FL flag. So to turn on COW for it, we can just clear the
> FS_NOCOW_FL flag.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
>  fs/btrfs/ioctl.c   |   15 ++++++---------
>  include/linux/fs.h |    1 -
>  2 files changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index f580a3a..3240dd9 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -144,16 +144,13 @@ static int check_flags(unsigned int flags)
>  	if (flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | \
>  		      FS_NOATIME_FL | FS_NODUMP_FL | \
>  		      FS_SYNC_FL | FS_DIRSYNC_FL | \
> -		      FS_NOCOMP_FL | FS_COMPR_FL | \
> -		      FS_NOCOW_FL | FS_COW_FL))
> +		      FS_NOCOMP_FL | FS_COMPR_FL |
> +		      FS_NOCOW_FL))
>  		return -EOPNOTSUPP;
>  
>  	if ((flags & FS_NOCOMP_FL) && (flags & FS_COMPR_FL))
>  		return -EINVAL;
>  
> -	if ((flags & FS_NOCOW_FL) && (flags & FS_COW_FL))
> -		return -EINVAL;
> -
>  	return 0;
>  }
>  
> @@ -218,6 +215,10 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>  		ip->flags |= BTRFS_INODE_DIRSYNC;
>  	else
>  		ip->flags &= ~BTRFS_INODE_DIRSYNC;
> +	if (flags & FS_NOCOW_FL)
> +		ip->flags |= BTRFS_INODE_NODATACOW;
> +	else
> +		ip->flags &= ~BTRFS_INODE_NODATACOW;
>  
>  	/*
>  	 * The COMPRESS flag can only be changed by users, while the NOCOMPRESS
> @@ -231,10 +232,6 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
>  		ip->flags |= BTRFS_INODE_COMPRESS;
>  		ip->flags &= ~BTRFS_INODE_NOCOMPRESS;
>  	}
> -	if (flags & FS_NOCOW_FL)
> -		ip->flags |= BTRFS_INODE_NODATACOW;
> -	else if (flags & FS_COW_FL)
> -		ip->flags &= ~BTRFS_INODE_NODATACOW;
>  
>  	trans = btrfs_join_transaction(root, 1);
>  	BUG_ON(IS_ERR(trans));
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index de9dd81..56a4141 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -365,7 +365,6 @@ struct inodes_stat_t {
>  #define FS_EXTENT_FL			0x00080000 /* Extents */
>  #define FS_DIRECTIO_FL			0x00100000 /* Use direct i/o */
>  #define FS_NOCOW_FL			0x00800000 /* Do not cow file */
> -#define FS_COW_FL			0x02000000 /* Cow file */
>  #define FS_RESERVED_FL			0x80000000 /* reserved for ext2 lib */
>  
>  #define FS_FL_USER_VISIBLE		0x0003DFFF /* User visible flags */

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

* Re: [PATCH 1/3] fs: remove FS_COW_FL
  2011-05-03  9:11 ` [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
@ 2011-05-03 11:20   ` Chris Mason
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Mason @ 2011-05-03 11:20 UTC (permalink / raw)
  To: Li Zefan; +Cc: linux-btrfs@vger.kernel.org, linux-fsdevel, LKML

Excerpts from Li Zefan's message of 2011-05-03 05:11:44 -0400:
> Any comments? If this patch is acceptable, it should be queued for .39?
> since fs.h is exported to userspace.
>
> Li Zefan wrote:
> > FS_COW_FL and FS_NOCOW_FL were newly introduced to control per file
> > COW in btrfs, but FS_NOCOW_FL is sufficient.
> > 

Good point, I'll send this in.

-chris

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

end of thread, other threads:[~2011-05-03 11:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-15  3:02 [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
2011-04-15  3:03 ` [PATCH 2/3] Btrfs: fix FS_IOC_GETFLAGS ioctl Li Zefan
2011-04-15  3:03 ` [PATCH 3/3] Btrfs: fix FS_IOC_SETFLAGS ioctl Li Zefan
2011-05-03  9:11 ` [PATCH 1/3] fs: remove FS_COW_FL Li Zefan
2011-05-03 11:20   ` Chris Mason

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