pNFS: Parse the results of layoutget on open even if permissions checks fail
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 29 Jun 2018 16:45:53 +0000 (12:45 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 26 Jul 2018 20:25:25 +0000 (16:25 -0400)
Even if the results of the permissions checks failed, we should parse
the results of the layout on open call so that we can return the
layout if required.
Note that we also want to ignore the sequence counter for whether or not
a layout recall occurred. If the recall pertained to our OPEN, then the
callback will know, and will attempt to wait for us to finih processing
anyway.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/callback_proc.c
fs/nfs/nfs4proc.c
fs/nfs/pnfs.c
include/linux/nfs_fs_sb.h
include/linux/nfs_xdr.h

index efca3d6c89f20d091456e8d5a9495c33f47171a1..43ba390bb653fcd7f7081f5b7b4c94e77b9e7625 100644 (file)
@@ -331,8 +331,6 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
 static u32 do_callback_layoutrecall(struct nfs_client *clp,
                                    struct cb_layoutrecallargs *args)
 {
-       write_seqcount_begin(&clp->cl_callback_count);
-       write_seqcount_end(&clp->cl_callback_count);
        if (args->cbl_recall_type == RETURN_FILE)
                return initiate_file_draining(clp, args);
        return initiate_bulk_draining(clp, args);
index 6dd146885da99304c8183f5fae21741f4aa3625f..5a8190ec31a236e4d269745eefd5aabb141108a1 100644 (file)
@@ -2843,6 +2843,9 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
                                nfs_save_change_attribute(d_inode(opendata->dir)));
        }
 
+       /* Parse layoutget results before we check for access */
+       pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
+
        ret = nfs4_opendata_access(sp->so_cred, opendata, state, fmode, flags);
        if (ret != 0)
                goto out;
@@ -2851,8 +2854,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
                nfs_inode_attach_open_context(ctx);
                if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
                        nfs4_schedule_stateid_recovery(server, state);
-               else
-                       pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
        }
 
 out:
index 030c39c107c21c498778538db1a3b0654cd6d1fd..7fdac8b504dd231438ca5dbd1d6e475c893fd21c 100644 (file)
@@ -1018,7 +1018,6 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
        nfs4_stateid_copy(&lgp->args.stateid, stateid);
        lgp->gfp_flags = gfp_flags;
        lgp->cred = get_rpccred(ctx->cred);
-       lgp->callback_count = raw_seqcount_begin(&server->nfs_client->cl_callback_count);
        return lgp;
 }
 
@@ -2181,9 +2180,6 @@ void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
        } else
                lo = NFS_I(lgp->args.inode)->layout;
 
-       if (read_seqcount_retry(&srv->nfs_client->cl_callback_count,
-                               lgp->callback_count))
-               return;
        lseg = pnfs_layout_process(lgp);
        if (!IS_ERR(lseg)) {
                iomode = lgp->args.range.iomode;
index 74ae3e1d19a04a8e3e1fbaa24dc64aa152c75f2d..2c18d618604ecfc7f8342236131e227c2003c89a 100644 (file)
@@ -28,7 +28,6 @@ struct nfs41_impl_id;
 struct nfs_client {
        refcount_t              cl_count;
        atomic_t                cl_mds_count;
-       seqcount_t              cl_callback_count;
        int                     cl_cons_state;  /* current construction state (-ve: init error) */
 #define NFS_CS_READY           0               /* ready to be used */
 #define NFS_CS_INITING         1               /* busy initialising */
index 712eed156d0912f1aecc97de222597f1d7cc5dc9..3b7325cfb291cd4412205d6446e896dace4b125d 100644 (file)
@@ -271,7 +271,6 @@ struct nfs4_layoutget {
        struct nfs4_layoutget_args args;
        struct nfs4_layoutget_res res;
        struct rpc_cred *cred;
-       unsigned callback_count;
        gfp_t gfp_flags;
 };