[RFC PATCH 24/36] cifs: Add netmem allocation functions
David Howells <[email protected]> Tue, 19 May 2026 11:21:42 +0100
| Newsgroups | dev.linux.lists.netfs,org.kernel.vger.linux-cifs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Add (stub) functions for doing netmem allocations. We want to allocate memory from the netmem buffering as that does bulk DMA and IOMMU management. Signed-off-by: David Howells <[email protected]> cc: Steve French <[email protected]> cc: Paulo Alcantara <[email protected]> cc: Shyam Prasad N <[email protected]> cc: Tom Talpey <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] --- fs/smb/client/cifsproto.h | 2 ++ fs/smb/client/transport.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 72ee5c5fd8b7..3067056f8ef9 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -508,5 +508,7 @@ int smb_rxqueue_refill(struct TCP_Server_Info *server, struct netfs_rxqueue *rxq size_t min_size); int smb_rxqueue_consume(struct TCP_Server_Info *server, struct netfs_rxqueue *rxq, size_t amount); +void *cifs_allocate_tx_buf(struct TCP_Server_Info *server, size_t size); +void cifs_free_tx_buf(void *p); #endif /* _CIFSPROTO_H */ diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c index 68536de2c1a0..1599afb9e5cf 100644 --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -33,6 +33,26 @@ #include "smbdirect.h" #include "compress.h" +/* + * Allocate transmission buffers for a socket. This memory will be allocated + * from the netmem buffers. It comes with a page ref that we need to drop. + * The networking layer can pin it by getting its own ref. + */ +void *cifs_allocate_tx_buf(struct TCP_Server_Info *server, size_t size) +{ + void *p; + + mutex_lock(&server->tx_alloc_lock); + p = page_frag_alloc_align(&server->tx_alloc, size, GFP_NOFS, 8); + mutex_unlock(&server->tx_alloc_lock); + return p; +} + +void cifs_free_tx_buf(void *p) +{ + page_frag_free(p); +} + struct smb_message *smb_message_alloc(enum smb_command_trace cmd, gfp_t gfp) { static atomic_t debug_ids;