From b876e22466a83dacfbbbeb90d841dc917a793666 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Tue, 27 Jun 2023 15:10:19 +0700 Subject: [PATCH] LU-16893 libcfs: Remove force_sig usage from lfsck The lfsck pool of kernel threads uses force_sig() to signal the worker threads to stop. A signal is used here as the lfsck workers may be waiting in various, and possibly nested, states. As force_sig() has been removed let us simply enable SIGINT to be passed to the worker threads using send_sig(). Test-parameters: testlist=sanity-lfsck,lfsck-performance HPE-bug-id: LUS-11670 Fixes: db9f9543ec ("LU-12634 libcfs: force_sig() removed task parameter") Signed-off-by: Shaun Tancheff Change-Id: Ibf6a67f43687960b3eff9cb9a7c7dc8b1be1da63 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51470 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Neil Brown --- libcfs/autoconf/lustre-libcfs.m4 | 23 ----------------------- libcfs/include/libcfs/linux/linux-misc.h | 14 -------------- lustre/lfsck/lfsck_engine.c | 10 ++++++++++ lustre/lfsck/lfsck_lib.c | 12 ++++++------ 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 5c201e0..5f82b37 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -1782,27 +1782,6 @@ AC_DEFUN([LIBCFS_LOOKUP_USER_KEY], [ ]) # LIBCFS_LOOKUP_USER_KEY # -# LIBCFS_FORCE_SIG_WITH_TASK -# -# kernel 5.3 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740 -# signal: Remove task parameter from force_sig -# -AC_DEFUN([LIBCFS_SRC_FORCE_SIG_WITH_TASK], [ - LB2_LINUX_TEST_SRC([force_sig_with_task], [ - #include - ],[ - force_sig(SIGINT, NULL); - ],[-Werror]) -]) -AC_DEFUN([LIBCFS_FORCE_SIG_WITH_TASK], [ - AC_MSG_CHECKING([if force_sig has task parameter]) - LB2_LINUX_TEST_RESULT([force_sig_with_task], [ - AC_DEFINE(HAVE_FORCE_SIG_WITH_TASK, 1, - [force_sig() has task parameter]) - ]) -]) # LIBCFS_FORCE_SIG_WITH_TASK - -# # LIBCFS_CACHE_DETAIL_WRITERS # # kernel v5.3-rc2-1-g64a38e840ce5 @@ -2442,7 +2421,6 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [ LIBCFS_SRC_KOBJ_TYPE_DEFAULT_GROUPS # 5.3 LIBCFS_SRC_LOOKUP_USER_KEY - LIBCFS_SRC_FORCE_SIG_WITH_TASK LIBCFS_SRC_CACHE_DETAIL_WRITERS # 5.4 LIBCFS_SRC_GENL_DUMPIT_INFO @@ -2587,7 +2565,6 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [ LIBCFS_KOBJ_TYPE_DEFAULT_GROUPS # 5.3 LIBCFS_LOOKUP_USER_KEY - LIBCFS_FORCE_SIG_WITH_TASK LIBCFS_CACHE_DETAIL_WRITERS # 5.4 LIBCFS_GENL_DUMPIT_INFO diff --git a/libcfs/include/libcfs/linux/linux-misc.h b/libcfs/include/libcfs/linux/linux-misc.h index 2f3b305..e00f79d 100644 --- a/libcfs/include/libcfs/linux/linux-misc.h +++ b/libcfs/include/libcfs/linux/linux-misc.h @@ -119,20 +119,6 @@ static inline int kref_read(const struct kref *kref) } #endif /* HAVE_KREF_READ */ -#ifdef HAVE_FORCE_SIG_WITH_TASK -#define cfs_force_sig(sig, task) force_sig((sig), (task)) -#else -#define cfs_force_sig(sig, task) \ -do { \ - unsigned long flags; \ - \ - spin_lock_irqsave(&task->sighand->siglock, flags); \ - task->sighand->action[sig - 1].sa.sa_handler = SIG_DFL; \ - send_sig(sig, task, 1); \ - spin_unlock_irqrestore(&task->sighand->siglock, flags); \ -} while (0) -#endif - void cfs_arch_init(void); #ifndef container_of_safe diff --git a/lustre/lfsck/lfsck_engine.c b/lustre/lfsck/lfsck_engine.c index 19564d6..969000a 100644 --- a/lustre/lfsck/lfsck_engine.c +++ b/lustre/lfsck/lfsck_engine.c @@ -1016,6 +1016,11 @@ int lfsck_master_engine(void *args) int rc; ENTRY; + /* + * thread is spawned with all signals set to SIG_IGN, re-enable + * SIGINT for lfsck_stop() to awaken and stop the thread. + */ + allow_signal(SIGINT); spin_lock(&lfsck->li_lock); lfsck->li_task = current; spin_unlock(&lfsck->li_lock); @@ -1597,6 +1602,11 @@ int lfsck_assistant_engine(void *args) GOTO(fini, rc); } + /* + * thread is spawned with all signals set to SIG_IGN, re-enable + * SIGINT for lfsck_stop() to awaken and stop the thread. + */ + allow_signal(SIGINT); spin_lock(&lad->lad_lock); lad->lad_task = current; thread_set_flags(athread, SVC_RUNNING); diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index bb69561..8703cb0 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -3403,8 +3403,8 @@ int lfsck_stop(const struct lu_env *env, struct dt_device *key, thread_set_flags(thread, SVC_STOPPING); - LASSERT(lfsck->li_task != NULL); - cfs_force_sig(SIGINT, lfsck->li_task); + LASSERT(lfsck->li_task); + send_sig(SIGINT, lfsck->li_task, 1); if (lfsck->li_master) { struct lfsck_component *com; @@ -3413,16 +3413,16 @@ int lfsck_stop(const struct lu_env *env, struct dt_device *key, list_for_each_entry(com, &lfsck->li_list_scan, lc_link) { lad = com->lc_data; spin_lock(&lad->lad_lock); - if (lad->lad_task != NULL) - cfs_force_sig(SIGINT, lad->lad_task); + if (lad->lad_task) + send_sig(SIGINT, lad->lad_task, 1); spin_unlock(&lad->lad_lock); } list_for_each_entry(com, &lfsck->li_list_double_scan, lc_link) { lad = com->lc_data; spin_lock(&lad->lad_lock); - if (lad->lad_task != NULL) - cfs_force_sig(SIGINT, lad->lad_task); + if (lad->lad_task) + send_sig(SIGINT, lad->lad_task, 1); spin_unlock(&lad->lad_lock); } } -- 1.8.3.1