Skip to content

Commit 1097a87

Browse files
joannekoongbrauner
authored andcommitted
fuse: use iomap for folio laundering
Use iomap for folio laundering, which will do granular dirty writeback when laundering a large folio. Signed-off-by: Joanne Koong <[email protected]> Link: https://lore.kernel.org/[email protected] Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent ef7e7cb commit 1097a87

File tree

1 file changed

+12
-40
lines changed

1 file changed

+12
-40
lines changed

fs/fuse/file.c

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,45 +2058,6 @@ static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio
20582058
return wpa;
20592059
}
20602060

2061-
static int fuse_writepage_locked(struct folio *folio)
2062-
{
2063-
struct address_space *mapping = folio->mapping;
2064-
struct inode *inode = mapping->host;
2065-
struct fuse_inode *fi = get_fuse_inode(inode);
2066-
struct fuse_writepage_args *wpa;
2067-
struct fuse_args_pages *ap;
2068-
struct fuse_file *ff;
2069-
int error = -EIO;
2070-
2071-
ff = fuse_write_file_get(fi);
2072-
if (!ff)
2073-
goto err;
2074-
2075-
wpa = fuse_writepage_args_setup(folio, 0, ff);
2076-
error = -ENOMEM;
2077-
if (!wpa)
2078-
goto err_writepage_args;
2079-
2080-
ap = &wpa->ia.ap;
2081-
ap->num_folios = 1;
2082-
2083-
folio_start_writeback(folio);
2084-
fuse_writepage_args_page_fill(wpa, folio, 0, 0, folio_size(folio));
2085-
2086-
spin_lock(&fi->lock);
2087-
list_add_tail(&wpa->queue_entry, &fi->queued_writes);
2088-
fuse_flush_writepages(inode);
2089-
spin_unlock(&fi->lock);
2090-
2091-
return 0;
2092-
2093-
err_writepage_args:
2094-
fuse_file_put(ff, false);
2095-
err:
2096-
mapping_set_error(folio->mapping, error);
2097-
return error;
2098-
}
2099-
21002061
struct fuse_fill_wb_data {
21012062
struct fuse_writepage_args *wpa;
21022063
struct fuse_file *ff;
@@ -2282,8 +2243,19 @@ static int fuse_writepages(struct address_space *mapping,
22822243
static int fuse_launder_folio(struct folio *folio)
22832244
{
22842245
int err = 0;
2246+
struct fuse_fill_wb_data data = {
2247+
.inode = folio->mapping->host,
2248+
};
2249+
struct iomap_writepage_ctx wpc = {
2250+
.inode = folio->mapping->host,
2251+
.iomap.type = IOMAP_MAPPED,
2252+
.ops = &fuse_writeback_ops,
2253+
.wb_ctx = &data,
2254+
};
2255+
22852256
if (folio_clear_dirty_for_io(folio)) {
2286-
err = fuse_writepage_locked(folio);
2257+
err = iomap_writeback_folio(&wpc, folio);
2258+
err = fuse_iomap_writeback_submit(&wpc, err);
22872259
if (!err)
22882260
folio_wait_writeback(folio);
22892261
}

0 commit comments

Comments
 (0)