diff mbox series

[09/17] cifs: Defer read completion

Message ID 20240620173137.610345-10-dhowells@redhat.com (mailing list archive)
State New, archived
Headers show
Series netfs, cifs: Miscellaneous fixes and read/write improvements | expand

Commit Message

David Howells June 20, 2024, 5:31 p.m. UTC
---
 fs/smb/client/smb2pdu.c      | 15 ++++++++++++---
 include/trace/events/netfs.h |  7 +++++--
 2 files changed, 17 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index 38a06e8a0f90..e213cecd5094 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -4484,6 +4484,16 @@  smb2_new_read_req(void **buf, unsigned int *total_len,
 	return rc;
 }
 
+static void smb2_readv_worker(struct work_struct *work)
+{
+	struct cifs_io_subrequest *rdata =
+		container_of(work, struct cifs_io_subrequest, subreq.work);
+
+	netfs_subreq_terminated(&rdata->subreq,
+				(rdata->result == 0 || rdata->result == -EAGAIN) ?
+				rdata->got_bytes : rdata->result, true);
+}
+
 static void
 smb2_readv_callback(struct mid_q_entry *mid)
 {
@@ -4578,9 +4588,8 @@  smb2_readv_callback(struct mid_q_entry *mid)
 			rdata->result = 0;
 	}
 	rdata->credits.value = 0;
-	netfs_subreq_terminated(&rdata->subreq,
-				(rdata->result == 0 || rdata->result == -EAGAIN) ?
-				rdata->got_bytes : rdata->result, true);
+	INIT_WORK(&rdata->subreq.work, smb2_readv_worker);
+	queue_work(cifsiod_wq, &rdata->subreq.work);
 	release_mid(mid);
 	add_credits(server, &credits, 0);
 }
diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h
index fc5dbd19f120..db603a4e22cd 100644
--- a/include/trace/events/netfs.h
+++ b/include/trace/events/netfs.h
@@ -412,6 +412,7 @@  TRACE_EVENT(netfs_folio,
 		    __field(ino_t,			ino)
 		    __field(pgoff_t,			index)
 		    __field(unsigned int,		nr)
+		    __field(bool,			ra_trigger)
 		    __field(enum netfs_folio_trace,	why)
 			     ),
 
@@ -420,11 +421,13 @@  TRACE_EVENT(netfs_folio,
 		    __entry->why = why;
 		    __entry->index = folio_index(folio);
 		    __entry->nr = folio_nr_pages(folio);
+		    __entry->ra_trigger = folio_test_readahead(folio);
 			   ),
 
-	    TP_printk("i=%05lx ix=%05lx-%05lx %s",
+	    TP_printk("i=%05lx ix=%05lx-%05lx %s%s",
 		      __entry->ino, __entry->index, __entry->index + __entry->nr - 1,
-		      __print_symbolic(__entry->why, netfs_folio_traces))
+		      __print_symbolic(__entry->why, netfs_folio_traces),
+		      __entry->ra_trigger ? " *RA*" : "")
 	    );
 
 TRACE_EVENT(netfs_write_iter,