Merge tag 'nfs-for-4.19-2' of git://git.linux-nfs.org/projects/anna/linux-nfs
[sfrench/cifs-2.6.git] / fs / nfs / nfs4proc.c
index 481787cac4c28e0df92ee9b714079563903d9198..8220a168282e054164cb5b3bb8534f76be89faa7 100644 (file)
@@ -3000,7 +3000,7 @@ static int _nfs4_do_open(struct inode *dir,
                }
        }
        if (opened && opendata->file_created)
-               *opened |= FILE_CREATED;
+               *opened = 1;
 
        if (pnfs_use_threshold(ctx_th, opendata->f_attr.mdsthreshold, server)) {
                *ctx_th = opendata->f_attr.mdsthreshold;
@@ -6575,34 +6575,34 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
                if (data->arg.new_lock && !data->cancelled) {
                        data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS);
                        if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0)
-                               break;
+                               goto out_restart;
                }
-
                if (data->arg.new_lock_owner != 0) {
                        nfs_confirm_seqid(&lsp->ls_seqid, 0);
                        nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid);
                        set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags);
-                       goto out_done;
-               } else if (nfs4_update_lock_stateid(lsp, &data->res.stateid))
-                       goto out_done;
-
+               } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
+                       goto out_restart;
                break;
        case -NFS4ERR_BAD_STATEID:
        case -NFS4ERR_OLD_STATEID:
        case -NFS4ERR_STALE_STATEID:
        case -NFS4ERR_EXPIRED:
                if (data->arg.new_lock_owner != 0) {
-                       if (nfs4_stateid_match(&data->arg.open_stateid,
+                       if (!nfs4_stateid_match(&data->arg.open_stateid,
                                                &lsp->ls_state->open_stateid))
-                               goto out_done;
-               } else if (nfs4_stateid_match(&data->arg.lock_stateid,
+                               goto out_restart;
+               } else if (!nfs4_stateid_match(&data->arg.lock_stateid,
                                                &lsp->ls_stateid))
-                               goto out_done;
+                               goto out_restart;
        }
-       if (!data->cancelled)
-               rpc_restart_call_prepare(task);
 out_done:
        dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
+       return;
+out_restart:
+       if (!data->cancelled)
+               rpc_restart_call_prepare(task);
+       goto out_done;
 }
 
 static void nfs4_lock_release(void *calldata)
@@ -6611,7 +6611,7 @@ static void nfs4_lock_release(void *calldata)
 
        dprintk("%s: begin!\n", __func__);
        nfs_free_seqid(data->arg.open_seqid);
-       if (data->cancelled) {
+       if (data->cancelled && data->rpc_status == 0) {
                struct rpc_task *task;
                task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
                                data->arg.lock_seqid);