Skip to content

Commit 86ab0c1

Browse files
committed
Merge patch series "netfs: Fix use of fscache with ceph"
David Howells <[email protected]> says: Here are a couple of patches that fix the use of fscaching with ceph: (1) Fix the read collector to mark the write request that it creates to copy data to the cache with NETFS_RREQ_OFFLOAD_COLLECTION so that it will run the write collector on a workqueue as it's meant to run in the background and the app isn't going to wait for it. (2) Fix the read collector to wake up the copy-to-cache write request after it sets NETFS_RREQ_ALL_QUEUED if the write request doesn't have any subrequests left on it. ALL_QUEUED indicates that there won't be any more subreqs coming and the collector should clean up - except that an event is needed to trigger that, but it only gets events from subreq termination and so the last event can beat us to setting ALL_QUEUED. * patches from https://lore.kernel.org/[email protected]: netfs: Fix race between cache write completion and ALL_QUEUED being set netfs: Fix copy-to-cache so that it performs collection with ceph+fscache Link: https://lore.kernel.org/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents fdfe013 + 89635ea commit 86ab0c1

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

fs/netfs/read_pgpriv2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ static struct netfs_io_request *netfs_pgpriv2_begin_copy_to_cache(
110110
if (!creq->io_streams[1].avail)
111111
goto cancel_put;
112112

113+
__set_bit(NETFS_RREQ_OFFLOAD_COLLECTION, &creq->flags);
114+
trace_netfs_copy2cache(rreq, creq);
113115
trace_netfs_write(creq, netfs_write_trace_copy_to_cache);
114116
netfs_stat(&netfs_n_wh_copy_to_cache);
115117
rreq->copy_to_cache = creq;
@@ -154,6 +156,9 @@ void netfs_pgpriv2_end_copy_to_cache(struct netfs_io_request *rreq)
154156
netfs_issue_write(creq, &creq->io_streams[1]);
155157
smp_wmb(); /* Write lists before ALL_QUEUED. */
156158
set_bit(NETFS_RREQ_ALL_QUEUED, &creq->flags);
159+
trace_netfs_rreq(rreq, netfs_rreq_trace_end_copy_to_cache);
160+
if (list_empty_careful(&creq->io_streams[1].subrequests))
161+
netfs_wake_collector(creq);
157162

158163
netfs_put_request(creq, netfs_rreq_trace_put_return);
159164
creq->copy_to_cache = NULL;

include/trace/events/netfs.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
EM(netfs_rreq_trace_copy, "COPY ") \
5656
EM(netfs_rreq_trace_dirty, "DIRTY ") \
5757
EM(netfs_rreq_trace_done, "DONE ") \
58+
EM(netfs_rreq_trace_end_copy_to_cache, "END-C2C") \
5859
EM(netfs_rreq_trace_free, "FREE ") \
5960
EM(netfs_rreq_trace_ki_complete, "KI-CMPL") \
6061
EM(netfs_rreq_trace_recollect, "RECLLCT") \
@@ -559,6 +560,35 @@ TRACE_EVENT(netfs_write,
559560
__entry->start, __entry->start + __entry->len - 1)
560561
);
561562

563+
TRACE_EVENT(netfs_copy2cache,
564+
TP_PROTO(const struct netfs_io_request *rreq,
565+
const struct netfs_io_request *creq),
566+
567+
TP_ARGS(rreq, creq),
568+
569+
TP_STRUCT__entry(
570+
__field(unsigned int, rreq)
571+
__field(unsigned int, creq)
572+
__field(unsigned int, cookie)
573+
__field(unsigned int, ino)
574+
),
575+
576+
TP_fast_assign(
577+
struct netfs_inode *__ctx = netfs_inode(rreq->inode);
578+
struct fscache_cookie *__cookie = netfs_i_cookie(__ctx);
579+
__entry->rreq = rreq->debug_id;
580+
__entry->creq = creq->debug_id;
581+
__entry->cookie = __cookie ? __cookie->debug_id : 0;
582+
__entry->ino = rreq->inode->i_ino;
583+
),
584+
585+
TP_printk("R=%08x CR=%08x c=%08x i=%x ",
586+
__entry->rreq,
587+
__entry->creq,
588+
__entry->cookie,
589+
__entry->ino)
590+
);
591+
562592
TRACE_EVENT(netfs_collect,
563593
TP_PROTO(const struct netfs_io_request *wreq),
564594

0 commit comments

Comments
 (0)