From dc01504c90d9613a83d6ecf8323800213495c966 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 19 Sep 2025 09:36:14 +0200 Subject: [PATCH] smb: smbdirect: introduce smbdirect_get_buf_page_count() 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 Cc: Tom Talpey Cc: Long Li Cc: Namjae Jeon Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher Acked-by: Namjae Jeon Signed-off-by: Steve French --- 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 874d4d1a56a0f..b2882935a5d86 100644 --- a/fs/smb/common/smbdirect/smbdirect_socket.h +++ b/fs/smb/common/smbdirect/smbdirect_socket.h @@ -734,4 +734,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.47.3