Skip to content

Commit dcfd95c

Browse files
joannekoongMiklos Szeredi
authored andcommitted
fuse: use DIV_ROUND_UP() for page count calculations
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>
1 parent 25307ca commit dcfd95c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

fs/fuse/dev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
18841884
else if (num > file_size - pos)
18851885
num = file_size - pos;
18861886

1887-
num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
1887+
num_pages = DIV_ROUND_UP(num + offset, PAGE_SIZE);
18881888
num_pages = min(num_pages, fc->max_pages);
18891889
num = min(num, num_pages << PAGE_SHIFT);
18901890

fs/fuse/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2176,7 +2176,7 @@ static bool fuse_folios_need_send(struct fuse_conn *fc, loff_t pos,
21762176
WARN_ON(!ap->num_folios);
21772177

21782178
/* Reached max pages */
2179-
if ((bytes + PAGE_SIZE - 1) >> PAGE_SHIFT > fc->max_pages)
2179+
if (DIV_ROUND_UP(bytes, PAGE_SIZE) > fc->max_pages)
21802180
return true;
21812181

21822182
if (bytes > max_bytes)

0 commit comments

Comments
 (0)