Support for NFSv4 READ + WRITE attribute cache consistency
Subsystems (2)
PATCH 1/1 Support for NFSv4 READ + WRITE attribute cache consistency
Retrieve the post-operation attribute changes for NFSv4 READ and WRITE operations. Unlike for NFSv2 and NFSv3, we do not retrieve the full set of file attributes. The main reason for this is that interpreting attributes is a much heavier task on NFSv4 (requiring, for instance, translation of file owner names into uids ...). Hence
For a READ request, we retrieve only the 'change attribute' (for cache consistency checking) and the atime.
For a WRITE request, we retrieve the 'change attribute' and the file size. In addition, we retrieve the value of the change attribute prior to the write operation, in order to be able to do weak cache consistency checking.
Cheers,
Trond
fs/nfs/nfs3proc.c +31 -0
@@ -67,6 +67,20 @@return 1 ; } +static void +nfs3_write_refresh_inode (struct inode *inode,struct nfs_fattr *fattr) +{ +if (fattr->valid &NFS_ATTR_FATTR ) { +if (!(fattr->valid &NFS_ATTR_WCC )) { + fattr->pre_size =NFS_CACHE_ISIZE (inode); + fattr->pre_mtime =NFS_CACHE_MTIME (inode); + fattr->pre_ctime =NFS_CACHE_CTIME (inode); + fattr->valid |=NFS_ATTR_WCC ; + } +nfs_refresh_inode (inode, fattr); + } +} +/* * Bare-bones access to getattr: this is for nfs_read_super. */
@@ -239,6 +253,8 @@dprintk ("NFS call read %d @ %Ld\n" , count, (long long )offset); fattr->valid =0 ; status =rpc_call_sync (NFS_CLIENT (inode), &msg, flags); +if (status >=0 ) +nfs_refresh_inode (inode, fattr);dprintk ("NFS reply read: %d\n" , status); *eofp = res.eof;return status;
@@ -279,6 +295,9 @@ status =rpc_call_sync (NFS_CLIENT (inode), &msg, rpcflags); +if (status >=0 ) +nfs3_write_refresh_inode (inode, fattr); +dprintk ("NFS reply read: %d\n" , status);return status <0 ? status : res.count; }
@@ -685,9 +704,13 @@static void nfs3_read_done (struct rpc_task *task) { +struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; +if (nfs3_async_handle_jukebox (task))return ;/* Call back common NFS readpage processing */ +if (task->tk_status >=0 ) +nfs_refresh_inode (data->inode, &data->fattr);nfs_readpage_result (task); }
@@ -730,8 +753,12 @@static void nfs3_write_done (struct rpc_task *task) { +struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; +if (nfs3_async_handle_jukebox (task))return ; +if (task->tk_status >=0 ) +nfs3_write_refresh_inode (data->inode, data->res.fattr);nfs_writeback_done (task); }
@@ -784,8 +811,12 @@static void nfs3_commit_done (struct rpc_task *task) { +struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata; +if (nfs3_async_handle_jukebox (task))return ; +if (task->tk_status >=0 ) +nfs3_write_refresh_inode (data->inode, data->res.fattr);nfs_commit_done (task); }
fs/nfs/nfs4proc.c +43 -5
85 lines not on this page · raw message
fs/nfs/nfs4xdr.c +242 -12
361 lines not on this page · raw message
fs/nfs/proc.c +39 -2
83 lines not on this page · raw message
fs/nfs/read.c +0 -3
@@ -100,7 +100,6 @@lock_kernel (); result =NFS_PROTO (inode)->read (inode, cred, &fattr, flags, offset, rsize, page, &eof); -nfs_refresh_inode (inode, &fattr);unlock_kernel ();/*
@@ -258,14 +257,12 @@ nfs_readpage_result(struct rpc_task *task) {struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata; -struct inode *inode = data->inode;struct nfs_fattr *fattr = &data->fattr;unsigned int count = data->res.count;dprintk ("NFS: %4d nfs_readpage_result, (status %d)\n" , task->tk_pid, task->tk_status); -nfs_refresh_inode (inode, fattr);while (!list_empty (&data->pages)) {struct nfs_page *req =nfs_list_entry (data->pages.next);struct page *page = req->wb_page;
fs/nfs/write.c +0 -21
@@ -125,23 +125,6 @@ }/* -* This function will be used to simulate weak cache consistency -* under NFSv2 when the NFSv3 attribute patch is included. -* For the moment, we just call nfs_refresh_inode(). -*/ -static __inline__int -nfs_write_attributes (struct inode *inode,struct nfs_fattr *fattr) -{ -if ((fattr->valid &NFS_ATTR_FATTR ) && !(fattr->valid &NFS_ATTR_WCC )) { - fattr->pre_size =NFS_CACHE_ISIZE (inode); - fattr->pre_mtime =NFS_CACHE_MTIME (inode); - fattr->pre_ctime =NFS_CACHE_CTIME (inode); - fattr->valid |=NFS_ATTR_WCC ; - } -return nfs_refresh_inode (inode, fattr); -} - -/* * Write a page synchronously. * Offset is the data offset within the page. */
@@ -178,7 +161,6 @@ result =NFS_PROTO (inode)->write (inode, cred, &fattr, flags, offset, wsize, page, &verf); -nfs_write_attributes (inode, &fattr);if (result <0 ) {/* Must mark the page invalid after I/O error */
@@ -893,7 +875,6 @@* writebacks since the page->count is kept > 1 for as long * as the page has a write request pending. */ -nfs_write_attributes (inode, &data->fattr);while (!list_empty (&data->pages)) { req =nfs_list_entry (data->pages.next);nfs_list_remove_request (req);
@@ -1018,12 +999,10 @@ {struct nfs_write_data *data = (struct nfs_write_data *)task->tk_calldata;struct nfs_page *req; -struct inode *inode = data->inode;dprintk ("NFS: %4d nfs_commit_done (status %d)\n" , task->tk_pid, task->tk_status); -nfs_write_attributes (inode, &data->fattr);while (!list_empty (&data->pages)) { req =nfs_list_entry (data->pages.next);nfs_list_remove_request (req);
include/linux/nfs_xdr.h +3 -0
@@ -35,8 +35,11 @@struct timespec atime;struct timespec mtime;struct timespec ctime; +#ifdef CONFIG_NFS_V4 +__u32 bitmap[2 ];/* NFSv4 returned attribute bitmap */ __u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ +#endif unsigned long timestamp; };
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
I _really_ don't like crud like this.
NFS v4 is still not exactly common, but this change makes the kernel uncompilable if you have one of the common NFS clients but didn't enable NFS_V4 - those fields are used unconditionally, but they are only defined conditionally.
Please don't do this, and please _do_ test with "normal" configurations.
Linus
Quoted 8 lines · Trond Myklebust
diff -u --recursive --new-file
linux-2.5.52-02-nfsv4_write/include/linux/nfs_xdr.hlinux-2.5.52-03-nfsv4_attr/include/linux/nfs_xdr.hinclude/linux/nfs_xdr.h +0
-0@@ -35,8 +35,11 @@struct timespec atime;
include/linux/nfs_xdr.h line 45
Quoted 10 lines
include/linux/nfs_xdr.h +3
-0struct timespec mtime;struct timespec ctime; +#ifdef CONFIG_NFS_V4 +__u32 bitmap[2 ];/* NFSv4 returned attribute bitmap */ __u64 change_attr;/* NFSv4 change attribute */ __u64 pre_change_attr;/* pre-op NFSv4 change attribute */ +#endif unsigned long timestamp; };
-------------------------------------------------------
This SF.NET email is sponsored by: The Best Geek Holiday Gifts! Time is running out! Thinkgeek.com has the coolest gifts for
your favorite geek. Let your fingers do the typing. Visit Now.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs
Quoted 8 lines · Linus Torvalds
I _really_ don't like crud like this.
NFS v4 is still not exactly common, but this change makes the kernel uncompilable if you have one of the common NFS clients but didn't enable
NFS_V4- those fields are used unconditionally, but they are only defined conditionally.Please don't do this, and please _do_ test with "normal" configurations.
Sorry. I'm still not quite finished looking into how to share the struct nfs_fattr between v2, v3, and v4 (in particular, I worry that we are currently being fairly careless with space) but I agree that breaking stock v2 and v3 in the process is not very productive behaviour 8-)...
Cheers,
Trond
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs