Skip to contentSkip to conversation

nfsd/vfs.c: endianness fixes

PATCH New Al Viro 1 participant 5 messages Dec 25, 2005 NFS server

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 nfsd/vfs.c: endianness fixes

From: Al Viro <[email protected]>
Date: 1135476096 -0500

several failure exits return -E<something> instead of nfserr_<something> and vice versa.

---

 fs/nfsd/vfs.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

38c78c8cfcd1be715fb280f83e2b1ce2f709abc8

fs/nfsd/vfs.c +3 -3
index af7c3c3..f237f98 100644
@@ -1134,7 +1134,7 @@ nfsd_create(struct svc_rqst *rqstp, stru
 				"nfsd_create: parent %s/%s not locked!\n",
 				dentry->d_parent->d_name.name,
 				dentry->d_name.name);
-			err = -EIO;
+			err = nfserr_io;
 			goto out;
 		}
 	}
@@ -1592,7 +1592,7 @@ nfsd_rename(struct svc_rqst *rqstp, stru
 	if ((ffhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
 		((atomic_read(&odentry->d_count) > 1)
 		 || (atomic_read(&ndentry->d_count) > 1))) {
-			err = nfserr_perm;
+			err = -EPERM;
 	} else
 #endif
 	err = vfs_rename(fdir, odentry, tdir, ndentry);
@@ -1663,7 +1663,7 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
 #ifdef MSNFS
 		if ((fhp->fh_export->ex_flags & NFSEXP_MSNFS) &&
 			(atomic_read(&rdentry->d_count) > 1)) {
-			err = nfserr_perm;
+			err = -EPERM;
 		} else
 #endif
 		err = vfs_unlink(dirp, rdentry);
Signature · 1 line
0.99.9.GIT
author
#1 lore raw

PATCH 1/1 nfsd4_truncate() bogus return value

From: Al Viro <[email protected]>
Date: 1135492779 -0500

-EINVAL (in host order, no less) is not a good thing to return to client. nfsd4_truncate() returns it in one case and its callers expect nfs_.... from it. AFAICS, it should be nfserr_inval

---

 fs/nfsd/nfs4state.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

af894f171cc6fb5612ff74a3d32c62492c7a5a98

fs/nfsd/nfs4state.c +1 -1
index 6bbefd0..7fec0ac 100644
@@ -1648,7 +1648,7 @@ nfsd4_truncate(struct svc_rqst *rqstp, s
 	if (!open->op_truncate)
 		return 0;
 	if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
-		return -EINVAL;
+		return nfserr_inval;
 	return nfsd_setattr(rqstp, fh, &iattr, 0, (time_t)0);
 }
 
Signature · 1 line
0.99.9.GIT
author
#2 lore raw

PATCH 1/1 NFSERR_SERVERFAULT returned host-endian

In reply to Al Viro

From: Al Viro <[email protected]>
Date: 1135492936 -0500

->rp_status is network-endian and nobody byteswaps it before sending to client; putting NFSERR_SERVERFAULT instead of nfserr_serverfault in there is not nice...

---

 fs/nfsd/nfs4state.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

8b3750ba77fdb6939689cbeff336d6153531fe96

fs/nfsd/nfs4state.c +2 -2
index 7fec0ac..71689b0 100644
@@ -1088,7 +1088,7 @@ alloc_init_open_stateowner(unsigned int 
 	sop->so_seqid = open->op_seqid;
 	sop->so_confirmed = 0;
 	rp = &sop->so_replay;
-	rp->rp_status = NFSERR_SERVERFAULT;
+	rp->rp_status = nfserr_serverfault;
 	rp->rp_buflen = 0;
 	rp->rp_buf = rp->rp_ibuf;
 	return sop;
@@ -2633,7 +2633,7 @@ alloc_init_lock_stateowner(unsigned int 
 	sop->so_seqid = lock->lk_new_lock_seqid + 1;
 	sop->so_confirmed = 1;
 	rp = &sop->so_replay;
-	rp->rp_status = NFSERR_SERVERFAULT;
+	rp->rp_status = nfserr_serverfault;
 	rp->rp_buflen = 0;
 	rp->rp_buf = rp->rp_ibuf;
 	return sop;
Signature · 1 line
0.99.9.GIT
author
#3 lore raw

PATCH 1/1 nfsd4_lock() returns bogus values to clients

In reply to Al Viro

From: Al Viro <[email protected]>
Date: 1135493243 -0500

missing nfserror() in default case of a switch by return value of posix_lock_file(); as the result we send negative host-endian to clients that expect positive network-endian, preferably mentioned in RFC... BTW, that case is not impossible - posix_lock_file() can return -ENOLCK and we do not handle that one explicitly.

---

 fs/nfsd/nfs4state.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

d91fdfa7ab75e45dd9dba36808d36fc2e1d5c634

fs/nfsd/nfs4state.c +3 -0
index 71689b0..f32f68c 100644
@@ -2815,7 +2815,10 @@ nfsd4_lock(struct svc_rqst *rqstp, struc
 		goto conflicting_lock;
 	case (EDEADLK):
 		status = nfserr_deadlock;
+		dprintk("NFSD: nfsd4_lock: posix_lock_file() failed! status %d\n",status);
+		goto out_destroy_new_stateid;
 	default:        
+		status = nfserror(status);
 		dprintk("NFSD: nfsd4_lock: posix_lock_file() failed! status %d\n",status);
 		goto out_destroy_new_stateid;
 	}
Signature · 1 line
0.99.9.GIT
author
#4 lore raw

Re: [PATCH] nfsd4_lock() returns bogus values to clients

Quoted 8 lines · Al Viro

From: Al Viro <[email protected]>
Date: 1135493243 -0500

missing nfserror() in default case of a switch by return value of posix_lock_file(); as the result we send negative host-endian to clients that expect positive network-endian, preferably mentioned in RFC... BTW, that case is not impossible - posix_lock_file() can return -ENOLCK and we do not handle that one explicitly.

Gaack... s/nfserror/nfserrno/, of course...