Skip to content

Commit a658e0e

Browse files
committed
Merge tag 'vfs-6.8-rc2.netfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull netfs fixes from Christian Brauner: "This contains various fixes for the netfs work merged earlier this cycle: afs: - Fix locking imbalance in afs_proc_addr_prefs_show() - Remove afs_dynroot_d_revalidate() which is redundant - Fix error handling during lookup - Hide sillyrenames from userspace. This fixes a race between silly-rename files being created/removed and userspace iterating over directory entries - Don't use unnecessary folio_*() functions cifs: - Don't use unnecessary folio_*() functions cachefiles: - erofs: Fix Null dereference when cachefiles are not doing ondemand-mode - Update mailing list netfs library: - Add Jeff Layton as reviewer - Update mailing list - Fix a error checking in netfs_perform_write() - fscache: Check error before dereferencing - Don't use unnecessary folio_*() functions" * tag 'vfs-6.8-rc2.netfs' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: afs: Fix missing/incorrect unlocking of RCU read lock afs: Remove afs_dynroot_d_revalidate() as it is redundant afs: Fix error handling with lookup via FS.InlineBulkStatus afs: Hide silly-rename files from userspace cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() netfs, fscache: Prevent Oops in fscache_put_cache() cifs: Don't use certain unnecessary folio_*() functions afs: Don't use certain unnecessary folio_*() functions netfs: Don't use certain unnecessary folio_*() functions netfs: Add Jeff Layton as reviewer netfs, cachefiles: Change mailing list
2 parents b9fa4cb + f13d8f2 commit a658e0e

File tree

12 files changed

+79
-42
lines changed

12 files changed

+79
-42
lines changed

MAINTAINERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ F: drivers/net/ieee802154/ca8210.c
45474547

45484548
CACHEFILES: FS-CACHE BACKEND FOR CACHING ON MOUNTED FILESYSTEMS
45494549
M: David Howells <dhowells@redhat.com>
4550-
L: linux-cachefs@redhat.com (moderated for non-subscribers)
4550+
L: netfs@lists.linux.dev
45514551
S: Supported
45524552
F: Documentation/filesystems/caching/cachefiles.rst
45534553
F: fs/cachefiles/
@@ -8224,7 +8224,8 @@ F: include/linux/iomap.h
82248224

82258225
FILESYSTEMS [NETFS LIBRARY]
82268226
M: David Howells <dhowells@redhat.com>
8227-
L: linux-cachefs@redhat.com (moderated for non-subscribers)
8227+
R: Jeff Layton <jlayton@kernel.org>
8228+
L: netfs@lists.linux.dev
82288229
L: linux-fsdevel@vger.kernel.org
82298230
S: Supported
82308231
F: Documentation/filesystems/caching/

fs/afs/dir.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void afs_dir_read_cleanup(struct afs_read *req)
124124
if (xas_retry(&xas, folio))
125125
continue;
126126
BUG_ON(xa_is_value(folio));
127-
ASSERTCMP(folio_file_mapping(folio), ==, mapping);
127+
ASSERTCMP(folio->mapping, ==, mapping);
128128

129129
folio_put(folio);
130130
}
@@ -202,12 +202,12 @@ static void afs_dir_dump(struct afs_vnode *dvnode, struct afs_read *req)
202202
if (xas_retry(&xas, folio))
203203
continue;
204204

205-
BUG_ON(folio_file_mapping(folio) != mapping);
205+
BUG_ON(folio->mapping != mapping);
206206

207207
size = min_t(loff_t, folio_size(folio), req->actual_len - folio_pos(folio));
208208
for (offset = 0; offset < size; offset += sizeof(*block)) {
209209
block = kmap_local_folio(folio, offset);
210-
pr_warn("[%02lx] %32phN\n", folio_index(folio) + offset, block);
210+
pr_warn("[%02lx] %32phN\n", folio->index + offset, block);
211211
kunmap_local(block);
212212
}
213213
}
@@ -233,7 +233,7 @@ static int afs_dir_check(struct afs_vnode *dvnode, struct afs_read *req)
233233
if (xas_retry(&xas, folio))
234234
continue;
235235

236-
BUG_ON(folio_file_mapping(folio) != mapping);
236+
BUG_ON(folio->mapping != mapping);
237237

238238
if (!afs_dir_check_folio(dvnode, folio, req->actual_len)) {
239239
afs_dir_dump(dvnode, req);
@@ -474,6 +474,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
474474
continue;
475475
}
476476

