Skip to contentSkip to conversation

Introduction

PATCH In review NeilBrown 2 participants 19 messages Mar 22, 2005

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 Introduction

Following are 16 patches against nfsd in 2.6.12-rc1-mm1

Most are nfsv4 related.
Patch 2 removes an inexplicable increment of f_count for a file. This fixes a problem wherein an exported filesystem may never be unmountable because a file on it is never closed.

This could possibly be a candidate for 2.6.12. The rest should wait to go in to 2.6.13-rc

NeilBrown

[PATCH kNFSd 0 of 16] Introduction
[PATCH kNFSd 1 of 16] svcrpc: auth_domain documentation
[PATCH kNFSd 2 of 16] nlm: fix f_count leak
[PATCH kNFSd 3 of 16] nfsd4: fix share conflict tests
[PATCH kNFSd 4 of 16] nfsd4: remove unneeded stateowner arguments [PATCH kNFSd 5 of 16] nfsd4: fix use after put() in cb_recall [PATCH kNFSd 6 of 16] nfsd4: allow read on open for write
[PATCH kNFSd 7 of 16] nfsd4: factor out common open_truncate code [PATCH kNFSd 8 of 16] nfsd4: fix failure to truncate on some opens [PATCH kNFSd 9 of 16] nfsd4_remove_unused_acl_function
[PATCH kNFSd 10 of 16] nfsd4: don't set WRITE_OWNER in either allow or deny bits [PATCH kNFSd 11 of 16] nfsd4: acl don't set named attrs
[PATCH kNFSd 12 of 16] nfsd4: acl error fix
[PATCH kNFSd 13 of 16] nfsd4: rename release_delegation
[PATCH kNFSd 14 of 16] nfsd4: remove trailing whitespace from nfs4proc.c [PATCH kNFSd 15 of 16] nfsd4: fix open returns for other claim types [PATCH kNFSd 16 of 16] nfsd4: fix indentation in nfsd4_open

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#1 lore raw

PATCH 1/1 nfsd4: rename release_delegation

Release_delegation is responsible for removing the delegation's connection with the v4 state and with the lease subsystem. The word "unhash" seems closer than "release" as a description of this....

### Diffstat output

 ./fs/nfsd/nfs4state.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +6 -10
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -176,15 +176,11 @@ nfs4_put_delegation(struct nfs4_delegati
 	}
 }
 
-/* release_delegation:
- *
- * Remove the associated file_lock first, then remove the delegation.
+/* Remove the associated file_lock first, then remove the delegation.
  * lease_modify() is called to remove the FS_LEASE file_lock from
  * the i_flock list, eventually calling nfsd's lock_manager
  * fl_release_callback.
- *
  */
