Skip to contentSkip to conversation

fs: fix iversion handling

PATCH In review Christoph Hellwig 8 participants 13 messages Nov 19, 2013 – Dec 5, 2013 3 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: fix iversion handling

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

fs/attr.c +0 -5
Index: xfs/fs/attr.c
===================================================================
@@ -182,11 +182,6 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
-	if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) {
-		if (attr->ia_size != inode->i_size)
-			inode_inc_iversion(inode);
-	}
-
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */
fs/btrfs/inode.c +6 -2
Index: xfs/fs/btrfs/inode.c
===================================================================
@@ -4345,8 +4345,12 @@ static int btrfs_setsize(struct inode *i
 	 * these flags set.  For all other operations the VFS set these flags
 	 * explicitly if it wants a timestamp update.
 	 */
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);
+		if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
+			inode->i_ctime = inode->i_mtime =
+				current_fs_time(inode->i_sb);
+	}
 
 	if (newsize > oldsize) {
 		truncate_pagecache(inode, newsize);
fs/ext4/inode.c +4 -0
Index: xfs/fs/ext4/inode.c
===================================================================
@@ -4594,6 +4594,10 @@ int ext4_setattr(struct dentry *dentry,
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
 		}
+
+		if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size)
+			inode_inc_iversion(inode);
+
 		if (S_ISREG(inode->i_mode) &&
 		    (attr->ia_size < inode->i_size)) {
 			if (ext4_should_order_data(inode)) {
#1 lore raw

ping?

Quoted 66 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Index: xfs/fs/attr.c
===================================================================

fs/attr.c +0 -5
@@ -182,11 +182,6 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
-	if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) {
-		if (attr->ia_size != inode->i_size)
-			inode_inc_iversion(inode);
-	}
-
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */

Index: xfs/fs/btrfs/inode.c
===================================================================

fs/btrfs/inode.c +6 -2
@@ -4345,8 +4345,12 @@ static int btrfs_setsize(struct inode *i
 	 * these flags set.  For all other operations the VFS set these flags
 	 * explicitly if it wants a timestamp update.
 	 */
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);
+		if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
+			inode->i_ctime = inode->i_mtime =
+				current_fs_time(inode->i_sb);
+	}
 
 	if (newsize > oldsize) {
 		truncate_pagecache(inode, newsize);

Index: xfs/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +4 -0
@@ -4594,6 +4594,10 @@ int ext4_setattr(struct dentry *dentry,
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
 		}
+
+		if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size)
+			inode_inc_iversion(inode);
+
 		if (S_ISREG(inode->i_mode) &&
 		    (attr->ia_size < inode->i_size)) {
 			if (ext4_should_order_data(inode)) {
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---

Reviewed-by
#2 lore raw
Quoted 1 line · Christoph Hellwig

ping?

Added linux-ext4 to the CC list.

I'm happy to see this cleanup. You can add my

for the ext4 part, one question inline for the btrfs change (someone with more btrfs knowledge needs to comment if that is important or not.

Cheers, Andreas

Quoted 36 lines · Christoph Hellwig
Quoted 35 lines

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Index: xfs/fs/attr.c
===================================================================

fs/attr.c +0 -5
@@ -182,11 +182,6 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
-	if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) {
-		if (attr->ia_size != inode->i_size)
-			inode_inc_iversion(inode);
-	}
-
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */

Index: xfs/fs/btrfs/inode.c
===================================================================

fs/btrfs/inode.c +0 -0
Quoted 8 lines

fs/btrfs/inode.c static int btrfs_setsize(struct inode *i · line 4349

Quoted 8 lines
fs/btrfs/inode.c +2 -2
@@ -4345,8 +4345,12 @@ static int btrfs_setsize(struct inode *i
 	 * these flags set.  For all other operations the VFS set these flags
 	 * explicitly if it wants a timestamp update.
 	 */
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);

Should this be conditional on IS_I_VERSION(inode)?

Quoted 23 lines
Quoted 23 lines
fs/btrfs/inode.c +4 -0
+		if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
+			inode->i_ctime = inode->i_mtime =
+				current_fs_time(inode->i_sb);
+	}
 
 	if (newsize > oldsize) {
 		truncate_pagecache(inode, newsize);

Index: xfs/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +4 -0
@@ -4594,6 +4594,10 @@ int ext4_setattr(struct dentry *dentry,
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
 		}
+
+		if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size)
+			inode_inc_iversion(inode);
+
 		if (S_ISREG(inode->i_mode) &&
 		    (attr->ia_size < inode->i_size)) {
 			if (ext4_should_order_data(inode)) {
Quoted 9 lines
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Cheers, Andreas

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 7 lines · Andreas Dilger
Quoted 5 lines

fs/btrfs/inode.c static int btrfs_setsize(struct inode *i · line 4349

Quoted 5 lines
	 */
fs/btrfs/inode.c +2 -2
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);

Should this be conditional on IS_I_VERSION(inode)?

btrfs sets MS_I_VERSION unconditionally.

reviewer Acked-by
#4 lore raw
In reply to Christoph Hellwig
Quoted 17 lines · Christoph Hellwig

ping?

Quoted 14 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Feel free to add my:

for the ext4 part.

Honza

Quoted 61 lines
Quoted 52 lines

Index: xfs/fs/attr.c
===================================================================

fs/attr.c +0 -5
@@ -182,11 +182,6 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
-	if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) {
-		if (attr->ia_size != inode->i_size)
-			inode_inc_iversion(inode);
-	}
-
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */

Index: xfs/fs/btrfs/inode.c
===================================================================

fs/btrfs/inode.c +6 -2
@@ -4345,8 +4345,12 @@ static int btrfs_setsize(struct inode *i
 	 * these flags set.  For all other operations the VFS set these flags
 	 * explicitly if it wants a timestamp update.
 	 */
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);
+		if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
+			inode->i_ctime = inode->i_mtime =
+				current_fs_time(inode->i_sb);
+	}
 
 	if (newsize > oldsize) {
 		truncate_pagecache(inode, newsize);

Index: xfs/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +4 -0
@@ -4594,6 +4594,10 @@ int ext4_setattr(struct dentry *dentry,
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
 		}
+
+		if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size)
+			inode_inc_iversion(inode);
+
 		if (S_ISREG(inode->i_mode) &&
 		    (attr->ia_size < inode->i_size)) {
 			if (ext4_should_order_data(inode)) {
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 26 lines · Christoph Hellwig

ping?

Quoted 23 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Index: xfs/fs/attr.c
===================================================================

fs/attr.c +0 -0
@@ -182,11 +182,6 @@ int notify_change(struct dentry * dentry
 			return -EPERM;
 	}
 
Quoted 5 lines

fs/attr.c int notify_change(struct dentry * dentry · line 189

Quoted 5 lines
fs/attr.c +0 -5
-	if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) {
-		if (attr->ia_size != inode->i_size)
-			inode_inc_iversion(inode);
-	}
-

Hi Christoph

What happens with all other filesystems exported under KNFSD?

As I understand inode_inc_iversion() is used in NFSv4 and up, what will increment the inode-version on changed attributes for them?

(ie. do I need the same change in an FS I care about?)

Thanks
Boaz

Quoted 38 lines
Quoted 38 lines
fs/attr.c +0 -0
 	if ((ia_valid & ATTR_MODE)) {
 		umode_t amode = attr->ia_mode;
 		/* Flag setting protected by i_mutex */

Index: xfs/fs/btrfs/inode.c
===================================================================

fs/btrfs/inode.c +6 -2
@@ -4345,8 +4345,12 @@ static int btrfs_setsize(struct inode *i
 	 * these flags set.  For all other operations the VFS set these flags
 	 * explicitly if it wants a timestamp update.
 	 */
-	if (newsize != oldsize && (!(mask & (ATTR_CTIME | ATTR_MTIME))))
-		inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
+	if (newsize != oldsize) {
+		inode_inc_iversion(inode);
+		if (!(mask & (ATTR_CTIME | ATTR_MTIME)))
+			inode->i_ctime = inode->i_mtime =
+				current_fs_time(inode->i_sb);
+	}
 
 	if (newsize > oldsize) {
 		truncate_pagecache(inode, newsize);

Index: xfs/fs/ext4/inode.c
===================================================================

fs/ext4/inode.c +4 -0
@@ -4594,6 +4594,10 @@ int ext4_setattr(struct dentry *dentry,
 			if (attr->ia_size > sbi->s_bitmap_maxbytes)
 				return -EFBIG;
 		}
+
+		if (IS_I_VERSION(inode) && attr->ia_size != inode->i_size)
+			inode_inc_iversion(inode);
+
 		if (S_ISREG(inode->i_mode) &&
 		    (attr->ia_size < inode->i_size)) {
 			if (ext4_should_order_data(inode)) {
Quoted 10 lines
Quoted 4 lines

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 7 lines · Boaz Harrosh

Hi Christoph

What happens with all other filesystems exported under KNFSD?

As I understand inode_inc_iversion() is used in NFSv4 and up, what will increment the inode-version on changed attributes for them?

It's used by the filesystem for the change attribute that NFSDd can optionally use. Most filesystsems don't support it and work okay enough when NFS exported. No other filesystem will need to adopt for this patch specificly, given that no other filesystem uses this infrastructure.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · Boaz Harrosh

Hi Christoph

What happens with all other filesystems exported under KNFSD?

As I understand inode_inc_iversion() is used in NFSv4 and up, what will increment the inode-version on changed attributes for them?

Quoted 6 lines

It's used by the filesystem for the change attribute that NFSDd can optionally use. Most filesystsems don't support it and work okay enough when NFS exported. No other filesystem will need to adopt for this patch specificly, given that no other filesystem uses this infrastructure.

OK Thanks, I did not know that. I assumed change-attribute is naturally supported.

I will look at ext4 example and wire up exofs. Because it is very important for me to support the change-attribute properly.

Thanks you
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 17 lines · Boaz Harrosh
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · Boaz Harrosh

Hi Christoph

What happens with all other filesystems exported under KNFSD?

As I understand inode_inc_iversion() is used in NFSv4 and up, what will increment the inode-version on changed attributes for them?

Quoted 6 lines

It's used by the filesystem for the change attribute that NFSDd can optionally use. Most filesystsems don't support it and work okay enough when NFS exported. No other filesystem will need to adopt for this patch specificly, given that no other filesystem uses this infrastructure.

Quoted 5 lines

OK Thanks, I did not know that. I assumed change-attribute is naturally supported.

I will look at ext4 example and wire up exofs. Because it is very important for me to support the change-attribute properly.

Just please don't follow ext4's example of making support dependent on a mount option.

--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 1/1
#12 lore raw
In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Quoted 8 lines

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Looks good to me.

Signature · 2 lines
Dave Chinner
[email protected]
#13 lore raw
In reply to Christoph Hellwig

Hey Christoph,

Quoted 6 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Quoted 8 lines

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Does this still need a btrfs ack, or is it ready to go?

-Ben

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#14 lore raw

Quoting Ben Myers (2013-12-04 16:25:04)

Quoted 13 lines

Hey Christoph,

Quoted 10 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

Quoted 6 lines
Quoted 4 lines

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Does this still need a btrfs ack, or is it ready to go?

The btrfs parts look good to me.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#15 lore raw
Quoted 17 lines · Chris Mason

Quoting Ben Myers (2013-12-04 16:25:04)

Quoted 16 lines

Hey Christoph,

Quoted 13 lines · Christoph Hellwig

Currently notify_change directly updates i_version for size updates, which not only is counter to how all other fields are updated through struct iattr, but also breaks XFS, which need inode updates to happen under its own lock, and synchronized to the structure that gets written to the log.

Remove the update in the common code, and it to btrfs and ext4, XFS already does a proper updaste internally and currently gets a double update with the existing code.

IMHO this is 3.13 and -stable material and should go in through the XFS tree.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Does this still need a btrfs ack, or is it ready to go?

The btrfs parts look good to me.

Great. Applied to the xfs tree as per Christoph's suggestion.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs