From: Xiubo Li <xiu...@redhat.com>

check_write_begin() will unlock and put the folio when return
non-zero. So we should avoid unlocking and putting it twice in
netfs layer.

URL: https://tracker.ceph.com/issues/56423
Signed-off-by: Xiubo Li <xiu...@redhat.com>
---
 fs/netfs/buffered_read.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
index 42f892c5712e..b6fd6e5fe019 100644
--- a/fs/netfs/buffered_read.c
+++ b/fs/netfs/buffered_read.c
@@ -320,7 +320,7 @@ static bool netfs_skip_folio_read(struct folio *folio, 
loff_t pos, size_t len,
  * pointer to the fsdata cookie that gets returned to the VM to be passed to
  * write_end.  It is permitted to sleep.  It should return 0 if the request
  * should go ahead; unlock the folio and return -EAGAIN to cause the folio to
- * be regot; or return an error.
+ * be regot; or unlock the folio and return an error.
  *
  * The calling netfs must initialise a netfs context contiguous to the vfs
  * inode before calling this.
@@ -353,7 +353,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
                        trace_netfs_failure(NULL, NULL, ret, 
netfs_fail_check_write_begin);
                        if (ret == -EAGAIN)
                                goto retry;
-                       goto error;
+                       goto error_unlocked;
                }
        }
 
@@ -375,7 +375,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
                                   NETFS_READ_FOR_WRITE);
        if (IS_ERR(rreq)) {
                ret = PTR_ERR(rreq);
-               goto error;
+               goto error_locked;
        }
        rreq->no_unlock_folio   = folio_index(folio);
        __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
@@ -402,12 +402,12 @@ int netfs_write_begin(struct netfs_inode *ctx,
 
        ret = netfs_begin_read(rreq, true);
        if (ret < 0)
-               goto error;
+               goto error_locked;
 
 have_folio:
        ret = folio_wait_fscache_killable(folio);
        if (ret < 0)
-               goto error;
+               goto error_locked;
 have_folio_no_wait:
        *_folio = folio;
        _leave(" = 0");
@@ -415,9 +415,10 @@ int netfs_write_begin(struct netfs_inode *ctx,
 
 error_put:
        netfs_put_request(rreq, false, netfs_rreq_trace_put_failed);
-error:
+error_locked:
        folio_unlock(folio);
        folio_put(folio);
+error_unlocked:
        _leave(" = %d", ret);
        return ret;
 }
-- 
2.36.0.rc1

--
Linux-cachefs mailing list
Linux-cachefs@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-cachefs

Reply via email to