]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fuse: use DIV_ROUND_UP() for page count calculations
authorJoanne Koong <joannelkoong@gmail.com>
Tue, 20 Jan 2026 22:44:48 +0000 (14:44 -0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 3 Mar 2026 16:43:33 +0000 (17:43 +0100)
Use DIV_ROUND_UP() instead of manually computing round-up division
calculations.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Horst Birthelmer <hbirthelmer@ddn.com>
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dev.c
fs/fuse/file.c

index 18622bf805d6fdd2d01fd15461de0814f3f694e2..2c16b94357d5155ec491ce960f5823a64dc349d9 100644 (file)
@@ -1884,7 +1884,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
        else if (num > file_size - pos)
                num = file_size - pos;
 
-       num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
+       num_pages = DIV_ROUND_UP(num + offset, PAGE_SIZE);
        num_pages = min(num_pages, fc->max_pages);
        num = min(num, num_pages << PAGE_SHIFT);
 
index c61d80e0a70dc7dd845c666ac0b7fe10a5cfe721..7294bd347412cbb8cff7ce1e7d1a791e0a0d18c8 100644 (file)
@@ -2176,7 +2176,7 @@ static bool fuse_folios_need_send(struct fuse_conn *fc, loff_t pos,
        WARN_ON(!ap->num_folios);
 
        /* Reached max pages */
-       if ((bytes + PAGE_SIZE - 1) >> PAGE_SHIFT > fc->max_pages)
+       if (DIV_ROUND_UP(bytes, PAGE_SIZE) > fc->max_pages)
                return true;
 
        if (bytes > max_bytes)