Skip to content

Commit

Permalink
netfs: Fix missing barriers by using clear_and_wake_up_bit()
Browse files Browse the repository at this point in the history
Use clear_and_wake_up_bit() rather than something like:

	clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
	wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS);

as there needs to be a barrier inserted between which is present in
clear_and_wake_up_bit().

Fixes: 288ace2 ("netfs: New writeback implementation")
Fixes: ee4cdf7 ("netfs: Speed up buffered reading")
Signed-off-by: David Howells <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Akira Yokosawa <[email protected]>
cc: Zilin Guan <[email protected]>
cc: Akira Yokosawa <[email protected]>
cc: Jeff Layton <[email protected]>
cc: [email protected]
cc: [email protected]
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
dhowells authored and brauner committed Dec 20, 2024
1 parent f4d3cde commit aa39564
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions fs/netfs/read_collect.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ static void netfs_rreq_assess(struct netfs_io_request *rreq)
task_io_account_read(rreq->transferred);

trace_netfs_rreq(rreq, netfs_rreq_trace_wake_ip);
clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
wake_up_bit(&rreq->flags, NETFS_RREQ_IN_PROGRESS);
clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);

trace_netfs_rreq(rreq, netfs_rreq_trace_done);
netfs_clear_subrequests(rreq, false);
Expand Down
9 changes: 3 additions & 6 deletions fs/netfs/write_collect.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq)
goto need_retry;
if ((notes & MADE_PROGRESS) && test_bit(NETFS_RREQ_PAUSE, &wreq->flags)) {
trace_netfs_rreq(wreq, netfs_rreq_trace_unpause);
clear_bit_unlock(NETFS_RREQ_PAUSE, &wreq->flags);
wake_up_bit(&wreq->flags, NETFS_RREQ_PAUSE);
clear_and_wake_up_bit(NETFS_RREQ_PAUSE, &wreq->flags);
}

if (notes & NEED_REASSESS) {
Expand Down Expand Up @@ -605,8 +604,7 @@ void netfs_write_collection_worker(struct work_struct *work)

_debug("finished");
trace_netfs_rreq(wreq, netfs_rreq_trace_wake_ip);
clear_bit_unlock(NETFS_RREQ_IN_PROGRESS, &wreq->flags);
wake_up_bit(&wreq->flags, NETFS_RREQ_IN_PROGRESS);
clear_and_wake_up_bit(NETFS_RREQ_IN_PROGRESS, &wreq->flags);

if (wreq->iocb) {
size_t written = min(wreq->transferred, wreq->len);
Expand Down Expand Up @@ -714,8 +712,7 @@ void netfs_write_subrequest_terminated(void *_op, ssize_t transferred_or_error,

trace_netfs_sreq(subreq, netfs_sreq_trace_terminated);

clear_bit_unlock(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
wake_up_bit(&subreq->flags, NETFS_SREQ_IN_PROGRESS);
clear_and_wake_up_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);

/* If we are at the head of the queue, wake up the collector,
* transferring a ref to it if we were the ones to do so.
Expand Down

0 comments on commit aa39564

Please sign in to comment.