cifs: Defer read completion
authorDavid Howells <dhowells@redhat.com>
Thu, 20 Jun 2024 19:30:00 +0000 (20:30 +0100)
committerSteve French <stfrench@microsoft.com>
Thu, 20 Jun 2024 20:21:23 +0000 (15:21 -0500)
Defer read completion from the I/O thread to the cifsiod thread so as not
to slow down the I/O thread.  This restores the behaviour of v6.9.

Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/smb2pdu.c

index 38a06e8..e213cec 100644 (file)
@@ -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);
 }