SunRPC/NFS: Use no_printk() in
Subsystems (4)
cover SunRPC/NFS: Use no_printk() in
Here's a series of patches to make SunRPC/NFS use no_printk() to implement its null dfprintk() macro (ie. when RPC_DEBUG is disabled). This prevents 'unused variable' errors from occurring when a variable is set only for use in debugging statements and renders RPC/NFS_IFDEBUG unnecessary.
David
---
David Howells (4):
SunRPC: Use the standard varargs macro method for dfprintk() and co.
SunRPC: Declare and use rpc_task_pid() to wrap task->tk_pid
SunRPC: Use no_printk() for the null dprintk() and dfprintk()
SunRPC: Kill RPC_IFDEBUG() and NFS_IFDEBUG()
fs/lockd/clntproc.c | 2 + fs/lockd/svc.c | 6 ++- fs/lockd/svc4proc.c | 2 + fs/lockd/svclock.c | 6 ++- fs/lockd/svcproc.c | 2 + fs/nfs/direct.c | 6 ++- fs/nfs/fscache.c | 2 + fs/nfs/nfs4filelayout.c | 8 ++-- fs/nfs/nfs4proc.c | 2 + fs/nfs/read.c | 4 +- fs/nfs/write.c | 8 ++-- fs/nfsd/nfs4proc.c | 6 +-- fs/nfsd/nfsfh.c | 10 +++--- include/linux/nfs_fs.h | 2 - include/linux/sunrpc/debug.h | 39 ++++++++++------------ include/linux/sunrpc/sched.h | 20 ++++++++--- include/trace/events/sunrpc.h | 8 ++-- net/sunrpc/auth.c | 18 +++++----- net/sunrpc/auth_gss/auth_gss.c | 20 ++++++----- net/sunrpc/clnt.c | 72 ++++++++++++++++++++-------------------- net/sunrpc/rpcb_clnt.c | 34 +++++++++---------- net/sunrpc/sched.c | 39 +++++++++------------- net/sunrpc/svcsock.c | 33 +++++++++++------- net/sunrpc/xprt.c | 30 ++++++++--------- net/sunrpc/xprtsock.c | 2 + 25 files changed, 194 insertions(+), 187 deletions(-)
PATCH 1/4 SunRPC: Use the standard varargs macro method for dfprintk() and co.
Use the standard varargs macro method rather than the old gcc method for dfprintk() and co.
---
include/linux/sunrpc/debug.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
include/linux/sunrpc/debug.h +9 -9
@@ -32,33 +32,33 @@ extern unsigned int nfsd_debug;extern unsigned int nlm_debug;#endif -#define dprintk(args...) dfprintk(FACILITY, ## args) -#define dprintk_rcu(args...) dfprintk_rcu(FACILITY, ## args) +#define dprintk (fmt, ...) dfprintk(FACILITY, fmt, ## __VA_ARGS__) +#define dprintk_rcu (fmt, ...) dfprintk_rcu(FACILITY, fmt, ## __VA_ARGS__)#undef ifdebug#ifdef RPC_DEBUG # define ifdebug (fac) if (unlikely(rpc_debug & RPCDBG_##fac)) -# define dfprintk(fac, args...) \ +# define dfprintk (fac, fmt, ...) \ do { \ ifdebug(fac) \ - printk(KERN_DEFAULT args); \ + printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ } while (0) -# define dfprintk_rcu(fac, args...) \ +# define dfprintk_rcu (fac, fmt, ...) \ do { \ ifdebug(fac) { \ rcu_read_lock(); \ - printk(KERN_DEFAULT args); \ + printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ rcu_read_unlock(); \ } \ } while (0)# define RPC_IFDEBUG (x) x#else -# define ifdebug (fac) if (0) -# define dfprintk(fac, args...) do {} while (0) -# define dfprintk_rcu(fac, args...) do {} while (0) +# define ifdebug (fac) if (0) +# define dfprintk (fac, fmt, ...) do {} while (0) +# define dfprintk_rcu (fac, fmt, ...) do {} while (0)# define RPC_IFDEBUG (x)#endif
PATCH 2/4 SunRPC: Declare and use rpc_task_pid() to wrap task->tk_pid
In reply to David HowellsDeclare and use rpc_task_pid() to wrap task->tk_pid (when it exists) and to return 0 when it doesn't. This allows us to move towards using no_printk().
This was mostly achieved with:
perl -p -i -e 's/task->tk_pid/rpc_task_pid(task)/g' git grep -l 'task->tk_pid' perl -p -i -e 's/data->task.tk_pid/rpc_task_pid(&data->task)/g' git grep -l 'data->task.tk_pid'
---
fs/lockd/clntproc.c | 2 + fs/lockd/svc4proc.c | 2 + fs/lockd/svcproc.c | 2 + fs/nfs/direct.c | 6 ++-- fs/nfs/nfs4filelayout.c | 8 ++--- fs/nfs/nfs4proc.c | 2 + fs/nfs/read.c | 4 +- fs/nfs/write.c | 8 ++--- include/linux/sunrpc/sched.h | 9 +++++ include/trace/events/sunrpc.h | 8 ++--- net/sunrpc/auth.c | 18 +++++------ net/sunrpc/auth_gss/auth_gss.c | 20 ++++++------ net/sunrpc/clnt.c | 68 ++++++++++++++++++++-------------------- net/sunrpc/rpcb_clnt.c | 34 ++++++++++---------- net/sunrpc/sched.c | 32 +++++++++---------- net/sunrpc/xprt.c | 30 +++++++++--------- net/sunrpc/xprtsock.c | 2 + 17 files changed, 132 insertions(+), 123 deletions(-)
fs/lockd/clntproc.c +1 -1
@@ -780,7 +780,7 @@ static void nlmclnt_cancel_callback(struct rpc_task *task, void *data) }dprintk ("lockd: cancel status %u (task %u)\n" , - status, task->tk_pid); + status,rpc_task_pid (task));switch (status) {case NLM_LCK_GRANTED :
fs/lockd/svc4proc.c +1 -1
@@ -224,7 +224,7 @@ nlm4svc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,*/ static void nlm4svc_callback_exit (struct rpc_task *task,void *data) { -dprintk ("lockd: %5u callback returned %d\n" , task->tk_pid, +dprintk ("lockd: %5u callback returned %d\n" ,rpc_task_pid (task), -task->tk_status); }
fs/lockd/svcproc.c +1 -1
@@ -257,7 +257,7 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,*/ static void nlmsvc_callback_exit (struct rpc_task *task,void *data) { -dprintk ("lockd: %5u callback returned %d\n" , task->tk_pid, +dprintk ("lockd: %5u callback returned %d\n" ,rpc_task_pid (task), -task->tk_status); }
fs/nfs/direct.c +3 -3
@@ -534,14 +534,14 @@ static void nfs_direct_commit_complete(struct nfs_commit_data *data)nfs_init_cinfo_from_dreq (&cinfo, dreq);if (status <0 ) {dprintk ("NFS: %5u commit failed with error %d.\n" , - data->task.tk_pid, status); +rpc_task_pid (&data->task), status); dreq->flags =NFS_ODIRECT_RESCHED_WRITES ; }else if (memcmp (&dreq->verf, &data->verf,sizeof (data->verf))) { -dprintk ("NFS: %5u commit verify failed\n" , data->task.tk_pid); +dprintk ("NFS: %5u commit verify failed\n" ,rpc_task_pid (&data->task)); dreq->flags =NFS_ODIRECT_RESCHED_WRITES ; } -dprintk ("NFS: %5u commit returned %d\n" , data->task.tk_pid, status); +dprintk ("NFS: %5u commit returned %d\n" ,rpc_task_pid (&data->task), status);while (!list_empty (&data->pages)) { req =nfs_list_entry (data->pages.next);nfs_list_remove_request (req);
fs/nfs/nfs4filelayout.c +4 -4
@@ -92,7 +92,7 @@ static void filelayout_reset_write(struct nfs_write_data *data)if (!test_and_set_bit (NFS_IOHDR_REDO , &hdr->flags)) { dprintk("%s Reset task %5u for i/o through MDS " "(req %s/%lld, %u bytes @ offset %llu)\n", __func__, - data->task.tk_pid, + rpc_task_pid(&data->task), hdr->inode->i_sb->s_id, (long long)NFS_FILEID(hdr->inode), data->args.count,
@@ -113,7 +113,7 @@ static void filelayout_reset_read(struct nfs_read_data *data)if (!test_and_set_bit (NFS_IOHDR_REDO , &hdr->flags)) { dprintk("%s Reset task %5u for i/o through MDS " "(req %s/%lld, %u bytes @ offset %llu)\n", __func__, - data->task.tk_pid, + rpc_task_pid(&data->task), hdr->inode->i_sb->s_id, (long long)NFS_FILEID(hdr->inode), data->args.count,
@@ -312,7 +312,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)return ; }if (filelayout_reset_to_mds (rdata->header->lseg)) { -dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid); +dprintk ("%s task %u reset io to MDS\n" , __func__,rpc_task_pid (task));filelayout_reset_read (rdata);rpc_exit (task,0 );return ;
@@ -423,7 +423,7 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)return ; }if (filelayout_reset_to_mds (wdata->header->lseg)) { -dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid); +dprintk ("%s task %u reset io to MDS\n" , __func__,rpc_task_pid (task));filelayout_reset_write (wdata);rpc_exit (task,0 );return ;
fs/nfs/nfs4proc.c +1 -1
@@ -7458,7 +7458,7 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)dprintk ("NFS: %4d initiating layoutcommit call. sync %d " "lbw: %llu inode %lu\n" , - data->task.tk_pid, sync, +rpc_task_pid (&data->task), sync, data->args.lastbytewritten, data->args.inode->i_ino);
fs/nfs/read.c +2 -2
@@ -230,7 +230,7 @@ int nfs_initiate_read(struct rpc_clnt *clnt, dprintk("NFS: %5u initiated read call (req %s/%lld, %u bytes @ " "offset %llu)\n", - data->task.tk_pid, + rpc_task_pid(&data->task), inode->i_sb->s_id, (long long)NFS_FILEID(inode), data->args.count,
@@ -444,7 +444,7 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)struct inode *inode = data->header->inode;int status; -dprintk ("NFS: %s: %5u, (status %d)\n" , __func__, task->tk_pid, +dprintk ("NFS: %s: %5u, (status %d)\n" , __func__,rpc_task_pid (task), task->tk_status); status =NFS_PROTO (inode)->read_done (task, data);
fs/nfs/write.c +4 -4
@@ -1016,7 +1016,7 @@ int nfs_initiate_write(struct rpc_clnt *clnt, dprintk("NFS: %5u initiated write call " "(req %s/%lld, %u bytes @ offset %llu)\n", - data->task.tk_pid, + rpc_task_pid(&data->task), inode->i_sb->s_id, (long long)NFS_FILEID(inode), data->args.count,
@@ -1361,7 +1361,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)int status;dprintk ("NFS: %5u nfs_writeback_done (status %d)\n" , - task->tk_pid, task->tk_status); +rpc_task_pid (task), task->tk_status);/* * ->write_done will attempt to use post-op attributes to detect
@@ -1489,7 +1489,7 @@ int nfs_initiate_commit(struct rpc_clnt *clnt, struct nfs_commit_data *data,/* Set up the initial task struct. */ NFS_PROTO (data->inode)->commit_setup (data, &msg); -dprintk ("NFS: %5u initiated commit call\n" , data->task.tk_pid); +dprintk ("NFS: %5u initiated commit call\n" ,rpc_task_pid (&data->task));nfs4_state_protect (NFS_SERVER (data->inode)->nfs_client,NFS_SP4_MACH_CRED_COMMIT , &task_setup_data.rpc_client, &msg);
@@ -1591,7 +1591,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)struct nfs_commit_data *data = calldata;dprintk ("NFS: %5u nfs_commit_done (status %d)\n" , - task->tk_pid, task->tk_status); +rpc_task_pid (task), task->tk_status);/* Call the NFS version-specific code */ NFS_PROTO (data->inode)->commit_done (task, data);
include/linux/sunrpc/sched.h +9 -0
@@ -268,4 +268,13 @@ static inline void rpc_assign_waitqueue_name(struct rpc_wait_queue *q, }#endif +static inline unsigned short rpc_task_pid (const struct rpc_task *t) +{ +#if defined(RPC_DEBUG ) || defined(RPC_TRACEPOINTS ) +return t->tk_pid; +#else +return 0 ; +#endif +} +#endif /* _LINUX_SUNRPC_SCHED_H_ */
include/trace/events/sunrpc.h +4 -4
@@ -23,7 +23,7 @@ DECLARE_EVENT_CLASS(rpc_task_status, ), TP_fast_assign( - __entry->task_id = task->tk_pid; + __entry->task_id = rpc_task_pid(task); __entry->client_id = task->tk_client->cl_clid; __entry->status = task->tk_status; ),
@@ -57,7 +57,7 @@ TRACE_EVENT(rpc_connect_status, ), TP_fast_assign( - __entry->task_id = task->tk_pid; + __entry->task_id = rpc_task_pid(task); __entry->client_id = task->tk_client->cl_clid; __entry->status = status; ),
@@ -84,7 +84,7 @@ DECLARE_EVENT_CLASS(rpc_task_running,TP_fast_assign ( __entry->client_id = clnt->cl_clid; - __entry->task_id = task->tk_pid; + __entry->task_id =rpc_task_pid (task); __entry->action = action; __entry->runstate = task->tk_runstate; __entry->status = task->tk_status;
@@ -142,7 +142,7 @@ DECLARE_EVENT_CLASS(rpc_task_queued,TP_fast_assign ( __entry->client_id = clnt->cl_clid; - __entry->task_id = task->tk_pid; + __entry->task_id =rpc_task_pid (task); __entry->timeout = task->tk_timeout; __entry->runstate = task->tk_runstate; __entry->status = task->tk_status;
net/sunrpc/auth.c +9 -9
@@ -613,7 +613,7 @@ EXPORT_SYMBOL_GPL(rpcauth_init_cred);struct rpc_cred *rpcauth_generic_bind_cred (struct rpc_task *task,struct rpc_cred *cred,int lookupflags) { -dprintk ("RPC: %5u holding %s cred %p\n" , task->tk_pid, +dprintk ("RPC: %5u holding %s cred %p\n" ,rpc_task_pid (task), cred->cr_auth->au_ops->au_name, cred);return get_rpccred (cred); }
@@ -629,7 +629,7 @@ rpcauth_bind_root_cred(struct rpc_task *task, int lookupflags) };dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); +rpc_task_pid (task), task->tk_client->cl_auth->au_ops->au_name);return auth->au_ops->lookup_cred (auth, &acred, lookupflags); }
@@ -639,7 +639,7 @@ rpcauth_bind_new_cred(struct rpc_task *task, int lookupflags)struct rpc_auth *auth = task->tk_client->cl_auth;dprintk ("RPC: %5u looking up %s cred\n" , - task->tk_pid, auth->au_ops->au_name); +rpc_task_pid (task), auth->au_ops->au_name);return rpcauth_lookupcred (auth, lookupflags); }
@@ -708,7 +708,7 @@ rpcauth_marshcred(struct rpc_task *task, __be32 *p)struct rpc_cred *cred = task->tk_rqstp->rq_cred;dprintk ("RPC: %5u marshaling %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); +rpc_task_pid (task), cred->cr_auth->au_ops->au_name, cred);return cred->cr_ops->crmarshal (task, p); }
@@ -719,7 +719,7 @@ rpcauth_checkverf(struct rpc_task *task, __be32 *p)struct rpc_cred *cred = task->tk_rqstp->rq_cred;dprintk ("RPC: %5u validating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); +rpc_task_pid (task), cred->cr_auth->au_ops->au_name, cred);return cred->cr_ops->crvalidate (task, p); }
@@ -740,7 +740,7 @@ rpcauth_wrap_req(struct rpc_task *task, kxdreproc_t encode, void *rqstp,struct rpc_cred *cred = task->tk_rqstp->rq_cred;dprintk ("RPC: %5u using %s cred %p to wrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred); +rpc_task_pid (task), cred->cr_ops->cr_name, cred);if (cred->cr_ops->crwrap_req)return cred->cr_ops->crwrap_req (task, encode, rqstp, data, obj);/* By default, we encode the arguments normally. */
@@ -765,7 +765,7 @@ rpcauth_unwrap_resp(struct rpc_task *task, kxdrdproc_t decode, void *rqstp,struct rpc_cred *cred = task->tk_rqstp->rq_cred;dprintk ("RPC: %5u using %s cred %p to unwrap rpc data\n" , - task->tk_pid, cred->cr_ops->cr_name, cred); +rpc_task_pid (task), cred->cr_ops->cr_name, cred);if (cred->cr_ops->crunwrap_resp)return cred->cr_ops->crunwrap_resp (task, decode, rqstp, data, obj);
@@ -787,7 +787,7 @@ rpcauth_refreshcred(struct rpc_task *task) cred = task->tk_rqstp->rq_cred; }dprintk ("RPC: %5u refreshing %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); +rpc_task_pid (task), cred->cr_auth->au_ops->au_name, cred); err = cred->cr_ops->crrefresh (task); out:
@@ -802,7 +802,7 @@ rpcauth_invalcred(struct rpc_task *task)struct rpc_cred *cred = task->tk_rqstp->rq_cred;dprintk ("RPC: %5u invalidating %s cred %p\n" , - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); +rpc_task_pid (task), cred->cr_auth->au_ops->au_name, cred);if (cred)clear_bit (RPCAUTH_CRED_UPTODATE , &cred->cr_flags); }
net/sunrpc/auth_gss/auth_gss.c +10 -10
@@ -536,7 +536,7 @@ gss_refresh_upcall(struct rpc_task *task)int err =0 ;dprintk ("RPC: %5u %s for uid %u\n" , - task->tk_pid, __func__,from_kuid (&init_user_ns, cred->cr_uid)); +rpc_task_pid (task), __func__,from_kuid (&init_user_ns, cred->cr_uid)); gss_msg =gss_setup_upcall (gss_auth, cred);if (PTR_ERR (gss_msg) == -EAGAIN ) {/* XXX: warning on the first, under the assumption we
@@ -568,7 +568,7 @@ gss_refresh_upcall(struct rpc_task *task)gss_release_msg (gss_msg); out:dprintk ("RPC: %5u %s for uid %u result %d\n" , - task->tk_pid, __func__, +rpc_task_pid (task), __func__,from_kuid (&init_user_ns, cred->cr_uid), err);return err; }
@@ -1387,7 +1387,7 @@ gss_marshal(struct rpc_task *task, __be32 *p)struct kvec iov;struct xdr_buf verf_buf; -dprintk ("RPC: %5u %s\n" , task->tk_pid, __func__); +dprintk ("RPC: %5u %s\n" ,rpc_task_pid (task), __func__); *p++ =htonl (RPC_AUTH_GSS ); cred_len = p++;
@@ -1514,7 +1514,7 @@ gss_validate(struct rpc_task *task, __be32 *p)u32 maj_stat;__be32 *ret =ERR_PTR (-EIO ); -dprintk ("RPC: %5u %s\n" , task->tk_pid, __func__); +dprintk ("RPC: %5u %s\n" ,rpc_task_pid (task), __func__); flav =ntohl (*p++);if ((len =ntohl (*p++)) >RPC_MAX_AUTH_SIZE )
@@ -1534,7 +1534,7 @@ gss_validate(struct rpc_task *task, __be32 *p)clear_bit (RPCAUTH_CRED_UPTODATE , &cred->cr_flags);if (maj_stat) {dprintk ("RPC: %5u %s: gss_verify_mic returned error 0x%08x\n" , - task->tk_pid, __func__, maj_stat); +rpc_task_pid (task), __func__, maj_stat); goto out_bad; }/* We leave it to unwrap to calculate au_rslack. For now we just
@@ -1542,11 +1542,11 @@ gss_validate(struct rpc_task *task, __be32 *p) cred->cr_auth->au_verfsize =XDR_QUADLEN (len) +2 ;gss_put_ctx (ctx);dprintk ("RPC: %5u %s: gss_verify_mic succeeded.\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__);return p +XDR_QUADLEN (len); out_bad:gss_put_ctx (ctx); -dprintk ("RPC: %5u %s failed ret %ld.\n" , task->tk_pid, __func__, +dprintk ("RPC: %5u %s failed ret %ld.\n" ,rpc_task_pid (task), __func__,PTR_ERR (ret));return ret; }
@@ -1729,7 +1729,7 @@ gss_wrap_req(struct rpc_task *task,struct gss_cl_ctx *ctx =gss_cred_get_ctx (cred);int status = -EIO ; -dprintk ("RPC: %5u %s\n" , task->tk_pid, __func__); +dprintk ("RPC: %5u %s\n" ,rpc_task_pid (task), __func__);if (ctx->gc_proc !=RPC_GSS_PROC_DATA ) {/* The spec seems a little ambiguous here, but I think that not * wrapping context destruction requests makes the most sense.
@@ -1752,7 +1752,7 @@ gss_wrap_req(struct rpc_task *task, } out:gss_put_ctx (ctx); -dprintk ("RPC: %5u %s returning %d\n" , task->tk_pid, __func__, status); +dprintk ("RPC: %5u %s returning %d\n" ,rpc_task_pid (task), __func__, status);return status; }
@@ -1868,7 +1868,7 @@ out_decode: out:gss_put_ctx (ctx);dprintk ("RPC: %5u %s returning %d\n" , - task->tk_pid, __func__, status); +rpc_task_pid (task), __func__, status);return status; }
net/sunrpc/clnt.c +34 -34
249 lines not on this page · raw message
net/sunrpc/rpcb_clnt.c +17 -17
@@ -688,7 +688,7 @@ void rpcb_getport_async(struct rpc_task *task)rcu_read_unlock ();dprintk ("RPC: %5u %s(%s, %u, %u, %d)\n" , - task->tk_pid, __func__, +rpc_task_pid (task), __func__, xprt->servername, clnt->cl_prog, clnt->cl_vers, xprt->prot);/* Put self on the wait queue to ensure we get notified if
@@ -697,7 +697,7 @@ void rpcb_getport_async(struct rpc_task *task)if (xprt_test_and_set_binding (xprt)) {dprintk ("RPC: %5u %s: waiting for another binder\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__);xprt_put (xprt);return ; }
@@ -706,7 +706,7 @@ void rpcb_getport_async(struct rpc_task *task)if (xprt_bound (xprt)) { status =0 ;dprintk ("RPC: %5u %s: already bound\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__); goto bailout_nofree; }
@@ -726,26 +726,26 @@ void rpcb_getport_async(struct rpc_task *task)default : status = -EAFNOSUPPORT ;dprintk ("RPC: %5u %s: bad address family\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__); goto bailout_nofree; }if (proc ==NULL ) { xprt->bind_index =0 ; status = -EPFNOSUPPORT ;dprintk ("RPC: %5u %s: no more getport versions available\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__); goto bailout_nofree; }dprintk ("RPC: %5u %s: trying rpcbind version %u\n" , - task->tk_pid, __func__, bind_version); +rpc_task_pid (task), __func__, bind_version); rpcb_clnt =rpcb_create (xprt->xprt_net, xprt->servername, sap, salen, xprt->prot, bind_version);if (IS_ERR (rpcb_clnt)) { status =PTR_ERR (rpcb_clnt);dprintk ("RPC: %5u %s: rpcb_create failed, error %ld\n" , - task->tk_pid, __func__,PTR_ERR (rpcb_clnt)); +rpc_task_pid (task), __func__,PTR_ERR (rpcb_clnt)); goto bailout_nofree; }
@@ -753,7 +753,7 @@ void rpcb_getport_async(struct rpc_task *task)if (!map) { status = -ENOMEM ;dprintk ("RPC: %5u %s: no memory available\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__); goto bailout_release_client; } map->r_prog = clnt->cl_prog;
@@ -782,7 +782,7 @@ void rpcb_getport_async(struct rpc_task *task)if (IS_ERR (child)) {/* rpcb_map_release() has freed the arguments */ dprintk ("RPC: %5u %s: rpc_run_task failed\n" , - task->tk_pid, __func__); +rpc_task_pid (task), __func__);return ; }
@@ -831,7 +831,7 @@ static void rpcb_getport_done(struct rpc_task *child, void *data) }dprintk ("RPC: %5u rpcb_getport_done(status %d, port %u)\n" , - child->tk_pid, status, map->r_port); +rpc_task_pid (child), status, map->r_port); map->r_status = status; }
@@ -846,7 +846,7 @@ static void rpcb_enc_mapping(struct rpc_rqst *req, struct xdr_stream *xdr,__be32 *p;dprintk ("RPC: %5u encoding PMAP_%s call (%u, %u, %d, %u)\n" , - req->rq_task->tk_pid, +rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name, rpcb->r_prog, rpcb->r_vers, rpcb->r_prot, rpcb->r_port);
@@ -870,7 +870,7 @@ static int rpcb_dec_getport(struct rpc_rqst *req, struct xdr_stream *xdr,return -EIO ; port =be32_to_cpup (p); -dprintk ("RPC: %5u PMAP_%s result: %lu\n" , req->rq_task->tk_pid, +dprintk ("RPC: %5u PMAP_%s result: %lu\n" ,rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name, port);if (unlikely (port >USHRT_MAX ))return -EIO ;
@@ -893,7 +893,7 @@ static int rpcb_dec_set(struct rpc_rqst *req, struct xdr_stream *xdr, *boolp =1 ;dprintk ("RPC: %5u RPCB_%s call %s\n" , - req->rq_task->tk_pid, +rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name, (*boolp ?"succeeded" :"failed" ));return 0 ;
@@ -920,7 +920,7 @@ static void rpcb_enc_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,__be32 *p;dprintk ("RPC: %5u encoding RPCB_%s call (%u, %u, '%s', '%s')\n" , - req->rq_task->tk_pid, +rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name, rpcb->r_prog, rpcb->r_vers, rpcb->r_netid, rpcb->r_addr);
@@ -955,7 +955,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,*/ if (len ==0 ) {dprintk ("RPC: %5u RPCB reply: program not registered\n" , - req->rq_task->tk_pid); +rpc_task_pid (req->rq_task));return 0 ; }
@@ -965,7 +965,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr, p =xdr_inline_decode (xdr, len);if (unlikely (p ==NULL )) goto out_fail; -dprintk ("RPC: %5u RPCB_%s reply: %s\n" , req->rq_task->tk_pid, +dprintk ("RPC: %5u RPCB_%s reply: %s\n" ,rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name, (char *)p); if (rpc_uaddr2sockaddr(req->rq_xprt->xprt_net, (char *)p, len,
@@ -977,7 +977,7 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr, out_fail:dprintk ("RPC: %5u malformed RPCB_%s reply\n" , - req->rq_task->tk_pid, +rpc_task_pid (req->rq_task), req->rq_task->tk_msg.rpc_proc->p_name);return -EIO ; }
net/sunrpc/sched.c +16 -16
@@ -66,7 +66,7 @@ __rpc_disable_timer(struct rpc_wait_queue *queue, struct rpc_task *task) {if (task->tk_timeout ==0 )return ; -dprintk ("RPC: %5u disabling timer\n" , task->tk_pid); +dprintk ("RPC: %5u disabling timer\n" ,rpc_task_pid (task)); task->tk_timeout =0 ;list_del (&task->u.tk_wait.timer_list);if (list_empty (&queue->timer_list.list))
@@ -90,7 +90,7 @@ __rpc_add_timer(struct rpc_wait_queue *queue, struct rpc_task *task)return ;dprintk ("RPC: %5u setting alarm for %lu ms\n" , - task->tk_pid, task->tk_timeout *1000 /HZ ); +rpc_task_pid (task), task->tk_timeout *1000 /HZ ); task->u.tk_wait.expires = jiffies + task->tk_timeout;if (list_empty (&queue->timer_list.list) ||time_before (task->u.tk_wait.expires, queue->timer_list.expires))
@@ -185,7 +185,7 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,rpc_set_queued (task);dprintk ("RPC: %5u added to queue %p \"%s\"\n" , - task->tk_pid, queue,rpc_qname (queue)); +rpc_task_pid (task), queue,rpc_qname (queue)); }/*
@@ -214,7 +214,7 @@ static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_taslist_del (&task->u.tk_wait.list); queue->qlen--;dprintk ("RPC: %5u removed from queue %p \"%s\"\n" , - task->tk_pid, queue,rpc_qname (queue)); +rpc_task_pid (task), queue,rpc_qname (queue)); }static void __rpc_init_priority_wait_queue (struct rpc_wait_queue *queue,const char *qname,unsigned char nr_queues)
@@ -263,7 +263,7 @@ static void rpc_task_set_debuginfo(struct rpc_task *task) {static atomic_t rpc_pid; - task->tk_pid =atomic_inc_return (&rpc_pid); +rpc_task_pid (task) =atomic_inc_return (&rpc_pid); }#else static inline void rpc_task_set_debuginfo (struct rpc_task *task)
@@ -355,7 +355,7 @@ static void __rpc_sleep_on_priority(struct rpc_wait_queue *q, unsigned char queue_priority) {dprintk ("RPC: %5u sleep_on(queue \"%s\" time %lu)\n" , - task->tk_pid,rpc_qname (q), jiffies); +rpc_task_pid (task),rpc_qname (q), jiffies);trace_rpc_task_sleep (task->tk_client, task, q);
@@ -416,7 +416,7 @@ EXPORT_SYMBOL_GPL(rpc_sleep_on_priority);static void __rpc_do_wake_up_task (struct rpc_wait_queue *queue,struct rpc_task *task) {dprintk ("RPC: %5u __rpc_wake_up_task (now %lu)\n" , - task->tk_pid, jiffies); +rpc_task_pid (task), jiffies);/* Has the task been executed yet? If not, we cannot wake it up! */ if (!RPC_IS_ACTIVATED (task)) {
@@ -622,7 +622,7 @@ static void __rpc_queue_timer_fn(unsigned long ptr)list_for_each_entry_safe (task, n, &queue->timer_list.list, u.tk_wait.timer_list) { timeo = task->u.tk_wait.expires;if (time_after_eq (now, timeo)) { -dprintk ("RPC: %5u timeout\n" , task->tk_pid); +dprintk ("RPC: %5u timeout\n" ,rpc_task_pid (task)); task->tk_status = -ETIMEDOUT ;rpc_wake_up_task_queue_locked (queue, task);continue ;
@@ -721,7 +721,7 @@ static void __rpc_execute(struct rpc_task *task)int status =0 ;dprintk ("RPC: %5u __rpc_execute flags=0x%x\n" , - task->tk_pid, task->tk_flags); +rpc_task_pid (task), task->tk_flags);WARN_ON_ONCE (RPC_IS_QUEUED (task));if (RPC_IS_QUEUED (task))
@@ -775,7 +775,7 @@ static void __rpc_execute(struct rpc_task *task)return ;/* sync task: sleep here */ -dprintk ("RPC: %5u sync task going to sleep\n" , task->tk_pid); +dprintk ("RPC: %5u sync task going to sleep\n" ,rpc_task_pid (task)); status =out_of_line_wait_on_bit (&task->tk_runstate,RPC_TASK_QUEUED , rpc_wait_bit_killable,TASK_KILLABLE );
@@ -786,14 +786,14 @@ static void __rpc_execute(struct rpc_task *task)* clean up after sleeping on some queue, we don't * break the loop here, but go around once more. */ -dprintk ("RPC: %5u got signal\n" , task->tk_pid); +dprintk ("RPC: %5u got signal\n" ,rpc_task_pid (task)); task->tk_flags |=RPC_TASK_KILLED ;rpc_exit (task, -ERESTARTSYS ); } -dprintk ("RPC: %5u sync task resuming\n" , task->tk_pid); +dprintk ("RPC: %5u sync task resuming\n" ,rpc_task_pid (task)); } -dprintk ("RPC: %5u return %d, status %d\n" , task->tk_pid, status, +dprintk ("RPC: %5u return %d, status %d\n" ,rpc_task_pid (task), status, task->tk_status);/* Release all resources associated with the task */ rpc_release_task (task);
@@ -860,7 +860,7 @@ void *rpc_malloc(struct rpc_task *task, size_t size) buf->len = size;dprintk ("RPC: %5u allocated buffer of size %zu at %p\n" , - task->tk_pid, size, buf); +rpc_task_pid (task), size, buf);return &buf->data; }EXPORT_SYMBOL_GPL (rpc_malloc);
@@ -974,7 +974,7 @@ static void rpc_free_task(struct rpc_task *task)rpc_release_calldata (task->tk_ops, task->tk_calldata);if (tk_flags &RPC_TASK_DYNAMIC ) { -dprintk ("RPC: %5u freeing task\n" , task->tk_pid); +dprintk ("RPC: %5u freeing task\n" ,rpc_task_pid (task));mempool_free (task, rpc_task_mempool); } }
@@ -1026,7 +1026,7 @@ EXPORT_SYMBOL_GPL(rpc_put_task_async);static void rpc_release_task (struct rpc_task *task) { -dprintk ("RPC: %5u release task\n" , task->tk_pid); +dprintk ("RPC: %5u release task\n" ,rpc_task_pid (task));WARN_ON_ONCE (RPC_IS_QUEUED (task));
net/sunrpc/xprt.c +15 -15
@@ -214,7 +214,7 @@ int xprt_reserve_xprt(struct rpc_xprt *xprt, struct rpc_task *task) out_sleep:dprintk ("RPC: %5u failed to lock transport %p\n" , - task->tk_pid, xprt); +rpc_task_pid (task), xprt); task->tk_timeout =0 ; task->tk_status = -EAGAIN ;if (req ==NULL )
@@ -269,7 +269,7 @@ int xprt_reserve_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task) }xprt_clear_locked (xprt); out_sleep: -dprintk ("RPC: %5u failed to lock transport %p\n" , task->tk_pid, xprt); +dprintk ("RPC: %5u failed to lock transport %p\n" ,rpc_task_pid (task), xprt); task->tk_timeout =0 ; task->tk_status = -EAGAIN ;if (req ==NULL )
@@ -400,7 +400,7 @@ __xprt_get_cong(struct rpc_xprt *xprt, struct rpc_task *task)if (req->rq_cong)return 1 ;dprintk ("RPC: %5u xprt_cwnd_limited cong = %lu cwnd = %lu\n" , - task->tk_pid, xprt->cong, xprt->cwnd); +rpc_task_pid (task), xprt->cong, xprt->cwnd);if (RPCXPRT_CONGESTED (xprt))return 0 ; req->rq_cong =1 ;
@@ -703,7 +703,7 @@ void xprt_connect(struct rpc_task *task) {struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt; -dprintk ("RPC: %5u xprt_connect xprt %p %s connected\n" , task->tk_pid, +dprintk ("RPC: %5u xprt_connect xprt %p %s connected\n" ,rpc_task_pid (task), xprt, (xprt_connected (xprt) ?"is" :"is not" ));if (!xprt_bound (xprt)) {
@@ -740,21 +740,21 @@ static void xprt_connect_status(struct rpc_task *task) xprt->stat.connect_count++; xprt->stat.connect_time += (long )jiffies - xprt->stat.connect_start;dprintk ("RPC: %5u xprt_connect_status: connection established\n" , - task->tk_pid); +rpc_task_pid (task));return ; }switch (task->tk_status) {case -EAGAIN : -dprintk ("RPC: %5u xprt_connect_status: retrying\n" , task->tk_pid); +dprintk ("RPC: %5u xprt_connect_status: retrying\n" ,rpc_task_pid (task));break ;case -ETIMEDOUT :dprintk ("RPC: %5u xprt_connect_status: connect attempt timed " -"out\n" , task->tk_pid); +"out\n" ,rpc_task_pid (task));break ;default :dprintk ("RPC: %5u xprt_connect_status: error %d connecting to " -"server %s\n" , task->tk_pid, -task->tk_status, +"server %s\n" ,rpc_task_pid (task), -task->tk_status, xprt->servername);xprt_release_write (xprt, task); task->tk_status = -EIO ;
@@ -809,7 +809,7 @@ void xprt_complete_rqst(struct rpc_task *task, int copied)struct rpc_xprt *xprt = req->rq_xprt;dprintk ("RPC: %5u xid %08x complete (%d bytes received)\n" , - task->tk_pid,ntohl (req->rq_xid), copied); +rpc_task_pid (task),ntohl (req->rq_xid), copied); xprt->stat.recvs++; req->rq_rtt =ktime_sub (ktime_get (), req->rq_xtime);
@@ -833,7 +833,7 @@ static void xprt_timer(struct rpc_task *task)if (task->tk_status != -ETIMEDOUT )return ; -dprintk ("RPC: %5u xprt_timer\n" , task->tk_pid); +dprintk ("RPC: %5u xprt_timer\n" ,rpc_task_pid (task));spin_lock_bh (&xprt->transport_lock);if (!req->rq_reply_bytes_recvd) {
@@ -860,7 +860,7 @@ int xprt_prepare_transmit(struct rpc_task *task)struct rpc_xprt *xprt = req->rq_xprt;int err =0 ; -dprintk ("RPC: %5u xprt_prepare_transmit\n" , task->tk_pid); +dprintk ("RPC: %5u xprt_prepare_transmit\n" ,rpc_task_pid (task));spin_lock_bh (&xprt->transport_lock);if (req->rq_reply_bytes_recvd && !req->rq_bytes_sent) {
@@ -891,7 +891,7 @@ void xprt_transmit(struct rpc_task *task)struct rpc_xprt *xprt = req->rq_xprt;int status, numreqs; -dprintk ("RPC: %5u xprt_transmit(%u)\n" , task->tk_pid, req->rq_slen); +dprintk ("RPC: %5u xprt_transmit(%u)\n" ,rpc_task_pid (task), req->rq_slen);if (!req->rq_reply_bytes_recvd) {if (list_empty (&req->rq_list) &&rpc_reply_expected (task)) {
@@ -920,7 +920,7 @@ void xprt_transmit(struct rpc_task *task)return ; } -dprintk ("RPC: %5u xmit complete\n" , task->tk_pid); +dprintk ("RPC: %5u xmit complete\n" ,rpc_task_pid (task)); task->tk_flags |=RPC_TASK_SENT ;spin_lock_bh (&xprt->transport_lock);
@@ -1188,7 +1188,7 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) req->rq_xid =xprt_alloc_xid (xprt); req->rq_release_snd_buf =NULL ;xprt_reset_majortimeo (req); -dprintk ("RPC: %5u reserved req %p xid %08x\n" , task->tk_pid, +dprintk ("RPC: %5u reserved req %p xid %08x\n" ,rpc_task_pid (task), req,ntohl (req->rq_xid)); }
@@ -1237,7 +1237,7 @@ void xprt_release(struct rpc_task *task)if (req->rq_release_snd_buf) req->rq_release_snd_buf (req); -dprintk ("RPC: %5u release request %p\n" , task->tk_pid, req); +dprintk ("RPC: %5u release request %p\n" ,rpc_task_pid (task), req);if (likely (!bc_prealloc (req)))xprt_free_slot (xprt, req);else
net/sunrpc/xprtsock.c +1 -1
@@ -501,7 +501,7 @@ static int xs_nospace(struct rpc_task *task)int ret = -EAGAIN ;dprintk ("RPC: %5u xmit incomplete (%u left of %u)\n" , - task->tk_pid, req->rq_slen - req->rq_bytes_sent, +rpc_task_pid (task), req->rq_slen - req->rq_bytes_sent, req->rq_slen);/* Protect against races with write_space */
Re: [PATCH 2/4] SunRPC: Declare and use rpc_task_pid() to wrap task->tk_pid
Quoted 7 lines · David Howells
Declare and use
rpc_task_pid()to wraptask->tk_pid(when it exists) and to return 0 when it doesn't. This allows us to move towards usingno_printk().This was mostly achieved with:
perl -p -i -e 's/task->tk_pid/rpc_task_pid(task)/g' `git grep -l 'task->tk_pid'` perl -p -i -e 's/data->task.tk_pid/rpc_task_pid(&data->task)/g' `git grep -l 'data->task.tk_pid'`
I missed one command out. This needs to be done first:
perl -p -i -e 's/req->rq_task->tk_pid/rpc_task_pid(req->rq_task)/g' `git grep -l 'req->rq_task->tk_pid'`
David
PATCH 3/4 SunRPC: Use no_printk() for the null dprintk() and dfprintk()
In reply to David HowellsUse no_printk() for the null dprintk() and dfprintk() so that the compiler doesn't complain about unused variables for stuff that's just printed.
---
fs/lockd/svc.c | 6 ++++-- fs/lockd/svclock.c | 6 ++++-- fs/nfs/fscache.c | 2 +- fs/nfsd/nfs4proc.c | 6 ++---- fs/nfsd/nfsfh.c | 10 ++++++---- include/linux/sunrpc/debug.h | 37 ++++++++++++++++++------------------- include/linux/sunrpc/sched.h | 15 +++++++-------- net/sunrpc/clnt.c | 4 ++-- net/sunrpc/sched.c | 11 +++-------- net/sunrpc/svcsock.c | 33 +++++++++++++++++++-------------- 10 files changed, 66 insertions(+), 64 deletions(-)
fs/lockd/svc.c +4 -2
@@ -147,7 +147,6 @@ lockd(void *vrqstp)*/ while (!kthread_should_stop ()) {long timeout =MAX_SCHEDULE_TIMEOUT ; - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);/* update sv_maxconn if it has changed */ rqstp->rq_server->sv_maxconn = nlm_max_connections;
@@ -167,8 +166,11 @@ lockd(void *vrqstp) err =svc_recv (rqstp, timeout);if (err == -EAGAIN || err == -EINTR )continue ; -dprintk ("lockd: request from %s\n" , +ifdebug (FACILITY ) { +char buf[RPC_MAX_ADDRBUFLEN ]; +dprintk ("lockd: request from %s\n" ,svc_print_addr (rqstp, buf,sizeof (buf))); + }svc_process (rqstp); }
fs/lockd/svclock.c +4 -2
@@ -53,9 +53,9 @@ static const struct rpc_call_ops nlmsvc_grant_ops;static LIST_HEAD (nlm_blocked);static DEFINE_SPINLOCK (nlm_blocked_lock); -#ifdef LOCKD_DEBUG static const char *nlmdbg_cookie2a (const struct nlm_cookie *cookie) { +#ifdef LOCKD_DEBUG /* * We can get away with a static buffer because we're only * called with BKL held.
@@ -79,8 +79,10 @@ static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) *p ='\0' ;return buf; -} +#else +return "" ;#endif +}/* * Insert a blocked lock into the global list
fs/nfs/fscache.c +1 -1
@@ -317,7 +317,7 @@ void nfs_fscache_reset_inode_cookie(struct inode *inode) {struct nfs_inode *nfsi =NFS_I (inode);struct nfs_server *nfss =NFS_SERVER (inode); - NFS_IFDEBUG(struct fscache_cookie *old = nfsi->fscache); +struct fscache_cookie *old = nfsi->fscache;nfs_fscache_inode_lock (inode);if (nfsi->fscache) {
fs/nfsd/nfs4proc.c +2 -4
@@ -1172,9 +1172,7 @@ struct nfsd4_operation {static struct nfsd4_operation nfsd4_ops[]; -#ifdef NFSD_DEBUG static const char *nfsd4_op_name (unsigned opnum); -#endif /* * Enforce NFSv4.1 COMPOUND ordering rules:
@@ -1842,14 +1840,14 @@ static struct nfsd4_operation nfsd4_ops[] = { }, }; -#ifdef NFSD_DEBUG static const char *nfsd4_op_name (unsigned opnum) { +#ifdef NFSD_DEBUG if (opnum <ARRAY_SIZE (nfsd4_ops))return nfsd4_ops[opnum].op_name; +#endif return "unknown_operation" ; } -#endif #define nfsd4_voidres nfsd4_voidargsstruct nfsd4_voidargs {int dummy; };
fs/nfsd/nfsfh.c +6 -4
@@ -87,10 +87,12 @@ static __be32 nfsd_setuser_and_check_port(struct svc_rqst *rqstp,/* Check if the request originated from a secure port. */ if (!rqstp->rq_secure && !(flags &NFSEXP_INSECURE_PORT )) { - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]); -dprintk (KERN_WARNING -"nfsd: request from insecure port %s!\n" , -svc_print_addr (rqstp, buf,sizeof (buf))); +ifdebug (FACILITY ) { +char buf[RPC_MAX_ADDRBUFLEN ]; +dprintk (KERN_WARNING +"nfsd: request from insecure port %s!\n" , +svc_print_addr (rqstp, buf,sizeof (buf))); + }return nfserr_perm; }
include/linux/sunrpc/debug.h +18 -19
@@ -38,30 +38,29 @@ extern unsigned int nlm_debug;#undef ifdebug#ifdef RPC_DEBUG # define ifdebug (fac) if (unlikely(rpc_debug & RPCDBG_##fac)) - -# define dfprintk (fac, fmt, ...) \ - do { \ - ifdebug(fac) \ - printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ - } while (0) - -# define dfprintk_rcu (fac, fmt, ...) \ - do { \ - ifdebug(fac) { \ - rcu_read_lock(); \ - printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \ - rcu_read_unlock(); \ - } \ - } while (0) - +# define __dprintk (fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__);# define RPC_IFDEBUG (x) x#else -# define ifdebug (fac) if (0) -# define dfprintk (fac, fmt, ...) do {} while (0) -# define dfprintk_rcu (fac, fmt, ...) do {} while (0) +# define ifdebug (fac) if (0) +# define __dprintk (fmt, ...) no_printk(KERN_DEFAULT fmt, ##__VA_ARGS__);# define RPC_IFDEBUG (x)#endif +#define dfprintk (fac, fmt, ...) \ + do { \ + ifdebug(fac) \ + __dprintk(fmt, ##__VA_ARGS__); \ + } while (0) + +#define dfprintk_rcu (fac, fmt, ...) \ + do { \ + ifdebug(fac) { \ + rcu_read_lock(); \ + __dprintk(fmt, ##__VA_ARGS__); \ + rcu_read_unlock(); \ + } \ + } while (0) +/* * Sysctl interface for RPC debugging */
include/linux/sunrpc/sched.h +7 -8
@@ -250,23 +250,22 @@ static inline int rpc_wait_for_completion_task(struct rpc_task *task)return __rpc_wait_for_completion_task (task,NULL ); } -#if defined(RPC_DEBUG ) || defined (RPC_TRACEPOINTS )static inline const char *rpc_qname (const struct rpc_wait_queue *q) { -return ((q && q->name) ? q->name :"unknown" ); +#if defined(RPC_DEBUG ) || defined (RPC_TRACEPOINTS ) +if (q && q->name) +return q->name; +#endif +return "unknown" ; }static inline void rpc_assign_waitqueue_name (struct rpc_wait_queue *q,const char *name) { +#if defined(RPC_DEBUG ) || defined (RPC_TRACEPOINTS ) q->name = name; -} -#else -static inline void rpc_assign_waitqueue_name (struct rpc_wait_queue *q, -const char *name) -{ -}#endif +}static inline unsigned short rpc_task_pid (const struct rpc_task *t) {
net/sunrpc/clnt.c +2 -2
@@ -1282,9 +1282,9 @@ rpc_restart_call(struct rpc_task *task) }EXPORT_SYMBOL_GPL (rpc_restart_call); -#ifdef RPC_DEBUG static const char *rpc_proc_name (const struct rpc_task *task) { +#ifdef RPC_DEBUG const struct rpc_procinfo *proc = task->tk_msg.rpc_proc;if (proc) {
@@ -1293,9 +1293,9 @@ static const char *rpc_proc_name(const struct rpc_task *task) else return "NULL"; } else +#endif return "no proc" ; } -#endif /* * 0. Initial state
net/sunrpc/sched.c +3 -8
@@ -258,18 +258,13 @@ static int rpc_wait_bit_killable(void *word)return 0 ; } -#if defined(RPC_DEBUG ) || defined(RPC_TRACEPOINTS )static void rpc_task_set_debuginfo (struct rpc_task *task) { +#if defined(RPC_DEBUG ) || defined(RPC_TRACEPOINTS )static atomic_t rpc_pid; - -rpc_task_pid (task) =atomic_inc_return (&rpc_pid); -} -#else -static inline void rpc_task_set_debuginfo (struct rpc_task *task) -{ -} + task->tk_pid =atomic_inc_return (&rpc_pid);#endif +}static void rpc_set_active (struct rpc_task *task) {
net/sunrpc/svcsock.c +19 -14
@@ -244,7 +244,6 @@ static int svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)int len =0 ;unsigned long tailoff;unsigned long headoff; - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);if (rqstp->rq_prot ==IPPROTO_UDP ) {struct msghdr msg = {
@@ -267,9 +266,12 @@ static int svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr) rqstp->rq_respages[0], tailoff); out: -dprintk ("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %s)\n" , - svsk, xdr->head[0 ].iov_base, xdr->head[0 ].iov_len, - xdr->len, len,svc_print_addr (rqstp, buf,sizeof (buf))); + ifdebug(FACILITY) { +char buf[RPC_MAX_ADDRBUFLEN ]; +dprintk ("svc: socket %p sendto([%p %Zu... ], %d) = %d (addr %s)\n" , + svsk, xdr->head[0 ].iov_base, xdr->head[0 ].iov_len, + xdr->len, len,svc_print_addr (rqstp, buf,sizeof (buf))); + }return len; }
@@ -809,7 +811,6 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)struct socket *newsock;struct svc_sock *newsvsk;int err, slen; - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);dprintk ("svc: tcp_accept %p sock %p\n" , svsk, sock);if (!sock)
@@ -839,14 +840,16 @@ static struct svc_xprt *svc_tcp_accept(struct svc_xprt *xprt)* hosts here, but when we get encryption, the IP of the host won't * tell us anything. For now just warn about unpriv connections. */ -if (!svc_port_is_privileged (sin)) { -dprintk (KERN_WARNING -"%s: connect from unprivileged port: %s\n" , - serv->sv_name, -__svc_print_addr (sin, buf,sizeof (buf))); +ifdebug (FACILITY ) { +char buf[RPC_MAX_ADDRBUFLEN ]; +__svc_print_addr (sin, buf,sizeof (buf)); +if (!svc_port_is_privileged (sin)) { +dprintk (KERN_WARNING +"%s: connect from unprivileged port: %s\n" , + serv->sv_name, buf); + } +dprintk ("%s: connect from %s\n" , serv->sv_name, buf); } -dprintk ("%s: connect from %s\n" , serv->sv_name, -__svc_print_addr (sin, buf,sizeof (buf)));/* make sure that a write doesn't block forever when * low on memory
@@ -1465,11 +1468,13 @@ static struct svc_xprt *svc_create_socket(struct svc_serv *serv,int newlen;int family;int val; - RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]); -dprintk ("svc: svc_create_socket(%s, %d, %s)\n" , +ifdebug (FACILITY ) { +char buf[RPC_MAX_ADDRBUFLEN ]; +dprintk ("svc: svc_create_socket(%s, %d, %s)\n" , serv->sv_program->pg_name, protocol,__svc_print_addr (sin, buf,sizeof (buf))); + }if (protocol !=IPPROTO_UDP && protocol !=IPPROTO_TCP ) { printk(KERN_WARNING "svc: only UDP and TCP "
Re: [PATCH 3/4] SunRPC: Use no_printk() for the null dprintk() and dfprintk()
Quoted 2 lines · David Howells
Use
no_printk()for the nulldprintk()anddfprintk()so that the compiler doesn't complain about unused variables for stuff that's just printed.
no_printk doesn't prevent any argument side-effects from being optimized away by the compiler.
ie:
dprintk("%d", func())func is now always called when before it wasn't.
Are there any side-effects?
btw: Using
#define dprintk(fmt, ...)
do {
if (0)
printk(fmt, ##__VA_ARGS__);
} while (0)does away with side-effects.
Re: [PATCH 3/4] SunRPC: Use no_printk() for the null dprintk() and dfprintk()
Quoted 6 lines · Joe Perches
no_printkdoesn't prevent any argument side-effects from being optimized away by the compiler.ie:
dprintk("%d", func())func is now always called when before it wasn't.
Yes, I know. There are half a dozen places where this is the case. Those I've wrapped in ifdebug(FACILITY) { ... } in the code. It's not the nicest, but at least the compiler always gets to see everything, rather than bits of it getting hidden by the preprocessor - which means the call points will be less likely to bit rot over time.
David
Re: [PATCH 3/4] SunRPC: Use no_printk() for the null dprintk() and dfprintk()
Quoted 9 lines · David Howells
Quoted 6 lines · Joe Perches
no_printkdoesn't prevent any argument side-effects from being optimized away by the compiler.ie:
dprintk("%d", func())func is now always called when before it wasn't.
Quoted 5 lines
Yes, I know. There are half a dozen places where this is the case. Those I've wrapped in ifdebug(FACILITY) { ... } in the code. It's not the nicest, but at least the compiler always gets to see everything, rather than bits of it getting hidden by the preprocessor - which means the call points will be less likely to bit rot over time.
No code is eliminated by the preprocessor
with the #define I suggest.
Re: [PATCH 3/4] SunRPC: Use no_printk() for the null dprintk() and dfprintk()
Quoted 2 lines · Joe Perches
No code is eliminated by the preprocessor
with the #define I suggest.
Sorry, I misunderstood. I assumed you meant comparing to:
#ifdef RPC_DEBUG
#define dfprintk(...) ...
#else
#define dfprintk(...) do {} while(0)
#endifsort of thing which would certainly eliminate code in cpp.
So, yes, you're right. So I shouldn't need to put the
ifdebug(FACILITY) { ... }clauses into the code as the function calls in the argument list will be behind the if-statement anyway.
David
RE: [PATCH 3/4] SunRPC: Use no_printk() for the null dprintk() and dfprintk()
In reply to David HowellsQuoted 18 lines
-----Original Message-----
From: David Howells [mailto:[email protected]]
Sent: Thursday, September 26, 2013 10:36 AM
To: Joe Perches
Cc: [email protected]; [email protected]; Myklebust, Trond; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 3/4] SunRPC: Useno_printk()for the nulldprintk()anddfprintk()Quoted 6 lines · Joe Perches
no_printkdoesn't prevent any argument side-effects from being optimized away by the compiler.ie:
dprintk("%d", func())func is now always called when before it wasn't.
Quoted 5 lines
Yes, I know. There are half a dozen places where this is the case. Those I've wrapped in ifdebug(FACILITY) { ... } in the code. It's not the nicest, but at least the compiler always gets to see everything, rather than bits of it getting hidden by the preprocessor - which means the call points will be less likely to bit rot over time.
Your assumption is that RPC_DEBUG is disabled for most compiles. That is not the case.
Trond
PATCH 4/4 SunRPC: Kill RPC_IFDEBUG() and NFS_IFDEBUG()
In reply to David HowellsKill RPC_IFDEBUG() and NFS_IFDEBUG() as they're no longer used.
---
include/linux/nfs_fs.h | 2 -- include/linux/sunrpc/debug.h | 2 -- 2 files changed, 4 deletions(-)
include/linux/nfs_fs.h +0 -2
@@ -623,9 +623,7 @@ nfs_fileid_to_ino_t(u64 fileid)# undef ifdebug# ifdef NFS_DEBUG # define ifdebug (fac) if (unlikely(nfs_debug & NFSDBG_##fac)) -# define NFS_IFDEBUG (x) x# else # define ifdebug (fac) if (0) -# define NFS_IFDEBUG (x)# endif #endif
include/linux/sunrpc/debug.h +0 -2
@@ -39,11 +39,9 @@ extern unsigned int nlm_debug;#ifdef RPC_DEBUG # define ifdebug (fac) if (unlikely(rpc_debug & RPCDBG_##fac))# define __dprintk (fmt, ...) printk(KERN_DEFAULT fmt, ##__VA_ARGS__); -# define RPC_IFDEBUG (x) x#else # define ifdebug (fac) if (0)# define __dprintk (fmt, ...) no_printk(KERN_DEFAULT fmt, ##__VA_ARGS__); -# define RPC_IFDEBUG (x)#endif #define dfprintk (fac, fmt, ...) \
Quoted 6 lines · David Howells
Here's a series of patches to make SunRPC/NFS use
no_printk()to implement its nulldfprintk()macro (ie. whenRPC_DEBUGis disabled). This prevents 'unused variable' errors from occurring when a variable is set only for use in debugging statements and renders RPC/NFS_IFDEBUG unnecessary.
Does this patch series fix any actual warnings? Or does it just change the way that we prevent the warnings?
Whatever, I've got no opinion--ACK for any parts that touch code I maintain....
--b.
Quoted 37 lines
David
---
David Howells (4):
SunRPC: Use the standard varargs macro method fordfprintk()and co.
SunRPC: Declare and userpc_task_pid()to wraptask->tk_pid
SunRPC: Useno_printk()for the nulldprintk()anddfprintk()
SunRPC: KillRPC_IFDEBUG()andNFS_IFDEBUG()fs/lockd/clntproc.c | 2 + fs/lockd/svc.c | 6 ++- fs/lockd/svc4proc.c | 2 + fs/lockd/svclock.c | 6 ++- fs/lockd/svcproc.c | 2 + fs/nfs/direct.c | 6 ++- fs/nfs/fscache.c | 2 + fs/nfs/nfs4filelayout.c | 8 ++-- fs/nfs/nfs4proc.c | 2 + fs/nfs/read.c | 4 +- fs/nfs/write.c | 8 ++-- fs/nfsd/nfs4proc.c | 6 +-- fs/nfsd/nfsfh.c | 10 +++--- include/linux/nfs_fs.h | 2 - include/linux/sunrpc/debug.h | 39 ++++++++++------------ include/linux/sunrpc/sched.h | 20 ++++++++--- include/trace/events/sunrpc.h | 8 ++-- net/sunrpc/auth.c | 18 +++++----- net/sunrpc/auth_gss/auth_gss.c | 20 ++++++----- net/sunrpc/clnt.c | 72 ++++++++++++++++++++-------------------- net/sunrpc/rpcb_clnt.c | 34 +++++++++---------- net/sunrpc/sched.c | 39 +++++++++------------- net/sunrpc/svcsock.c | 33 +++++++++++------- net/sunrpc/xprt.c | 30 ++++++++--------- net/sunrpc/xprtsock.c | 2 + 25 files changed, 194 insertions(+), 187 deletions(-)
Quoted 11 lines
-----Original Message-----
From: J. Bruce Fields [mailto:[email protected]]
Sent: Thursday, September 26, 2013 10:21 AM
To: David Howells
Cc: Myklebust, Trond; [email protected]; [email protected]; linux- [email protected]
Subject: Re: [RFC][PATCH 0/4] SunRPC/NFS: Useno_printk()inQuoted 2 lines · David Howells
Quoted 9 lines
Quoted 4 lines
Here's a series of patches to make SunRPC/NFS use
no_printk()to implement its nulldfprintk()macro (ie. whenRPC_DEBUGis disabled). This prevents 'unused variable' errors from occurring when a variable is set only for use in debugging statements and renders RPC/NFS_IFDEBUGunnecessary.
Does this patch series fix any actual warnings? Or does it just change the way that we prevent the warnings?
Right. If this is just code churn, then let's drop it. Otherwise, please explain why it is a good idea.
Cheers,
Trond
Quoted 7 lines · J. Bruce Fields
Quoted 4 lines
Here's a series of patches to make SunRPC/NFS use
no_printk()to implement its nulldfprintk()macro (ie. whenRPC_DEBUGis disabled). This prevents 'unused variable' errors from occurring when a variable is set only for use in debugging statements and renders RPC/NFS_IFDEBUG unnecessary.Does this patch series fix any actual warnings? Or does it just change the way that we prevent the warnings?
It fixes some unused variable warnings introduced by NFS FS-Cache patches that I have (a variable is set up and only passed to dfprintk() a couple of times).
I could change those patches to do something different, but I think changing dfprintk() is actually the right solution as it will catch errors introduced into dfprintk() calls that are currently reduced to do{}while(0) by the preprocessor rather than letting the compiler chew on them and then reducing them to nothing with the optimiser.
David