Skip to content

Commit

Permalink
Simplify issig().
Browse files Browse the repository at this point in the history
We always call it twice with JUSTLOOKING and then FORREAL.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Closes #16225
  • Loading branch information
pjd authored May 29, 2024
1 parent 6b95031 commit 01c8efd
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 35 deletions.
8 changes: 1 addition & 7 deletions include/os/freebsd/spl/sys/sig.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,14 @@
#include <sys/signalvar.h>
#include <sys/debug.h>

#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);
Expand Down
5 changes: 1 addition & 4 deletions include/os/linux/spl/sys/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#include <linux/sched/signal.h>
#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 */
3 changes: 1 addition & 2 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 3 additions & 13 deletions module/os/linux/spl/spl-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_objset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_redact.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/dmu_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions module/zfs/zcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 01c8efd

Please sign in to comment.