-
 static void
 nfs4_close_delegation(struct nfs4_delegation *dp)
 {
@@ -201,7 +197,7 @@ nfs4_close_delegation(struct nfs4_delega
 
 /* Called under the state lock. */
 static void
-release_delegation(struct nfs4_delegation *dp)
+unhash_delegation(struct nfs4_delegation *dp)
 {
 	list_del_init(&dp->dl_del_perfile);
 	list_del_init(&dp->dl_del_perclnt);
@@ -345,7 +341,7 @@ expire_client(struct nfs4_client *clp)
 	while (!list_empty(&reaplist)) {
 		dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
 		list_del_init(&dp->dl_recall_lru);
-		release_delegation(dp);
+		unhash_delegation(dp);
 	}
 	list_del(&clp->cl_idhash);
 	list_del(&clp->cl_strhash);
@@ -1859,7 +1855,7 @@ nfs4_laundromat(void)
 	list_for_each_safe(pos, next, &reaplist) {
 		dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
 		list_del_init(&dp->dl_recall_lru);
-		release_delegation(dp);
+		unhash_delegation(dp);
 	}
 	test_val = NFSD_LEASE_TIME;
 	list_for_each_safe(pos, next, &close_lru) {
@@ -2064,7 +2060,7 @@ nfs4_preprocess_stateid_op(struct svc_fh
 			goto out;
 		renew_client(dp->dl_client);
 		if (flags & DELEG_RET)
-			release_delegation(dp);
+			unhash_delegation(dp);
 		if (filpp)
 			*filpp = dp->dl_vfs_file;
 	}
@@ -3239,7 +3235,7 @@ __nfs4_state_shutdown(void)
 	list_for_each_safe(pos, next, &reaplist) {
 		dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
 		list_del_init(&dp->dl_recall_lru);
-		release_delegation(dp);
+		unhash_delegation(dp);
 	}
 
 	release_all_files();

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#2 lore raw

PATCH 1/1 nfsd4: fix open returns for other claim types

In reply to NeilBrown

Switch on OPEN claim type instead of if-else. add remaining OPEN claim types.

Return nfserr_notsupp instead of nfserr_inval for valid claim types.

### Diffstat output

 ./fs/nfsd/nfs4proc.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +21 -11
diff ./fs/nfsd/nfs4proc.c~current~ ./fs/nfsd/nfs4proc.c
@@ -197,30 +197,40 @@ nfsd4_open(struct svc_rqst *rqstp, struc
 	}
 	if (status)
 		goto out;
-	if (open->op_claim_type == NFS4_OPEN_CLAIM_NULL) {
+	switch (open->op_claim_type) {
+		case NFS4_OPEN_CLAIM_NULL:
 	/*
 	 * This block of code will (1) set CURRENT_FH to the file being opened,
 	 * creating it if necessary, (2) set open->op_cinfo,
 	 * (3) set open->op_truncate if the file is to be truncated
 	 * after opening, (4) do permission checking.
 	 */
-		status = do_open_lookup(rqstp, current_fh, open);
-		if (status)
-			goto out;
-	} else if (open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) {
+			status = do_open_lookup(rqstp, current_fh, open);
+			if (status)
+				goto out;
+			break;
+		case NFS4_OPEN_CLAIM_PREVIOUS:
 	/*
 	* The CURRENT_FH is already set to the file being opened. This
 	* block of code will (1) set open->op_cinfo, (2) set
 	* open->op_truncate if the file is to be truncated after opening,
 	* (3) do permission checking.
 	*/
-		status = do_open_fhandle(rqstp, current_fh, open);
-		if (status)
+			status = do_open_fhandle(rqstp, current_fh, open);
+			if (status)
+				goto out;
+			break;
+		case NFS4_OPEN_CLAIM_DELEGATE_CUR:
+             	case NFS4_OPEN_CLAIM_DELEGATE_PREV:
+			printk("NFSD: unsupported OPEN claim type %d\n",
+				open->op_claim_type);
+			status = nfserr_notsupp;
+			goto out;
+		default:
+			printk("NFSD: Invalid OPEN claim type %d\n",
+				open->op_claim_type);
+			status = nfserr_inval;
 			goto out;
-	} else {
-		printk("NFSD: unsupported OPEN claim type\n");
-		status = nfserr_inval;
-		goto out;
 	}
 	/*
 	 * nfsd4_process_open2() does the actual opening of the file.  If

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#3 lore raw

PATCH 1/1 svcrpc: auth_domain documentation

In reply to NeilBrown

The use of auth_domains is somewhat confusing, in part because they were originally intended to be used in a more general way than they currently are.

Update the documentation a little with an eye towards how it's currently used.

### Diffstat output

 ./include/linux/sunrpc/svcauth.h |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
include/linux/sunrpc/svcauth.h renamed from include/linux/sunrpc/svcauth.h~current~ +8 -6
diff ./include/linux/sunrpc/svcauth.h~current~ ./include/linux/sunrpc/svcauth.h
@@ -26,21 +26,23 @@ struct svc_cred {
 struct svc_rqst;		/* forward decl */
 
 /* Authentication is done in the context of a domain.
- * For a server, a domain represents a group of clients using
+ *
+ * Currently, the nfs server uses the auth_domain to stand
+ * for the "client" listed in /etc/exports.
+ *
+ * More generally, a domain might represent a group of clients using
  * a common mechanism for authentication and having a common mapping
  * between local identity (uid) and network identity.  All clients
  * in a domain have similar general access rights.  Each domain can
  * contain multiple principals which will have different specific right
  * based on normal Discretionary Access Control.
  *
- * For a client, a domain represents a number of servers which all
- * use a common authentication mechanism and network identity name space.
- *
  * A domain is created by an authentication flavour module based on name
  * only.  Userspace then fills in detail on demand.
  *
- * The creation of a domain typically implies creation of one or
- * more caches for storing domain specific information.
+ * In the case of auth_unix and auth_null, the auth_domain is also
+ * associated with entries in another cache representing the mapping
+ * of ip addresses to the given client.
  */
 struct auth_domain {
 	struct	cache_head	h;

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#4 lore raw

PATCH 1/1 nfsd4: fix use after put() in cb_recall

In reply to NeilBrown

nfs4_put_delegation() did a dprintk using a pointer that it had just called a put() on. This could cause a dereference of a pointer to freed memory in some situations.

### Diffstat output

 ./fs/nfsd/nfs4callback.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c~current~ +1 -1
diff ./fs/nfsd/nfs4callback.c~current~ ./fs/nfsd/nfs4callback.c
@@ -541,7 +541,7 @@ out:
 		atomic_set(&clp->cl_callback.cb_set, 0);
 	/* Success or failure, now we're either waiting for lease expiration
 	 * or deleg_return. */
-	nfs4_put_delegation(dp);
 	dprintk("NFSD: nfs4_cb_recall: dp %p dl_flock %p dl_count %d\n",dp, dp->dl_flock, atomic_read(&dp->dl_count));
+	nfs4_put_delegation(dp);
 	return;
 }

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#5 lore raw

PATCH 1/1 nfsd4: fix failure to truncate on some opens

In reply to NeilBrown

An OPEN upgrade on a file already open for WRITE will not upgrade the OPEN, but can still truncate the file.

### Diffstat output

 ./fs/nfsd/nfs4state.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +15 -14
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -1602,21 +1602,22 @@ nfs4_upgrade_open(struct svc_rqst *rqstp
 	share_access = ~share_access;
 	share_access &= open->op_share_access;
 
-	/* update the struct file */
-	if (share_access & NFS4_SHARE_ACCESS_WRITE) {
-		status = get_write_access(inode);
-		if (status)
-			return nfserrno(status);
-		status = nfsd4_truncate(rqstp, cur_fh, open);
-		if (status) {
-			put_write_access(inode);
-			return status;
-		}
-		/* remember the open */
-		filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ;
-		set_bit(open->op_share_access, &stp->st_access_bmap);
-		set_bit(open->op_share_deny, &stp->st_deny_bmap);
+	if (!(share_access & NFS4_SHARE_ACCESS_WRITE))
+		return nfsd4_truncate(rqstp, cur_fh, open);
+
+	status = get_write_access(inode);
+	if (status)
+		return nfserrno(status);
+	status = nfsd4_truncate(rqstp, cur_fh, open);
+	if (status) {
+		put_write_access(inode);
+		return status;
 	}
+	/* remember the open */
+	filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ;
+	set_bit(open->op_share_access, &stp->st_access_bmap);
+	set_bit(open->op_share_deny, &stp->st_deny_bmap);
+
 	return nfs_ok;
 }
 

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#6 lore raw

PATCH 1/1 nfsd4: allow read on open for write

In reply to NeilBrown

The rfc recommends allowing read using stateid's from opens that only requested write access, as clients may in some cases be unable to write without doing reads.

### Diffstat output

 ./fs/nfsd/nfs4state.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +2 -1
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -1928,7 +1928,8 @@ static inline int
 access_permit_read(unsigned long access_bmap)
 {
 	return test_bit(NFS4_SHARE_ACCESS_READ, &access_bmap) ||
-		test_bit(NFS4_SHARE_ACCESS_BOTH, &access_bmap);
+		test_bit(NFS4_SHARE_ACCESS_BOTH, &access_bmap) ||
+		test_bit(NFS4_SHARE_ACCESS_WRITE, &access_bmap);
 }
 
 static inline int

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#7 lore raw

PATCH 1/1 nfsd4: acl error fix

In reply to NeilBrown

When a client sends an ACL that is a legal NFSv4 ACL, but that we don't support (because we can't represent it using a POSIX ACL), the correct error to return is NFS4ERR_ATTRNOTSUPP.

(rfc3530, section 5.11.1: "If the server recieves a request to set an ACE that it cannot store, it MUST reject the request with NFS4ERR_ATTRNOTSUPP. If the server receives a request to set an ACE that it can store but cannot enforce, the server SHOULD reject the request with NFS4ERR_ATTRNOTSUPP").

### Diffstat output

 ./fs/nfsd/nfs4acl.c |    3 +++
 ./fs/nfsd/nfs4xdr.c |    5 ++++-
 ./fs/nfsd/vfs.c     |    7 +++++--
 3 files changed, 12 insertions(+), 3 deletions(-)
fs/nfsd/nfs4acl.c renamed from fs/nfsd/nfs4acl.c~current~ +3 -0
diff ./fs/nfsd/nfs4acl.c~current~ ./fs/nfsd/nfs4acl.c
@@ -93,6 +93,9 @@ deny_mask(u32 allow_mask, unsigned int f
 	return ret;
 }
 
+/* XXX: modify functions to return NFS errors; they're only ever
+ * used by nfs code, after all.... */
+
 static int
 mode_from_nfs4(u32 perm, unsigned short *mode, unsigned int flags)
 {
fs/nfsd/nfs4xdr.c renamed from fs/nfsd/nfs4xdr.c~current~ +4 -1
diff ./fs/nfsd/nfs4xdr.c~current~ ./fs/nfsd/nfs4xdr.c
@@ -1331,7 +1331,10 @@ nfsd4_encode_fattr(struct svc_fh *fhp, s
 		if (bmval0 & FATTR4_WORD0_ACL) {
 			if (status == -EOPNOTSUPP)
 				bmval0 &= ~FATTR4_WORD0_ACL;
-			else if (status != 0)
+			else if (status == -EINVAL) {
+				status = nfserr_attrnotsupp;
+				goto out;
+			} else if (status != 0)
 				goto out_nfserr;
 		}
 	}
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +5 -2
diff ./fs/nfsd/vfs.c~current~ ./fs/nfsd/vfs.c
@@ -393,7 +393,7 @@ set_nfsv4_acl_one(struct dentry *dentry,
 	}
 out:
 	kfree(buf);
-	return (error);
+	return error;
 }
 
 int
@@ -417,7 +417,10 @@ nfsd4_set_nfs4_acl(struct svc_rqst *rqst
 		flags = NFS4_ACL_DIR;
 
 	error = nfs4_acl_nfsv4_to_posix(acl, &pacl, &dpacl, flags);
-	if (error < 0)
+	if (error == -EINVAL) {
+		error = nfserr_attrnotsupp;
+		goto out;
+	} else if (error < 0)
 		goto out_nfserr;
 
 	if (pacl) {

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#8 lore raw

PATCH 1/1 nfsd4: fix share conflict tests

In reply to NeilBrown

In nfs4_check_open():

Move 'is_open_owner' check to be first. Remove continue so as to call test_share on OPENs with a previously seen open_owner as per rfc3530.

### Diffstat output

 ./fs/nfsd/nfs4state.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +3 -5
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -1535,14 +1535,12 @@ nfs4_check_open(struct nfs4_file *fp, st
 	int status = nfserr_share_denied;
 
 	list_for_each_entry(local, &fp->fi_perfile, st_perfile) {
-		/* have we seen this open owner */
-		if (local->st_stateowner == sop) {
-			*stpp = local;
-			continue;
-		}
 		/* ignore lock owners */
 		if (local->st_stateowner->so_is_open_owner == 0)
 			continue;
+		/* remember if we have seen this open owner */
+		if (local->st_stateowner == sop)
+			*stpp = local;
 		/* check for conflicting share reservations */
 		if (!test_share(local, open))
 			goto out;

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#9 lore raw

PATCH 1/1 nlm: fix f_count leak

In reply to NeilBrown

I can't see any reason for this file->f_count++. Removing it fixes a bug which leaves an exported filesystem busy if a callback for a lock held on that filesystem ever failed.

Found by Terence Rokop.

### Diffstat output

 ./fs/lockd/svclock.c |    1 -
 1 files changed, 1 deletion(-)
fs/lockd/svclock.c renamed from fs/lockd/svclock.c~current~ +0 -1
diff ./fs/lockd/svclock.c~current~ ./fs/lockd/svclock.c
@@ -641,7 +641,6 @@ nlmsvc_grant_reply(struct svc_rqst *rqst
 		} else {
 			/* Lock is now held by client, or has been rejected.
 			 * In both cases, the block should be removed. */
-			file->f_count++;
 			up(&file->f_sema);
 			if (status == NLM_LCK_GRANTED)
 				nlmsvc_delete_block(block, 0);

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#10 lore raw

PATCH 1/1 nfsd4: remove unneeded stateowner arguments

In reply to NeilBrown

Remove the unneeded stateowner argument from nfs4_check_open() and init_stateid.

### Diffstat output

 ./fs/nfsd/nfs4state.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +6 -5
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -1123,7 +1123,8 @@ release_stateowner(struct nfs4_stateowne
 }
 
 static inline void
-init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_open *open) {
+init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *open) {
+	struct nfs4_stateowner *sop = open->op_stateowner;
 	unsigned int hashval = stateid_hashval(sop->so_id, fp->fi_id);
 
 	INIT_LIST_HEAD(&stp->st_hash);
@@ -1529,10 +1530,11 @@ out:
 }
 
 static int
-nfs4_check_open(struct nfs4_file *fp, struct nfs4_stateowner *sop, struct nfsd4_open *open, struct nfs4_stateid **stpp)
+nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_stateid **stpp)
 {
 	struct nfs4_stateid *local;
 	int status = nfserr_share_denied;
+	struct nfs4_stateowner *sop = open->op_stateowner;
 
 	list_for_each_entry(local, &fp->fi_perfile, st_perfile) {
 		/* ignore lock owners */
@@ -1692,7 +1694,6 @@ out:
 int
 nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
 {
-	struct nfs4_stateowner *sop = open->op_stateowner;
 	struct nfs4_file *fp = NULL;
 	struct inode *ino = current_fh->fh_dentry->d_inode;
 	struct nfs4_stateid *stp = NULL;
@@ -1708,7 +1709,7 @@ nfsd4_process_open2(struct svc_rqst *rqs
 	 */
 	fp = find_file(ino);
 	if (fp) {
-		if ((status = nfs4_check_open(fp, sop, open, &stp)))
+		if ((status = nfs4_check_open(fp, open, &stp)))
 			goto out;
 	} else {
 		status = nfserr_resource;
@@ -1735,7 +1736,7 @@ nfsd4_process_open2(struct svc_rqst *rqs
 			flags = MAY_READ;
 		if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags)))
 			goto out;
-		init_stateid(stp, fp, sop, open);
+		init_stateid(stp, fp, open);
 		if (open->op_truncate) {
 			struct iattr iattr = {
 				.ia_valid = ATTR_SIZE,

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#11 lore raw

PATCH 1/1 nfsd4: factor out common open_truncate code

In reply to NeilBrown

Factor out a bit of common code.

### Diffstat output

 ./fs/nfsd/nfs4state.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c~current~ +23 -23
diff ./fs/nfsd/nfs4state.c~current~ ./fs/nfsd/nfs4state.c
@@ -1575,6 +1575,21 @@ nfs4_new_open(struct svc_rqst *rqstp, st
 	return 0;
 }
 
+static inline int
+nfsd4_truncate(struct svc_rqst *rqstp, struct svc_fh *fh,
+		struct nfsd4_open *open)
+{
+	struct iattr iattr = {
+		.ia_valid = ATTR_SIZE,
+		.ia_size = 0,
+	};
+	if (!open->op_truncate)
+		return 0;
+	if (!(open->op_share_access & NFS4_SHARE_ACCESS_WRITE))
+		return -EINVAL;
+	return nfsd_setattr(rqstp, fh, &iattr, 0, (time_t)0);
+}
+
 static int
 nfs4_upgrade_open(struct svc_rqst *rqstp, struct svc_fh *cur_fh, struct nfs4_stateid *stp, struct nfsd4_open *open)
 {
@@ -1592,19 +1607,11 @@ nfs4_upgrade_open(struct svc_rqst *rqstp
 		status = get_write_access(inode);
 		if (status)
 			return nfserrno(status);
-		if (open->op_truncate) {
-			struct iattr iattr = {
-				.ia_valid = ATTR_SIZE,
-				.ia_size = 0,
-			};
-			status = nfsd_setattr(rqstp, cur_fh, &iattr, 0,
-					(time_t)0);
-			if (status) {
-				put_write_access(inode);
-				return status;
-			}
+		status = nfsd4_truncate(rqstp, cur_fh, open);
+		if (status) {
+			put_write_access(inode);
+			return status;
 		}
-
 		/* remember the open */
 		filp->f_mode = (filp->f_mode | FMODE_WRITE) & ~FMODE_READ;
 		set_bit(open->op_share_access, &stp->st_access_bmap);
@@ -1737,17 +1744,10 @@ nfsd4_process_open2(struct svc_rqst *rqs
 		if ((status = nfs4_new_open(rqstp, &stp, current_fh, flags)))
 			goto out;
 		init_stateid(stp, fp, open);
-		if (open->op_truncate) {
-			struct iattr iattr = {
-				.ia_valid = ATTR_SIZE,
-				.ia_size = 0,
-			};
-			status = nfsd_setattr(rqstp, current_fh, &iattr, 0,
-					(time_t)0);
-			if (status) {
-				release_stateid(stp, OPEN_STATE);
-				goto out;
-			}
+		status = nfsd4_truncate(rqstp, current_fh, open);
+		if (status) {
+			release_stateid(stp, OPEN_STATE);
+			goto out;
 		}
 	}
 	memcpy(&open->op_stateid, &stp->st_stateid, sizeof(stateid_t));

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#12 lore raw

PATCH 1/1 nfsd4_remove_unused_acl_function

In reply to NeilBrown

We're translating v4 ACL's to POSIX ACL's and relying on the filesystem to check those, so there's no need for a NFSv4 ACL-checking algorithm.

Some day we'd like to find a way to implement the full v4 ACL protocol on the server side, but for now this is dead code.

### Diffstat output

 ./fs/nfsd/nfs4acl.c |   27 ---------------------------
 1 files changed, 27 deletions(-)
fs/nfsd/nfs4acl.c renamed from fs/nfsd/nfs4acl.c~current~ +0 -27
diff ./fs/nfsd/nfs4acl.c~current~ ./fs/nfsd/nfs4acl.c
@@ -940,35 +940,8 @@ match_who(struct nfs4_ace *ace, uid_t ow
 	}
 }
 
-/* 0 = granted, -EACCES = denied; mask is an nfsv4 mask, not mode bits */
-int
-nfs4_acl_permission(struct nfs4_acl *acl, uid_t owner, gid_t group,
-			uid_t who, u32 mask)
-{
-	struct nfs4_ace *ace;
-	u32 allowed = 0;
-
-	list_for_each_entry(ace, &acl->ace_head, l_ace) {
-		if (!match_who(ace, group, owner, who))
-			continue;
-		switch (ace->type) {
-			case NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE:
-				allowed |= ace->access_mask;
-				if ((allowed & mask) == mask)
-					return 0;
-				break;
-			case NFS4_ACE_ACCESS_DENIED_ACE_TYPE:
-				if (ace->access_mask & mask)
-					return -EACCES;
-				break;
-		}
-	}
-	return -EACCES;
-}
-
 EXPORT_SYMBOL(nfs4_acl_new);
 EXPORT_SYMBOL(nfs4_acl_free);
 EXPORT_SYMBOL(nfs4_acl_add_ace);
 EXPORT_SYMBOL(nfs4_acl_get_whotype);
 EXPORT_SYMBOL(nfs4_acl_write_who);
-EXPORT_SYMBOL(nfs4_acl_permission);

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#13 lore raw

PATCH 1/1 nfsd4: acl don't set named attrs

In reply to NeilBrown

We were expecting {read,write}_named_attributes to be set in sync with the read and write bits. But we don't actually support named attributes, and when we eventually do, it's unlikely that we'll want to use these ACL mode bits to control access to them. So let's just stop supporting these two bits.

This also updates our mapping to the latest ietf draft.

### Diffstat output

 ./fs/nfsd/nfs4acl.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
fs/nfsd/nfs4acl.c renamed from fs/nfsd/nfs4acl.c~current~ +4 -3
diff ./fs/nfsd/nfs4acl.c~current~ ./fs/nfsd/nfs4acl.c
@@ -49,14 +49,15 @@
 
 
 /* mode bit translations: */
-#define NFS4_READ_MODE (NFS4_ACE_READ_DATA | NFS4_ACE_READ_NAMED_ATTRS)
-#define NFS4_WRITE_MODE (NFS4_ACE_WRITE_DATA | NFS4_ACE_WRITE_NAMED_ATTRS | NFS4_ACE_APPEND_DATA)
+#define NFS4_READ_MODE (NFS4_ACE_READ_DATA)
+#define NFS4_WRITE_MODE (NFS4_ACE_WRITE_DATA | NFS4_ACE_APPEND_DATA)
 #define NFS4_EXECUTE_MODE NFS4_ACE_EXECUTE
 #define NFS4_ANYONE_MODE (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL | NFS4_ACE_SYNCHRONIZE)
 #define NFS4_OWNER_MODE (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL)
 
 /* We don't support these bits; insist they be neither allowed nor denied */
-#define NFS4_MASK_UNSUPP (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER)
+#define NFS4_MASK_UNSUPP (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER \
+		| NFS4_ACE_READ_NAMED_ATTRS | NFS4_ACE_WRITE_NAMED_ATTRS)
 
 /* flags used to simulate posix default ACLs */
 #define NFS4_INHERITANCE_FLAGS (NFS4_ACE_FILE_INHERIT_ACE \

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#14 lore raw

PATCH 1/1 nfsd4: remove trailing whitespace from nfs4proc.c

In reply to NeilBrown

Trivial whitespace

### Diffstat output

 ./fs/nfsd/nfs4proc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +5 -5
diff ./fs/nfsd/nfs4proc.c~current~ ./fs/nfsd/nfs4proc.c
@@ -200,8 +200,8 @@ nfsd4_open(struct svc_rqst *rqstp, struc
 	if (open->op_claim_type == NFS4_OPEN_CLAIM_NULL) {
 	/*
 	 * This block of code will (1) set CURRENT_FH to the file being opened,
-	 * creating it if necessary, (2) set open->op_cinfo, 
-	 * (3) set open->op_truncate if the file is to be truncated 
+	 * creating it if necessary, (2) set open->op_cinfo,
+	 * (3) set open->op_truncate if the file is to be truncated
 	 * after opening, (4) do permission checking.
 	 */
 		status = do_open_lookup(rqstp, current_fh, open);
@@ -573,8 +573,8 @@ nfsd4_setattr(struct svc_rqst *rqstp, st
 	status = nfs_ok;
 	if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
 		nfs4_lock_state();
-		if ((status = nfs4_preprocess_stateid_op(current_fh, 
-						&setattr->sa_stateid, 
+		if ((status = nfs4_preprocess_stateid_op(current_fh,
+						&setattr->sa_stateid,
 						CHECK_FH | WR_STATE, NULL))) {
 			dprintk("NFSD: nfsd4_setattr: couldn't process stateid!\n");
 			goto out_unlock;
@@ -609,7 +609,7 @@ nfsd4_write(struct svc_rqst *rqstp, stru
 		return nfserr_inval;
 
 	nfs4_lock_state();
-	if ((status = nfs4_preprocess_stateid_op(current_fh, stateid, 
+	if ((status = nfs4_preprocess_stateid_op(current_fh, stateid,
 					CHECK_FH | WR_STATE, &filp))) {
 		dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
 		goto out;

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#15 lore raw

PATCH 1/1 nfsd4: fix indentation in nfsd4_open

In reply to NeilBrown

OK, so it's trivial, but these misaligned comments have been bugging me forever....

### Diffstat output

 ./fs/nfsd/nfs4proc.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
fs/nfsd/nfs4proc.c renamed from fs/nfsd/nfs4proc.c~current~ +12 -12
diff ./fs/nfsd/nfs4proc.c~current~ ./fs/nfsd/nfs4proc.c
@@ -199,23 +199,23 @@ nfsd4_open(struct svc_rqst *rqstp, struc
 		goto out;
 	switch (open->op_claim_type) {
 		case NFS4_OPEN_CLAIM_NULL:
-	/*
-	 * This block of code will (1) set CURRENT_FH to the file being opened,
-	 * creating it if necessary, (2) set open->op_cinfo,
-	 * (3) set open->op_truncate if the file is to be truncated
-	 * after opening, (4) do permission checking.
-	 */
+			/*
+			 * (1) set CURRENT_FH to the file being opened,
+			 * creating it if necessary, (2) set open->op_cinfo,
+			 * (3) set open->op_truncate if the file is to be
+			 * truncated after opening, (4) do permission checking.
+			 */
 			status = do_open_lookup(rqstp, current_fh, open);
 			if (status)
 				goto out;
 			break;
 		case NFS4_OPEN_CLAIM_PREVIOUS:
-	/*
-	* The CURRENT_FH is already set to the file being opened. This
-	* block of code will (1) set open->op_cinfo, (2) set
-	* open->op_truncate if the file is to be truncated after opening,
-	* (3) do permission checking.
-	*/
+			/*
+			 * The CURRENT_FH is already set to the file being
+			 * opened.  (1) set open->op_cinfo, (2) set
+			 * open->op_truncate if the file is to be truncated
+			 * after opening, (3) do permission checking.
+			*/
 			status = do_open_fhandle(rqstp, current_fh, open);
 			if (status)
 				goto out;

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#16 lore raw

PATCH 1/1 nfsd4: don't set WRITE_OWNER in either allow or deny bits

In reply to NeilBrown

WRITE_OWNER should be neither allowed nor denied.

This improves interoperability with Solaris clients and represents our permissions more accurately.

It breaks compatibility with clients using the old version of the NFSv4<->POSIX mapping. I believe the only code that did that was older versions of experimental client-side code available only from our website, so I prefer not to introduce a hack just to continue support the old mapping.

### Diffstat output

 ./fs/nfsd/nfs4acl.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfs4acl.c renamed from fs/nfsd/nfs4acl.c~current~ +4 -1
diff ./fs/nfsd/nfs4acl.c~current~ ./fs/nfsd/nfs4acl.c
@@ -55,6 +55,9 @@
 #define NFS4_ANYONE_MODE (NFS4_ACE_READ_ATTRIBUTES | NFS4_ACE_READ_ACL | NFS4_ACE_SYNCHRONIZE)
 #define NFS4_OWNER_MODE (NFS4_ACE_WRITE_ATTRIBUTES | NFS4_ACE_WRITE_ACL)
 
+/* We don't support these bits; insist they be neither allowed nor denied */
+#define NFS4_MASK_UNSUPP (NFS4_ACE_DELETE | NFS4_ACE_WRITE_OWNER)
+
 /* flags used to simulate posix default ACLs */
 #define NFS4_INHERITANCE_FLAGS (NFS4_ACE_FILE_INHERIT_ACE \
 		| NFS4_ACE_DIRECTORY_INHERIT_ACE | NFS4_ACE_INHERIT_ONLY_ACE)
@@ -83,7 +86,7 @@ mask_from_posix(unsigned short perm, uns
 static u32
 deny_mask(u32 allow_mask, unsigned int flags)
 {
-	u32 ret = ~allow_mask & ~NFS4_ACE_DELETE;
+	u32 ret = ~allow_mask & ~NFS4_MASK_UNSUPP;
 	if (!(flags & NFS4_ACL_DIR))
 		ret &= ~NFS4_ACE_DELETE_CHILD;
 	return ret;

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#17 lore raw
In reply to NeilBrown
Quoted 7 lines · NeilBrown

Following are 16 patches against nfsd in 2.6.12-rc1-mm1

Most are nfsv4 related.
Patch 2 removes an inexplicable increment of f_count for a file. This fixes a problem wherein an exported filesystem may never be unmountable because a file on it is never closed.

OK, I'll send nlm-fix-f_count-leak.patch in for 2.6.12 and will buffer the rest.

Quoted 2 lines

This could possibly be a candidate for 2.6.12. The rest should wait to go in to 2.6.13-rc

Is it a 2.6.11.x candidate?

-------------------------------------------------------
This SF.net email is sponsored by Microsoft Mobile & Embedded DevCon 2005 Attend MEDC 2005 May 9-12 in Vegas. Learn more about the latest Windows Embedded(r) & Windows Mobile(tm) platforms, applications & content. Register by 3/29 & save $300 http://ads.osdn.com/?ad_id=6883&alloc_id=15149&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

author
#18 lore raw
Quoted 11 lines · On Monday March 21, [email protected] wrote:
Quoted 7 lines · NeilBrown

Following are 16 patches against nfsd in 2.6.12-rc1-mm1

Most are nfsv4 related.
Patch 2 removes an inexplicable increment of f_count for a file. This fixes a problem wherein an exported filesystem may never be unmountable because a file on it is never closed.

OK, I'll send nlm-fix-f_count-leak.patch in for 2.6.12 and will buffer the rest.

Thanks.

Quoted 5 lines
Quoted 3 lines

This could possibly be a candidate for 2.6.12. The rest should wait to go in to 2.6.13-rc

Is it a 2.6.11.x candidate?

Not really. It is a long way for serious. Just annoyingly inconvenient very occasionally (it needs to be fix in 2.4 too, which shows how long it has been around).

NeilBrown

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs