mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
btrfs: check for exit condition after waking in wait_log_commit()
We check for the exit condition after we add ourselves to the wait queue and before we unlock the root's log_mutex, sleep and lock again log_mutex. This is not incorrect, but it's not optimal since in the first iteration this is pointless because we already know that root->log_commit[index] is not zero, so we should check the exit condition only after unlocking log_mutex, sleeping, waking up and locking again the log_mutex. So move the check for the exit condition to bottom of the loop, after we were woken and locked log_mutex again. Reviewed-by: Boris Burkov <boris@bur.io> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
31ffb32245
commit
3ccdd23e9f
|
|
@ -3182,13 +3182,13 @@ static bool wait_log_commit(struct btrfs_root *root, int transid)
|
|||
prepare_to_wait(&root->log_commit_wait[index],
|
||||
&wait, TASK_UNINTERRUPTIBLE);
|
||||
|
||||
if (!(root->log_transid_committed < transid &&
|
||||
atomic_read(&root->log_commit[index])))
|
||||
break;
|
||||
|
||||
mutex_unlock(&root->log_mutex);
|
||||
schedule();
|
||||
mutex_lock(&root->log_mutex);
|
||||
|
||||
if (!(root->log_transid_committed < transid &&
|
||||
atomic_read(&root->log_commit[index]) != 0))
|
||||
break;
|
||||
}
|
||||
finish_wait(&root->log_commit_wait[index], &wait);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user