From: Joanne Koong <joannelkoong@gmail.com>
To: miklos@szeredi.hu
Cc: jefflexu@linux.alibaba.com, luochunsheng@ustc.edu,
djwong@kernel.org, horst@birthelmer.de,
linux-fsdevel@vger.kernel.org,
Horst Birthelmer <hbirthelmer@ddn.com>
Subject: [PATCH v2 4/4] fuse: use offset_in_page() for page offset calculations
Date: Tue, 20 Jan 2026 14:44:49 -0800 [thread overview]
Message-ID: <20260120224449.1847176-5-joannelkoong@gmail.com> (raw)
In-Reply-To: <20260120224449.1847176-1-joannelkoong@gmail.com>
Replace open-coded (x & ~PAGE_MASK) with offset_in_page().
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Horst Birthelmer <hbirthelmer@ddn.com>
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/readdir.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index c2aae2eef086..c88194e52d18 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -52,7 +52,7 @@ static void fuse_add_dirent_to_cache(struct file *file,
}
version = fi->rdc.version;
size = fi->rdc.size;
- offset = size & ~PAGE_MASK;
+ offset = offset_in_page(size);
index = size >> PAGE_SHIFT;
/* Dirent doesn't fit in current page? Jump to next page. */
if (offset + reclen > PAGE_SIZE) {
@@ -392,7 +392,7 @@ static enum fuse_parse_result fuse_parse_cache(struct fuse_file *ff,
void *addr, unsigned int size,
struct dir_context *ctx)
{
- unsigned int offset = ff->readdir.cache_off & ~PAGE_MASK;
+ unsigned int offset = offset_in_page(ff->readdir.cache_off);
enum fuse_parse_result res = FOUND_NONE;
WARN_ON(offset >= size);
@@ -518,13 +518,13 @@ static int fuse_readdir_cached(struct file *file, struct dir_context *ctx)
index = ff->readdir.cache_off >> PAGE_SHIFT;
if (index == (fi->rdc.size >> PAGE_SHIFT))
- size = fi->rdc.size & ~PAGE_MASK;
+ size = offset_in_page(fi->rdc.size);
else
size = PAGE_SIZE;
spin_unlock(&fi->rdc.lock);
/* EOF? */
- if ((ff->readdir.cache_off & ~PAGE_MASK) == size)
+ if (offset_in_page(ff->readdir.cache_off) == size)
return 0;
page = find_get_page_flags(file->f_mapping, index,
--
2.47.3
next prev parent reply other threads:[~2026-01-20 22:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 22:44 [PATCH v2 0/4] fuse: clean up offset and page count calculations Joanne Koong
2026-01-20 22:44 ` [PATCH v2 1/4] fuse: validate outarg offset and size in notify store/retrieve Joanne Koong
2026-01-21 0:03 ` Darrick J. Wong
2026-01-21 0:06 ` Darrick J. Wong
2026-01-29 19:45 ` Joanne Koong
2026-01-21 2:08 ` Jingbo Xu
2026-01-29 19:30 ` Joanne Koong
2026-01-30 2:48 ` Jingbo Xu
2026-01-20 22:44 ` [PATCH v2 2/4] fuse: simplify logic in fuse_notify_store() and fuse_retrieve() Joanne Koong
2026-01-21 0:27 ` Darrick J. Wong
2026-01-21 2:32 ` Jingbo Xu
2026-01-21 8:32 ` kernel test robot
2026-01-21 15:22 ` kernel test robot
2026-01-20 22:44 ` [PATCH v2 3/4] fuse: use DIV_ROUND_UP() for page count calculations Joanne Koong
2026-01-20 22:44 ` Joanne Koong [this message]
2026-01-21 2:39 ` [PATCH v2 4/4] fuse: use offset_in_page() for page offset calculations Jingbo Xu
2026-03-02 13:10 ` [PATCH v2 0/4] fuse: clean up offset and page count calculations Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260120224449.1847176-5-joannelkoong@gmail.com \
--to=joannelkoong@gmail.com \
--cc=djwong@kernel.org \
--cc=hbirthelmer@ddn.com \
--cc=horst@birthelmer.de \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=luochunsheng@ustc.edu \
--cc=miklos@szeredi.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.