Commit 4046d3ad authored by Joanne Koong's avatar Joanne Koong Committed by Miklos Szeredi

fuse: move fuse file initialization to wpa allocation time

Before this change, wpa->ia.ff is initialized with an acquired reference
on the fuse file right before it submits the writeback request. If there
are auxiliary writebacks, then the initialization and reference
acquisition needs to also be set before we submit the auxiliary writeback
request.

To make the logic simpler and to pave the way for a subsequent
refactoring of fuse_writepages_fill() and fuse_writepage_locked(), this
change initializes and acquires wpa->ia.ff when the wpa is allocated.

No functional changes added.
Signed-off-by: default avatarJoanne Koong <joannelkoong@gmail.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent 9a8ebcf5
...@@ -1762,8 +1762,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa) ...@@ -1762,8 +1762,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
for (i = 0; i < ap->num_pages; i++) for (i = 0; i < ap->num_pages; i++)
__free_page(ap->pages[i]); __free_page(ap->pages[i]);
if (wpa->ia.ff) fuse_file_put(wpa->ia.ff, false);
fuse_file_put(wpa->ia.ff, false);
kfree(ap->pages); kfree(ap->pages);
kfree(wpa); kfree(wpa);
...@@ -1936,7 +1935,6 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args, ...@@ -1936,7 +1935,6 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
wpa->next = next->next; wpa->next = next->next;
next->next = NULL; next->next = NULL;
next->ia.ff = fuse_file_get(wpa->ia.ff);
tree_insert(&fi->writepages, next); tree_insert(&fi->writepages, next);
/* /*
...@@ -2155,7 +2153,6 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data) ...@@ -2155,7 +2153,6 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data)
int num_pages = wpa->ia.ap.num_pages; int num_pages = wpa->ia.ap.num_pages;
int i; int i;
wpa->ia.ff = fuse_file_get(data->ff);
spin_lock(&fi->lock); spin_lock(&fi->lock);
list_add_tail(&wpa->queue_entry, &fi->queued_writes); list_add_tail(&wpa->queue_entry, &fi->queued_writes);
fuse_flush_writepages(inode); fuse_flush_writepages(inode);
...@@ -2300,6 +2297,7 @@ static int fuse_writepages_fill(struct folio *folio, ...@@ -2300,6 +2297,7 @@ static int fuse_writepages_fill(struct folio *folio,
ap = &wpa->ia.ap; ap = &wpa->ia.ap;
fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0); fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0);
wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE; wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE;
wpa->ia.ff = fuse_file_get(data->ff);
wpa->next = NULL; wpa->next = NULL;
ap->args.in_pages = true; ap->args.in_pages = true;
ap->args.end = fuse_writepage_end; ap->args.end = fuse_writepage_end;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment