linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kNFSd 001 of 3] semaphore to mutex conversion.
  2006-01-13  3:14 [PATCH kNFSd 000 of 3] Introduction NeilBrown
@ 2006-01-13  3:14 ` NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 002 of 3] Fix some more errno/nfserr confusion in vfs.c NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 003 of 3] Provide missing NFSv2 part of patch for checking vfs_getattr NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-01-13  3:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nfs, linux-kernel


From: Ingo Molnar <mingo@elte.hu>

the conversion was generated via scripts, and the result was validated
automatically via a script as well.

build and boot tested.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./include/linux/sunrpc/svcsock.h |    2 +-
 ./net/sunrpc/svcsock.c           |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff ./include/linux/sunrpc/svcsock.h~current~ ./include/linux/sunrpc/svcsock.h
--- ./include/linux/sunrpc/svcsock.h~current~	2006-01-13 12:37:33.000000000 +1100
+++ ./include/linux/sunrpc/svcsock.h	2006-01-13 12:37:33.000000000 +1100
@@ -36,7 +36,7 @@ struct svc_sock {
 
 	struct list_head	sk_deferred;	/* deferred requests that need to
 						 * be revisted */
-	struct semaphore        sk_sem;		/* to serialize sending data */
+	struct mutex		sk_mutex;	/* to serialize sending data */
 
 	int			(*sk_recvfrom)(struct svc_rqst *rqstp);
 	int			(*sk_sendto)(struct svc_rqst *rqstp);

diff ./net/sunrpc/svcsock.c~current~ ./net/sunrpc/svcsock.c
--- ./net/sunrpc/svcsock.c~current~	2006-01-13 12:37:25.000000000 +1100
+++ ./net/sunrpc/svcsock.c	2006-01-13 12:37:33.000000000 +1100
@@ -1296,13 +1296,13 @@ svc_send(struct svc_rqst *rqstp)
 		xb->page_len +
 		xb->tail[0].iov_len;
 
-	/* Grab svsk->sk_sem to serialize outgoing data. */
-	down(&svsk->sk_sem);
+	/* Grab svsk->sk_mutex to serialize outgoing data. */
+	mutex_lock(&svsk->sk_mutex);
 	if (test_bit(SK_DEAD, &svsk->sk_flags))
 		len = -ENOTCONN;
 	else
 		len = svsk->sk_sendto(rqstp);
-	up(&svsk->sk_sem);
+	mutex_unlock(&svsk->sk_mutex);
 	svc_sock_release(rqstp);
 
 	if (len == -ECONNREFUSED || len == -ENOTCONN || len == -EAGAIN)
@@ -1351,7 +1351,7 @@ svc_setup_socket(struct svc_serv *serv, 
 	svsk->sk_lastrecv = get_seconds();
 	INIT_LIST_HEAD(&svsk->sk_deferred);
 	INIT_LIST_HEAD(&svsk->sk_ready);
-	sema_init(&svsk->sk_sem, 1);
+	mutex_init(&svsk->sk_mutex);
 
 	/* Initialize the socket */
 	if (sock->type == SOCK_DGRAM)

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

* [PATCH kNFSd 000 of 3] Introduction
@ 2006-01-13  3:14 NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 001 of 3] semaphore to mutex conversion NeilBrown
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: NeilBrown @ 2006-01-13  3:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nfs, linux-kernel

Three more assorted nfsd patches.
The last is somewhat embarassing... a previous patch completely left out the
nfsv2 section.  This didn't cause compile errors, but completely broke
NFSv2 service... and it was in -mm for at least a month with noone noticing.

 [PATCH kNFSd 001 of 3] semaphore to mutex conversion.
 [PATCH kNFSd 002 of 3] Fix some more errno/nfserr confusion in vfs.c
 [PATCH kNFSd 003 of 3] Provide missing NFSv2 part of patch for checking vfs_getattr.

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

* [PATCH kNFSd 002 of 3] Fix some more errno/nfserr confusion in vfs.c
  2006-01-13  3:14 [PATCH kNFSd 000 of 3] Introduction NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 001 of 3] semaphore to mutex conversion NeilBrown
@ 2006-01-13  3:14 ` NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 003 of 3] Provide missing NFSv2 part of patch for checking vfs_getattr NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-01-13  3:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nfs, linux-kernel


From: NeilBrown <neilb@suse.de>

nfsd_sync* return an errno, which usually needs to be converted to an errno,
sometimes immediately, sometimes a little later.

Also, nfsd_setattr returns an nfserr which SHOULDN'T be converted from
an errno (because it isn't one).

Also some tidyups of the form:
  err = XX
  err = nfserrno(err)
and
  err = XX
  if (err)
      err = nfserrno(err)
become
  err = nfserrno(XX)

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./fs/nfsd/vfs.c |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff ./fs/nfsd/vfs.c~current~ ./fs/nfsd/vfs.c
--- ./fs/nfsd/vfs.c~current~	2006-01-13 12:37:26.000000000 +1100
+++ ./fs/nfsd/vfs.c	2006-01-13 13:20:55.000000000 +1100
@@ -891,9 +891,9 @@ nfsd_vfs_write(struct svc_rqst *rqstp, s
 	int			err = 0;
 	int			stable = *stablep;
 
+#ifdef MSNFS
 	err = nfserr_perm;
 
-#ifdef MSNFS
 	if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
 		(!lock_may_write(file->f_dentry->d_inode, offset, cnt)))
 		goto out;
@@ -1065,8 +1065,7 @@ nfsd_commit(struct svc_rqst *rqstp, stru
 		return err;
 	if (EX_ISSYNC(fhp->fh_export)) {
 		if (file->f_op && file->f_op->fsync) {
-			err = nfsd_sync(file);
-			err = nfserrno(err);
+			err = nfserrno(nfsd_sync(file));
 		} else {
 			err = nfserr_notsupp;
 		}
@@ -1177,7 +1176,7 @@ nfsd_create(struct svc_rqst *rqstp, stru
 		goto out_nfserr;
 
 	if (EX_ISSYNC(fhp->fh_export)) {
-		err = nfsd_sync_dir(dentry);
+		err = nfserrno(nfsd_sync_dir(dentry));
 		write_inode_now(dchild->d_inode, 1);
 	}
 
@@ -1310,9 +1309,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, s
 		goto out_nfserr;
 
 	if (EX_ISSYNC(fhp->fh_export)) {
-		err = nfsd_sync_dir(dentry);
-		if (err)
-			err = nfserrno(err);
+		err = nfserrno(nfsd_sync_dir(dentry));
 		/* setattr will sync the child (or not) */
 	}
 
@@ -1339,7 +1336,7 @@ nfsd_create_v3(struct svc_rqst *rqstp, s
 	if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID)) != 0) {
  		int err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
 		if (err2)
-			err = nfserrno(err2);
+			err = err2;
 	}
 
 	/*
@@ -1514,10 +1511,8 @@ nfsd_link(struct svc_rqst *rqstp, struct
 	err = vfs_link(dold, dirp, dnew);
 	if (!err) {
 		if (EX_ISSYNC(ffhp->fh_export)) {
-			err = nfsd_sync_dir(ddir);
+			err = nfserrno(nfsd_sync_dir(ddir));
 			write_inode_now(dest, 1);
-			if (err)
-				err = nfserrno(err);
 		}
 	} else {
 		if (err == -EXDEV && rqstp->rq_vers == 2)

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

* [PATCH kNFSd 003 of 3] Provide missing NFSv2 part of patch for checking vfs_getattr.
  2006-01-13  3:14 [PATCH kNFSd 000 of 3] Introduction NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 001 of 3] semaphore to mutex conversion NeilBrown
  2006-01-13  3:14 ` [PATCH kNFSd 002 of 3] Fix some more errno/nfserr confusion in vfs.c NeilBrown
@ 2006-01-13  3:14 ` NeilBrown
  2 siblings, 0 replies; 4+ messages in thread
From: NeilBrown @ 2006-01-13  3:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: nfs, linux-kernel


From: David Shaw <dshaw@jabberwocky.com>

A recent patch which checked the return status of vfs_getattr in nfsd,
completely missed the nfsproc.c (NFSv2) part.  Here is it.

This patch moved the call to vfs_getattr from the xdr encoding (at
which point it is too late to return an error) to the call handling.
This means several calls to vfs_getattr are needed in nfsproc.c.  Many
are encapsulated in nfsd_return_attrs and nfsd_return_dirop.

Signed-off-by: Neil Brown <neilb@suse.de>

### Diffstat output
 ./fs/nfsd/nfsproc.c |   37 ++++++++++++++++++++++++++++++-------
 1 file changed, 30 insertions(+), 7 deletions(-)

diff ./fs/nfsd/nfsproc.c~current~ ./fs/nfsd/nfsproc.c
--- ./fs/nfsd/nfsproc.c~current~	2006-01-13 13:42:09.000000000 +1100
+++ ./fs/nfsd/nfsproc.c	2006-01-13 13:42:14.000000000 +1100
@@ -36,6 +36,22 @@ nfsd_proc_null(struct svc_rqst *rqstp, v
 	return nfs_ok;
 }
 
+static int
+nfsd_return_attrs(int err, struct nfsd_attrstat *resp)
+{
+	if (err) return err;
+	return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+				    resp->fh.fh_dentry,
+				    &resp->stat));
+}
+static int
+nfsd_return_dirop(int err, struct nfsd_diropres *resp)
+{
+	if (err) return err;
+	return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+				    resp->fh.fh_dentry,
+				    &resp->stat));
+}
 /*
  * Get a file's attributes
  * N.B. After this call resp->fh needs an fh_put
@@ -44,10 +60,12 @@ static int
 nfsd_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle  *argp,
 					  struct nfsd_attrstat *resp)
 {
+	int nfserr;
 	dprintk("nfsd: GETATTR  %s\n", SVCFH_fmt(&argp->fh));
 
 	fh_copy(&resp->fh, &argp->fh);
-	return fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
+	nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP);
+	return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -58,12 +76,14 @@ static int
 nfsd_proc_setattr(struct svc_rqst *rqstp, struct nfsd_sattrargs *argp,
 					  struct nfsd_attrstat  *resp)
 {
+	int nfserr;
 	dprintk("nfsd: SETATTR  %s, valid=%x, size=%ld\n",
 		SVCFH_fmt(&argp->fh),
 		argp->attrs.ia_valid, (long) argp->attrs.ia_size);
 
 	fh_copy(&resp->fh, &argp->fh);
-	return nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0);
+	nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,0, (time_t)0);
+	return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -86,7 +106,7 @@ nfsd_proc_lookup(struct svc_rqst *rqstp,
 				 &resp->fh);
 
 	fh_put(&argp->fh);
-	return nfserr;
+	return nfsd_return_dirop(nfserr, resp);
 }
 
 /*
@@ -142,7 +162,10 @@ nfsd_proc_read(struct svc_rqst *rqstp, s
 			   	  argp->vec, argp->vlen,
 				  &resp->count);
 
-	return nfserr;
+	if (nfserr) return nfserr;
+	return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt,
+				    resp->fh.fh_dentry,
+				    &resp->stat));
 }
 
 /*
@@ -165,7 +188,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, 
 				   argp->vec, argp->vlen,
 				   argp->len,
 				   &stable);
-	return nfserr;
+	return nfsd_return_attrs(nfserr, resp);
 }
 
 /*
@@ -322,7 +345,7 @@ out_unlock:
 
 done:
 	fh_put(dirfhp);
-	return nfserr;
+	return nfsd_return_dirop(nfserr, resp);
 }
 
 static int
@@ -425,7 +448,7 @@ nfsd_proc_mkdir(struct svc_rqst *rqstp, 
 	nfserr = nfsd_create(rqstp, &argp->fh, argp->name, argp->len,
 				    &argp->attrs, S_IFDIR, 0, &resp->fh);
 	fh_put(&argp->fh);
-	return nfserr;
+	return nfsd_return_dirop(nfserr, resp);
 }
 
 /*

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

end of thread, other threads:[~2006-01-13  3:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-13  3:14 [PATCH kNFSd 000 of 3] Introduction NeilBrown
2006-01-13  3:14 ` [PATCH kNFSd 001 of 3] semaphore to mutex conversion NeilBrown
2006-01-13  3:14 ` [PATCH kNFSd 002 of 3] Fix some more errno/nfserr confusion in vfs.c NeilBrown
2006-01-13  3:14 ` [PATCH kNFSd 003 of 3] Provide missing NFSv2 part of patch for checking vfs_getattr NeilBrown

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