Merge branch 'flexfiles'
[deliverable/linux.git] / fs / nfs / nfs4proc.c
index e941261527144860cc19a887af75ee0524c9fd1d..adae525edec4e932b1298676a672648016a19ef5 100644 (file)
@@ -5050,7 +5050,6 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
 static int
 nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 {
-       int result;
        size_t len;
        char *str;
 
@@ -5078,7 +5077,7 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
                return -ENOMEM;
 
        rcu_read_lock();
-       result = scnprintf(str, len, "Linux NFSv4.0 %s/%s %s",
+       scnprintf(str, len, "Linux NFSv4.0 %s/%s %s",
                        clp->cl_ipaddr,
                        rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR),
                        rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO));
@@ -5091,7 +5090,6 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
 static int
 nfs4_init_uniquifier_client_string(struct nfs_client *clp)
 {
-       int result;
        size_t len;
        char *str;
 
@@ -5111,7 +5109,7 @@ nfs4_init_uniquifier_client_string(struct nfs_client *clp)
        if (!str)
                return -ENOMEM;
 
-       result = scnprintf(str, len, "Linux NFSv%u.%u %s/%s",
+       scnprintf(str, len, "Linux NFSv%u.%u %s/%s",
                        clp->rpc_ops->version, clp->cl_minorversion,
                        nfs4_client_id_uniquifier,
                        clp->cl_rpcclient->cl_nodename);
@@ -5122,7 +5120,6 @@ nfs4_init_uniquifier_client_string(struct nfs_client *clp)
 static int
 nfs4_init_uniform_client_string(struct nfs_client *clp)
 {
-       int result;
        size_t len;
        char *str;
 
@@ -5147,7 +5144,7 @@ nfs4_init_uniform_client_string(struct nfs_client *clp)
        if (!str)
                return -ENOMEM;
 
-       result = scnprintf(str, len, "Linux NFSv%u.%u %s",
+       scnprintf(str, len, "Linux NFSv%u.%u %s",
                        clp->rpc_ops->version, clp->cl_minorversion,
                        clp->cl_rpcclient->cl_nodename);
        clp->cl_owner_id = str;
@@ -5386,6 +5383,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
        if (data == NULL)
                return -ENOMEM;
        nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
+
+       nfs4_state_protect(server->nfs_client,
+                       NFS_SP4_MACH_CRED_CLEANUP,
+                       &task_setup_data.rpc_client, &msg);
+
        data->args.fhandle = &data->fh;
        data->args.stateid = &data->stateid;
        data->args.bitmask = server->cache_consistency_bitmask;
@@ -6862,10 +6864,13 @@ static const struct nfs41_state_protection nfs4_sp4_mach_cred_request = {
        },
        .allow.u.words = {
                [0] = 1 << (OP_CLOSE) |
+                     1 << (OP_OPEN_DOWNGRADE) |
                      1 << (OP_LOCKU) |
+                     1 << (OP_DELEGRETURN) |
                      1 << (OP_COMMIT),
                [1] = 1 << (OP_SECINFO - 32) |
                      1 << (OP_SECINFO_NO_NAME - 32) |
+                     1 << (OP_LAYOUTRETURN - 32) |
                      1 << (OP_TEST_STATEID - 32) |
                      1 << (OP_FREE_STATEID - 32) |
                      1 << (OP_WRITE - 32)
@@ -6930,11 +6935,19 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp,
                }
 
                if (test_bit(OP_CLOSE, sp->allow.u.longs) &&
+                   test_bit(OP_OPEN_DOWNGRADE, sp->allow.u.longs) &&
+                   test_bit(OP_DELEGRETURN, sp->allow.u.longs) &&
                    test_bit(OP_LOCKU, sp->allow.u.longs)) {
                        dfprintk(MOUNT, "  cleanup mode enabled\n");
                        set_bit(NFS_SP4_MACH_CRED_CLEANUP, &clp->cl_sp4_flags);
                }
 
+               if (test_bit(OP_LAYOUTRETURN, sp->allow.u.longs)) {
+                       dfprintk(MOUNT, "  pnfs cleanup mode enabled\n");
+                       set_bit(NFS_SP4_MACH_CRED_PNFS_CLEANUP,
+                               &clp->cl_sp4_flags);
+               }
+
                if (test_bit(OP_SECINFO, sp->allow.u.longs) &&
                    test_bit(OP_SECINFO_NO_NAME, sp->allow.u.longs)) {
                        dfprintk(MOUNT, "  secinfo mode enabled\n");
@@ -7798,6 +7811,15 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata)
        switch (task->tk_status) {
        case 0:
                goto out;
+
+       /*
+        * NFS4ERR_LAYOUTUNAVAILABLE means we are not supposed to use pnfs
+        * on the file. set tk_status to -ENODATA to tell upper layer to
+        * retry go inband.
+        */
+       case -NFS4ERR_LAYOUTUNAVAILABLE:
+               task->tk_status = -ENODATA;
+               goto out;
        /*
         * NFS4ERR_BADLAYOUT means the MDS cannot return a layout of
         * length lgp->args.minlength != 0 (see RFC5661 section 18.43.3).
@@ -8087,6 +8109,10 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
        };
        int status = 0;
 
+       nfs4_state_protect(NFS_SERVER(lrp->args.inode)->nfs_client,
+                       NFS_SP4_MACH_CRED_PNFS_CLEANUP,
+                       &task_setup_data.rpc_client, &msg);
+
        dprintk("--> %s\n", __func__);
        if (!sync) {
                lrp->inode = nfs_igrab_and_active(lrp->args.inode);
This page took 0.02854 seconds and 5 git commands to generate.