Skip to contentSkip to conversation

NFS: Read unlock folio on nfs_page_create_from_folio() error

PATCH Superseded Benjamin Coddington 2 participants 3 messages Mar 5, 2024 – Mar 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: Read unlock folio on nfs_page_create_from_folio() error

The netfs conversion lost a folio_unlock() for the case where nfs_page_create_from_folio() returns an error (usually -ENOMEM). Restore it.

Cc <[email protected]> # 6.4+
Fixes 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")
---
 fs/nfs/read.c | 2 ++
 1 file changed, 2 insertions(+)
fs/nfs/read.c +2 -0
index 7dc21a48e3e7..a142287d86f6 100644
@@ -305,6 +305,8 @@ int nfs_read_add_folio(struct nfs_pageio_descriptor *pgio,
 	new = nfs_page_create_from_folio(ctx, folio, 0, aligned_len);
 	if (IS_ERR(new)) {
 		error = PTR_ERR(new);
+		if (nfs_netfs_folio_unlock(folio))
+			folio_unlock(folio);
 		goto out;
 	}
 
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 27 lines · Benjamin Coddington

The netfs conversion lost a folio_unlock() for the case where nfs_page_create_from_folio() returns an error (usually -ENOMEM). Restore it.

Cc <[email protected]> # 6.4+
Fixes 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")
---
 fs/nfs/read.c | 2 ++
 1 file changed, 2 insertions(+)
fs/nfs/read.c +2 -1
index 7dc21a48e3e7..a142287d86f6 100644
@@ -305,6 +305,8 @@ int nfs_read_add_folio(struct nfs_pageio_descriptor *pgio,
        new = nfs_page_create_from_folio(ctx, folio, 0, aligned_len);
        if (IS_ERR(new)) {
                error = PTR_ERR(new);
+               if (nfs_netfs_folio_unlock(folio))
+                       folio_unlock(folio);
                goto out;
        }
 
--
Quoted 2 lines

2.43.0

#2 lore raw

PATCH RESEND 1/1 NFS: Read unlock folio on nfs_page_create_from_folio() error

In reply to Benjamin Coddington

The netfs conversion lost a folio_unlock() for the case where nfs_page_create_from_folio() returns an error (usually -ENOMEM). Restore it.

Cc <[email protected]> # 6.4+
Fixes 000dbe0bec05 ("NFS: Convert buffered read paths to use netfs when fscache is enabled")

---

Resending this as I messed up Trond's email address on the first try:
https://lore.kernel.org/linux-nfs/CALF+zOn50xfKDBxqG1JfWVcRa+PvMvMpcWYfJmt0FWoUe0mW5w@mail.gmail.com/T/#t

---
 fs/nfs/read.c | 2 ++
 1 file changed, 2 insertions(+)
fs/nfs/read.c +2 -0
index 7dc21a48e3e7..a142287d86f6 100644
@@ -305,6 +305,8 @@ int nfs_read_add_folio(struct nfs_pageio_descriptor *pgio,
 	new = nfs_page_create_from_folio(ctx, folio, 0, aligned_len);
 	if (IS_ERR(new)) {
 		error = PTR_ERR(new);
+		if (nfs_netfs_folio_unlock(folio))
+			folio_unlock(folio);
 		goto out;
 	}
 
Signature · 1 line
2.43.0