Commit 672c3b74 authored by Joanne Koong's avatar Joanne Koong Committed by Miklos Szeredi

fuse: move initialization of fuse_file to fuse_writepages() instead of in callback

Prior to this change, data->ff is checked and if not initialized then
initialized in the fuse_writepages_fill() callback, which gets called
for every dirty page in the address space mapping.

This logic is better placed in the main fuse_writepages() caller where
data.ff is initialized before walking the dirty pages.

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 c04e3b21
...@@ -2263,13 +2263,6 @@ static int fuse_writepages_fill(struct folio *folio, ...@@ -2263,13 +2263,6 @@ static int fuse_writepages_fill(struct folio *folio,
struct page *tmp_page; struct page *tmp_page;
int err; int err;
if (!data->ff) {
err = -EIO;
data->ff = fuse_write_file_get(fi);
if (!data->ff)
goto out_unlock;
}
if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) { if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) {
fuse_writepages_send(data); fuse_writepages_send(data);
data->wpa = NULL; data->wpa = NULL;
...@@ -2348,13 +2341,13 @@ static int fuse_writepages(struct address_space *mapping, ...@@ -2348,13 +2341,13 @@ static int fuse_writepages(struct address_space *mapping,
struct writeback_control *wbc) struct writeback_control *wbc)
{ {
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_fill_wb_data data; struct fuse_fill_wb_data data;
int err; int err;
err = -EIO;
if (fuse_is_bad(inode)) if (fuse_is_bad(inode))
goto out; return -EIO;
if (wbc->sync_mode == WB_SYNC_NONE && if (wbc->sync_mode == WB_SYNC_NONE &&
fc->num_background >= fc->congestion_threshold) fc->num_background >= fc->congestion_threshold)
...@@ -2362,7 +2355,9 @@ static int fuse_writepages(struct address_space *mapping, ...@@ -2362,7 +2355,9 @@ static int fuse_writepages(struct address_space *mapping,
data.inode = inode; data.inode = inode;
data.wpa = NULL; data.wpa = NULL;
data.ff = NULL; data.ff = fuse_write_file_get(fi);
if (!data.ff)
return -EIO;
err = -ENOMEM; err = -ENOMEM;
data.orig_pages = kcalloc(fc->max_pages, data.orig_pages = kcalloc(fc->max_pages,
...@@ -2376,11 +2371,10 @@ static int fuse_writepages(struct address_space *mapping, ...@@ -2376,11 +2371,10 @@ static int fuse_writepages(struct address_space *mapping,
WARN_ON(!data.wpa->ia.ap.num_pages); WARN_ON(!data.wpa->ia.ap.num_pages);
fuse_writepages_send(&data); fuse_writepages_send(&data);
} }
if (data.ff)
fuse_file_put(data.ff, false);
kfree(data.orig_pages); kfree(data.orig_pages);
out: out:
fuse_file_put(data.ff, false);
return err; return err;
} }
......
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