]> git.baikalelectronics.ru Git - kernel.git/commitdiff
SUNRPC: Add a flag to avoid reference counts on credentials
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Sat, 8 Feb 2020 00:11:12 +0000 (19:11 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 16 Mar 2020 12:34:28 +0000 (08:34 -0400)
Add a flag to signal to the RPC layer that the credential is already
pinned for the duration of the RPC call.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
include/linux/sunrpc/sched.h
net/sunrpc/clnt.c
net/sunrpc/sched.c

index a6ef35184ef1338d8f20cbeda95c648c1496b42b..df696efdd6753f2c01737241394662089a9c6272 100644 (file)
@@ -132,6 +132,7 @@ struct rpc_task_setup {
 #define RPC_TASK_TIMEOUT       0x1000          /* fail with ETIMEDOUT on timeout */
 #define RPC_TASK_NOCONNECT     0x2000          /* return ENOTCONN if not connected */
 #define RPC_TASK_NO_RETRANS_TIMEOUT    0x4000          /* wait forever for a reply */
+#define RPC_TASK_CRED_NOREF    0x8000          /* No refcount on the credential */
 
 #define RPC_IS_ASYNC(t)                ((t)->tk_flags & RPC_TASK_ASYNC)
 #define RPC_IS_SWAPPER(t)      ((t)->tk_flags & RPC_TASK_SWAPPER)
index 7324b21f923e6816399168a1ad9ef3dd9fb362bc..2345e563c2f44d0fd68641ba8d530207d21c291c 100644 (file)
@@ -1099,8 +1099,9 @@ rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg)
                task->tk_msg.rpc_proc = msg->rpc_proc;
                task->tk_msg.rpc_argp = msg->rpc_argp;
                task->tk_msg.rpc_resp = msg->rpc_resp;
-               if (msg->rpc_cred != NULL)
-                       task->tk_msg.rpc_cred = get_cred(msg->rpc_cred);
+               task->tk_msg.rpc_cred = msg->rpc_cred;
+               if (!(task->tk_flags & RPC_TASK_CRED_NOREF))
+                       get_cred(task->tk_msg.rpc_cred);
        }
 }
 
index 55e900255b0c27c77df116accb12e82cf11d7c84..6eff14119a88450043582e6178451ae5fbd39766 100644 (file)
@@ -1162,7 +1162,8 @@ static void rpc_release_resources_task(struct rpc_task *task)
 {
        xprt_release(task);
        if (task->tk_msg.rpc_cred) {
-               put_cred(task->tk_msg.rpc_cred);
+               if (!(task->tk_flags & RPC_TASK_CRED_NOREF))
+                       put_cred(task->tk_msg.rpc_cred);
                task->tk_msg.rpc_cred = NULL;
        }
        rpc_task_release_client(task);