From 01c8efdd59b540eb6ea21e339d2dbd0283095130 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Wed, 29 May 2024 10:49:11 -0700 Subject: [PATCH] Simplify issig(). We always call it twice with JUSTLOOKING and then FORREAL. Reviewed-by: Brian Behlendorf Signed-off-by: Pawel Jakub Dawidek Closes #16225 --- include/os/freebsd/spl/sys/sig.h | 8 +------- include/os/linux/spl/sys/signal.h | 5 +---- include/sys/zfs_context.h | 3 +-- module/os/linux/spl/spl-thread.c | 16 +++------------- module/zfs/dmu_diff.c | 2 +- module/zfs/dmu_objset.c | 2 +- module/zfs/dmu_recv.c | 2 +- module/zfs/dmu_redact.c | 2 +- module/zfs/dmu_send.c | 2 +- module/zfs/zcp.c | 3 +-- module/zfs/zfs_ioctl.c | 2 +- module/zfs/zfs_vnops.c | 2 +- 12 files changed, 14 insertions(+), 35 deletions(-) diff --git a/include/os/freebsd/spl/sys/sig.h b/include/os/freebsd/spl/sys/sig.h index a4d440d38..17fc65cbe 100644 --- a/include/os/freebsd/spl/sys/sig.h +++ b/include/os/freebsd/spl/sys/sig.h @@ -39,20 +39,14 @@ #include #include -#define FORREAL 0 -#define JUSTLOOKING 1 - static __inline int -issig(int why) +issig(void) { struct thread *td = curthread; struct proc *p; int sig; - ASSERT(why == FORREAL || why == JUSTLOOKING); if (SIGPENDING(td)) { - if (why == JUSTLOOKING) - return (1); p = td->td_proc; PROC_LOCK(p); mtx_lock(&p->p_sigacts->ps_mtx); diff --git a/include/os/linux/spl/sys/signal.h b/include/os/linux/spl/sys/signal.h index 6b538c896..cb4b33261 100644 --- a/include/os/linux/spl/sys/signal.h +++ b/include/os/linux/spl/sys/signal.h @@ -30,9 +30,6 @@ #include #endif -#define FORREAL 0 /* Usual side-effects */ -#define JUSTLOOKING 1 /* Don't stop the process */ - -extern int issig(int why); +extern int issig(void); #endif /* SPL_SIGNAL_H */ diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 8f264b50e..e4711ce41 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -249,8 +249,7 @@ extern struct proc p0; extern kthread_t *zk_thread_create(const char *name, void (*func)(void *), void *arg, size_t stksize, int state); -#define issig(why) (FALSE) -#define ISSIG(thr, why) (FALSE) +#define issig() (FALSE) #define KPREEMPT_SYNC (-1) diff --git a/module/os/linux/spl/spl-thread.c b/module/os/linux/spl/spl-thread.c index ee3eb4690..dbb8eefa7 100644 --- a/module/os/linux/spl/spl-thread.c +++ b/module/os/linux/spl/spl-thread.c @@ -152,26 +152,16 @@ spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...) EXPORT_SYMBOL(spl_kthread_create); /* - * The "why" argument indicates the allowable side-effects of the call: - * - * FORREAL: Extract the next pending signal from p_sig into p_cursig; - * stop the process if a stop has been requested or if a traced signal - * is pending. - * - * JUSTLOOKING: Don't stop the process, just indicate whether or not - * a signal might be pending (FORREAL is needed to tell for sure). + * Extract the next pending signal from p_sig into p_cursig; stop the process + * if a stop has been requested or if a traced signal is pending. */ int -issig(int why) +issig(void) { - ASSERT(why == FORREAL || why == JUSTLOOKING); if (!signal_pending(current)) return (0); - if (why != FORREAL) - return (1); - struct task_struct *task = current; spl_kernel_siginfo_t __info; sigset_t set; diff --git a/module/zfs/dmu_diff.c b/module/zfs/dmu_diff.c index a2b1a27c8..0def0956b 100644 --- a/module/zfs/dmu_diff.c +++ b/module/zfs/dmu_diff.c @@ -116,7 +116,7 @@ diff_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, dmu_diffarg_t *da = arg; int err = 0; - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) return (SET_ERROR(EINTR)); if (zb->zb_level == ZB_DNODE_LEVEL || diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index f1818ae15..8f4fefa4f 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -2437,7 +2437,7 @@ dmu_objset_space_upgrade(objset_t *os) if (err != 0) return (err); - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) return (SET_ERROR(EINTR)); objerr = dmu_bonus_hold(os, obj, FTAG, &db); diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c index 680aed451..0119191d7 100644 --- a/module/zfs/dmu_recv.c +++ b/module/zfs/dmu_recv.c @@ -3389,7 +3389,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, offset_t *voffp) * stream, then we free drc->drc_rrd and exit. */ while (rwa->err == 0) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { err = SET_ERROR(EINTR); break; } diff --git a/module/zfs/dmu_redact.c b/module/zfs/dmu_redact.c index 5ac14edfc..1feba0ba8 100644 --- a/module/zfs/dmu_redact.c +++ b/module/zfs/dmu_redact.c @@ -912,7 +912,7 @@ perform_redaction(objset_t *os, redaction_list_t *rl, object = prev_obj; } while (err == 0 && object <= rec->end_object) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { err = EINTR; break; } diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c index b6cc2f0a5..cb2b62fed 100644 --- a/module/zfs/dmu_send.c +++ b/module/zfs/dmu_send.c @@ -2552,7 +2552,7 @@ dmu_send_impl(struct dmu_send_params *dspp) while (err == 0 && !range->eos_marker) { err = do_dump(&dsc, range); range = get_next_range(&srt_arg->q, range); - if (issig(JUSTLOOKING) && issig(FORREAL)) + if (issig()) err = SET_ERROR(EINTR); } diff --git a/module/zfs/zcp.c b/module/zfs/zcp.c index 959404f66..7c279162a 100644 --- a/module/zfs/zcp.c +++ b/module/zfs/zcp.c @@ -780,8 +780,7 @@ zcp_lua_counthook(lua_State *state, lua_Debug *ar) * Check if we were canceled while waiting for the * txg to sync or from our open context thread */ - if (ri->zri_canceled || - (!ri->zri_sync && issig(JUSTLOOKING) && issig(FORREAL))) { + if (ri->zri_canceled || (!ri->zri_sync && issig())) { ri->zri_canceled = B_TRUE; (void) lua_pushstring(state, "Channel program was canceled."); (void) lua_error(state); diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index b720b4f22..7b527eb75 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -2336,7 +2336,7 @@ zfs_ioc_snapshot_list_next(zfs_cmd_t *zc) } while (error == 0) { - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { error = SET_ERROR(EINTR); break; } diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index b222a6f88..f3db953ea 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1413,7 +1413,7 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp, len -= size; done += size; - if (issig(JUSTLOOKING) && issig(FORREAL)) { + if (issig()) { error = SET_ERROR(EINTR); break; }