Skip to contentSkip to conversation

NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR

PATCH In review Chuck Lever 2 participants 5 messages Jul 6, 2010 – Jul 8, 2010 1 message not in the archive

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

PATCH 1/1 NFSD: Fill in WCC data for REMOVE, RMDIR, MKNOD, and MKDIR

Some well-known NFSv3 clients drop their directory entry caches when they receive replies with no WCC data. Without this data, they employ extra READ, LOOKUP, and GETATTR requests to ensure their directory entry caches are up to date, causing performance to suffer needlessly.

In order to return WCC data, our server has to have both the pre-op and the post-op attribute data on hand when a reply is XDR encoded. The pre-op data is filled in when the incoming fh is locked, and the post-op data is filled in when the fh is unlocked.

Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh is not unlocked until well after the reply has been XDR encoded. This means that encode_wcc_data() does not have wcc_data for the parent directory, so none is returned to the client after these operations complete.

By unlocking the parent directory fh immediately after the internal operations for each NFS procedure is complete, the post-op data is filled in before XDR encoding starts, so it can be returned to the client properly.

---

Bruce-

This patch seems to go a long way towards fixing the pre-wcc data problem and related performance issues. Perhaps this patch is also appropriate for stable releases, though I haven't tested it with any.

 fs/nfsd/nfs3proc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
fs/nfsd/nfs3proc.c +4 -2
index 3d68f45..9ae9331 100644
@@ -271,7 +271,7 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
 	fh_init(&resp->fh, NFS3_FHSIZE);
 	nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
 				    &argp->attrs, S_IFDIR, 0, &resp->fh);
-
+	fh_unlock(&resp->dirfh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -327,7 +327,7 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp,
 	type = nfs3_ftypes[argp->ftype];
 	nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
 				    &argp->attrs, type, rdev, &resp->fh);
-
+	fh_unlock(&resp->dirfh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -348,6 +348,7 @@ nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
 	/* Unlink. -S_IFDIR means file must not be a directory */
 	fh_copy(&resp->fh, &argp->fh);
 	nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
+	fh_unlock(&resp->fh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -367,6 +368,7 @@ nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
 
 	fh_copy(&resp->fh, &argp->fh);
 	nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
+	fh_unlock(&resp->fh);
 	RETURN_STATUS(nfserr);
 }
 

A message that is not in the archive (sent off-list or not yet received): 20100706204750.2918.92546.stgit-ewv44WTpT0t9HhUboXbp9zCvJB+x5qRC@public.gmane.org

#2 lore raw
Quoted 2 lines · Chuck Lever

Some well-known NFSv3 clients drop their directory entry caches when they receive replies with no WCC data.

Can we include any more details? (And/or a simple test case that demonstrates the difference?)

Quoted 5 lines

Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their directory entry caches are up to date, causing performance to suffer needlessly.

Quoted 7 lines

In order to return WCC data, our server has to have both the pre-op and the post-op attribute data on hand when a reply is XDR encoded. The pre-op data is filled in when the incoming fh is locked, and the post-op data is filled in when the fh is unlocked.

Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh is not unlocked until well after the reply has been XDR encoded.

So it wasn't happening until an fh_put() was done in .pc_release()?

Quoted 9 lines

This
means that encode_wcc_data() does not have wcc_data for the parent directory, so none is returned to the client after these operations complete.

By unlocking the parent directory fh immediately after the internal operations for each NFS procedure is complete, the post-op data is filled in before XDR encoding starts, so it can be returned to the client properly.

Looks good to me, thanks, applying for 2.6.36.

Quoted 8 lines

---

Bruce-

This patch seems to go a long way towards fixing the pre-wcc data problem and related performance issues. Perhaps this patch is also appropriate for stable releases, though I haven't tested it with any.

If it's a longstanding problem, I'm inclined to leave it be on the grounds that people sticking with a stable release are resigned to the performance they've always had....

--b.

Quoted 44 lines

 fs/nfsd/nfs3proc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
fs/nfsd/nfs3proc.c +4 -2
index 3d68f45..9ae9331 100644
@@ -271,7 +271,7 @@ nfsd3_proc_mkdir(struct svc_rqst *rqstp, struct nfsd3_createargs *argp,
 	fh_init(&resp->fh, NFS3_FHSIZE);
 	nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
 				    &argp->attrs, S_IFDIR, 0, &resp->fh);
-
+	fh_unlock(&resp->dirfh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -327,7 +327,7 @@ nfsd3_proc_mknod(struct svc_rqst *rqstp, struct nfsd3_mknodargs *argp,
 	type = nfs3_ftypes[argp->ftype];
 	nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
 				    &argp->attrs, type, rdev, &resp->fh);
-
+	fh_unlock(&resp->dirfh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -348,6 +348,7 @@ nfsd3_proc_remove(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
 	/* Unlink. -S_IFDIR means file must not be a directory */
 	fh_copy(&resp->fh, &argp->fh);
 	nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
+	fh_unlock(&resp->fh);
 	RETURN_STATUS(nfserr);
 }
 
@@ -367,6 +368,7 @@ nfsd3_proc_rmdir(struct svc_rqst *rqstp, struct nfsd3_diropargs *argp,
 
 	fh_copy(&resp->fh, &argp->fh);
 	nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
+	fh_unlock(&resp->fh);
 	RETURN_STATUS(nfserr);
 }
 
#3 lore raw
Quoted 6 lines · J. Bruce Fields
Quoted 2 lines · Chuck Lever

Some well-known NFSv3 clients drop their directory entry caches when they receive replies with no WCC data.

Can we include any more details? (And/or a simple test case that demonstrates the difference?)

I have a version of this patch with a much more comprehensive description which I can post later today.

As for a test case... among other things, I untarred a large tarball on a Mac OS 10.6 NFS client, and, once the server was fixed, it went as quickly as you would expect. Before, it took much longer.

Quoted 10 lines
Quoted 10 lines

Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their directory entry caches are up to date, causing performance to suffer needlessly.

In order to return WCC data, our server has to have both the pre-op and the post-op attribute data on hand when a reply is XDR encoded. The pre-op data is filled in when the incoming fh is locked, and the post-op data is filled in when the fh is unlocked.

Quoted 4 lines
Quoted 2 lines

Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh is not unlocked until well after the reply has been XDR encoded.

So it wasn't happening until an fh_put() was done in .pc_release()?

Correct.

#4 lore raw
Quoted 10 lines · Chuck Lever
Quoted 6 lines · J. Bruce Fields
Quoted 2 lines · Chuck Lever

Some well-known NFSv3 clients drop their directory entry caches when they receive replies with no WCC data.

Can we include any more details? (And/or a simple test case that demonstrates the difference?)

I have a version of this patch with a much more comprehensive description which I can post later today.

Thanks, that would be interesting.

(Though note the version you posted is already applied for 2.6.36.)

--b.

Quoted 20 lines

As for a test case... among other things, I untarred a large tarball on a Mac OS 10.6 NFS client, and, once the server was fixed, it went as quickly as you would expect. Before, it took much longer.

Quoted 10 lines
Quoted 10 lines

Without this data, they
employ extra READ, LOOKUP, and GETATTR requests to ensure their directory entry caches are up to date, causing performance to suffer needlessly.

In order to return WCC data, our server has to have both the pre-op and the post-op attribute data on hand when a reply is XDR encoded. The pre-op data is filled in when the incoming fh is locked, and the post-op data is filled in when the fh is unlocked.

Quoted 4 lines
Quoted 2 lines

Unfortunately, for REMOVE, RMDIR, MKNOD, and MKDIR, the directory fh is not unlocked until well after the reply has been XDR encoded.

So it wasn't happening until an fh_put() was done in .pc_release()?

Correct.

#5 lore raw
In reply to Chuck Lever
Quoted 8 lines · Chuck Lever
Quoted 6 lines · J. Bruce Fields
Quoted 2 lines · Chuck Lever

Some well-known NFSv3 clients drop their directory entry caches when they receive replies with no WCC data.

Can we include any more details? (And/or a simple test case that demonstrates the difference?)

Quoted 6 lines

I have a version of this patch with a much more comprehensive description which I can post later today.

As for a test case... among other things, I untarred a large tarball on a Mac OS 10.6 NFS client, and, once the server was fixed, it went as quickly as you would expect. Before, it took much longer.

By the way, why isn't this reproduceable on the Linux client?

If it's ignoring whether updates are atomic--is that really OK?

--b.