Skip to contentSkip to conversation

fuse: use offset_in_folio() for large folio offset calculations

PATCH Chunsheng Luo 1 participant 2 messages Jan 19 VFS

lore
Share & tools
lore
#0 lore raw
Quoted 12 lines · Joanne Koong

Use offset_in_folio() instead of manually calculating the folio offset.

---
  fs/fuse/dev.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/fuse/dev.c +0 -0
index 698289b5539e..4dda4e24cc90 100644

fs/fuse/dev.c static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, · line 1815

Quoted 4 lines
fs/fuse/dev.c +1 -0
@@ -1812,7 +1812,7 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
          if (IS_ERR(folio))
              goto out_iput;
  -        folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
+        folio_offset = offset_in_folio(folio, outarg.offset);

offset is a loop variable, and later offset maybe set to 0. Replacing it with outarg.offset here would change the behavior. The same below. Will this cause any problems?

Thanks,
Chunsheng Luo

Quoted 10 lines
fs/fuse/dev.c +1 -0
          nr_bytes = min_t(unsigned, num, folio_size(folio) - folio_offset);
          nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);
  @@ -1916,7 +1916,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
          if (IS_ERR(folio))
              break;
  -        folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
+        folio_offset = offset_in_folio(folio, outarg->offset);
          nr_bytes = min(folio_size(folio) - folio_offset, num);
          nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);
#1 lore raw

Dear Community Members,

I sincerely apologize for the email that was mistakenly sent earlier due to an operational error on my part.

Please kindly ignore the previous message, and if possible, you may delete it from your inbox.

My deepest apologies for any inconvenience this may have caused.

Thanks
Chunsheng Luo

Quoted 38 lines · Chunsheng Luo
Quoted 12 lines · Joanne Koong

Use offset_in_folio() instead of manually calculating the folio offset.

---
   fs/fuse/dev.c | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
fs/fuse/dev.c +0 -0
index 698289b5539e..4dda4e24cc90 100644

fs/fuse/dev.c static int fuse_notify_store(struct fuse_conn *fc, unsigned int size, · line 1815

Quoted 4 lines
fs/fuse/dev.c +1 -0
@@ -1812,7 +1812,7 @@ static int fuse_notify_store(struct fuse_conn *fc, unsigned int size,
           if (IS_ERR(folio))
               goto out_iput;
   -        folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
+        folio_offset = offset_in_folio(folio, outarg.offset);

offset is a loop variable, and later offset maybe set to 0. Replacing it with outarg.offset here would change the behavior. The same below. Will this cause any problems?

Thanks,
Chunsheng Luo

Quoted 10 lines
fs/fuse/dev.c +1 -0
           nr_bytes = min_t(unsigned, num, folio_size(folio) - folio_offset);
           nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);
   @@ -1916,7 +1916,7 @@ static int fuse_retrieve(struct fuse_mount *fm, struct inode *inode,
           if (IS_ERR(folio))
               break;
   -        folio_offset = ((index - folio->index) << PAGE_SHIFT) + offset;
+        folio_offset = offset_in_folio(folio, outarg->offset);
           nr_bytes = min(folio_size(folio) - folio_offset, num);
           nr_pages = DIV_ROUND_UP(offset + nr_bytes, PAGE_SIZE);