* [PATCH v4 0/7] fuse: writeback clean up / refactoring
@ 2024-08-26 21:19 Joanne Koong
2024-08-26 21:19 ` [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Joanne Koong
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
This patchset contains some minor clean up / refactoring for the fuse
writeback code.
As a sanity check, I ran fio to check against crashes -
./libfuse/build/example/passthrough_ll -o cache=always -o writeback -o
source=~/fstests ~/tmp_mount
fio --name=test --ioengine=psync --iodepth=1 --rw=randwrite --bs=1M --direct=0
--size=2G --numjobs=2 --directory=/home/user/tmp_mount
and (suggested by Miklos) fsx test -
sudo HOST_OPTIONS=fuse.config ./check -fuse generic/616
generic/616 (soak buffered fsx test) without the -U (io_uring) flag
(verified this uses the fuse_writepages_fill path)
v3:
https://lore.kernel.org/linux-fsdevel/20240823162730.521499-1-joannelkoong@gmail.com/
Changes from v3 -> v4:
* Merge v3's 4/9 and 5/9 into 1 patch (Josef)
* Merge v3's 7/9 and 9/9 into 1 patch
v2:
https://lore.kernel.org/linux-fsdevel/20240821232241.3573997-1-joannelkoong@gmail.com/
Changes from v2 -> v3:
* Drop v2 9/9 (Miklos)
* Split v2 8/9 into 2 patches (v3 8/9 and 9/9) to make review easier
* Change error pattern usage (Miklos)
v1:
https://lore.kernel.org/linux-fsdevel/20240819182417.504672-1-joannelkoong@gmail.com/
Changes from v1 -> v2:
* Added patches 2 and 4-9
* Add commit message to patch 1 (Jingbo)
Joanne Koong (7):
fuse: drop unused fuse_mount arg in fuse_writepage_finish()
fuse: refactor finished writeback stats updates into helper function
fuse: update stats for pages in dropped aux writeback list
fuse: move initialization of fuse_file to fuse_writepages() instead of
in callback
fuse: convert fuse_writepages_fill() to use a folio for its tmp page
fuse: move fuse file initialization to wpa allocation time
fuse: refactor out shared logic in fuse_writepages_fill() and
fuse_writepage_locked()
fs/fuse/file.c | 167 +++++++++++++++++++++++++------------------------
1 file changed, 86 insertions(+), 81 deletions(-)
--
2.43.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish()
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 2/7] fuse: refactor finished writeback stats updates into helper function Joanne Koong
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
Drop the unused "struct fuse_mount *fm" arg in
fuse_writepage_finish().
No functional changes added.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/fuse/file.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f39456c65ed7..63fd5fc6872e 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1769,8 +1769,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
kfree(wpa);
}
-static void fuse_writepage_finish(struct fuse_mount *fm,
- struct fuse_writepage_args *wpa)
+static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
{
struct fuse_args_pages *ap = &wpa->ia.ap;
struct inode *inode = wpa->inode;
@@ -1829,7 +1828,7 @@ __acquires(fi->lock)
out_free:
fi->writectr--;
rb_erase(&wpa->writepages_entry, &fi->writepages);
- fuse_writepage_finish(fm, wpa);
+ fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
/* After fuse_writepage_finish() aux request list is private */
@@ -1959,7 +1958,7 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
fuse_send_writepage(fm, next, inarg->offset + inarg->size);
}
fi->writectr--;
- fuse_writepage_finish(fm, wpa);
+ fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
fuse_writepage_free(wpa);
}
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/7] fuse: refactor finished writeback stats updates into helper function
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
2024-08-26 21:19 ` [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 3/7] fuse: update stats for pages in dropped aux writeback list Joanne Koong
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
Move the logic for updating the bdi and page stats for a finished
writeback into a separate helper function, where it can be called from
both fuse_writepage_finish() and fuse_writepage_add() (in the case
where there is already an auxiliary write request for the page).
No functional changes added.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Suggested by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/fuse/file.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 63fd5fc6872e..320fa26b23e8 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1769,19 +1769,25 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
kfree(wpa);
}
+static void fuse_writepage_finish_stat(struct inode *inode, struct page *page)
+{
+ struct backing_dev_info *bdi = inode_to_bdi(inode);
+
+ dec_wb_stat(&bdi->wb, WB_WRITEBACK);
+ dec_node_page_state(page, NR_WRITEBACK_TEMP);
+ wb_writeout_inc(&bdi->wb);
+}
+
static void fuse_writepage_finish(struct fuse_writepage_args *wpa)
{
struct fuse_args_pages *ap = &wpa->ia.ap;
struct inode *inode = wpa->inode;
struct fuse_inode *fi = get_fuse_inode(inode);
- struct backing_dev_info *bdi = inode_to_bdi(inode);
int i;
- for (i = 0; i < ap->num_pages; i++) {
- dec_wb_stat(&bdi->wb, WB_WRITEBACK);
- dec_node_page_state(ap->pages[i], NR_WRITEBACK_TEMP);
- wb_writeout_inc(&bdi->wb);
- }
+ for (i = 0; i < ap->num_pages; i++)
+ fuse_writepage_finish_stat(inode, ap->pages[i]);
+
wake_up(&fi->page_waitq);
}
@@ -2203,11 +2209,7 @@ static bool fuse_writepage_add(struct fuse_writepage_args *new_wpa,
spin_unlock(&fi->lock);
if (tmp) {
- struct backing_dev_info *bdi = inode_to_bdi(new_wpa->inode);
-
- dec_wb_stat(&bdi->wb, WB_WRITEBACK);
- dec_node_page_state(new_ap->pages[0], NR_WRITEBACK_TEMP);
- wb_writeout_inc(&bdi->wb);
+ fuse_writepage_finish_stat(new_wpa->inode, new_ap->pages[0]);
fuse_writepage_free(new_wpa);
}
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/7] fuse: update stats for pages in dropped aux writeback list
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
2024-08-26 21:19 ` [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Joanne Koong
2024-08-26 21:19 ` [PATCH v4 2/7] fuse: refactor finished writeback stats updates into helper function Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 4/7] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Joanne Koong
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
In the case where the aux writeback list is dropped (eg the pages
have been truncated or the connection is broken), the stats for
its pages and backing device info need to be updated as well.
Fixes: e2653bd53a98 ("fuse: fix leaked aux requests")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 320fa26b23e8..1ae58f93884e 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1837,10 +1837,11 @@ __acquires(fi->lock)
fuse_writepage_finish(wpa);
spin_unlock(&fi->lock);
- /* After fuse_writepage_finish() aux request list is private */
+ /* After rb_erase() aux request list is private */
for (aux = wpa->next; aux; aux = next) {
next = aux->next;
aux->next = NULL;
+ fuse_writepage_finish_stat(aux->inode, aux->ia.ap.pages[0]);
fuse_writepage_free(aux);
}
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 4/7] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (2 preceding siblings ...)
2024-08-26 21:19 ` [PATCH v4 3/7] fuse: update stats for pages in dropped aux writeback list Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 5/7] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Joanne Koong
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
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: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 1ae58f93884e..c1e938b311fb 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2263,13 +2263,6 @@ static int fuse_writepages_fill(struct folio *folio,
struct page *tmp_page;
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)) {
fuse_writepages_send(data);
data->wpa = NULL;
@@ -2348,13 +2341,13 @@ static int fuse_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
struct inode *inode = mapping->host;
+ struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_fill_wb_data data;
int err;
- err = -EIO;
if (fuse_is_bad(inode))
- goto out;
+ return -EIO;
if (wbc->sync_mode == WB_SYNC_NONE &&
fc->num_background >= fc->congestion_threshold)
@@ -2362,7 +2355,9 @@ static int fuse_writepages(struct address_space *mapping,
data.inode = inode;
data.wpa = NULL;
- data.ff = NULL;
+ data.ff = fuse_write_file_get(fi);
+ if (!data.ff)
+ return -EIO;
err = -ENOMEM;
data.orig_pages = kcalloc(fc->max_pages,
@@ -2376,11 +2371,10 @@ static int fuse_writepages(struct address_space *mapping,
WARN_ON(!data.wpa->ia.ap.num_pages);
fuse_writepages_send(&data);
}
- if (data.ff)
- fuse_file_put(data.ff, false);
kfree(data.orig_pages);
out:
+ fuse_file_put(data.ff, false);
return err;
}
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 5/7] fuse: convert fuse_writepages_fill() to use a folio for its tmp page
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (3 preceding siblings ...)
2024-08-26 21:19 ` [PATCH v4 4/7] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 6/7] fuse: move fuse file initialization to wpa allocation time Joanne Koong
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
To pave the way for refactoring out the shared logic in
fuse_writepages_fill() and fuse_writepage_locked(), this change converts
the temporary page in fuse_writepages_fill() to use the folio API.
This is similar to the change in e0887e095a80 ("fuse: Convert
fuse_writepage_locked to take a folio"), which converted the tmp page in
fuse_writepage_locked() to use the folio API.
inc_node_page_state() is intentionally preserved here instead of
converting to node_stat_add_folio() since it is updating the stat of the
underlying page and to better maintain API symmetry with
dec_node_page_stat() in fuse_writepage_finish_stat().
No functional changes added.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index c1e938b311fb..b879cd8711c0 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2260,7 +2260,7 @@ static int fuse_writepages_fill(struct folio *folio,
struct inode *inode = data->inode;
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode);
- struct page *tmp_page;
+ struct folio *tmp_folio;
int err;
if (wpa && fuse_writepage_need_send(fc, &folio->page, ap, data)) {
@@ -2269,8 +2269,8 @@ static int fuse_writepages_fill(struct folio *folio,
}
err = -ENOMEM;
- tmp_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
- if (!tmp_page)
+ tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0);
+ if (!tmp_folio)
goto out_unlock;
/*
@@ -2290,7 +2290,7 @@ static int fuse_writepages_fill(struct folio *folio,
err = -ENOMEM;
wpa = fuse_writepage_args_alloc();
if (!wpa) {
- __free_page(tmp_page);
+ folio_put(tmp_folio);
goto out_unlock;
}
fuse_writepage_add_to_bucket(fc, wpa);
@@ -2308,14 +2308,14 @@ static int fuse_writepages_fill(struct folio *folio,
}
folio_start_writeback(folio);
- copy_highpage(tmp_page, &folio->page);
- ap->pages[ap->num_pages] = tmp_page;
+ folio_copy(tmp_folio, folio);
+ ap->pages[ap->num_pages] = &tmp_folio->page;
ap->descs[ap->num_pages].offset = 0;
ap->descs[ap->num_pages].length = PAGE_SIZE;
data->orig_pages[ap->num_pages] = &folio->page;
inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
- inc_node_page_state(tmp_page, NR_WRITEBACK_TEMP);
+ inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP);
err = 0;
if (data->wpa) {
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 6/7] fuse: move fuse file initialization to wpa allocation time
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (4 preceding siblings ...)
2024-08-26 21:19 ` [PATCH v4 5/7] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-26 21:19 ` [PATCH v4 7/7] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Joanne Koong
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
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: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index b879cd8711c0..ef25dcfcac18 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1762,8 +1762,7 @@ static void fuse_writepage_free(struct fuse_writepage_args *wpa)
for (i = 0; i < ap->num_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(wpa);
@@ -1936,7 +1935,6 @@ static void fuse_writepage_end(struct fuse_mount *fm, struct fuse_args *args,
wpa->next = next->next;
next->next = NULL;
- next->ia.ff = fuse_file_get(wpa->ia.ff);
tree_insert(&fi->writepages, next);
/*
@@ -2155,7 +2153,6 @@ static void fuse_writepages_send(struct fuse_fill_wb_data *data)
int num_pages = wpa->ia.ap.num_pages;
int i;
- wpa->ia.ff = fuse_file_get(data->ff);
spin_lock(&fi->lock);
list_add_tail(&wpa->queue_entry, &fi->queued_writes);
fuse_flush_writepages(inode);
@@ -2300,6 +2297,7 @@ static int fuse_writepages_fill(struct folio *folio,
ap = &wpa->ia.ap;
fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0);
wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE;
+ wpa->ia.ff = fuse_file_get(data->ff);
wpa->next = NULL;
ap->args.in_pages = true;
ap->args.end = fuse_writepage_end;
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 7/7] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked()
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (5 preceding siblings ...)
2024-08-26 21:19 ` [PATCH v4 6/7] fuse: move fuse file initialization to wpa allocation time Joanne Koong
@ 2024-08-26 21:19 ` Joanne Koong
2024-08-27 11:00 ` [PATCH v4 0/7] fuse: writeback clean up / refactoring Josef Bacik
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Joanne Koong @ 2024-08-26 21:19 UTC (permalink / raw)
To: miklos, linux-fsdevel; +Cc: josef, bernd.schubert, jefflexu, kernel-team
This change refactors the shared logic in fuse_writepages_fill() and
fuse_writepages_locked() into two separate helper functions,
fuse_writepage_args_page_fill() and fuse_writepage_args_setup().
No functional changes added.
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
fs/fuse/file.c | 103 +++++++++++++++++++++++++++----------------------
1 file changed, 57 insertions(+), 46 deletions(-)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index ef25dcfcac18..726743e33b7f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2047,49 +2047,77 @@ static void fuse_writepage_add_to_bucket(struct fuse_conn *fc,
rcu_read_unlock();
}
+static void fuse_writepage_args_page_fill(struct fuse_writepage_args *wpa, struct folio *folio,
+ struct folio *tmp_folio, uint32_t page_index)
+{
+ struct inode *inode = folio->mapping->host;
+ struct fuse_args_pages *ap = &wpa->ia.ap;
+
+ folio_copy(tmp_folio, folio);
+
+ ap->pages[page_index] = &tmp_folio->page;
+ ap->descs[page_index].offset = 0;
+ ap->descs[page_index].length = PAGE_SIZE;
+
+ inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
+ inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP);
+}
+
+static struct fuse_writepage_args *fuse_writepage_args_setup(struct folio *folio,
+ struct fuse_file *ff)
+{
+ struct inode *inode = folio->mapping->host;
+ struct fuse_conn *fc = get_fuse_conn(inode);
+ struct fuse_writepage_args *wpa;
+ struct fuse_args_pages *ap;
+
+ wpa = fuse_writepage_args_alloc();
+ if (!wpa)
+ return NULL;
+
+ fuse_writepage_add_to_bucket(fc, wpa);
+ fuse_write_args_fill(&wpa->ia, ff, folio_pos(folio), 0);
+ wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE;
+ wpa->inode = inode;
+ wpa->ia.ff = ff;
+
+ ap = &wpa->ia.ap;
+ ap->args.in_pages = true;
+ ap->args.end = fuse_writepage_end;
+
+ return wpa;
+}
+
static int fuse_writepage_locked(struct folio *folio)
{
struct address_space *mapping = folio->mapping;
struct inode *inode = mapping->host;
- struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_writepage_args *wpa;
struct fuse_args_pages *ap;
struct folio *tmp_folio;
+ struct fuse_file *ff;
int error = -ENOMEM;
- folio_start_writeback(folio);
-
- wpa = fuse_writepage_args_alloc();
- if (!wpa)
- goto err;
- ap = &wpa->ia.ap;
-
tmp_folio = folio_alloc(GFP_NOFS | __GFP_HIGHMEM, 0);
if (!tmp_folio)
- goto err_free;
+ goto err;
error = -EIO;
- wpa->ia.ff = fuse_write_file_get(fi);
- if (!wpa->ia.ff)
+ ff = fuse_write_file_get(fi);
+ if (!ff)
goto err_nofile;
- fuse_writepage_add_to_bucket(fc, wpa);
- fuse_write_args_fill(&wpa->ia, wpa->ia.ff, folio_pos(folio), 0);
+ wpa = fuse_writepage_args_setup(folio, ff);
+ error = -ENOMEM;
+ if (!wpa)
+ goto err_writepage_args;
- folio_copy(tmp_folio, folio);
- wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE;
- wpa->next = NULL;
- ap->args.in_pages = true;
+ ap = &wpa->ia.ap;
ap->num_pages = 1;
- ap->pages[0] = &tmp_folio->page;
- ap->descs[0].offset = 0;
- ap->descs[0].length = PAGE_SIZE;
- ap->args.end = fuse_writepage_end;
- wpa->inode = inode;
- inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
- node_stat_add_folio(tmp_folio, NR_WRITEBACK_TEMP);
+ folio_start_writeback(folio);
+ fuse_writepage_args_page_fill(wpa, folio, tmp_folio, 0);
spin_lock(&fi->lock);
tree_insert(&fi->writepages, wpa);
@@ -2101,13 +2129,12 @@ static int fuse_writepage_locked(struct folio *folio)
return 0;
+err_writepage_args:
+ fuse_file_put(ff, false);
err_nofile:
folio_put(tmp_folio);
-err_free:
- kfree(wpa);
err:
mapping_set_error(folio->mapping, error);
- folio_end_writeback(folio);
return error;
}
@@ -2285,36 +2312,20 @@ static int fuse_writepages_fill(struct folio *folio,
*/
if (data->wpa == NULL) {
err = -ENOMEM;
- wpa = fuse_writepage_args_alloc();
+ wpa = fuse_writepage_args_setup(folio, data->ff);
if (!wpa) {
folio_put(tmp_folio);
goto out_unlock;
}
- fuse_writepage_add_to_bucket(fc, wpa);
-
+ fuse_file_get(wpa->ia.ff);
data->max_pages = 1;
-
ap = &wpa->ia.ap;
- fuse_write_args_fill(&wpa->ia, data->ff, folio_pos(folio), 0);
- wpa->ia.write.in.write_flags |= FUSE_WRITE_CACHE;
- wpa->ia.ff = fuse_file_get(data->ff);
- wpa->next = NULL;
- ap->args.in_pages = true;
- ap->args.end = fuse_writepage_end;
- ap->num_pages = 0;
- wpa->inode = inode;
}
folio_start_writeback(folio);
- folio_copy(tmp_folio, folio);
- ap->pages[ap->num_pages] = &tmp_folio->page;
- ap->descs[ap->num_pages].offset = 0;
- ap->descs[ap->num_pages].length = PAGE_SIZE;
+ fuse_writepage_args_page_fill(wpa, folio, tmp_folio, ap->num_pages);
data->orig_pages[ap->num_pages] = &folio->page;
- inc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);
- inc_node_page_state(&tmp_folio->page, NR_WRITEBACK_TEMP);
-
err = 0;
if (data->wpa) {
/*
--
2.43.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 0/7] fuse: writeback clean up / refactoring
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (6 preceding siblings ...)
2024-08-26 21:19 ` [PATCH v4 7/7] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Joanne Koong
@ 2024-08-27 11:00 ` Josef Bacik
2024-08-30 9:26 ` Miklos Szeredi
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2024-08-27 11:00 UTC (permalink / raw)
To: Joanne Koong; +Cc: miklos, linux-fsdevel, bernd.schubert, jefflexu, kernel-team
On Mon, Aug 26, 2024 at 02:19:01PM -0700, Joanne Koong wrote:
> This patchset contains some minor clean up / refactoring for the fuse
> writeback code.
>
> As a sanity check, I ran fio to check against crashes -
> ./libfuse/build/example/passthrough_ll -o cache=always -o writeback -o
> source=~/fstests ~/tmp_mount
> fio --name=test --ioengine=psync --iodepth=1 --rw=randwrite --bs=1M --direct=0
> --size=2G --numjobs=2 --directory=/home/user/tmp_mount
>
> and (suggested by Miklos) fsx test -
> sudo HOST_OPTIONS=fuse.config ./check -fuse generic/616
> generic/616 (soak buffered fsx test) without the -U (io_uring) flag
> (verified this uses the fuse_writepages_fill path)
>
> v3:
> https://lore.kernel.org/linux-fsdevel/20240823162730.521499-1-joannelkoong@gmail.com/
> Changes from v3 -> v4:
> * Merge v3's 4/9 and 5/9 into 1 patch (Josef)
> * Merge v3's 7/9 and 9/9 into 1 patch
>
> v2:
> https://lore.kernel.org/linux-fsdevel/20240821232241.3573997-1-joannelkoong@gmail.com/
> Changes from v2 -> v3:
> * Drop v2 9/9 (Miklos)
> * Split v2 8/9 into 2 patches (v3 8/9 and 9/9) to make review easier
> * Change error pattern usage (Miklos)
>
> v1:
> https://lore.kernel.org/linux-fsdevel/20240819182417.504672-1-joannelkoong@gmail.com/
> Changes from v1 -> v2:
> * Added patches 2 and 4-9
> * Add commit message to patch 1 (Jingbo)
This is good, I've based my folio conversion patches ontop of this series as
well,
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks for this,
Josef
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 0/7] fuse: writeback clean up / refactoring
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (7 preceding siblings ...)
2024-08-27 11:00 ` [PATCH v4 0/7] fuse: writeback clean up / refactoring Josef Bacik
@ 2024-08-30 9:26 ` Miklos Szeredi
2024-09-10 20:55 ` Bernd Schubert
2024-09-11 1:36 ` Jingbo Xu
10 siblings, 0 replies; 12+ messages in thread
From: Miklos Szeredi @ 2024-08-30 9:26 UTC (permalink / raw)
To: Joanne Koong; +Cc: linux-fsdevel, josef, bernd.schubert, jefflexu, kernel-team
On Mon, 26 Aug 2024 at 23:20, Joanne Koong <joannelkoong@gmail.com> wrote:
>
> This patchset contains some minor clean up / refactoring for the fuse
> writeback code.
>
> As a sanity check, I ran fio to check against crashes -
> ./libfuse/build/example/passthrough_ll -o cache=always -o writeback -o
> source=~/fstests ~/tmp_mount
> fio --name=test --ioengine=psync --iodepth=1 --rw=randwrite --bs=1M --direct=0
> --size=2G --numjobs=2 --directory=/home/user/tmp_mount
>
> and (suggested by Miklos) fsx test -
> sudo HOST_OPTIONS=fuse.config ./check -fuse generic/616
> generic/616 (soak buffered fsx test) without the -U (io_uring) flag
> (verified this uses the fuse_writepages_fill path)
Applied, thanks.
Miklos
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 0/7] fuse: writeback clean up / refactoring
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (8 preceding siblings ...)
2024-08-30 9:26 ` Miklos Szeredi
@ 2024-09-10 20:55 ` Bernd Schubert
2024-09-11 1:36 ` Jingbo Xu
10 siblings, 0 replies; 12+ messages in thread
From: Bernd Schubert @ 2024-09-10 20:55 UTC (permalink / raw)
To: Joanne Koong, miklos, linux-fsdevel; +Cc: josef, jefflexu, kernel-team
On 8/26/24 23:19, Joanne Koong wrote:
> This patchset contains some minor clean up / refactoring for the fuse
> writeback code.
Thanks Joanne, especially after 7/7 this looks so much better now!
I'm a bit late, reviewed-by: Bernd Schubert <bschubert@ddn.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 0/7] fuse: writeback clean up / refactoring
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
` (9 preceding siblings ...)
2024-09-10 20:55 ` Bernd Schubert
@ 2024-09-11 1:36 ` Jingbo Xu
10 siblings, 0 replies; 12+ messages in thread
From: Jingbo Xu @ 2024-09-11 1:36 UTC (permalink / raw)
To: Joanne Koong, miklos, linux-fsdevel; +Cc: josef, bernd.schubert, kernel-team
On 8/27/24 5:19 AM, Joanne Koong wrote:
> This patchset contains some minor clean up / refactoring for the fuse
> writeback code.
Sorry maybe it's too late and not sure if it's still needed, but anyway,
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-09-11 1:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 21:19 [PATCH v4 0/7] fuse: writeback clean up / refactoring Joanne Koong
2024-08-26 21:19 ` [PATCH v4 1/7] fuse: drop unused fuse_mount arg in fuse_writepage_finish() Joanne Koong
2024-08-26 21:19 ` [PATCH v4 2/7] fuse: refactor finished writeback stats updates into helper function Joanne Koong
2024-08-26 21:19 ` [PATCH v4 3/7] fuse: update stats for pages in dropped aux writeback list Joanne Koong
2024-08-26 21:19 ` [PATCH v4 4/7] fuse: move initialization of fuse_file to fuse_writepages() instead of in callback Joanne Koong
2024-08-26 21:19 ` [PATCH v4 5/7] fuse: convert fuse_writepages_fill() to use a folio for its tmp page Joanne Koong
2024-08-26 21:19 ` [PATCH v4 6/7] fuse: move fuse file initialization to wpa allocation time Joanne Koong
2024-08-26 21:19 ` [PATCH v4 7/7] fuse: refactor out shared logic in fuse_writepages_fill() and fuse_writepage_locked() Joanne Koong
2024-08-27 11:00 ` [PATCH v4 0/7] fuse: writeback clean up / refactoring Josef Bacik
2024-08-30 9:26 ` Miklos Szeredi
2024-09-10 20:55 ` Bernd Schubert
2024-09-11 1:36 ` Jingbo Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).