From: David Howells <dhowells@redhat.com>
To: Steve French <sfrench@samba.org>
Cc: David Howells <dhowells@redhat.com>,
Paulo Alcantara <pc@manguebit.org>,
Shyam Prasad N <sprasad@microsoft.com>,
Stefan Metzmacher <metze@samba.org>,
linux-cifs@vger.kernel.org, netfs@lists.linux.dev,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Tom Talpey <tom@talpey.com>
Subject: [PATCH v4 01/11] cifs: Use netfs_alloc/free_folioq_buffer()
Date: Mon, 24 Nov 2025 12:42:40 +0000 [thread overview]
Message-ID: <20251124124251.3565566-2-dhowells@redhat.com> (raw)
In-Reply-To: <20251124124251.3565566-1-dhowells@redhat.com>
Use netfs_alloc/free_folioq_buffer() rather than doing its own version.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.org>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com> (RDMA, smbdirect)
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
---
fs/smb/client/smb2ops.c | 75 +++++++----------------------------------
1 file changed, 12 insertions(+), 63 deletions(-)
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 4b005a7adce0..549fffbca246 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -4484,61 +4484,6 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst,
return rc;
}
-/*
- * Clear a read buffer, discarding the folios which have the 1st mark set.
- */
-static void cifs_clear_folioq_buffer(struct folio_queue *buffer)
-{
- struct folio_queue *folioq;
-
- while ((folioq = buffer)) {
- for (int s = 0; s < folioq_count(folioq); s++)
- if (folioq_is_marked(folioq, s))
- folio_put(folioq_folio(folioq, s));
- buffer = folioq->next;
- kfree(folioq);
- }
-}
-
-/*
- * Allocate buffer space into a folio queue.
- */
-static struct folio_queue *cifs_alloc_folioq_buffer(ssize_t size)
-{
- struct folio_queue *buffer = NULL, *tail = NULL, *p;
- struct folio *folio;
- unsigned int slot;
-
- do {
- if (!tail || folioq_full(tail)) {
- p = kmalloc(sizeof(*p), GFP_NOFS);
- if (!p)
- goto nomem;
- folioq_init(p, 0);
- if (tail) {
- tail->next = p;
- p->prev = tail;
- } else {
- buffer = p;
- }
- tail = p;
- }
-
- folio = folio_alloc(GFP_KERNEL|__GFP_HIGHMEM, 0);
- if (!folio)
- goto nomem;
-
- slot = folioq_append_mark(tail, folio);
- size -= folioq_folio_size(tail, slot);
- } while (size > 0);
-
- return buffer;
-
-nomem:
- cifs_clear_folioq_buffer(buffer);
- return NULL;
-}
-
/*
* Copy data from an iterator to the folios in a folio queue buffer.
*/
@@ -4564,7 +4509,7 @@ void
smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst)
{
for (int i = 0; i < num_rqst; i++)
- cifs_clear_folioq_buffer(rqst[i].rq_buffer);
+ netfs_free_folioq_buffer(rqst[i].rq_buffer);
}
/*
@@ -4599,8 +4544,11 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, int num_rqst,
new->rq_nvec = old->rq_nvec;
if (size > 0) {
- buffer = cifs_alloc_folioq_buffer(size);
- if (!buffer)
+ size_t cur_size = 0;
+
+ rc = netfs_alloc_folioq_buffer(NULL, &buffer, &cur_size,
+ size, GFP_NOFS);
+ if (rc < 0)
goto err_free;
new->rq_buffer = buffer;
@@ -4932,7 +4880,7 @@ static void smb2_decrypt_offload(struct work_struct *work)
}
free_pages:
- cifs_clear_folioq_buffer(dw->buffer);
+ netfs_free_folioq_buffer(dw->buffer);
cifs_small_buf_release(dw->buf);
kfree(dw);
}
@@ -4970,9 +4918,10 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
dw->len = len;
len = round_up(dw->len, PAGE_SIZE);
- rc = -ENOMEM;
- dw->buffer = cifs_alloc_folioq_buffer(len);
- if (!dw->buffer)
+ size_t cur_size = 0;
+
+ rc = netfs_alloc_folioq_buffer(NULL, &dw->buffer, &cur_size, len, GFP_NOFS);
+ if (rc < 0)
goto discard_data;
iov_iter_folio_queue(&iter, ITER_DEST, dw->buffer, 0, 0, len);
@@ -5033,7 +4982,7 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
}
free_pages:
- cifs_clear_folioq_buffer(dw->buffer);
+ netfs_free_folioq_buffer(dw->buffer);
free_dw:
kfree(dw);
return rc;
next prev parent reply other threads:[~2025-11-24 12:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-24 12:42 [PATCH v4 00/11] cifs: Miscellaneous prep patches for rewrite of I/O layer David Howells
2025-11-24 12:42 ` David Howells [this message]
2025-11-24 12:42 ` [PATCH v4 02/11] cifs: Do some preparation prior to organising the function declarations David Howells
2025-11-24 12:42 ` [PATCH v4 03/11] cifs: Clean up declarations David Howells
2025-11-24 12:42 ` [PATCH v4 04/11] cifs: Rename mid_q_entry to smb_message David Howells
2025-11-24 12:42 ` [PATCH v4 05/11] cifs: Remove the RFC1002 header from smb_hdr David Howells
2025-11-24 17:27 ` Tom Talpey
2025-11-24 19:56 ` David Howells
2025-11-24 12:42 ` [PATCH v4 06/11] cifs: Make smb1's SendReceive() wrap cifs_send_recv() David Howells
2025-11-24 12:42 ` [PATCH v4 07/11] cifs: Clean up some places where an extra kvec[] was required for rfc1002 David Howells
2025-11-24 14:20 ` Stefan Metzmacher
2025-11-24 14:36 ` David Howells
2025-11-24 14:40 ` Stefan Metzmacher
2025-11-24 14:44 ` David Howells
2025-11-24 14:46 ` Stefan Metzmacher
2025-11-25 11:11 ` David Howells
2025-11-25 11:19 ` Stefan Metzmacher
2025-11-24 12:42 ` [PATCH v4 08/11] cifs: Replace SendReceiveBlockingLock() with SendReceive() plus flags David Howells
2025-11-24 12:42 ` [PATCH v4 09/11] cifs: Remove the server pointer from smb_message David Howells
2025-11-24 12:42 ` [PATCH v4 10/11] cifs: Don't need state locking in smb2_get_mid_entry() David Howells
2025-11-24 12:42 ` [PATCH v4 11/11] cifs: Add a tracepoint to log EIO errors David Howells
2025-11-24 14:22 ` Stefan Metzmacher
2025-11-24 14:38 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251124124251.3565566-2-dhowells@redhat.com \
--to=dhowells@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=metze@samba.org \
--cc=netfs@lists.linux.dev \
--cc=pc@manguebit.org \
--cc=sfrench@samba.org \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).