Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfd01f02 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Linus Torvalds
Browse files

sched/wait: Fix the signal handling fix



Jan Stancek reported that I wrecked things for him by fixing things for
Vladimir :/

His report was due to an UNINTERRUPTIBLE wait getting -EINTR, which
should not be possible, however my previous patch made this possible by
unconditionally checking signal_pending().

We cannot use current->state as was done previously, because the
instruction after the store to that variable it can be changed.  We must
instead pass the initial state along and use that.

Fixes: 68985633 ("sched/wait: Fix signal handling in bit wait helpers")
Reported-by: default avatarJan Stancek <jstancek@redhat.com>
Reported-by: default avatarChris Mason <clm@fb.com>
Tested-by: default avatarJan Stancek <jstancek@redhat.com>
Tested-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
Tested-by: default avatarChris Mason <clm@fb.com>
Reviewed-by: default avatarPaul Turner <pjt@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: tglx@linutronix.de
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: hpa@zytor.com
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fc891828
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1831,11 +1831,11 @@ cifs_invalidate_mapping(struct inode *inode)
 * @word: long word containing the bit lock
 */
static int
cifs_wait_bit_killable(struct wait_bit_key *key)
cifs_wait_bit_killable(struct wait_bit_key *key, int mode)
{
	if (fatal_signal_pending(current))
		return -ERESTARTSYS;
	freezable_schedule_unsafe();
	if (signal_pending_state(mode, current))
		return -ERESTARTSYS;
	return 0;
}

+3 −3
Original line number Diff line number Diff line
@@ -75,11 +75,11 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
 * nfs_wait_bit_killable - helper for functions that are sleeping on bit locks
 * @word: long word containing the bit lock
 */
int nfs_wait_bit_killable(struct wait_bit_key *key)
int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
{
	if (fatal_signal_pending(current))
		return -ERESTARTSYS;
	freezable_schedule_unsafe();
	if (signal_pending_state(mode, current))
		return -ERESTARTSYS;
	return 0;
}
EXPORT_SYMBOL_GPL(nfs_wait_bit_killable);
+1 −1
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ extern int nfs_drop_inode(struct inode *);
extern void nfs_clear_inode(struct inode *);
extern void nfs_evict_inode(struct inode *);
void nfs_zap_acl_cache(struct inode *inode);
extern int nfs_wait_bit_killable(struct wait_bit_key *key);
extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);

/* super.c */
extern const struct super_operations nfs_sops;
+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ __nfs_iocounter_wait(struct nfs_io_counter *c)
		set_bit(NFS_IO_INPROGRESS, &c->flags);
		if (atomic_read(&c->io_count) == 0)
			break;
		ret = nfs_wait_bit_killable(&q.key);
		ret = nfs_wait_bit_killable(&q.key, TASK_KILLABLE);
	} while (atomic_read(&c->io_count) != 0 && !ret);
	finish_wait(wq, &q.wait);
	return ret;
+2 −2
Original line number Diff line number Diff line
@@ -1466,11 +1466,11 @@ static bool pnfs_within_mdsthreshold(struct nfs_open_context *ctx,
}

/* stop waiting if someone clears NFS_LAYOUT_RETRY_LAYOUTGET bit. */
static int pnfs_layoutget_retry_bit_wait(struct wait_bit_key *key)
static int pnfs_layoutget_retry_bit_wait(struct wait_bit_key *key, int mode)
{
	if (!test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, key->flags))
		return 1;
	return nfs_wait_bit_killable(key);
	return nfs_wait_bit_killable(key, mode);
}

static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo)
Loading