477+
/* Don't expose silly rename entries to userspace. */
478+
if (nlen > 6 &&
479+
dire->u.name[0] == '.' &&
480+
ctx->actor != afs_lookup_filldir &&
481+
ctx->actor != afs_lookup_one_filldir &&
482+
memcmp(dire->u.name, ".__afs", 6) == 0)
483+
continue;
484+
477485
/* found the next entry */
478486
if (!dir_emit(ctx, dire->u.name, nlen,
479487
ntohl(dire->u.vnode),
@@ -708,6 +716,8 @@ static void afs_do_lookup_success(struct afs_operation *op)
708716
break;
709717
}
710718

719+
if (vp->scb.status.abort_code)
720+
trace_afs_bulkstat_error(op, &vp->fid, i, vp->scb.status.abort_code);
711721
if (!vp->scb.have_status && !vp->scb.have_error)
712722
continue;
713723

@@ -897,12 +907,16 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
897907
afs_begin_vnode_operation(op);
898908
afs_wait_for_operation(op);
899909
}
900-
inode = ERR_PTR(afs_op_error(op));
901910

902911
out_op:
903912
if (!afs_op_error(op)) {
904-
inode = &op->file[1].vnode->netfs.inode;
905-
op->file[1].vnode = NULL;
913+
if (op->file[1].scb.status.abort_code) {
914+
afs_op_accumulate_error(op, -ECONNABORTED,
915+
op->file[1].scb.status.abort_code);
916+
} else {
917+
inode = &op->file[1].vnode->netfs.inode;
918+
op->file[1].vnode = NULL;
919+
}
906920
}
907921

908922
if (op->file[0].scb.have_status)
@@ -2022,7 +2036,7 @@ static bool afs_dir_release_folio(struct folio *folio, gfp_t gfp_flags)
20222036
{
20232037
struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio));
20242038

2025-
_enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio));
2039+
_enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio->index);
20262040

20272041
folio_detach_private(folio);
20282042

fs/afs/dynroot.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,7 @@ const struct inode_operations afs_dynroot_inode_operations = {
258258
.lookup = afs_dynroot_lookup,
259259
};
260260

261-
/*
262-
* Dirs in the dynamic root don't need revalidation.
263-
*/
264-
static int afs_dynroot_d_revalidate(struct dentry *dentry, unsigned int flags)
265-
{
266-
return 1;
267-
}
268-
269261
const struct dentry_operations afs_dynroot_dentry_operations = {
270-
.d_revalidate = afs_dynroot_d_revalidate,
271262
.d_delete = always_delete_dentry,
272263
.d_release = afs_d_release,
273264
.d_automount = afs_d_automount,

fs/afs/proc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
166166

167167
if (!preflist) {
168168
seq_puts(m, "NO PREFS\n");
169-
return 0;
169+
goto out;
170170
}
171171

172172
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)
191191
}
192192
}
193193

194-
rcu_read_lock();
194+
out:
195+
rcu_read_unlock();
195196
return 0;
196197
}
197198

fs/cachefiles/ondemand.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,9 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object)
539539
struct fscache_volume *volume = object->volume->vcookie;
540540
size_t volume_key_size, cookie_key_size, data_len;
541541

542+
if (!object->ondemand)
543+
return 0;
544+
542545
/*
543546
* CacheFiles will firstly check the cache file under the root cache
544547
* directory. If the coherency check failed, it will fallback to

fs/netfs/buffered_read.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
101101
}
102102

103103
if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) {
104-
if (folio_index(folio) == rreq->no_unlock_folio &&
104+
if (folio->index == rreq->no_unlock_folio &&
105105
test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags))
106106
_debug("no unlock");
107107
else
@@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead);
246246
*/
247247
int netfs_read_folio(struct file *file, struct folio *folio)
248248
{
249-
struct address_space *mapping = folio_file_mapping(folio);
249+
struct address_space *mapping = folio->mapping;
250250
struct netfs_io_request *rreq;
251251
struct netfs_inode *ctx = netfs_inode(mapping->host);
252252
struct folio *sink = NULL;
253253
int ret;
254254

255-
_enter("%lx", folio_index(folio));
255+
_enter("%lx", folio->index);
256256

257257
rreq = netfs_alloc_request(mapping, file,
258258
folio_file_pos(folio), folio_size(folio),
@@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
460460
ret = PTR_ERR(rreq);
461461
goto error;
462462
}
463-
rreq->no_unlock_folio = folio_index(folio);
463+
rreq->no_unlock_folio = folio->index;
464464
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
465465

466466
ret = netfs_begin_cache_read(rreq, ctx);
@@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
518518
size_t offset, size_t len)
519519
{
520520
struct netfs_io_request *rreq;
521-
struct address_space *mapping = folio_file_mapping(folio);
521+
struct address_space *mapping = folio->mapping;
522522
struct netfs_inode *ctx = netfs_inode(mapping->host);
523523
unsigned long long start = folio_pos(folio);
524524
size_t flen = folio_size(folio);
@@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio,
535535
goto error;
536536
}
537537

