[1/5] NFSv4: Don't check file access when reclaiming state
diff mbox

Message ID 1478814070-17140-2-git-send-email-trond.myklebust@primarydata.com
State New
Headers show

Commit Message

Trond Myklebust Nov. 10, 2016, 9:41 p.m. UTC
If we're reclaiming state after a reboot, or as part of returning a
delegation, we don't need to check access modes again.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/nfs4proc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

kbuild test robot Nov. 10, 2016, 10:18 p.m. UTC | #1
Hi Trond,

[auto build test WARNING on nfs/linux-next]
[also build test WARNING on v4.9-rc4 next-20161110]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Trond-Myklebust/Optimisations-for-state-management/20161111-054856
base:   git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
config: x86_64-eywa-module (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   fs/nfs/nfs4proc.c: In function 'nfs4_opendata_alloc':
>> fs/nfs/nfs4proc.c:1232:3: warning: enumeration value 'NFS4_OPEN_CLAIM_PREVIOUS' not handled in switch [-Wswitch]
      switch (p->o_arg.claim) {
      ^~~~~~
>> fs/nfs/nfs4proc.c:1232:3: warning: enumeration value 'NFS4_OPEN_CLAIM_DELEGATE_CUR' not handled in switch [-Wswitch]
>> fs/nfs/nfs4proc.c:1232:3: warning: enumeration value 'NFS4_OPEN_CLAIM_DELEGATE_PREV' not handled in switch [-Wswitch]
>> fs/nfs/nfs4proc.c:1232:3: warning: enumeration value 'NFS4_OPEN_CLAIM_DELEG_CUR_FH' not handled in switch [-Wswitch]
>> fs/nfs/nfs4proc.c:1232:3: warning: enumeration value 'NFS4_OPEN_CLAIM_DELEG_PREV_FH' not handled in switch [-Wswitch]

vim +/NFS4_OPEN_CLAIM_PREVIOUS +1232 fs/nfs/nfs4proc.c

  1216			goto err_free_label;
  1217		nfs_sb_active(dentry->d_sb);
  1218		p->dentry = dget(dentry);
  1219		p->dir = parent;
  1220		p->owner = sp;
  1221		atomic_inc(&sp->so_count);
  1222		p->o_arg.open_flags = flags;
  1223		p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
  1224		p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
  1225		p->o_arg.share_access = nfs4_map_atomic_open_share(server,
  1226				fmode, flags);
  1227		/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
  1228		 * will return permission denied for all bits until close */
  1229		if (!(flags & O_EXCL)) {
  1230			/* ask server to check for all possible rights as results
  1231			 * are cached */
> 1232			switch (p->o_arg.claim) {
  1233			case NFS4_OPEN_CLAIM_NULL:
  1234			case NFS4_OPEN_CLAIM_FH:
  1235				p->o_arg.access = NFS4_ACCESS_READ |
  1236					NFS4_ACCESS_MODIFY |
  1237					NFS4_ACCESS_EXTEND |
  1238					NFS4_ACCESS_EXECUTE;
  1239			}
  1240		}

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Schumaker, Anna Nov. 14, 2016, 8:44 p.m. UTC | #2
Hi Trond,

On 11/10/2016 04:41 PM, Trond Myklebust wrote:
> If we're reclaiming state after a reboot, or as part of returning a
> delegation, we don't need to check access modes again.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
>  fs/nfs/nfs4proc.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 6a1d650e0419..4eead738da8e 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -1221,6 +1221,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
>  	atomic_inc(&sp->so_count);
>  	p->o_arg.open_flags = flags;
>  	p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
> +	p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
>  	p->o_arg.share_access = nfs4_map_atomic_open_share(server,
>  			fmode, flags);
>  	/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
> @@ -1228,8 +1229,14 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
>  	if (!(flags & O_EXCL)) {
>  		/* ask server to check for all possible rights as results
>  		 * are cached */
> -		p->o_arg.access = NFS4_ACCESS_READ | NFS4_ACCESS_MODIFY |
> -				  NFS4_ACCESS_EXTEND | NFS4_ACCESS_EXECUTE;
> +		switch (p->o_arg.claim) {
> +		case NFS4_OPEN_CLAIM_NULL:
> +		case NFS4_OPEN_CLAIM_FH:
> +			p->o_arg.access = NFS4_ACCESS_READ |
> +				NFS4_ACCESS_MODIFY |
> +				NFS4_ACCESS_EXTEND |
> +				NFS4_ACCESS_EXECUTE;
> +		}

This adds these warnings when I compile:

fs/nfs/nfs4proc.c: In function 'nfs4_opendata_alloc':
fs/nfs/nfs4proc.c:1232:3: error: enumeration value 'NFS4_OPEN_CLAIM_PREVIOUS' not handled in switch [-Werror=switch]
   switch (p->o_arg.claim) {
   ^~~~~~
fs/nfs/nfs4proc.c:1232:3: error: enumeration value 'NFS4_OPEN_CLAIM_DELEGATE_CUR' not handled in switch [-Werror=switch]
fs/nfs/nfs4proc.c:1232:3: error: enumeration value 'NFS4_OPEN_CLAIM_DELEGATE_PREV' not handled in switch [-Werror=switch]
fs/nfs/nfs4proc.c:1232:3: error: enumeration value 'NFS4_OPEN_CLAIM_DELEG_CUR_FH' not handled in switch [-Werror=switch]
fs/nfs/nfs4proc.c:1232:3: error: enumeration value 'NFS4_OPEN_CLAIM_DELEG_PREV_FH' not handled in switch [-Werror=switch]

Thanks,
Anna


>  	}
>  	p->o_arg.clientid = server->nfs_client->cl_clientid;
>  	p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
> @@ -1239,7 +1246,6 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
>  	p->o_arg.bitmask = nfs4_bitmask(server, label);
>  	p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
>  	p->o_arg.label = nfs4_label_copy(p->a_label, label);
> -	p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
>  	switch (p->o_arg.claim) {
>  	case NFS4_OPEN_CLAIM_NULL:
>  	case NFS4_OPEN_CLAIM_DELEGATE_CUR:
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6a1d650e0419..4eead738da8e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1221,6 +1221,7 @@  static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
 	atomic_inc(&sp->so_count);
 	p->o_arg.open_flags = flags;
 	p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
+	p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
 	p->o_arg.share_access = nfs4_map_atomic_open_share(server,
 			fmode, flags);
 	/* don't put an ACCESS op in OPEN compound if O_EXCL, because ACCESS
@@ -1228,8 +1229,14 @@  static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
 	if (!(flags & O_EXCL)) {
 		/* ask server to check for all possible rights as results
 		 * are cached */
-		p->o_arg.access = NFS4_ACCESS_READ | NFS4_ACCESS_MODIFY |
-				  NFS4_ACCESS_EXTEND | NFS4_ACCESS_EXECUTE;
+		switch (p->o_arg.claim) {
+		case NFS4_OPEN_CLAIM_NULL:
+		case NFS4_OPEN_CLAIM_FH:
+			p->o_arg.access = NFS4_ACCESS_READ |
+				NFS4_ACCESS_MODIFY |
+				NFS4_ACCESS_EXTEND |
+				NFS4_ACCESS_EXECUTE;
+		}
 	}
 	p->o_arg.clientid = server->nfs_client->cl_clientid;
 	p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
@@ -1239,7 +1246,6 @@  static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
 	p->o_arg.bitmask = nfs4_bitmask(server, label);
 	p->o_arg.open_bitmap = &nfs4_fattr_bitmap[0];
 	p->o_arg.label = nfs4_label_copy(p->a_label, label);
-	p->o_arg.claim = nfs4_map_atomic_open_claim(server, claim);
 	switch (p->o_arg.claim) {
 	case NFS4_OPEN_CLAIM_NULL:
 	case NFS4_OPEN_CLAIM_DELEGATE_CUR: