Lustre-devel archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct()
Date: Thu, 04 Apr 2019 10:56:12 +1100	[thread overview]
Message-ID: <87y34qzlr7.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <54670010-3CDE-45F3-AF8D-FAC8D74F69D5@whamcloud.com>

On Wed, Apr 03 2019, Andreas Dilger wrote:

> On Mar 13, 2019, at 18:11, NeilBrown <neilb@suse.com> wrote:
>> 
>> A kthread runs with the same fs_struct as init.
>> It is only helpful to unshare this if the thread
>> will change one of the fields in the fs_struct:
>> root directory
>> current working directory
>> umask.
>> 
>> No lustre kthread changes any of these, so there is
>> no need to call unshare_fs_struct().
>> 
>> Signed-off-by: NeilBrown <neilb@suse.com>
>
> I recall one of the issues ages ago is that when the kthreads are
> started in the context of "mount" that they would use the same
> CWD as the mount process, which may be undesirable (e.g. it will
> prevent unmounting that filesystem).
>
> It is entirely possible that things have changed since this was
> written, but worthwhile to mention.

That sounds familiar .....
We used to have a function "daemonize()" which would disconnect a kernel
thread from anything it had inherited.  That was dropped in 3.8.
New kthreads are always forked from kthreadd, which is pid 2 (on my
desktop).  They cannot inherit anything from the thread that requested
them except what is explicitly passed.

So yes, it used to be as you say (though there were "kthreads" back
then), but it hasn't been that way for a while.

Thanks,
NeilBrown

