* [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes
@ 2024-01-22 12:38 David Howells
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
` (11 more replies)
0 siblings, 12 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel
Hi Christian,
Here are some miscellaneous fixes for netfslib and a number of filesystems:
(1) Replace folio_index() with folio->index in netfs, afs and cifs.
(2) Fix an oops in fscache_put_cache().
(3) Fix error handling in netfs_perform_write().
(4) Fix an oops in cachefiles when not using erofs ondemand mode.
(5) In afs, hide silly-rename files from getdents() to avoid problems with
tar and suchlike.
(6) In afs, fix error handling in lookup with a bulk status fetch.
(7) In afs, afs_dynroot_d_revalidate() is redundant, so remove it.
(8) In afs, fix the RCU unlocking in afs_proc_addr_prefs_show().
The patches can also be found here:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-fixes
Thanks,
David
Dan Carpenter (2):
netfs, fscache: Prevent Oops in fscache_put_cache()
netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write()
David Howells (8):
netfs: Don't use certain internal folio_*() functions
afs: Don't use certain internal folio_*() functions
cifs: Don't use certain internal folio_*() functions
cachefiles, erofs: Fix NULL deref in when cachefiles is not doing
ondemand-mode
afs: Hide silly-rename files from userspace
afs: Fix error handling with lookup via FS.InlineBulkStatus
afs: Remove afs_dynroot_d_revalidate() as it is redundant
afs: Fix missing/incorrect unlocking of RCU read lock
fs/afs/dir.c | 30 ++++++++++++++++++++++--------
fs/afs/dynroot.c | 9 ---------
fs/afs/proc.c | 5 +++--
fs/cachefiles/namei.c | 16 ++++++++++------
fs/netfs/buffered_read.c | 12 ++++++------
fs/netfs/buffered_write.c | 15 ++++++++-------
fs/netfs/fscache_cache.c | 3 ++-
fs/netfs/io.c | 2 +-
fs/netfs/misc.c | 2 +-
fs/smb/client/file.c | 10 +++++-----
include/trace/events/afs.h | 25 +++++++++++++++++++++++++
11 files changed, 83 insertions(+), 46 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 01/10] netfs: Don't use certain internal folio_*() functions
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 15:38 ` Jeff Layton
2024-01-22 17:22 ` David Howells
2024-01-22 12:38 ` [PATCH 02/10] afs: " David Howells
` (10 subsequent siblings)
11 siblings, 2 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, linux-cachefs
Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.
Change this automagically with:
perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/netfs/*.c
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-afs@lists.infradead.org
cc: linux-cachefs@redhat.com
cc: linux-cifs@vger.kernel.org
cc: linux-erofs@lists.ozlabs.org
cc: linux-fsdevel@vger.kernel.org
---
fs/netfs/buffered_read.c | 12 ++++++------
fs/netfs/buffered_write.c | 10 +++++-----
fs/netfs/io.c | 2 +-
fs/netfs/misc.c | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
index a59e7b2edaac..3298c29b5548 100644
--- a/fs/netfs/buffered_read.c
+++ b/fs/netfs/buffered_read.c
@@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
}
if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
- if (folio_index(folio) == rreq->no_unlock_folio &&
+ if (folio->index == rreq->no_unlock_folio &&
test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags))
_debug("no unlock");
else
@@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead);
*/
int netfs_read_folio(struct file *file, struct folio *folio)
{
- struct address_space *mapping = folio_file_mapping(folio);
+ struct address_space *mapping = folio->mapping;
struct netfs_io_request *rreq;
struct netfs_inode *ctx = netfs_inode(mapping->host);
struct folio *sink = NULL;
int ret;
- _enter("%lx", folio_index(folio));
+ _enter("%lx", folio->index);
rreq = netfs_alloc_request(mapping, file,
folio_file_pos(folio), folio_size(folio),
@@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
ret = PTR_ERR(rreq);
goto error;
}
- rreq->no_unlock_folio = folio_index(folio);
+ rreq->no_unlock_folio = folio->index;
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
ret = netfs_begin_cache_read(rreq, ctx);
@@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
size_t offset, size_t len)
{
struct netfs_io_request *rreq;
- struct address_space *mapping = folio_file_mapping(folio);
+ struct address_space *mapping = folio->mapping;
struct netfs_inode *ctx = netfs_inode(mapping->host);
unsigned long long start = folio_pos(folio);
size_t flen = folio_size(folio);
@@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
goto error;
}
- rreq->no_unlock_folio = folio_index(folio);
+ rreq->no_unlock_folio = folio->index;
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
ret = netfs_begin_cache_read(rreq, ctx);
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index 93dc76f34e39..e7f9ba6fb16b 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -343,7 +343,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
break;
default:
WARN(true, "Unexpected modify type %u ix=%lx\n",
- howto, folio_index(folio));
+ howto, folio->index);
ret = -EIO;
goto error_folio_unlock;
}
@@ -648,7 +648,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
xas_for_each(&xas, folio, last) {
WARN(!folio_test_writeback(folio),
"bad %zx @%llx page %lx %lx\n",
- wreq->len, wreq->start, folio_index(folio), last);
+ wreq->len, wreq->start, folio->index, last);
if ((finfo = netfs_folio_info(folio))) {
/* Streaming writes cannot be redirtied whilst under
@@ -795,7 +795,7 @@ static void netfs_extend_writeback(struct address_space *mapping,
continue;
if (xa_is_value(folio))
break;
- if (folio_index(folio) != index) {
+ if (folio->index != index) {
xas_reset(xas);
break;
}
@@ -901,7 +901,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping,
long count = wbc->nr_to_write;
int ret;
- _enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching);
+ _enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching);
wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio),
NETFS_WRITEBACK);
@@ -1047,7 +1047,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
start = folio_pos(folio); /* May regress with THPs */
- _debug("wback %lx", folio_index(folio));
+ _debug("wback %lx", folio->index);
/* At this point we hold neither the i_pages lock nor the page lock:
* the page may be truncated or invalidated (changing page->mapping to
diff --git a/fs/netfs/io.c b/fs/netfs/io.c
index 4309edf33862..e8ff1e61ce79 100644
--- a/fs/netfs/io.c
+++ b/fs/netfs/io.c
@@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
/* We might have multiple writes from the same huge
* folio, but we mustn't unlock a folio more than once.
*/
- if (have_unlocked && folio_index(folio) <= unlocked)
+ if (have_unlocked && folio->index <= unlocked)
continue;
unlocked = folio_next_index(folio) - 1;
trace_netfs_folio(folio, netfs_folio_trace_end_copy);
diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c
index 0e3af37fc924..90051ced8e2a 100644
--- a/fs/netfs/misc.c
+++ b/fs/netfs/misc.c
@@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)
struct netfs_folio *finfo = NULL;
size_t flen = folio_size(folio);
- _enter("{%lx},%zx,%zx", folio_index(folio), offset, length);
+ _enter("{%lx},%zx,%zx", folio->index, offset, length);
folio_wait_fscache(folio);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 02/10] afs: Don't use certain internal folio_*() functions
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 03/10] cifs: " David Howells
` (9 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Marc Dionne
Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.
Change this automagically with:
perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/afs/*.c
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/dir.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index c14533ef108f..3f73d61f7c8a 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -124,7 +124,7 @@ static void afs_dir_read_cleanup(struct afs_read *req)
if (xas_retry(&xas, folio))
continue;
BUG_ON(xa_is_value(folio));
- ASSERTCMP(folio_file_mapping(folio), ==, mapping);
+ ASSERTCMP(folio->mapping, ==, mapping);
folio_put(folio);
}
@@ -202,12 +202,12 @@ static void afs_dir_dump(struct afs_vnode *dvnode, struct afs_read *req)
if (xas_retry(&xas, folio))
continue;
- BUG_ON(folio_file_mapping(folio) != mapping);
+ BUG_ON(folio->mapping != mapping);
size = min_t(loff_t, folio_size(folio), req->actual_len - folio_pos(folio));
for (offset = 0; offset < size; offset += sizeof(*block)) {
block = kmap_local_folio(folio, offset);
- pr_warn("[%02lx] %32phN\n", folio_index(folio) + offset, block);
+ pr_warn("[%02lx] %32phN\n", folio->index + offset, block);
kunmap_local(block);
}
}
@@ -233,7 +233,7 @@ static int afs_dir_check(struct afs_vnode *dvnode, struct afs_read *req)
if (xas_retry(&xas, folio))
continue;
- BUG_ON(folio_file_mapping(folio) != mapping);
+ BUG_ON(folio->mapping != mapping);
if (!afs_dir_check_folio(dvnode, folio, req->actual_len)) {
afs_dir_dump(dvnode, req);
@@ -2022,7 +2022,7 @@ static bool afs_dir_release_folio(struct folio *folio, gfp_t gfp_flags)
{
struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio));
- _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio));
+ _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio->index);
folio_detach_private(folio);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 03/10] cifs: Don't use certain internal folio_*() functions
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
2024-01-22 12:38 ` [PATCH 02/10] afs: " David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 04/10] netfs, fscache: Prevent Oops in fscache_put_cache() David Howells
` (8 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Steve French,
Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey
Filesystems should not be using folio->index not folio_index(folio) and
folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
code.
Change this automagically with:
perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c
perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c
perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/smb/client/*.c
Reported-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: Steve French <sfrench@samba.org>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Ronnie Sahlberg <lsahlber@redhat.com>
cc: Shyam Prasad N <sprasad@microsoft.com>
cc: Tom Talpey <tom@talpey.com>
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
---
fs/smb/client/file.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 3a213432775b..90da81d0372a 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -87,7 +87,7 @@ void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len
continue;
if (!folio_test_writeback(folio)) {
WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
- len, start, folio_index(folio), end);
+ len, start, folio->index, end);
continue;
}
@@ -120,7 +120,7 @@ void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len
continue;
if (!folio_test_writeback(folio)) {
WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
- len, start, folio_index(folio), end);
+ len, start, folio->index, end);
continue;
}
@@ -151,7 +151,7 @@ void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int le
xas_for_each(&xas, folio, end) {
if (!folio_test_writeback(folio)) {
WARN_ONCE(1, "bad %x @%llx page %lx %lx\n",
- len, start, folio_index(folio), end);
+ len, start, folio->index, end);
continue;
}
@@ -2651,7 +2651,7 @@ static void cifs_extend_writeback(struct address_space *mapping,
continue;
if (xa_is_value(folio))
break;
- if (folio_index(folio) != index)
+ if (folio->index != index)
break;
if (!folio_try_get_rcu(folio)) {
xas_reset(&xas);
@@ -2899,7 +2899,7 @@ static int cifs_writepages_region(struct address_space *mapping,
goto skip_write;
}
- if (folio_mapping(folio) != mapping ||
+ if (folio->mapping != mapping ||
!folio_test_dirty(folio)) {
start += folio_size(folio);
folio_unlock(folio);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 04/10] netfs, fscache: Prevent Oops in fscache_put_cache()
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (2 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 03/10] cifs: " David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() David Howells
` (7 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Dan Carpenter
From: Dan Carpenter <dan.carpenter@linaro.org>
This function dereferences "cache" and then checks if it's
IS_ERR_OR_NULL(). Check first, then dereference.
Fixes: 9549332df4ed ("fscache: Implement cache registration")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/e84bc740-3502-4f16-982a-a40d5676615c@moroto.mountain/ # v2
---
fs/netfs/fscache_cache.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/netfs/fscache_cache.c b/fs/netfs/fscache_cache.c
index d645f8b302a2..9397ed39b0b4 100644
--- a/fs/netfs/fscache_cache.c
+++ b/fs/netfs/fscache_cache.c
@@ -179,13 +179,14 @@ EXPORT_SYMBOL(fscache_acquire_cache);
void fscache_put_cache(struct fscache_cache *cache,
enum fscache_cache_trace where)
{
- unsigned int debug_id = cache->debug_id;
+ unsigned int debug_id;
bool zero;
int ref;
if (IS_ERR_OR_NULL(cache))
return;
+ debug_id = cache->debug_id;
zero = __refcount_dec_and_test(&cache->ref, &ref);
trace_fscache_cache(debug_id, ref - 1, where);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write()
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (3 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 04/10] netfs, fscache: Prevent Oops in fscache_put_cache() David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
` (6 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Dan Carpenter
From: Dan Carpenter <dan.carpenter@linaro.org>
The netfs_grab_folio_for_write() function doesn't return NULL, it returns
error pointers. Update the check accordingly.
Fixes: c38f4e96e605 ("netfs: Provide func to copy data to pagecache for buffered write")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/29fb1310-8e2d-47ba-b68d-40354eb7b896@moroto.mountain/
---
fs/netfs/buffered_write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
index e7f9ba6fb16b..a3059b3168fd 100644
--- a/fs/netfs/buffered_write.c
+++ b/fs/netfs/buffered_write.c
@@ -221,10 +221,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
if (unlikely(fault_in_iov_iter_readable(iter, part) == part))
break;
- ret = -ENOMEM;
folio = netfs_grab_folio_for_write(mapping, pos, part);
- if (!folio)
+ if (IS_ERR(folio)) {
+ ret = PTR_ERR(folio);
break;
+ }
flen = folio_size(folio);
offset = pos & (flen - 1);
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (4 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 13:48 ` Jingbo Xu
` (2 more replies)
2024-01-22 12:38 ` [PATCH 07/10] afs: Hide silly-rename files from userspace David Howells
` (5 subsequent siblings)
11 siblings, 3 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Marc Dionne, Gao Xiang,
Chao Yu, Yue Hu, Jeffle Xu
cachefiles_ondemand_init_object() as called from cachefiles_open_file() and
cachefiles_create_tmpfile() does not check if object->ondemand is set
before dereferencing it, leading to an oops something like:
RIP: 0010:cachefiles_ondemand_init_object+0x9/0x41
...
Call Trace:
<TASK>
cachefiles_open_file+0xc9/0x187
cachefiles_lookup_cookie+0x122/0x2be
fscache_cookie_state_machine+0xbe/0x32b
fscache_cookie_worker+0x1f/0x2d
process_one_work+0x136/0x208
process_scheduled_works+0x3a/0x41
worker_thread+0x1a2/0x1f6
kthread+0xca/0xd2
ret_from_fork+0x21/0x33
Fix this by making the calls to cachefiles_ondemand_init_object()
conditional.
Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object")
Reported-by: Marc Dionne <marc.dionne@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Gao Xiang <xiang@kernel.org>
cc: Chao Yu <chao@kernel.org>
cc: Yue Hu <huyue2@coolpad.com>
cc: Jeffle Xu <jefflexu@linux.alibaba.com>
cc: linux-erofs@lists.ozlabs.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
---
fs/cachefiles/namei.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
index 7ade836beb58..180594d24c44 100644
--- a/fs/cachefiles/namei.c
+++ b/fs/cachefiles/namei.c
@@ -473,9 +473,11 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
if (!cachefiles_mark_inode_in_use(object, file_inode(file)))
WARN_ON(1);
- ret = cachefiles_ondemand_init_object(object);
- if (ret < 0)
- goto err_unuse;
+ if (object->ondemand) {
+ ret = cachefiles_ondemand_init_object(object);
+ if (ret < 0)
+ goto err_unuse;
+ }
ni_size = object->cookie->object_size;
ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE);
@@ -579,9 +581,11 @@ static bool cachefiles_open_file(struct cachefiles_object *object,
}
_debug("file -> %pd positive", dentry);
- ret = cachefiles_ondemand_init_object(object);
- if (ret < 0)
- goto error_fput;
+ if (object->ondemand) {
+ ret = cachefiles_ondemand_init_object(object);
+ if (ret < 0)
+ goto error_fput;
+ }
ret = cachefiles_check_auxdata(object, file);
if (ret < 0)
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 07/10] afs: Hide silly-rename files from userspace
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (5 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus David Howells
` (4 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Marc Dionne
There appears to be a race between silly-rename files being created/removed
and various userspace tools iterating over the contents of a directory,
leading to such errors as:
find: './kernel/.tmp_cpio_dir/include/dt-bindings/reset/.__afs2080': No such file or directory
tar: ./include/linux/greybus/.__afs3C95: File removed before we read it
when building a kernel.
Fix afs_readdir() so that it doesn't return .__afsXXXX silly-rename files
to userspace. This doesn't stop them being looked up directly by name as
we need to be able to look them up from within the kernel as part of the
silly-rename algorithm.
Fixes: 79ddbfa500b3 ("afs: Implement sillyrename for unlink and rename")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
---
fs/afs/dir.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 3f73d61f7c8a..eface67ccc06 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -474,6 +474,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
continue;
}
+ /* Don't expose silly rename entries to userspace. */
+ if (nlen > 6 &&
+ dire->u.name[0] == '.' &&
+ ctx->actor != afs_lookup_filldir &&
+ ctx->actor != afs_lookup_one_filldir &&
+ memcmp(dire->u.name, ".__afs", 6) == 0)
+ continue;
+
/* found the next entry */
if (!dir_emit(ctx, dire->u.name, nlen,
ntohl(dire->u.vnode),
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (6 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 07/10] afs: Hide silly-rename files from userspace David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant David Howells
` (3 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Jeffrey Altman,
Marc Dionne
When afs does a lookup, it tries to use FS.InlineBulkStatus to preemptively
look up a bunch of files in the parent directory and cache this locally, on
the basis that we might want to look at them too (for example if someone
does an ls on a directory, they may want want to then stat every file
listed).
FS.InlineBulkStatus can be considered a compound op with the normal abort
code applying to the compound as a whole. Each status fetch within the
compound is then given its own individual abort code - but assuming no
error that prevents the bulk fetch from returning the compound result will
be 0, even if all the constituent status fetches failed.
At the conclusion of afs_do_lookup(), we should use the abort code from the
appropriate status to determine the error to return, if any - but instead
it is assumed that we were successful if the op as a whole succeeded and we
return an incompletely initialised inode, resulting in ENOENT, no matter
the actual reason. In the particular instance reported, a vnode with no
permission granted to be accessed is being given a UAEACCES abort code
which should be reported as EACCES, but is instead being reported as
ENOENT.
Fix this by abandoning the inode (which will be cleaned up with the op) if
file[1] has an abort code indicated and turn that abort code into an error
instead.
Whilst we're at it, add a tracepoint so that the abort codes of the
individual subrequests of FS.InlineBulkStatus can be logged. At the moment
only the container abort code can be 0.
Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
Reported-by: Jeffrey Altman <jaltman@auristor.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
---
fs/afs/dir.c | 12 +++++++++---
include/trace/events/afs.h | 25 +++++++++++++++++++++++++
2 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index eface67ccc06..b5b8de521f99 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -716,6 +716,8 @@ static void afs_do_lookup_success(struct afs_operation *op)
break;
}
+ if (vp->scb.status.abort_code)
+ trace_afs_bulkstat_error(op, &vp->fid, i, vp->scb.status.abort_code);
if (!vp->scb.have_status && !vp->scb.have_error)
continue;
@@ -905,12 +907,16 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
afs_begin_vnode_operation(op);
afs_wait_for_operation(op);
}
- inode = ERR_PTR(afs_op_error(op));
out_op:
if (!afs_op_error(op)) {
- inode = &op->file[1].vnode->netfs.inode;
- op->file[1].vnode = NULL;
+ if (op->file[1].scb.status.abort_code) {
+ afs_op_accumulate_error(op, -ECONNABORTED,
+ op->file[1].scb.status.abort_code);
+ } else {
+ inode = &op->file[1].vnode->netfs.inode;
+ op->file[1].vnode = NULL;
+ }
}
if (op->file[0].scb.have_status)
diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h
index 8d73171cb9f0..08f2c93d6b16 100644
--- a/include/trace/events/afs.h
+++ b/include/trace/events/afs.h
@@ -1071,6 +1071,31 @@ TRACE_EVENT(afs_file_error,
__print_symbolic(__entry->where, afs_file_errors))
);
+TRACE_EVENT(afs_bulkstat_error,
+ TP_PROTO(struct afs_operation *op, struct afs_fid *fid, unsigned int index, s32 abort),
+
+ TP_ARGS(op, fid, index, abort),
+
+ TP_STRUCT__entry(
+ __field_struct(struct afs_fid, fid)
+ __field(unsigned int, op)
+ __field(unsigned int, index)
+ __field(s32, abort)
+ ),
+
+ TP_fast_assign(
+ __entry->op = op->debug_id;
+ __entry->fid = *fid;
+ __entry->index = index;
+ __entry->abort = abort;
+ ),
+
+ TP_printk("OP=%08x[%02x] %llx:%llx:%x a=%d",
+ __entry->op, __entry->index,
+ __entry->fid.vid, __entry->fid.vnode, __entry->fid.unique,
+ __entry->abort)
+ );
+
TRACE_EVENT(afs_cm_no_server,
TP_PROTO(struct afs_call *call, struct sockaddr_rxrpc *srx),
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (7 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 12:38 ` [PATCH 10/10] afs: Fix missing/incorrect unlocking of RCU read lock David Howells
` (2 subsequent siblings)
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Alexander Viro,
Marc Dionne
Remove afs_dynroot_d_revalidate() as it is redundant as all it does is
return 1 and the caller assumes that if the op is not given.
Suggested-by: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/dynroot.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c
index d3bc4a2d7085..c4d2711e20ad 100644
--- a/fs/afs/dynroot.c
+++ b/fs/afs/dynroot.c
@@ -258,16 +258,7 @@ const struct inode_operations afs_dynroot_inode_operations = {
.lookup = afs_dynroot_lookup,
};
-/*
- * Dirs in the dynamic root don't need revalidation.
- */
-static int afs_dynroot_d_revalidate(struct dentry *dentry, unsigned int flags)
-{
- return 1;
-}
-
const struct dentry_operations afs_dynroot_dentry_operations = {
- .d_revalidate = afs_dynroot_d_revalidate,
.d_delete = always_delete_dentry,
.d_release = afs_d_release,
.d_automount = afs_d_automount,
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 10/10] afs: Fix missing/incorrect unlocking of RCU read lock
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (8 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant David Howells
@ 2024-01-22 12:38 ` David Howells
2024-01-22 15:18 ` [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes Christian Brauner
2024-01-22 15:57 ` Jeff Layton
11 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 12:38 UTC (permalink / raw)
To: Christian Brauner
Cc: David Howells, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, kernel test robot
In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both
places before returning (and not lock it again).
Fixes: f94f70d39cc2 ("afs: Provide a way to configure address priorities")
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202401172243.cd53d5f6-oliver.sang@intel.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/proc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index 3bd02571f30d..15eab053af6d 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -166,7 +166,7 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
if (!preflist) {
seq_puts(m, "NO PREFS\n");
- return 0;
+ goto out;
}
seq_printf(m, "PROT SUBNET PRIOR (v=%u n=%u/%u/%u)\n",
@@ -191,7 +191,8 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
}
}
- rcu_read_lock();
+out:
+ rcu_read_unlock();
return 0;
}
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
@ 2024-01-22 13:48 ` Jingbo Xu
2024-01-22 15:27 ` Gao Xiang
2024-01-22 22:01 ` David Howells
2 siblings, 0 replies; 20+ messages in thread
From: Jingbo Xu @ 2024-01-22 13:48 UTC (permalink / raw)
To: David Howells, Christian Brauner
Cc: Jeff Layton, Matthew Wilcox, netfs, linux-afs, linux-cifs,
linux-nfs, ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm,
linux-kernel, Marc Dionne, Gao Xiang, Chao Yu, Yue Hu
On 1/22/24 8:38 PM, David Howells wrote:
> cachefiles_ondemand_init_object() as called from cachefiles_open_file() and
> cachefiles_create_tmpfile() does not check if object->ondemand is set
> before dereferencing it, leading to an oops something like:
>
> RIP: 0010:cachefiles_ondemand_init_object+0x9/0x41
> ...
> Call Trace:
> <TASK>
> cachefiles_open_file+0xc9/0x187
> cachefiles_lookup_cookie+0x122/0x2be
> fscache_cookie_state_machine+0xbe/0x32b
> fscache_cookie_worker+0x1f/0x2d
> process_one_work+0x136/0x208
> process_scheduled_works+0x3a/0x41
> worker_thread+0x1a2/0x1f6
> kthread+0xca/0xd2
> ret_from_fork+0x21/0x33
>
> Fix this by making the calls to cachefiles_ondemand_init_object()
> conditional.
>
> Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object")
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Gao Xiang <xiang@kernel.org>
> cc: Chao Yu <chao@kernel.org>
> cc: Yue Hu <huyue2@coolpad.com>
> cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> cc: linux-erofs@lists.ozlabs.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
> ---
> fs/cachefiles/namei.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
> index 7ade836beb58..180594d24c44 100644
> --- a/fs/cachefiles/namei.c
> +++ b/fs/cachefiles/namei.c
> @@ -473,9 +473,11 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object)
> if (!cachefiles_mark_inode_in_use(object, file_inode(file)))
> WARN_ON(1);
>
> - ret = cachefiles_ondemand_init_object(object);
> - if (ret < 0)
> - goto err_unuse;
> + if (object->ondemand) {
> + ret = cachefiles_ondemand_init_object(object);
> + if (ret < 0)
> + goto err_unuse;
> + }
I'm not sure if object->ondemand shall be checked by the caller or
inside cachefiles_ondemand_init_object(), as
cachefiles_ondemand_clean_object() is also called without checking
object->ondemand. cachefiles_ondemand_clean_object() won't trigger the
NULL oops as the called cachefiles_ondemand_send_req() will actually
checks that.
Anyway this patch looks good to me. Thanks.
Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com>
>
> ni_size = object->cookie->object_size;
> ni_size = round_up(ni_size, CACHEFILES_DIO_BLOCK_SIZE);
> @@ -579,9 +581,11 @@ static bool cachefiles_open_file(struct cachefiles_object *object,
> }
> _debug("file -> %pd positive", dentry);
>
> - ret = cachefiles_ondemand_init_object(object);
> - if (ret < 0)
> - goto error_fput;
> + if (object->ondemand) {
> + ret = cachefiles_ondemand_init_object(object);
> + if (ret < 0)
> + goto error_fput;
> + }
>
> ret = cachefiles_check_auxdata(object, file);
> if (ret < 0)
--
Thanks,
Jingbo
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (9 preceding siblings ...)
2024-01-22 12:38 ` [PATCH 10/10] afs: Fix missing/incorrect unlocking of RCU read lock David Howells
@ 2024-01-22 15:18 ` Christian Brauner
2024-01-23 15:03 ` Christian Brauner
2024-01-22 15:57 ` Jeff Layton
11 siblings, 1 reply; 20+ messages in thread
From: Christian Brauner @ 2024-01-22 15:18 UTC (permalink / raw)
To: David Howells
Cc: Christian Brauner, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel
On Mon, Jan 22, 2024 at 12:38:33PM +0000, David Howells wrote:
> Hi Christian,
>
> Here are some miscellaneous fixes for netfslib and a number of filesystems:
>
> (1) Replace folio_index() with folio->index in netfs, afs and cifs.
>
> (2) Fix an oops in fscache_put_cache().
>
> (3) Fix error handling in netfs_perform_write().
>
> (4) Fix an oops in cachefiles when not using erofs ondemand mode.
>
> (5) In afs, hide silly-rename files from getdents() to avoid problems with
> tar and suchlike.
>
> (6) In afs, fix error handling in lookup with a bulk status fetch.
>
> (7) In afs, afs_dynroot_d_revalidate() is redundant, so remove it.
>
> (8) In afs, fix the RCU unlocking in afs_proc_addr_prefs_show().
>
> The patches can also be found here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-fixes
Thank you! I can pull this in right and will send a pr together with the
other changes around Wednesday/Thursday for -rc2. So reviews before that
would be nice.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
2024-01-22 13:48 ` Jingbo Xu
@ 2024-01-22 15:27 ` Gao Xiang
2024-01-22 22:01 ` David Howells
2 siblings, 0 replies; 20+ messages in thread
From: Gao Xiang @ 2024-01-22 15:27 UTC (permalink / raw)
To: David Howells, Christian Brauner
Cc: Jeff Layton, Matthew Wilcox, netfs, linux-afs, linux-cifs,
linux-nfs, ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm,
linux-kernel, Marc Dionne, Gao Xiang, Chao Yu, Yue Hu, Jeffle Xu
On 2024/1/22 20:38, David Howells wrote:
> cachefiles_ondemand_init_object() as called from cachefiles_open_file() and
> cachefiles_create_tmpfile() does not check if object->ondemand is set
> before dereferencing it, leading to an oops something like:
>
> RIP: 0010:cachefiles_ondemand_init_object+0x9/0x41
> ...
> Call Trace:
> <TASK>
> cachefiles_open_file+0xc9/0x187
> cachefiles_lookup_cookie+0x122/0x2be
> fscache_cookie_state_machine+0xbe/0x32b
> fscache_cookie_worker+0x1f/0x2d
> process_one_work+0x136/0x208
> process_scheduled_works+0x3a/0x41
> worker_thread+0x1a2/0x1f6
> kthread+0xca/0xd2
> ret_from_fork+0x21/0x33
>
> Fix this by making the calls to cachefiles_ondemand_init_object()
> conditional.
>
> Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object")
> Reported-by: Marc Dionne <marc.dionne@auristor.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Gao Xiang <xiang@kernel.org>
> cc: Chao Yu <chao@kernel.org>
> cc: Yue Hu <huyue2@coolpad.com>
> cc: Jeffle Xu <jefflexu@linux.alibaba.com>
> cc: linux-erofs@lists.ozlabs.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
Looks good to me, thanks for fixing this:
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] netfs: Don't use certain internal folio_*() functions
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
@ 2024-01-22 15:38 ` Jeff Layton
2024-01-22 16:10 ` Matthew Wilcox
2024-01-22 17:22 ` David Howells
1 sibling, 1 reply; 20+ messages in thread
From: Jeff Layton @ 2024-01-22 15:38 UTC (permalink / raw)
To: David Howells, Christian Brauner
Cc: Matthew Wilcox, netfs, linux-afs, linux-cifs, linux-nfs,
ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm,
linux-kernel, linux-cachefs
On Mon, 2024-01-22 at 12:38 +0000, David Howells wrote:
> Filesystems should not be using folio->index not folio_index(folio) and
I think you mean "should be" here.
> folio->mapping, not folio_mapping() or folio_file_mapping() in filesystem
> code.
>
> Change this automagically with:
>
> perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
> perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c
> perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/netfs/*.c
>
> Reported-by: Matthew Wilcox <willy@infradead.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: linux-cachefs@redhat.com
> cc: linux-cifs@vger.kernel.org
> cc: linux-erofs@lists.ozlabs.org
> cc: linux-fsdevel@vger.kernel.org
> ---
> fs/netfs/buffered_read.c | 12 ++++++------
> fs/netfs/buffered_write.c | 10 +++++-----
> fs/netfs/io.c | 2 +-
> fs/netfs/misc.c | 2 +-
> 4 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c
> index a59e7b2edaac..3298c29b5548 100644
> --- a/fs/netfs/buffered_read.c
> +++ b/fs/netfs/buffered_read.c
> @@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
> }
>
> if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
> - if (folio_index(folio) == rreq->no_unlock_folio &&
> + if (folio->index == rreq->no_unlock_folio &&
> test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags))
> _debug("no unlock");
> else
> @@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead);
> */
> int netfs_read_folio(struct file *file, struct folio *folio)
> {
> - struct address_space *mapping = folio_file_mapping(folio);
> + struct address_space *mapping = folio->mapping;
> struct netfs_io_request *rreq;
> struct netfs_inode *ctx = netfs_inode(mapping->host);
> struct folio *sink = NULL;
> int ret;
>
> - _enter("%lx", folio_index(folio));
> + _enter("%lx", folio->index);
>
> rreq = netfs_alloc_request(mapping, file,
> folio_file_pos(folio), folio_size(folio),
> @@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
> ret = PTR_ERR(rreq);
> goto error;
> }
> - rreq->no_unlock_folio = folio_index(folio);
> + rreq->no_unlock_folio = folio->index;
> __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
>
> ret = netfs_begin_cache_read(rreq, ctx);
> @@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
> size_t offset, size_t len)
> {
> struct netfs_io_request *rreq;
> - struct address_space *mapping = folio_file_mapping(folio);
> + struct address_space *mapping = folio->mapping;
> struct netfs_inode *ctx = netfs_inode(mapping->host);
> unsigned long long start = folio_pos(folio);
> size_t flen = folio_size(folio);
> @@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
> goto error;
> }
>
> - rreq->no_unlock_folio = folio_index(folio);
> + rreq->no_unlock_folio = folio->index;
> __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
> ret = netfs_begin_cache_read(rreq, ctx);
> if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
> diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c
> index 93dc76f34e39..e7f9ba6fb16b 100644
> --- a/fs/netfs/buffered_write.c
> +++ b/fs/netfs/buffered_write.c
> @@ -343,7 +343,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
> break;
> default:
> WARN(true, "Unexpected modify type %u ix=%lx\n",
> - howto, folio_index(folio));
> + howto, folio->index);
> ret = -EIO;
> goto error_folio_unlock;
> }
> @@ -648,7 +648,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
> xas_for_each(&xas, folio, last) {
> WARN(!folio_test_writeback(folio),
> "bad %zx @%llx page %lx %lx\n",
> - wreq->len, wreq->start, folio_index(folio), last);
> + wreq->len, wreq->start, folio->index, last);
>
> if ((finfo = netfs_folio_info(folio))) {
> /* Streaming writes cannot be redirtied whilst under
> @@ -795,7 +795,7 @@ static void netfs_extend_writeback(struct address_space *mapping,
> continue;
> if (xa_is_value(folio))
> break;
> - if (folio_index(folio) != index) {
> + if (folio->index != index) {
> xas_reset(xas);
> break;
> }
> @@ -901,7 +901,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping,
> long count = wbc->nr_to_write;
> int ret;
>
> - _enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching);
> + _enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching);
>
> wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio),
> NETFS_WRITEBACK);
> @@ -1047,7 +1047,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
>
> start = folio_pos(folio); /* May regress with THPs */
>
> - _debug("wback %lx", folio_index(folio));
> + _debug("wback %lx", folio->index);
>
> /* At this point we hold neither the i_pages lock nor the page lock:
> * the page may be truncated or invalidated (changing page->mapping to
> diff --git a/fs/netfs/io.c b/fs/netfs/io.c
> index 4309edf33862..e8ff1e61ce79 100644
> --- a/fs/netfs/io.c
> +++ b/fs/netfs/io.c
> @@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
> /* We might have multiple writes from the same huge
> * folio, but we mustn't unlock a folio more than once.
> */
> - if (have_unlocked && folio_index(folio) <= unlocked)
> + if (have_unlocked && folio->index <= unlocked)
> continue;
> unlocked = folio_next_index(folio) - 1;
> trace_netfs_folio(folio, netfs_folio_trace_end_copy);
> diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c
> index 0e3af37fc924..90051ced8e2a 100644
> --- a/fs/netfs/misc.c
> +++ b/fs/netfs/misc.c
> @@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)
> struct netfs_folio *finfo = NULL;
> size_t flen = folio_size(folio);
>
> - _enter("{%lx},%zx,%zx", folio_index(folio), offset, length);
> + _enter("{%lx},%zx,%zx", folio->index, offset, length);
>
> folio_wait_fscache(folio);
>
>
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
` (10 preceding siblings ...)
2024-01-22 15:18 ` [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes Christian Brauner
@ 2024-01-22 15:57 ` Jeff Layton
11 siblings, 0 replies; 20+ messages in thread
From: Jeff Layton @ 2024-01-22 15:57 UTC (permalink / raw)
To: David Howells, Christian Brauner
Cc: Matthew Wilcox, netfs, linux-afs, linux-cifs, linux-nfs,
ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm,
linux-kernel
On Mon, 2024-01-22 at 12:38 +0000, David Howells wrote:
> Hi Christian,
>
> Here are some miscellaneous fixes for netfslib and a number of filesystems:
>
> (1) Replace folio_index() with folio->index in netfs, afs and cifs.
>
> (2) Fix an oops in fscache_put_cache().
>
> (3) Fix error handling in netfs_perform_write().
>
> (4) Fix an oops in cachefiles when not using erofs ondemand mode.
>
> (5) In afs, hide silly-rename files from getdents() to avoid problems with
> tar and suchlike.
>
> (6) In afs, fix error handling in lookup with a bulk status fetch.
>
> (7) In afs, afs_dynroot_d_revalidate() is redundant, so remove it.
>
> (8) In afs, fix the RCU unlocking in afs_proc_addr_prefs_show().
>
> The patches can also be found here:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-fixes
>
> Thanks,
> David
>
> Dan Carpenter (2):
> netfs, fscache: Prevent Oops in fscache_put_cache()
> netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write()
>
> David Howells (8):
> netfs: Don't use certain internal folio_*() functions
> afs: Don't use certain internal folio_*() functions
> cifs: Don't use certain internal folio_*() functions
> cachefiles, erofs: Fix NULL deref in when cachefiles is not doing
> ondemand-mode
> afs: Hide silly-rename files from userspace
> afs: Fix error handling with lookup via FS.InlineBulkStatus
> afs: Remove afs_dynroot_d_revalidate() as it is redundant
> afs: Fix missing/incorrect unlocking of RCU read lock
>
> fs/afs/dir.c | 30 ++++++++++++++++++++++--------
> fs/afs/dynroot.c | 9 ---------
> fs/afs/proc.c | 5 +++--
> fs/cachefiles/namei.c | 16 ++++++++++------
> fs/netfs/buffered_read.c | 12 ++++++------
> fs/netfs/buffered_write.c | 15 ++++++++-------
> fs/netfs/fscache_cache.c | 3 ++-
> fs/netfs/io.c | 2 +-
> fs/netfs/misc.c | 2 +-
> fs/smb/client/file.c | 10 +++++-----
> include/trace/events/afs.h | 25 +++++++++++++++++++++++++
> 11 files changed, 83 insertions(+), 46 deletions(-)
>
These all look fine to me. You can add this to the set:
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] netfs: Don't use certain internal folio_*() functions
2024-01-22 15:38 ` Jeff Layton
@ 2024-01-22 16:10 ` Matthew Wilcox
0 siblings, 0 replies; 20+ messages in thread
From: Matthew Wilcox @ 2024-01-22 16:10 UTC (permalink / raw)
To: Jeff Layton
Cc: David Howells, Christian Brauner, netfs, linux-afs, linux-cifs,
linux-nfs, ceph-devel, v9fs, linux-erofs, linux-fsdevel, linux-mm,
linux-kernel, linux-cachefs
On Mon, Jan 22, 2024 at 10:38:58AM -0500, Jeff Layton wrote:
> On Mon, 2024-01-22 at 12:38 +0000, David Howells wrote:
> > Filesystems should not be using folio->index not folio_index(folio) and
>
> I think you mean "should be" here.
Also these are not internal functions! They're just functions that
filesystems shouldn't be using because filesystems are only exposed to
their own folios. The erofs patch used the word "unnecessary", which I
like better (2b872b0f466d).
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 01/10] netfs: Don't use certain internal folio_*() functions
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
2024-01-22 15:38 ` Jeff Layton
@ 2024-01-22 17:22 ` David Howells
1 sibling, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 17:22 UTC (permalink / raw)
To: Jeff Layton
Cc: dhowells, Christian Brauner, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, linux-cachefs
Jeff Layton <jlayton@kernel.org> wrote:
> > Filesystems should not be using folio->index not folio_index(folio) and
>
> I think you mean "should be" here.
Ach. I forgot to update the patch descriptions!
David
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
2024-01-22 13:48 ` Jingbo Xu
2024-01-22 15:27 ` Gao Xiang
@ 2024-01-22 22:01 ` David Howells
2 siblings, 0 replies; 20+ messages in thread
From: David Howells @ 2024-01-22 22:01 UTC (permalink / raw)
To: Jingbo Xu
Cc: dhowells, Christian Brauner, Jeff Layton, Matthew Wilcox, netfs,
linux-afs, linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel, Marc Dionne, Gao Xiang,
Chao Yu, Yue Hu
Jingbo Xu <jefflexu@linux.alibaba.com> wrote:
> > - ret = cachefiles_ondemand_init_object(object);
> > - if (ret < 0)
> > - goto err_unuse;
> > + if (object->ondemand) {
> > + ret = cachefiles_ondemand_init_object(object);
> > + if (ret < 0)
> > + goto err_unuse;
> > + }
>
> I'm not sure if object->ondemand shall be checked by the caller or
> inside cachefiles_ondemand_init_object(), as
> cachefiles_ondemand_clean_object() is also called without checking
> object->ondemand. cachefiles_ondemand_clean_object() won't trigger the
> NULL oops as the called cachefiles_ondemand_send_req() will actually
> checks that.
Meh. The above doesn't actually build if CONFIG_CACHEFILES_ONDEMAND=N. I
think I have to push the check down into cachefiles_ondemand_init_object()
instead.
David
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes
2024-01-22 15:18 ` [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes Christian Brauner
@ 2024-01-23 15:03 ` Christian Brauner
0 siblings, 0 replies; 20+ messages in thread
From: Christian Brauner @ 2024-01-23 15:03 UTC (permalink / raw)
To: David Howells
Cc: Christian Brauner, Jeff Layton, Matthew Wilcox, netfs, linux-afs,
linux-cifs, linux-nfs, ceph-devel, v9fs, linux-erofs,
linux-fsdevel, linux-mm, linux-kernel
On Mon, Jan 22, 2024 at 04:18:08PM +0100, Christian Brauner wrote:
> On Mon, Jan 22, 2024 at 12:38:33PM +0000, David Howells wrote:
> > Hi Christian,
> >
> > Here are some miscellaneous fixes for netfslib and a number of filesystems:
> >
> > (1) Replace folio_index() with folio->index in netfs, afs and cifs.
> >
> > (2) Fix an oops in fscache_put_cache().
> >
> > (3) Fix error handling in netfs_perform_write().
> >
> > (4) Fix an oops in cachefiles when not using erofs ondemand mode.
> >
> > (5) In afs, hide silly-rename files from getdents() to avoid problems with
> > tar and suchlike.
> >
> > (6) In afs, fix error handling in lookup with a bulk status fetch.
> >
> > (7) In afs, afs_dynroot_d_revalidate() is redundant, so remove it.
> >
> > (8) In afs, fix the RCU unlocking in afs_proc_addr_prefs_show().
> >
> > The patches can also be found here:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=netfs-fixes
>
> Thank you! I can pull this in right and will send a pr together with the
> other changes around Wednesday/Thursday for -rc2. So reviews before that
> would be nice.
Pulled and pushed:
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.netfs
Timeline still the same.
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-01-23 15:03 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 12:38 [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes David Howells
2024-01-22 12:38 ` [PATCH 01/10] netfs: Don't use certain internal folio_*() functions David Howells
2024-01-22 15:38 ` Jeff Layton
2024-01-22 16:10 ` Matthew Wilcox
2024-01-22 17:22 ` David Howells
2024-01-22 12:38 ` [PATCH 02/10] afs: " David Howells
2024-01-22 12:38 ` [PATCH 03/10] cifs: " David Howells
2024-01-22 12:38 ` [PATCH 04/10] netfs, fscache: Prevent Oops in fscache_put_cache() David Howells
2024-01-22 12:38 ` [PATCH 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() David Howells
2024-01-22 12:38 ` [PATCH 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode David Howells
2024-01-22 13:48 ` Jingbo Xu
2024-01-22 15:27 ` Gao Xiang
2024-01-22 22:01 ` David Howells
2024-01-22 12:38 ` [PATCH 07/10] afs: Hide silly-rename files from userspace David Howells
2024-01-22 12:38 ` [PATCH 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus David Howells
2024-01-22 12:38 ` [PATCH 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant David Howells
2024-01-22 12:38 ` [PATCH 10/10] afs: Fix missing/incorrect unlocking of RCU read lock David Howells
2024-01-22 15:18 ` [PATCH 00/10] netfs, afs, cifs, cachefiles, erofs: Miscellaneous fixes Christian Brauner
2024-01-23 15:03 ` Christian Brauner
2024-01-22 15:57 ` Jeff Layton
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).