Whamcloud - gitweb
LU-16056 libcfs: restore umask handling in kernel threads 14/48414/2
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 1 Sep 2022 17:31:48 +0000 (10:31 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 10 Sep 2022 00:55:17 +0000 (00:55 +0000)
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.

Lustre-change: https://review.whamcloud.com/48233
Lustre-commit: c92bdd97d99cc755a187987f3d5963adeb3ea475

Change-Id: I589b72e4286dc84f4e3f1a0c54fe31aa988e6c18
Fixes: 9013eb2bb5 (LU-9859 libcfs: don't call unshare_fs_struct()")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shuichi Ihara <sihara@ddn.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/48414
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_request.c
lustre/obdclass/llog.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpcd.c
lustre/ptlrpc/service.c

index aacf22f..62c182c 100644 (file)
@@ -39,6 +39,7 @@
 #define DEBUG_SUBSYSTEM S_LDLM
 
 #include <cl_object.h>
+#include <linux/fs_struct.h>
 #include <linux/jiffies.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
@@ -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);
index 048f5c3..38ca9ed 100644 (file)
@@ -56,6 +56,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <linux/fs_struct.h>
 #include <lustre_errno.h>
 #include <lustre_dlm.h>
 #include <obd_class.h>
@@ -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);
index e021ee4..24ed571 100644 (file)
@@ -42,6 +42,7 @@
 
 #define DEBUG_SUBSYSTEM S_LOG
 
+#include <linux/fs_struct.h>
 #include <linux/pid_namespace.h>
 #include <linux/kthread.h>
 #include <llog_swab.h>
@@ -824,6 +825,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)
index 77d9da0..1e0dd2d 100644 (file)
@@ -35,6 +35,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/fs_struct.h>
 #include <linux/kthread.h>
 #include <linux/delay.h>
 #include <obd_support.h>
@@ -1507,6 +1508,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);
index 9bcfebd..72825b2 100644 (file)
@@ -35,6 +35,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/fs_struct.h>
 #include <linux/kthread.h>
 #include <linux/workqueue.h>
 #include <obd_support.h>
@@ -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) {
index 1f540af..9d29cc7 100644 (file)
@@ -50,6 +50,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/fs_struct.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <lustre_net.h>
@@ -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);
 
index abe24c4..4453e4d 100644 (file)
@@ -31,6 +31,7 @@
 
 #define DEBUG_SUBSYSTEM S_RPC
 
+#include <linux/fs_struct.h>
 #include <linux/kthread.h>
 #include <linux/ratelimit.h>
 
@@ -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);