>
>> ---
>> drivers/staging/lustre/lustre/obdclass/llog.c  |    3 ---
>> drivers/staging/lustre/lustre/ptlrpc/import.c  |    3 ---
>> drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c |    2 --
>> drivers/staging/lustre/lustre/ptlrpc/service.c |    4 ----
>> 4 files changed, 12 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
>> index a34b1a7108b7..ebb6c03ef038 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/llog.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/llog.c
>> @@ -45,7 +45,6 @@
>> #define DEBUG_SUBSYSTEM S_LOG
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <llog_swab.h>
>> #include <lustre_log.h>
>> #include <obd_class.h>
>> @@ -399,8 +398,6 @@ static int llog_process_thread_daemonize(void *arg)
>> 	struct lu_env env;
>> 	int rc;
>> 
>> -	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/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> index 26a976865fbd..b2a57d2bdde7 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/import.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
>> @@ -38,7 +38,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <obd_support.h>
>> #include <lustre_ha.h>
>> #include <lustre_net.h>
>> @@ -1328,8 +1327,6 @@ static int ptlrpc_invalidate_import_thread(void *data)
>> {
>> 	struct obd_import *imp = data;
>> 
>> -	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/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> index c295e9943bf7..b02e6c50bae1 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
>> @@ -53,7 +53,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <linux/libcfs/libcfs.h>
>> #include <linux/libcfs/libcfs_cpu.h>
>> #include <linux/libcfs/libcfs_string.h>
>> @@ -389,7 +388,6 @@ static int ptlrpcd(void *arg)
>> 	int rc = 0;
>> 	int exit = 0;
>> 
>> -	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/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> index c6b95c721167..571f0455e7b0 100644
>> --- a/drivers/staging/lustre/lustre/ptlrpc/service.c
>> +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
>> @@ -34,7 +34,6 @@
>> #define DEBUG_SUBSYSTEM S_RPC
>> 
>> #include <linux/kthread.h>
>> -#include <linux/fs_struct.h>
>> #include <obd_support.h>
>> #include <obd_class.h>
>> #include <lustre_net.h>
>> @@ -2029,7 +2028,6 @@ static int ptlrpc_main(void *arg)
>> 	int counter = 0, rc = 0;
>> 
>> 	thread->t_pid = current->pid;
>> -	unshare_fs_struct();
>> 
>> 	/* NB: we will call cfs_cpt_bind() for all threads, because we
>> 	 * might want to run lustre server only on a subset of system CPUs,
>> @@ -2230,8 +2228,6 @@ static int ptlrpc_hr_main(void *arg)
>> 	LIST_HEAD(replies);
>> 	int rc;
>> 
>> -	unshare_fs_struct();
>> -
>> 	rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
>> 	if (rc != 0) {
>> 		char threadname[20];
>> 
>> 
>
> Cheers, Andreas
> ---
> Andreas Dilger
> CTO Whamcloud
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20190404/8d50d395/attachment.sig>

  reply	other threads:[~2019-04-03 23:56 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  0:11 [lustre-devel] [PATCH 00/32] Another bunch of lustre patches NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 02/32] lustre: ptlrpc: remove ptlrpc_prep_bulk_frag NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 01/32] lustre: remove outdated comments about ->ap_* functions NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 03/32] lustre: ptlrpc: make ptlrpc_bulk_frag_ops always const NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 06/32] lustre: ptlrpc: discard BULK_BUF types NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 05/32] lustre: ptlrpc: drop support for KVEC bulk descriptors NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 07/32] lustre: ptlrpc: remove *GET*KIOV macros and fields NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 10/32] lustre: lnet: discard LNET_MD_IOVEC NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 11/32] lustre: lnet: don't embed whole lnet_md in lnet_event NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 08/32] lustre: ptlrpc: simplify bd_vec access NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 09/32] lustre: lnet: discard LNET_MD_PHYS NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 04/32] lustre: ptlrpc: remove inline on non-inlined functions NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 21/32] lustre: ptlrpc: discard a server-only waitq NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 12/32] lustre: lnet: merge lnet_md_alloc into lnet_md_build NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 20/32] lustre: lnet: discard lnet_kvaddr_to_page NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 18/32] lustre: socklnd: don't fall-back to tcp_sendpage NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 16/32] lustre: lnet: simplify ksock_tx NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 17/32] lustre: socklnd: discard tx_iov NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 15/32] lustre: lnet: remove msg_iov from lnet_msg NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 19/32] lustre: socklnd: discard kiblnd_setup_rd_iov NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 14/32] lustre: lnet: discard kvec option from lnet_libmd NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 13/32] lustre: lnet: always put a page list into struct lnet_libmd NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 26/32] lustre: ptlrpc: don't use list_for_each_entry_safe unnecessarily NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 25/32] lustre: incorporate BUILD_BUG_ON into ptlrpc_req_async_args() NeilBrown
2019-04-03 20:49   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 24/32] lustre: ptlrpc: discard cb_list and ptlrpc_set_cbdata; NeilBrown
2019-04-03 20:53   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 22/32] lustre: ptlrpc: simplify locking in ptlrpc_add_rqs_to_pool() NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 28/32] lustre: don't declare extern variables in C files NeilBrown
2019-04-03 20:43   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 23/32] lustre: ptlrpc: make ptlrpc_last_xid an atomic64_t NeilBrown
2019-04-03 20:26   ` Andreas Dilger
2019-04-03 23:46     ` NeilBrown
2019-03-14  0:11 ` [lustre-devel] [PATCH 27/32] lustre: don't call unshare_fs_struct() NeilBrown
2019-04-03 20:30   ` Andreas Dilger
2019-04-03 23:56     ` NeilBrown [this message]
2019-03-14  0:11 ` [lustre-devel] [PATCH 29/32] lustre: introduce CONFIG_LUSTRE_FS_POSIX_ACL NeilBrown
2019-04-03 20:44   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 31/32] lustre: mdc: create mdc_acl.c NeilBrown
2019-04-03 20:47   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 32/32] lustre: mgc: remove llog_process_lock NeilBrown
2019-04-03 20:47   ` Andreas Dilger
2019-03-14  0:11 ` [lustre-devel] [PATCH 30/32] lustre: remove some "#ifdef CONFIG*" from .c files NeilBrown
2019-04-03 20:45   ` Andreas Dilger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y34qzlr7.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).