Merge tag 'pci-v5.18-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / fs / nfs / nfs42proc.c
index 32129446beca6cc4c3cc0f007e88d4dde630ceeb..068c45b3bc1ab19593441cc5b336e5e50a5e4322 100644 (file)
@@ -175,28 +175,27 @@ static int handle_async_copy(struct nfs42_copy_res *res,
                             nfs4_stateid *src_stateid,
                             bool *restart)
 {
-       struct nfs4_copy_state *copy, *tmp_copy;
+       struct nfs4_copy_state *copy, *tmp_copy = NULL, *iter;
        int status = NFS4_OK;
-       bool found_pending = false;
        struct nfs_open_context *dst_ctx = nfs_file_open_context(dst);
        struct nfs_open_context *src_ctx = nfs_file_open_context(src);
 
-       copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_NOFS);
+       copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_KERNEL);
        if (!copy)
                return -ENOMEM;
 
        spin_lock(&dst_server->nfs_client->cl_lock);
-       list_for_each_entry(tmp_copy,
+       list_for_each_entry(iter,
                                &dst_server->nfs_client->pending_cb_stateids,
                                copies) {
-               if (memcmp(&res->write_res.stateid, &tmp_copy->stateid,
+               if (memcmp(&res->write_res.stateid, &iter->stateid,
                                NFS4_STATEID_SIZE))
                        continue;
-               found_pending = true;
-               list_del(&tmp_copy->copies);
+               tmp_copy = iter;
+               list_del(&iter->copies);
                break;
        }
-       if (found_pending) {
+       if (tmp_copy) {
                spin_unlock(&dst_server->nfs_client->cl_lock);
                kfree(copy);
                copy = tmp_copy;
@@ -254,7 +253,7 @@ static int process_copy_commit(struct file *dst, loff_t pos_dst,
        struct nfs_commitres cres;
        int status = -ENOMEM;
 
-       cres.verf = kzalloc(sizeof(struct nfs_writeverf), GFP_NOFS);
+       cres.verf = kzalloc(sizeof(struct nfs_writeverf), GFP_KERNEL);
        if (!cres.verf)
                goto out;
 
@@ -357,7 +356,7 @@ static ssize_t _nfs42_proc_copy(struct file *src,
        res->commit_res.verf = NULL;
        if (args->sync) {
                res->commit_res.verf =
-                       kzalloc(sizeof(struct nfs_writeverf), GFP_NOFS);
+                       kzalloc(sizeof(struct nfs_writeverf), GFP_KERNEL);
                if (!res->commit_res.verf)
                        return -ENOMEM;
        }
@@ -552,7 +551,7 @@ static int nfs42_do_offload_cancel_async(struct file *dst,
        if (!(dst_server->caps & NFS_CAP_OFFLOAD_CANCEL))
                return -EOPNOTSUPP;
 
-       data = kzalloc(sizeof(struct nfs42_offloadcancel_data), GFP_NOFS);
+       data = kzalloc(sizeof(struct nfs42_offloadcancel_data), GFP_KERNEL);
        if (data == NULL)
                return -ENOMEM;
 
@@ -591,8 +590,10 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
 
        ctx = get_nfs_open_context(nfs_file_open_context(src));
        l_ctx = nfs_get_lock_context(ctx);
-       if (IS_ERR(l_ctx))
-               return PTR_ERR(l_ctx);
+       if (IS_ERR(l_ctx)) {
+               status = PTR_ERR(l_ctx);
+               goto out;
+       }
 
        status = nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx,
                                     FMODE_READ);
@@ -600,7 +601,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
        if (status) {
                if (status == -EAGAIN)
                        status = -NFS4ERR_BAD_STATEID;
-               return status;
+               goto out;
        }
 
        status = nfs4_call_sync(src_server->client, src_server, &msg,
@@ -609,6 +610,7 @@ static int _nfs42_proc_copy_notify(struct file *src, struct file *dst,
        if (status == -ENOTSUPP)
                src_server->caps &= ~NFS_CAP_COPY_NOTIFY;
 
+out:
        put_nfs_open_context(nfs_file_open_context(src));
        return status;
 }
@@ -626,7 +628,7 @@ int nfs42_proc_copy_notify(struct file *src, struct file *dst,
        if (!(src_server->caps & NFS_CAP_COPY_NOTIFY))
                return -EOPNOTSUPP;
 
-       args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_NOFS);
+       args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_KERNEL);
        if (args == NULL)
                return -ENOMEM;
 
@@ -1014,7 +1016,7 @@ int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg,
                return -EOPNOTSUPP;
        if (n > NFS42_LAYOUTERROR_MAX)
                return -EINVAL;
-       data = nfs42_alloc_layouterror_data(lseg, GFP_NOFS);
+       data = nfs42_alloc_layouterror_data(lseg, nfs_io_gfp_mask());
        if (!data)
                return -ENOMEM;
        for (i = 0; i < n; i++) {