538-
rreq->no_unlock_folio = folio_index(folio);
538+
rreq->no_unlock_folio = folio->index;
539539
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
540540
ret = netfs_begin_cache_read(rreq, ctx);
541541
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)

fs/netfs/buffered_write.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
221221
if (unlikely(fault_in_iov_iter_readable(iter, part) == part))
222222
break;
223223

224-
ret = -ENOMEM;
225224
folio = netfs_grab_folio_for_write(mapping, pos, part);
226-
if (!folio)
225+
if (IS_ERR(folio)) {
226+
ret = PTR_ERR(folio);
227227
break;
228+
}
228229

229230
flen = folio_size(folio);
230231
offset = pos & (flen - 1);
@@ -343,7 +344,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter,
343344
break;
344345
default:
345346
WARN(true, "Unexpected modify type %u ix=%lx\n",
346-
howto, folio_index(folio));
347+
howto, folio->index);
347348
ret = -EIO;
348349
goto error_folio_unlock;
349350
}
@@ -648,7 +649,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq)
648649
xas_for_each(&xas, folio, last) {
649650
WARN(!folio_test_writeback(folio),
650651
"bad %zx @%llx page %lx %lx\n",
651-
wreq->len, wreq->start, folio_index(folio), last);
652+
wreq->len, wreq->start, folio->index, last);
652653

653654
if ((finfo = netfs_folio_info(folio))) {
654655
/* Streaming writes cannot be redirtied whilst under
@@ -795,7 +796,7 @@ static void netfs_extend_writeback(struct address_space *mapping,
795796
continue;
796797
if (xa_is_value(folio))
797798
break;
798-
if (folio_index(folio) != index) {
799+
if (folio->index != index) {
799800
xas_reset(xas);
800801
break;
801802
}
@@ -901,7 +902,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping,
901902
long count = wbc->nr_to_write;
902903
int ret;
903904

904-
_enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching);
905+
_enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching);
905906

906907
wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio),
907908
NETFS_WRITEBACK);
@@ -1047,7 +1048,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping,
10471048

10481049
start = folio_pos(folio); /* May regress with THPs */
10491050

1050-
_debug("wback %lx", folio_index(folio));
1051+
_debug("wback %lx", folio->index);
10511052

10521053
/* At this point we hold neither the i_pages lock nor the page lock:
10531054
* the page may be truncated or invalidated (changing page->mapping to

fs/netfs/fscache_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ EXPORT_SYMBOL(fscache_acquire_cache);
179179
void fscache_put_cache(struct fscache_cache *cache,
180180
enum fscache_cache_trace where)
181181
{
182-
unsigned int debug_id = cache->debug_id;
182+
unsigned int debug_id;
183183
bool zero;
184184
int ref;
185185

186186
if (IS_ERR_OR_NULL(cache))
187187
return;
188188

189+
debug_id = cache->debug_id;
189190
zero = __refcount_dec_and_test(&cache->ref, &ref);
190191
trace_fscache_cache(debug_id, ref - 1, where);
191192

fs/netfs/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
124124
/* We might have multiple writes from the same huge
125125
* folio, but we mustn't unlock a folio more than once.
126126
*/
127-
if (have_unlocked && folio_index(folio) <= unlocked)
127+
if (have_unlocked && folio->index <= unlocked)
128128
continue;
129129
unlocked = folio_next_index(folio) - 1;
130130
trace_netfs_folio(folio, netfs_folio_trace_end_copy);

fs/netfs/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length)
180180
struct netfs_folio *finfo = NULL;
181181
size_t flen = folio_size(folio);
182182

183-
_enter("{%lx},%zx,%zx", folio_index(folio), offset, length);
183+
_enter("{%lx},%zx,%zx", folio->index, offset, length);
184184

185185
folio_wait_fscache(folio);
186186

0 commit comments

Comments
 (0)