From: Andreas Dilger Date: Tue, 16 Aug 2022 15:52:26 +0000 (+0000) Subject: LU-16056 libcfs: restore umask handling in kernel threads X-Git-Tag: 2.15.52~75 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c92bdd97d99cc755a187987f3d5963adeb3ea475 LU-16056 libcfs: restore umask handling in kernel threads This reverts commit 9013eb2bb5 which incorrectly assumes that Lustre service threads do not modify umask. A quick grep shows that umask is modified in osd-ldiskfs __osd_create(). If some other thread sharing the same fs context is modifying umask in an incompatible way (which includes all Lustre threads after this patch) then it will occasionally break created file access permissions for Lustre. Change-Id: I589b72e4286dc84f4e3f1a0c54fe31aa988e6c18 Fixes: 9013eb2bb5 (LU-9859 libcfs: don't call unshare_fs_struct()") Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/48233 Tested-by: jenkins Reviewed-by: Shuichi Ihara Reviewed-by: Lai Siyao Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index aacf22f..62c182c 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_LDLM #include +#include #include #include #include @@ -2716,6 +2717,7 @@ static int target_recovery_thread(void *arg) int rc = 0; ENTRY; + unshare_fs_struct(); OBD_ALLOC_PTR(thread); if (thread == NULL) RETURN(-ENOMEM); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 02deec2..6fe7af9 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -56,6 +56,7 @@ #define DEBUG_SUBSYSTEM S_LDLM +#include #include #include #include @@ -2609,6 +2610,7 @@ static int ldlm_lock_replay_thread(void *data) { struct obd_import *imp = data; + unshare_fs_struct(); CDEBUG(D_HA, "lock replay thread %s to %s@%s\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); diff --git a/lustre/obdclass/llog.c b/lustre/obdclass/llog.c index 1af4ae5..79f89fe 100644 --- a/lustre/obdclass/llog.c +++ b/lustre/obdclass/llog.c @@ -42,6 +42,7 @@ #define DEBUG_SUBSYSTEM S_LOG +#include #include #include #include @@ -836,6 +837,7 @@ static int llog_process_thread_daemonize(void *arg) } task_unlock(lpi->lpi_reftask); + unshare_fs_struct(); /* client env has no keys, tags is just 0 */ rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 2afcf6a..82dd394 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -35,6 +35,7 @@ #define DEBUG_SUBSYSTEM S_RPC +#include #include #include #include @@ -1508,6 +1509,7 @@ static int ptlrpc_invalidate_import_thread(void *data) struct obd_import *imp = data; ENTRY; + unshare_fs_struct(); CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), imp->imp_connection->c_remote_uuid.uuid); diff --git a/lustre/ptlrpc/pinger.c b/lustre/ptlrpc/pinger.c index 9bcfebd..72825b2 100644 --- a/lustre/ptlrpc/pinger.c +++ b/lustre/ptlrpc/pinger.c @@ -35,6 +35,7 @@ #define DEBUG_SUBSYSTEM S_RPC +#include #include #include #include @@ -465,6 +466,7 @@ static int ping_evictor_main(void *arg) time64_t expire_time; ENTRY; + unshare_fs_struct(); CDEBUG(D_HA, "Starting Ping Evictor\n"); pet_state = PET_READY; while (1) { diff --git a/lustre/ptlrpc/ptlrpcd.c b/lustre/ptlrpc/ptlrpcd.c index 1f540af..9d29cc7 100644 --- a/lustre/ptlrpc/ptlrpcd.c +++ b/lustre/ptlrpc/ptlrpcd.c @@ -50,6 +50,7 @@ #define DEBUG_SUBSYSTEM S_RPC +#include #include #include #include @@ -436,6 +437,7 @@ static int ptlrpcd(void *arg) int exit = 0; ENTRY; + unshare_fs_struct(); if (cfs_cpt_bind(cfs_cpt_tab, pc->pc_cpt) != 0) CWARN("Failed to bind %s on CPT %d\n", pc->pc_name, pc->pc_cpt); diff --git a/lustre/ptlrpc/service.c b/lustre/ptlrpc/service.c index abe24c4..4453e4d 100644 --- a/lustre/ptlrpc/service.c +++ b/lustre/ptlrpc/service.c @@ -31,6 +31,7 @@ #define DEBUG_SUBSYSTEM S_RPC +#include #include #include @@ -2751,6 +2752,7 @@ static int ptlrpc_main(void *arg) int counter = 0, rc = 0; ENTRY; + unshare_fs_struct(); thread->t_task = current; thread->t_pid = current->pid; @@ -2957,6 +2959,7 @@ static int ptlrpc_hr_main(void *arg) struct lu_env *env; int rc; + unshare_fs_struct(); OBD_ALLOC_PTR(env); if (env == NULL) RETURN(-ENOMEM);