i_version:64 bit inode version
PATCH 1/5 i_version:64 bit inode version
This patch converts the 32-bit i_version in the generic inode to a 64-bit i_version field.
include/linux/fs.h +1 -1
@@ -549,7 +549,7 @@ struct inode {uid_t i_uid;gid_t i_gid;dev_t i_rdev; -unsigned long i_version; +u64 i_version;loff_t i_size;#ifdef __NEED_I_SIZE_ORDEREDseqcount_t i_size_seqcount;
Trond or Bruce, can you please review these patch series and ack if you agrees? Thanks.
As to performance concerns that raise before the inode version counter (at least for ext4) is done inside ext4_mark_inode_dirty), so there is no extra IO work to store this counter to disk.
Mingming
Quoted 26 lines · Mingming Cao
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.Signed-off-by Mingming Cao <[email protected]>Signed-off-by Jean Noel Cordenner <[email protected]>Signed-off-by Kalpak Shah <[email protected]>Index:
linux-2.6.21/include/linux/fs.h
===================================================================include/linux/fs.h +1
-2@@ -549,7 +549,7 @@ struct inode {uid_t i_uid;gid_t i_gid;dev_t i_rdev; -unsigned long i_version; +u64 i_version;loff_t i_size;#ifdef __NEED_I_SIZE_ORDEREDseqcount_t i_size_seqcount; -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
Quoted 6 lines · Mingming Cao
Trond or Bruce, can you please review these patch series and ack if you agrees? Thanks.
As to performance concerns that raise before the inode version counter (at least for ext4) is done inside
ext4_mark_inode_dirty), so there is no extra IO work to store this counter to disk.
Hi Mingming,
It looks OK to me, but you might want to strip out the now redundant i_version updates in add_dirent_to_buf(), ext4_rmdir(), ext4_rename().
I also have some questions about how this will affect the readdir code:
unless I missed something, the filp->f_version is still unsigned long, so the comparisons and assignments in ext4_readdir()/ext4_dx_readdir() no longer make sense.
Cheers
Trond
Quoted 2 lines · Trond Myklebust
It looks OK to me, but you might want to strip out the now redundant
i_versionupdates inadd_dirent_to_buf(),ext4_rmdir(),ext4_rename().
Agreed, and I thought we discussed that already on the ext4 list.
Quoted 4 lines
I also have some questions about how this will affect the readdir code:
unless I missed something, thefilp->f_versionis still unsigned long, so the comparisons and assignments in ext4_readdir()/ext4_dx_readdir() no longer make sense.
I don't see them as any worse than existing checks. For 32-bit systems we only ever had a 32-bit in-memory version anyway so using only the low 32 bits of i_version in f_version is no more racy than in the past. For 64-bit systems using the full on-disk i_version is possible.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Quoted 2 lines · Mingming Cao
Trond or Bruce, can you please review these patch series and ack if you agrees?
Thanks, looks like what we need!
How will nfsd tell whether it can really on a given filesystem's i_version, or whether it should fall back on ctime?
Quoted 3 lines
As to performance concerns that raise before the inode version counter (at least for ext4) is done inside
ext4_mark_inode_dirty), so there is no extra IO work to store this counter to disk.
So what's the motivation for the "noversion" mount option?
--b.
Quoted 2 lines · J. Bruce Fields
How will nfsd tell whether it can really on a given filesystem's
i_version, or whether it should fall back on ctime?
Good question.
Quoted 5 lines
Quoted 3 lines
As to performance concerns that raise before the inode version counter (at least for ext4) is done inside
ext4_mark_inode_dirty), so there is no extra IO work to store this counter to disk.So what's the motivation for the "noversion" mount option?
Lustre needs to be able to control the version number directly (version number needs to be ordered between all inodes, is set by Lustre to be a transaction number). Instead of trying to incorporate this unused code into ext4 we just turn off the ext4 version code and let Lustre control this directly. It may even be that NFSv4 will need to control the version numbers itself...
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Quoted 5 lines · Andreas Dilger
Quoted 2 lines · J. Bruce Fields
How will nfsd tell whether it can really on a given filesystem's
i_version, or whether it should fall back on ctime?Good question.
Well, we don't need anything particularly complicated--just a one-bit flag on the superblock would be enough.
Quoted 8 lines
Quoted 1 line
So what's the motivation for the "noversion" mount option?
Lustre needs to be able to control the version number directly (version number needs to be ordered between all inodes, is set by Lustre to be a transaction number). Instead of trying to incorporate this unused code into ext4 we just turn off the ext4 version code and let Lustre control this directly. It may even be that NFSv4 will need to control the version numbers itself...
I can't think of any reason we would need to in the near future, but maybe I'm insufficiently creative.
The use of a mount option means the change attribute could be inconsistent across mounts. If we really need this, wouldn't it make more sense for it to be a persistent feature of the filesystem, set at mkfs time?
--b.
Quoted 4 lines · J. Bruce Fields
The use of a mount option means the change attribute could be inconsistent across mounts. If we really need this, wouldn't it make more sense for it to be a persistent feature of the filesystem, set at mkfs time?
Yes, having it stored into the superblock in s_flags is probably a good idea. Kalpak, do you think you could get a patch that adds e.g. EXT4_FLAGS_NO_INODE_VERSION (like EXT4_FLAGS_SIGNED_HASH in e2fsprogs).
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Quoted 10 lines · Andreas Dilger
Quoted 4 lines · J. Bruce Fields
The use of a mount option means the change attribute could be inconsistent across mounts. If we really need this, wouldn't it make more sense for it to be a persistent feature of the filesystem, set at mkfs time?
Yes, having it stored into the superblock in
s_flagsis probably a good idea. Kalpak, do you think you could get a patch that adds e.g.EXT4_FLAGS_NO_INODE_VERSION(likeEXT4_FLAGS_SIGNED_HASHin e2fsprogs).
Per our ext4 interlock discussion today, I have dropped the ext4-no-inode version-mount-option patch from ext4 patch queue.
Thanks,
Mingming
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.
That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
Please update the changelog for this.
Quoted 13 lines
Index:
linux-2.6.21/include/linux/fs.h
===================================================================include/linux/fs.h +1
-1@@ -549,7 +549,7 @@ struct inode {uid_t i_uid;gid_t i_gid;dev_t i_rdev; -unsigned long i_version; +u64 i_version;loff_t i_size;#ifdef __NEED_I_SIZE_ORDEREDseqcount_t i_size_seqcount;
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
The need is came from NFSv4
Quoted 20 lines · Jean noel Cordenner
Hi,
This is an update of the
i_versionpatch.
Thei_versionfield is a 64bit counter that is set on every inode creation and that is incremented every time the inode data is modified (similarly to the "ctime" time-stamp).
The aim is to fulfill a NFSv4 requirement for rfc3530:
"5.5. Mandatory Attributes - Definitions
Name # DataType Access Description
___________________________________________________________________
change 3 uint64 READ A value created by the
server that the client can use to determine if file data, directory contents or attributes of the object have been modified. The servermay return the object'stime_metadataattribute for this attribute's value but only if the filesystem object can not be updated more frequently than the resolution oftime_metadata.
"
Quoted 2 lines
Please update the changelog for this.
Is above description clear to you?
Quoted 14 lines
Quoted 13 lines
Index:
linux-2.6.21/include/linux/fs.h
===================================================================include/linux/fs.h +1
-1@@ -549,7 +549,7 @@ struct inode {uid_t i_uid;gid_t i_gid;dev_t i_rdev; -unsigned long i_version; +u64 i_version;loff_t i_size;#ifdef __NEED_I_SIZE_ORDEREDseqcount_t i_size_seqcount;
Quoted 35 lines · On Tue, 10 Jul 2007 18:09:40 -0400 Mingming Cao <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
The need is came from NFSv4
Quoted 19 lines · Jean noel Cordenner
Hi,
This is an update of the
i_versionpatch.
Thei_versionfield is a 64bit counter that is set on every inode creation and that is incremented every time the inode data is modified (similarly to the "ctime" time-stamp).
The aim is to fulfill a NFSv4 requirement for rfc3530:
"5.5. Mandatory Attributes - Definitions
Name # DataType Access Description
___________________________________________________________________
change 3 uint64 READ A value created by the
server that the client can use to determine if file data, directory contents or attributes of the object have been modified. The servermay return the object'stime_metadataattribute for this attribute's value but only if the filesystem object can not be updated more frequently than the resolution oftime_metadata.
"
Quoted 5 lines
Quoted 2 lines
Please update the changelog for this.
Is above description clear to you?
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update i_version for file overwrites (especially if s_time_gran can indeed be 1,000,000,000) and of course for MAP_SHARED modifications. What would be the implications of this?
And how does the NFS server know that the filesystem implements i_version? Will a zero-value of i_version have special significance, telling the server to not send this attribute, perhaps?
Quoted 43 lines · Andrew Morton
Quoted 35 lines · On Tue, 10 Jul 2007 18:09:40 -0400 Mingming Cao <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
The need is came from NFSv4
Quoted 19 lines · Jean noel Cordenner
Hi,
This is an update of the
i_versionpatch.
Thei_versionfield is a 64bit counter that is set on every inode creation and that is incremented every time the inode data is modified (similarly to the "ctime" time-stamp).
The aim is to fulfill a NFSv4 requirement for rfc3530:
"5.5. Mandatory Attributes - Definitions
Name # DataType Access Description
___________________________________________________________________
change 3 uint64 READ A value created by the
server that the client can use to determine if file data, directory contents or attributes of the object have been modified. The servermay return the object'stime_metadataattribute for this attribute's value but only if the filesystem object can not be updated more frequently than the resolution oftime_metadata.
"Quoted 5 lines
Quoted 2 lines
Please update the changelog for this.
Is above description clear to you?
Quoted 9 lines
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?
In the case of overwrite (file date updated), I assume the ctime/mtime is being updated and the inode is being dirtied, so the version number is being updated.
vfs_write()->..
->__generic_file_aio_write_nolock()
->file_update_time()
->mark_inode_dirty_sync()
->__mark_inode_dirty(I_DIRTY_SYNC)
->ext4_dirty_inode()
->ext4_mark_inode_dirty()Quoted 3 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?
Bruce raised up this question a few days back when he reviewed this patch, I think the solution is add a superblock flag for fs support inode versioning, probably at VFS layer?
Mingming
Quoted 58 lines · On Tue, 10 Jul 2007 20:19:16 -0400 Mingming Cao <[email protected]> wrote:
Quoted 43 lines · Andrew Morton
Quoted 35 lines · On Tue, 10 Jul 2007 18:09:40 -0400 Mingming Cao <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
The need is came from NFSv4
Quoted 19 lines · Jean noel Cordenner
Hi,
This is an update of the
i_versionpatch.
Thei_versionfield is a 64bit counter that is set on every inode creation and that is incremented every time the inode data is modified (similarly to the "ctime" time-stamp).
The aim is to fulfill a NFSv4 requirement for rfc3530:
"5.5. Mandatory Attributes - Definitions
Name # DataType Access Description
___________________________________________________________________
change 3 uint64 READ A value created by the
server that the client can use to determine if file data, directory contents or attributes of the object have been modified. The servermay return the object'stime_metadataattribute for this attribute's value but only if the filesystem object can not be updated more frequently than the resolution oftime_metadata.
"Quoted 5 lines
Quoted 2 lines
Please update the changelog for this.
Is above description clear to you?
Quoted 9 lines
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?In the case of overwrite (file date updated), I assume the ctime/mtime is being updated and the inode is being dirtied, so the version number is being updated.
Quoted 7 lines
vfs_write()->..
->__generic_file_aio_write_nolock() ->file_update_time() ->mark_inode_dirty_sync() ->__mark_inode_dirty(I_DIRTY_SYNC) ->ext4_dirty_inode() ->ext4_mark_inode_dirty()
That assumes an mtime update for every write(). OK, so two writes in a single nanosecond won't be happening. But in that case why is this code:
static inline struct timespec ext4_current_time(struct inode *inode)
{
return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ?
current_fs_time(inode->i_sb) : CURRENT_TIME_SEC;
}checking (s_time_gran < NSEC_PER_SEC) ??
Overall it is a bit unpleasing to rely upon mtime updates for a correct NFS server implementation: if we were to later decrease s_time_gran (as we might do, for performance reasons), the NFS server implementation starts reporting incorrect information.
Quoted 7 lines
Quoted 3 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?Bruce raised up this question a few days back when he reviewed this patch, I think the solution is add a superblock flag for fs support inode versioning, probably at VFS layer?
That would work.
Quoted 71 lines · Andrew Morton
Quoted 58 lines · On Tue, 10 Jul 2007 20:19:16 -0400 Mingming Cao <[email protected]> wrote:
Quoted 43 lines · Andrew Morton
Quoted 35 lines · On Tue, 10 Jul 2007 18:09:40 -0400 Mingming Cao <[email protected]> wrote:
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Sun, 01 Jul 2007 03:37:04 -0400 Mingming Cao <[email protected]> wrote:
This patch converts the 32-bit
i_versionin the generic inode to a 64-biti_versionfield.That's obvious from the patch. But what was the reason for making this (unrelated to ext4) change?
The need is came from NFSv4
Quoted 19 lines · Jean noel Cordenner
Hi,
This is an update of the
i_versionpatch.
Thei_versionfield is a 64bit counter that is set on every inode creation and that is incremented every time the inode data is modified (similarly to the "ctime" time-stamp).
The aim is to fulfill a NFSv4 requirement for rfc3530:
"5.5. Mandatory Attributes - Definitions
Name # DataType Access Description
___________________________________________________________________
change 3 uint64 READ A value created by the
server that the client can use to determine if file data, directory contents or attributes of the object have been modified. The servermay return the object'stime_metadataattribute for this attribute's value but only if the filesystem object can not be updated more frequently than the resolution oftime_metadata.
"Quoted 5 lines
Quoted 2 lines
Please update the changelog for this.
Is above description clear to you?
Quoted 9 lines
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?In the case of overwrite (file date updated), I assume the ctime/mtime is being updated and the inode is being dirtied, so the version number is being updated.
Quoted 7 lines
vfs_write()->..
->__generic_file_aio_write_nolock() ->file_update_time() ->mark_inode_dirty_sync() ->__mark_inode_dirty(I_DIRTY_SYNC) ->ext4_dirty_inode() ->ext4_mark_inode_dirty()That assumes an mtime update for every
write(). OK, so two writes in a single nanosecond won't be happening. But in that case why is this code:
Quoted 8 lines
static inline struct timespec
ext4_current_time(struct inode *inode){ return (inode->i_sb->s_time_gran < NSEC_PER_SEC) ? current_fs_time(inode->i_sb) : CURRENT_TIME_SEC; }checking (
s_time_gran<NSEC_PER_SEC) ??
Ext4 can still load/read ext3 fs (which by default with 128 bytes old inode size, means doens't have support nanosecond timestamps), so it's not always gurantee nanosecond timestamps granularity.(it depends on the size of the inode (>128 bytes), by default, a fresh ext4 increase inode size to 256 bytes to have the room to store nanoseond timestamps, inode versioning etc)
Quoted 5 lines
Overall it is a bit unpleasing to rely upon mtime updates for a correct NFS server implementation: if we were to later decrease
s_time_gran(as we might do, for performance reasons), the NFS server implementation starts reporting incorrect information.
:( that is a problem...
Quoted 13 lines
Quoted 7 lines
Quoted 3 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?Bruce raised up this question a few days back when he reviewed this patch, I think the solution is add a superblock flag for fs support inode versioning, probably at VFS layer?
That would work.
-
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
Quoted 8 lines · Mingming Cao
Quoted 3 lines · Andrew Morton
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?Bruce raised up this question a few days back when he reviewed this patch, I think the solution is add a superblock flag for fs support inode versioning, probably at VFS layer?
Sounds fine. As long as it's something that's standard across filesystems, then I can just do something like
if (sb->s_flags & MS_CHANGEATTR) /* return i_version to client as change attribute */ else /* return ctime to client as change attribute */
--b.
Quoted 4 lines · On Tuesday July 10, [email protected] wrote:
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
You would like to think so, but remember NFSv4 was designed by a committee :-)
The 'change' number is used for cache consistency, and as the spec makes very strong statements about the 'change' number, it is very hard (or impossible) to implement a server correctly without storing a change number in stable storage (just one of my grips about V4).
Quoted 5 lines
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?
The first part sounds like a bug - i_version should really be updated by every call to ->commit_write (if that is still what it is called).
The MAP_SHARED thing is less obvious. I guess every time we notice that the page might have been changed, we need to increment i_version.
Quoted 4 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?
That is a very important question. Zero probably makes sense, but what ever it is needs to be agreed and documented.
And just by-the-way, the server doesn't really have the option of not sending the attribute. If i_version isn't defined, it has to fake something using mtime, and hope that is good enough.
Alternately we could mandate that i_version is always kept up-to-date and if a filesystem doesn't have anything to load from storage, it just sets it to the current time in nanoseconds.
That would mean that a client would need to flush it's cache whenever the inode fell out of cache on the server, but I don't think we can reliably do better than that.
I think I like that approach.
So my vote is to increment i_version in common code every time any change is made to the file, and alloc_inode should initialise it to current time, which might be changed by the filesystem before it calls unlock_new_inode.
... but doesn't lustre want to control its i_version... so maybe not :-(
NeilBrown
Quoted 41 lines · Neil Brown
Quoted 4 lines · On Tuesday July 10, [email protected] wrote:
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
You would like to think so, but remember NFSv4 was designed by a committee :-)
The 'change' number is used for cache consistency, and as the spec makes very strong statements about the 'change' number, it is very hard (or impossible) to implement a server correctly without storing a change number in stable storage (just one of my grips about V4).
Quoted 5 lines
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?The first part sounds like a bug -
i_versionshould really be updated by every call to ->commit_write (if that is still what it is called).The
MAP_SHAREDthing is less obvious. I guess every time we notice that the page might have been changed, we need to incrementi_version.Quoted 4 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?That is a very important question. Zero probably makes sense, but what ever it is needs to be agreed and documented.
And just by-the-way, the server doesn't really have the option of not sending the attribute. Ifi_versionisn't defined, it has to fake something using mtime, and hope that is good enough.Alternately we could mandate that
i_versionis always kept up-to-date and if a filesystem doesn't have anything to load from storage, it just sets it to the current time in nanoseconds.
Quoted 8 lines
That would mean that a client would need to flush it's cache whenever the inode fell out of cache on the server, but I don't think we can reliably do better than that.
I think I like that approach.
So my vote is to increment
i_versionin common code every time any change is made to the file,
David Chinneer pointed that we need to journal the version number updates together with the operations that causes the change of the inode version number, in order to survive server crashes so clients won't see the counter go backwards.
So increment i_version in fs code is probably the place to ensure the inode version changes are stored to disk. It's seems update the ext4 inode version in every ext4_mark_inode_dirty() is the easiest way.
Quoted 6 lines
and
alloc_inodeshould initialise it to
current time, which might be changed by the filesystem before it callsunlock_new_inode.
... but doesn't lustre want to control itsi_version... so maybe not :-(NeilBrown
Quoted 8 lines · On Tue, 10 Jul 2007 22:09:08 -0400 Mingming Cao <[email protected]> wrote:
David Chinneer pointed that we need to journal the version number updates together with the operations that causes the change of the inode version number, in order to survive server crashes so clients won't see the counter go backwards.
So increment
i_versionin fs code is probably the place to ensure the inode version changes are stored to disk. It's seems update the ext4 inode version in everyext4_mark_inode_dirty()is the easiest way.
That still makes us dependent upon _something_ changing the inode. For overwrites the only something is mtime.
If we don't want to have a peculiar dependency upon s_time_gran=1e9 (and I don't think we do) then I guess we'll need new code in or around file_update_time() to do this.
Quoted 11 lines · Andrew Morton
Quoted 8 lines · On Tue, 10 Jul 2007 22:09:08 -0400 Mingming Cao <[email protected]> wrote:
David Chinneer pointed that we need to journal the version number updates together with the operations that causes the change of the inode version number, in order to survive server crashes so clients won't see the counter go backwards.
So increment
i_versionin fs code is probably the place to ensure the inode version changes are stored to disk. It's seems update the ext4 inode version in everyext4_mark_inode_dirty()is the easiest way.
Quoted 6 lines
That still makes us dependent upon _something_ changing the inode. For overwrites the only something is mtime.
If we don't want to have a peculiar dependency upon s_time_gran=1e9 (and I don't think we do) then I guess we'll need new code in or around
file_update_time()to do this.
do you mean mark inode dirty all the times in file_update_time()? Not sure about the overhead for ext3/4.
Mingming
Quoted 15 lines · On Tue, 10 Jul 2007 23:18:50 -0400 Mingming Cao <[email protected]> wrote:
Quoted 14 lines · Andrew Morton
Quoted 8 lines · On Tue, 10 Jul 2007 22:09:08 -0400 Mingming Cao <[email protected]> wrote:
David Chinneer pointed that we need to journal the version number updates together with the operations that causes the change of the inode version number, in order to survive server crashes so clients won't see the counter go backwards.
So increment
i_versionin fs code is probably the place to ensure the inode version changes are stored to disk. It's seems update the ext4 inode version in everyext4_mark_inode_dirty()is the easiest way.That still makes us dependent upon _something_ changing the inode. For overwrites the only something is mtime.
Quoted 7 lines
Quoted 3 lines
If we don't want to have a peculiar dependency upon s_time_gran=1e9 (and I don't think we do) then I guess we'll need new code in or around
file_update_time()to do this.do you mean mark inode dirty all the times in
file_update_time()? Not sure about the overhead for ext3/4.
hm, I hadn't thought about it in any detail.
Maybe something like
fs/inode.c renamed from fs/inode.c~a +5 -0
@@ -1238,6 +1238,11 @@ void file_update_time(struct file *file) sync_it =1 ; } +if (IS_I_VERSION_64 (inode)) { +inode_inc_iversion (inode);/* Takes i_lock on 32-bit */ + sync_it =1 ; + } +if (sync_it)mark_inode_dirty_sync (inode); }
_
?
Quoted 6 lines · Neil Brown
Quoted 4 lines · On Tuesday July 10, [email protected] wrote:
Yes, thanks. It doesn't actually tell us why we want to implement this attribute and it doesn't tell us what the implications of failing to do so are, but I guess we can take that on trust from the NFS guys.
Quoted 7 lines
You would like to think so, but remember NFSv4 was designed by a committee :-)
The 'change' number is used for cache consistency, and as the spec makes very strong statements about the 'change' number, it is very hard (or impossible) to implement a server correctly without storing a change number in stable storage (just one of my grips about V4).
Well... It reflects a requirement that was just as present in the caching models that we use for NFSv2/v3, but that we glossed over for other reasons.
The real difference here is that v2/v3 caching model assumes that you have sufficient resolution in the ctime/mtime to allow clients to detect any changes to the file/directory contents, whereas NFSv4 allows you to use an arbitrary variable (that may be the ctime, if it has sufficient resolution) for the same purposes.
Quoted 10 lines
Quoted 4 lines
But I suspect the ext4 implementation doesn't actually do this. afaict we won't update
i_versionfor file overwrites (especially ifs_time_grancan indeed be 1,000,000,000) and of course forMAP_SHAREDmodifications. What would be the implications of this?The first part sounds like a bug -
i_versionshould really be updated by every call to ->commit_write (if that is still what it is called).The
MAP_SHAREDthing is less obvious. I guess every time we notice that the page might have been changed, we need to incrementi_version.
You need to increment is any time that you detect remotely visible changes.
IOW: any change that posix mandates should result in a ctime update, must also result in an update of i_version. The only difference is that i_version must not suffer from the time resolution issues that ctime does.
Quoted 18 lines
Quoted 3 lines
And how does the NFS server know that the filesystem implements
i_version? Will a zero-value ofi_versionhave special significance, telling the server to not send this attribute, perhaps?That is a very important question. Zero probably makes sense, but what ever it is needs to be agreed and documented.
And just by-the-way, the server doesn't really have the option of not sending the attribute. Ifi_versionisn't defined, it has to fake something using mtime, and hope that is good enough.Alternately we could mandate that
i_versionis always kept up-to-date and if a filesystem doesn't have anything to load from storage, it just sets it to the current time in nanoseconds.That would mean that a client would need to flush it's cache whenever the inode fell out of cache on the server, but I don't think we can reliably do better than that.
Quoted 7 lines
I think I like that approach.
So my vote is to increment
i_versionin common code every time any change is made to the file, andalloc_inodeshould initialise it to current time, which might be changed by the filesystem before it callsunlock_new_inode.
... but doesn't lustre want to control itsi_version... so maybe not :-(
If lustre wants to be exportable via pNFS (as Peter Braam has suggested it should), then it had better be able to return a change attribute that is compatible with the NFSv4.1 spec...
Trond
Quoted 10 lines · Trond Myklebust
Quoted 5 lines · Neil Brown
So my vote is to increment
i_versionin common code every time any change is made to the file, andalloc_inodeshould initialise it to current time, which might be changed by the filesystem before it callsunlock_new_inode.
... but doesn't lustre want to control itsi_version... so maybe not :-(If lustre wants to be exportable via pNFS (as Peter Braam has suggested it should), then it had better be able to return a change attribute that is compatible with the NFSv4.1 spec...
The Lustre use of i_version is a superset of what NFSv4 needs - the Lustre version can be used to compare the updates of two inodes. It is set to be the Lustre transaction number (which is sequentially incremented on a per filesystem basis), so that we can use the per-inode version to do replay of client operations even if they have been disconnected for a long time, which is why we want to be able to control the actual value. We don't want the version to be updated for e.g. file defragmentation or other similar internal-only changes which need ext4_mark_inode_dirty().
We had a patch to disable ext4 inode versioning by a flag the superblock, but we dropped it at the last minute because it needed some updates and we didn't want to wait on that for submitting these changes upstream.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
It just occurred to me:
If i_version is 64bit, then knfsd would need to be careful when reading it on a 32bit host. What are the locking rules?
Presumably it is only updated under i_mutex protection, but having to get i_mutex to read it would seem a little heavy handed.
Should it use a seqlock like i_size?
Could we use the same seqlock that i_size uses, or would we need a separate one?
NeilBrown
Quoted 6 lines · On Wed, 11 Jul 2007 15:05:27 +1000 Neil Brown <[email protected]> wrote:
It just occurred to me:
If
i_versionis 64bit, then knfsd would need to be careful when reading it on a 32bit host. What are the locking rules?
Quoted 7 lines
Presumably it is only updated under
i_mutexprotection, but having to geti_mutexto read it would seem a little heavy handed.Should it use a seqlock like
i_size?
Could we use the same seqlock thati_sizeuses, or would we need a separate one?
seqlocks are a bit of a pain to use (we've had plenty of deadlocks on the i_size one). We could reuse inode.i_lock for this modification. Its mandate is "general purpose innermost lock to protect stuff in this inode".
Quoted 4 lines · Neil Brown
It just occurred to me:
If
i_versionis 64bit, then knfsd would need to be careful when reading it on a 32bit host. What are the locking rules?
How does knfsd use i_version? I would think that if all it was doing was to compare (i_version == previous_version), then locking wouldn't really matter. Well, theoretically, previous_version could be 0x100000000, and i_version could be 0x1ffffffff, knfsd checks the high word, then ext4 updates i_version to 0x200000000, then knfsd checks the low word, detecting no change. How likely is this? (I don't understand why i_version even needs to be 64 bits in the first place.)
Quoted 2 lines
Presumably it is only updated under
i_mutexprotection, but having to geti_mutexto read it would seem a little heavy handed.
How does knfsd protect itself from the inode changing after i_version is checked? Is any locking being done otherwise?
Quoted 5 lines
Should it use a seqlock like
i_size?
Could we use the same seqlock thati_sizeuses, or would we need a separate one?NeilBrown
Signature · 2 lines
David Kleikamp IBM Linux Technology Center
Quoted 8 lines · Dave Kleikamp
Quoted 4 lines · Neil Brown
It just occurred to me:
If
i_versionis 64bit, then knfsd would need to be careful when reading it on a 32bit host. What are the locking rules?How does knfsd use
i_version? I would think that if all it was doing was to compare (i_version==previous_version)
That's correct. (Though it's the client that's doing the comparison, actually--the server is just reporting the value.)
Quoted 5 lines
then locking wouldn't really matter. Well, theoretically,
previous_versioncould be0x100000000, andi_versioncould be0x1ffffffff, knfsd checks the high word, then ext4 updatesi_versionto0x200000000, then knfsd checks the low word, detecting no change. How likely is this?
The choice of upper word in your example is arbitrary, but other than that I believe your example is essentially the only one. So this would only happen when *both*
- the read of the new value of the low word happens precisely 2^32 i_version updates after the word was read on the client's previous cache revalidation, and
- the value of i_version itself is close enough to a 32-bit boundary that wraparound can happen between the reads of the high and low words.
Quoted 2 lines
(I don't understand why
i_versioneven needs to be 64 bits in the first place.)
A 32-bit i_version could in theory wrap pretty quickly, couldn't it? That's not a problem in itself--the problem would only arise if two subsequent client queries of the change attribute happened a multiple of 2^32 i_version increments apart.
This is more likely than the previous scenario, but still very unlikely. I would have guessed that even in situations with a very high rate of updates and a low rate of client revalidations, the chance of two revalidations happening exactly 2^32 updates apart would still be no more than 1 in 2^32. (Could odd characteristics of the workloads (like updates that tend to happen in power-of-2 groups?) make it any more likely?)
I'd be happier if ext4 at least allowed the possibility of 64 bits in the future. And there's always the chance someone would find a use for an i_version that was nondecreasing, even if nfs didn't care.
Quoted 5 lines
Quoted 2 lines
Presumably it is only updated under
i_mutexprotection, but having to geti_mutexto read it would seem a little heavy handed.How does knfsd protect itself from the inode changing after
i_versionis checked? Is any locking being done otherwise?
If the client always requests the change attribute before reading, and the i_version is always updated after data is modified, I think we're OK. Admittedly this is a little subtle.
--b.
Quoted 13 lines · J. Bruce Fields
A 32-bit
i_versioncould in theory wrap pretty quickly, couldn't it? That's not a problem in itself--the problem would only arise if two subsequent client queries of the change attribute happened a multiple of 2^32i_versionincrements apart.This is more likely than the previous scenario, but still very unlikely. I would have guessed that even in situations with a very high rate of updates and a low rate of client revalidations, the chance of two revalidations happening exactly 2^32 updates apart would still be no more than 1 in 2^32. (Could odd characteristics of the workloads (like updates that tend to happen in power-of-2 groups?) make it any more likely?)
Quoted 3 lines
I'd be happier if ext4 at least allowed the possibility of 64 bits in the future. And there's always the chance someone would find a use for an
i_versionthat was nondecreasing, even if nfs didn't care.
This would indeed be the case for ext3 filesystems updated to ext4. They will only be able to store the low 32 bits of the version, which is itself normally enough for NFSv4 because it only uses the inequality check. Having the full 64 bits available eliminates the risk of collisions, and given that the spec mandates a 64-bit version I'm sure someone will take full advantage of it in NFS at some point.
Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.
Quoted 3 lines · Neil Brown
And just by-the-way, the server doesn't really have the option of not sending the attribute. If
i_versionisn't defined, it has to fake something using mtime, and hope that is good enough.
ctime, actually--the change attribute is also supposed to be updated on attribute updates.
Quoted 8 lines
Alternately we could mandate that
i_versionis always kept up-to-date and if a filesystem doesn't have anything to load from storage, it just sets it to the current time in nanoseconds.That would mean that a client would need to flush it's cache whenever the inode fell out of cache on the server, but I don't think we can reliably do better than that.
Quoted 6 lines
I think I like that approach.
So my vote is to increment
i_versionin common code every time any change is made to the file, andalloc_inodeshould initialise it to current time, which might be changed by the filesystem before it callsunlock_new_inode.
So the client would be invalidating its cache more often than necessary, rather than failing to invalidate it when it should. I agree that that's probably the better tradeoff, although I wish I had a better idea of the downside. I don't know, for example, whether users might see unpleasant results if every client has to reread its cached data on a reboot.
The currently proposed change--just providing a model change attribute implementation for ext4 and leaving other filesystems untouched--is a more conservative step.
So I'm inclined to just do this ext4 thing first, and then look into further change attribute experiments next time around....
--b.