[PATCH v2 029/127] smb: smbdirect: introduce smbdirect_get_buf_page_count()
Stefan Metzmacher
metze at samba.org
Wed Oct 29 13:20:07 UTC 2025
This is a copy of get_buf_page_count() in the server
and will replace it soon.
The only difference is that we now use size_t instead
of int.
Cc: Steve French <smfrench at gmail.com>
Cc: Tom Talpey <tom at talpey.com>
Cc: Long Li <longli at microsoft.com>
Cc: Namjae Jeon <linkinjeon at kernel.org>
Cc: linux-cifs at vger.kernel.org
Cc: samba-technical at lists.samba.org
Signed-off-by: Stefan Metzmacher <metze at samba.org>
---
fs/smb/common/smbdirect/smbdirect_socket.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/smb/common/smbdirect/smbdirect_socket.h b/fs/smb/common/smbdirect/smbdirect_socket.h
index 5856ce287afa..983e08c8d2ee 100644
--- a/fs/smb/common/smbdirect/smbdirect_socket.h
+++ b/fs/smb/common/smbdirect/smbdirect_socket.h
@@ -640,4 +640,10 @@ struct smbdirect_rw_io {
struct scatterlist sg_list[];
};
+static inline size_t smbdirect_get_buf_page_count(const void *buf, size_t size)
+{
+ return DIV_ROUND_UP((uintptr_t)buf + size, PAGE_SIZE) -
+ (uintptr_t)buf / PAGE_SIZE;
+}
+
#endif /* __FS_SMB_COMMON_SMBDIRECT_SMBDIRECT_SOCKET_H__ */
--
2.43.0
More information about the samba-technical
mailing list