diff options
author | Joanne Koong <joannelkoong@gmail.com> | 2025-05-12 15:58:32 -0700 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2025-05-29 12:31:23 +0200 |
commit | 63c69ad3d18a8032d50c65de5a3b87136f0cfb42 (patch) | |
tree | 24563ad3187d7af6def11432f237e6baf49f005f | |
parent | 3568a956932621cafadafc8b75fcf6dc06555105 (diff) |
fuse: refactor fuse_fill_write_pages()
Refactor the logic in fuse_fill_write_pages() for copying out write
data. This will make the future change for supporting large folios for
writes easier. No functional changes.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Bernd Schubert <bschubert@ddn.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r-- | fs/fuse/file.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e203dd4fcc0f..6b77daa2fbce 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1132,21 +1132,21 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, struct fuse_args_pages *ap = &ia->ap; struct fuse_conn *fc = get_fuse_conn(mapping->host); unsigned offset = pos & (PAGE_SIZE - 1); - unsigned int nr_pages = 0; size_t count = 0; - int err; + unsigned int num; + int err = 0; + + num = min(iov_iter_count(ii), fc->max_write); + num = min(num, max_pages << PAGE_SHIFT); ap->args.in_pages = true; ap->descs[0].offset = offset; - do { + while (num) { size_t tmp; struct folio *folio; pgoff_t index = pos >> PAGE_SHIFT; - size_t bytes = min_t(size_t, PAGE_SIZE - offset, - iov_iter_count(ii)); - - bytes = min_t(size_t, bytes, fc->max_write - count); + unsigned bytes = min(PAGE_SIZE - offset, num); again: folio = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, @@ -1178,14 +1178,13 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, goto again; } - err = 0; ap->folios[ap->num_folios] = folio; ap->descs[ap->num_folios].length = tmp; ap->num_folios++; - nr_pages++; count += tmp; pos += tmp; + num -= tmp; offset += tmp; if (offset == PAGE_SIZE) offset = 0; @@ -1200,10 +1199,9 @@ static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia, ia->write.folio_locked = true; break; } - if (!fc->big_writes) + if (!fc->big_writes || offset != 0) break; - } while (iov_iter_count(ii) && count < fc->max_write && - nr_pages < max_pages && offset == 0); + } return count > 0 ? count : err; } |