From ee7ca785615f2da71932512d8545763836ef8197 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 2 Mar 2020 12:37:35 -0500 Subject: [PATCH] LU-9859 lustre: remove current_pid() and current_comm() Just use current->pid and current->comm directly, instead of having wrappers. Linux-commit: 63fd7d04580b6345ff1e0aab906c034f973d493e Test-Parameters: trivial Change-Id: I278f32d6dd8c370a7ab211c5147ee8d246ea1893 Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/37776 Reviewed-by: Neil Brown Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Yang Sheng --- libcfs/include/libcfs/curproc.h | 4 ---- libcfs/libcfs/debug.c | 2 +- libcfs/libcfs/linux-debug.c | 2 +- lustre/ldlm/ldlm_lib.c | 12 ++++++------ lustre/ldlm/ldlm_lock.c | 2 +- lustre/lfsck/lfsck_engine.c | 4 ++-- lustre/llite/llite_internal.h | 2 +- lustre/llite/statahead.c | 6 +++--- lustre/lov/lov_merge.c | 2 +- lustre/lov/lov_obd.c | 6 +++--- lustre/mdt/mdt_coordinator.c | 6 +++--- lustre/obdclass/jobid.c | 8 ++++---- lustre/osc/osc_request.c | 2 +- lustre/osp/osp_dev.c | 2 +- lustre/ptlrpc/client.c | 8 ++++---- lustre/ptlrpc/gss/gss_keyring.c | 2 +- lustre/ptlrpc/service.c | 6 +++--- lustre/target/tgt_handler.c | 2 +- 18 files changed, 37 insertions(+), 41 deletions(-) diff --git a/libcfs/include/libcfs/curproc.h b/libcfs/include/libcfs/curproc.h index 17ecd90..6a2b09a 100644 --- a/libcfs/include/libcfs/curproc.h +++ b/libcfs/include/libcfs/curproc.h @@ -39,10 +39,6 @@ #ifndef __LIBCFS_CURPROC_H__ #define __LIBCFS_CURPROC_H__ -/* check if task is running in compat mode.*/ -#define current_pid() (current->pid) -#define current_comm() (current->comm) - typedef __u32 cfs_cap_t; #define CFS_CAP_CHOWN 0 diff --git a/libcfs/libcfs/debug.c b/libcfs/libcfs/debug.c index 8669dad..99518ab 100644 --- a/libcfs/libcfs/debug.c +++ b/libcfs/libcfs/debug.c @@ -419,7 +419,7 @@ void libcfs_debug_dumplog(void) */ reinit_completion(&debug_complete); dumper = kthread_run(libcfs_debug_dumplog_thread, - (void *)(long)current_pid(), + (void *)(long)current->pid, "libcfs_debug_dumper"); if (IS_ERR(dumper)) pr_err("LustreError: cannot start log dump thread: rc = %ld\n", diff --git a/libcfs/libcfs/linux-debug.c b/libcfs/libcfs/linux-debug.c index 3dd1307..f93bac5 100644 --- a/libcfs/libcfs/linux-debug.c +++ b/libcfs/libcfs/linux-debug.c @@ -264,7 +264,7 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1, if (in_interrupt()) { cfs_trace_debug_print(); } else { - libcfs_debug_dumplog_internal((void *)(long)current_pid()); + libcfs_debug_dumplog_internal((void *)(long)current->pid); } #endif return 0; diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 79c6e99..8a0ea40 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -2507,7 +2507,7 @@ static void replay_request_or_update(struct lu_env *env, continue; } - LASSERT(trd->trd_processing_task == current_pid()); + LASSERT(trd->trd_processing_task == current->pid); DEBUG_REQ(D_HA, req, "processing x%llu t%lld from %s", req->rq_xid, lustre_msg_get_transno(req->rq_reqmsg), @@ -2608,8 +2608,8 @@ static int target_recovery_thread(void *arg) tgt_io_thread_init(thread); /* init thread_big_cache for IO requests */ CDEBUG(D_HA, "%s: started recovery thread pid %d\n", obd->obd_name, - current_pid()); - trd->trd_processing_task = current_pid(); + current->pid); + trd->trd_processing_task = current->pid; spin_lock(&obd->obd_dev_lock); obd->obd_recovering = 1; @@ -2638,7 +2638,7 @@ static int target_recovery_thread(void *arg) CDEBUG(D_INFO, "2: lock replay stage - %d clients\n", atomic_read(&obd->obd_lock_replay_clients)); while ((req = target_next_replay_lock(lut))) { - LASSERT(trd->trd_processing_task == current_pid()); + LASSERT(trd->trd_processing_task == current->pid); DEBUG_REQ(D_HA, req, "processing lock from %s:", libcfs_nid2str(req->rq_peer.nid)); handle_recovery_req(thread, req, @@ -2666,7 +2666,7 @@ static int target_recovery_thread(void *arg) target_cancel_recovery_timer(obd); spin_unlock(&obd->obd_recovery_task_lock); while ((req = target_next_final_ping(obd))) { - LASSERT(trd->trd_processing_task == current_pid()); + LASSERT(trd->trd_processing_task == current->pid); DEBUG_REQ(D_HA, req, "processing final ping from %s:", libcfs_nid2str(req->rq_peer.nid)); handle_recovery_req(thread, req, @@ -2847,7 +2847,7 @@ int target_queue_recovery_request(struct ptlrpc_request *req, ENTRY; - if (obd->obd_recovery_data.trd_processing_task == current_pid()) { + if (obd->obd_recovery_data.trd_processing_task == current->pid) { /* Processing the queue right now, don't re-add. */ RETURN(1); } diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index ad9cafa..1496808 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1671,7 +1671,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, lock->l_req_mode = mode; lock->l_ast_data = data; - lock->l_pid = current_pid(); + lock->l_pid = current->pid; if (ns_is_server(ns)) ldlm_set_ns_srv(lock); if (cbs) { diff --git a/lustre/lfsck/lfsck_engine.c b/lustre/lfsck/lfsck_engine.c index 3d0b80e..3be7606 100644 --- a/lustre/lfsck/lfsck_engine.c +++ b/lustre/lfsck/lfsck_engine.c @@ -1071,7 +1071,7 @@ int lfsck_master_engine(void *args) lfsck->li_pos_checkpoint.lp_oit_cookie, lfsck->li_pos_checkpoint.lp_dir_cookie, PFID(&lfsck->li_pos_checkpoint.lp_dir_parent), - current_pid()); + current->pid); spin_lock(&lfsck->li_lock); if (unlikely(!thread_is_starting(thread))) { @@ -1102,7 +1102,7 @@ int lfsck_master_engine(void *args) lfsck->li_pos_checkpoint.lp_oit_cookie, lfsck->li_pos_checkpoint.lp_dir_cookie, PFID(&lfsck->li_pos_checkpoint.lp_dir_parent), - current_pid(), rc); + current->pid, rc); if (!OBD_FAIL_CHECK(OBD_FAIL_LFSCK_CRASH)) rc = lfsck_post(env, lfsck, rc); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 9dda901..5f71f2a 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1439,7 +1439,7 @@ dentry_may_statahead(struct inode *dir, struct dentry *dentry) return false; /* not the same process, don't statahead */ - if (lli->lli_opendir_pid != current_pid()) + if (lli->lli_opendir_pid != current->pid) return false; /* diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index 25b3849..6f7af5e 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -1122,7 +1122,7 @@ static int ll_statahead_thread(void *arg) "statahead thread: pid %d\n", PFID(&lli->lli_fid), sai->sai_hit, sai->sai_miss, sai->sai_sent, - sai->sai_replied, current_pid()); + sai->sai_replied, current->pid); break; } } @@ -1189,7 +1189,7 @@ void ll_authorize_statahead(struct inode *dir, void *key) */ LASSERT(lli->lli_opendir_pid == 0); lli->lli_opendir_key = key; - lli->lli_opendir_pid = current_pid(); + lli->lli_opendir_pid = current->pid; lli->lli_sa_enabled = 1; } spin_unlock(&lli->lli_sa_lock); @@ -1567,7 +1567,7 @@ static int start_statahead_thread(struct inode *dir, struct dentry *dentry) spin_unlock(&lli->lli_sa_lock); CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n", - current_pid(), parent->d_name.len, parent->d_name.name); + current->pid, parent->d_name.len, parent->d_name.name); task = kthread_create(ll_statahead_thread, parent, "ll_sa_%u", lli->lli_opendir_pid); diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index 8a6ced2..c82db71 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -56,7 +56,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index, int rc = 0; assert_spin_locked(&lsm->lsm_lock); - LASSERT(lsm->lsm_lock_owner == current_pid()); + LASSERT(lsm->lsm_lock_owner == current->pid); CDEBUG(D_INODE, "MDT ID "DOSTID" initial value: s=%llu m=%llu" " a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi), diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index b1600e4..2075312 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1248,16 +1248,16 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, void lov_stripe_lock(struct lov_stripe_md *md) __acquires(&md->lsm_lock) { - LASSERT(md->lsm_lock_owner != current_pid()); + LASSERT(md->lsm_lock_owner != current->pid); spin_lock(&md->lsm_lock); LASSERT(md->lsm_lock_owner == 0); - md->lsm_lock_owner = current_pid(); + md->lsm_lock_owner = current->pid; } void lov_stripe_unlock(struct lov_stripe_md *md) __releases(&md->lsm_lock) { - LASSERT(md->lsm_lock_owner == current_pid()); + LASSERT(md->lsm_lock_owner == current->pid); md->lsm_lock_owner = 0; spin_unlock(&md->lsm_lock); } diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index e1101e7..6ab98d7 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -558,7 +558,7 @@ static int mdt_coordinator(void *data) ENTRY; CDEBUG(D_HSM, "%s: coordinator thread starting, pid=%d\n", - mdt_obd_name(mdt), current_pid()); + mdt_obd_name(mdt), current->pid); hsd.hsd_mti = mti; obd_uuid2fsname(hsd.hsd_fsname, mdt_obd_name(mdt), @@ -738,11 +738,11 @@ clean_cb_alloc: if (rc != 0) CERROR("%s: coordinator thread exiting, process=%d, rc=%d\n", - mdt_obd_name(mdt), current_pid(), rc); + mdt_obd_name(mdt), current->pid, rc); else CDEBUG(D_HSM, "%s: coordinator thread exiting, process=%d," " no error\n", - mdt_obd_name(mdt), current_pid()); + mdt_obd_name(mdt), current->pid); RETURN(rc); } diff --git a/lustre/obdclass/jobid.c b/lustre/obdclass/jobid.c index 15fe75a..868f19d 100644 --- a/lustre/obdclass/jobid.c +++ b/lustre/obdclass/jobid.c @@ -334,7 +334,7 @@ static int jobid_get_from_cache(char *jobid, size_t joblen) { static time64_t last_expire; bool expire_cache = false; - pid_t pid = current_pid(); + pid_t pid = current->pid; struct jobid_pid_map *pidmap = NULL; time64_t now = ktime_get_real_seconds(); int rc = 0; @@ -495,7 +495,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid, switch ((f = *jobfmt++)) { case 'e': /* executable name */ - l = snprintf(jobid, joblen, "%s", current_comm()); + l = snprintf(jobid, joblen, "%s", current->comm); break; case 'g': /* group ID */ l = snprintf(jobid, joblen, "%u", @@ -511,7 +511,7 @@ static int jobid_interpret_string(const char *jobfmt, char *jobid, l = 0; break; case 'p': /* process ID */ - l = snprintf(jobid, joblen, "%u", current_pid()); + l = snprintf(jobid, joblen, "%u", current->pid); break; case 'u': /* user ID */ l = snprintf(jobid, joblen, "%u", @@ -705,7 +705,7 @@ int lustre_get_jobid(char *jobid, size_t joblen) if (jid) strlcpy(jobid, jid, sizeof(jobid)); rcu_read_unlock(); - } else if (jobid_name_is_valid(current_comm())) { + } else if (jobid_name_is_valid(current->comm)) { /* * obd_jobid_var holds the jobid environment variable name. * Skip initial check if obd_jobid_name already uses "%j", diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 63532c0..074cf6b 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2846,7 +2846,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, default: rc = -ENOTTY; CDEBUG(D_INODE, "%s: unrecognised ioctl %#x by %s: rc = %d\n", - obd->obd_name, cmd, current_comm(), rc); + obd->obd_name, cmd, current->comm, rc); break; } diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 20eef80..69643fa 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -1687,7 +1687,7 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len, break; default: CERROR("%s: unrecognized ioctl %#x by %s\n", obd->obd_name, - cmd, current_comm()); + cmd, current->comm); rc = -ENOTTY; } module_put(THIS_MODULE); diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index b7be022..2ce24c9 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -1671,7 +1671,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) lustre_msg_set_last_xid(req->rq_reqmsg, min_xid); - lustre_msg_set_status(req->rq_reqmsg, current_pid()); + lustre_msg_set_status(req->rq_reqmsg, current->pid); rc = sptlrpc_req_refresh_ctx(req, -1); if (rc) { @@ -1688,7 +1688,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) CDEBUG(D_RPCTRACE, "Sending RPC req@%p pname:cluuid:pid:xid:nid:opc:job %s:%s:%d:%llu:%s:%d:%s\n", - req, current_comm(), + req, current->comm, imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, obd_import_nid2str(imp), lustre_msg_get_opc(req->rq_reqmsg), @@ -2139,7 +2139,7 @@ interpret: if (req->rq_reqmsg) CDEBUG(D_RPCTRACE, "Completed RPC req@%p pname:cluuid:pid:xid:nid:opc:job %s:%s:%d:%llu:%s:%d:%s\n", - req, current_comm(), + req, current->comm, imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, @@ -3033,7 +3033,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) } /* for distributed debugging */ - lustre_msg_set_status(req->rq_reqmsg, current_pid()); + lustre_msg_set_status(req->rq_reqmsg, current->pid); /* add a ref for the set (see comment in ptlrpc_set_add_req) */ ptlrpc_request_addref(req); diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index b15e1d0..d2640a9 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -848,7 +848,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, imp->imp_connection->c_peer.nid, imp->imp_obd->obd_name, imp->imp_connection->c_self, sec_part_flags[0] == '\0' ? - current_pid() : imp->imp_sec_refpid); + current->pid : imp->imp_sec_refpid); CDEBUG(D_SEC, "requesting key for %s\n", desc); diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index be5df0d..c2c467e 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -2289,7 +2289,7 @@ static int ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, CDEBUG(D_RPCTRACE, "Handling RPC req@%p pname:cluuid+ref:pid:xid:nid:opc:job %s:%s+%d:%d:x%llu:%s:%d:%s\n", - request, current_comm(), + request, current->comm, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? @@ -2329,7 +2329,7 @@ put_conn: arrived_usecs = ktime_us_delta(work_end, arrived); CDEBUG(D_RPCTRACE, "Handled RPC req@%p pname:cluuid+ref:pid:xid:nid:opc:job %s:%s+%d:%d:x%llu:%s:%d:%s Request processed in %lldus (%lldus total) trans %llu rc %d/%d\n", - request, current_comm(), + request, current->comm, (request->rq_export ? (char *)request->rq_export->exp_client_uuid.uuid : "0"), (request->rq_export ? @@ -2746,7 +2746,7 @@ static int ptlrpc_main(void *arg) ENTRY; thread->t_task = current; - thread->t_pid = current_pid(); + thread->t_pid = current->pid; unshare_fs_struct(); if (svc->srv_cpt_bind) { diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 2cb7359..1cc8067 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -779,7 +779,7 @@ int tgt_request_handle(struct ptlrpc_request *req) /* reset the exp_last_xid on each connection. */ req->rq_export->exp_last_xid = 0; } else if (obd->obd_recovery_data.trd_processing_task != - current_pid()) { + current->pid) { rc = process_req_last_xid(req); if (rc) { req->rq_status = rc; -- 1.8.3.1