Skip to content

Commit 0a7b0ac

Browse files
committed
Merge tag 'vfs-6.9-rc1.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: "This contains a few small fixes for this merge window: - Undo the hiding of silly-rename files in afs. If they're hidden they can't be deleted by rm manually anymore causing regressions - Avoid caching the preferred address for an afs server to avoid accidently overriding an explicitly specified preferred server address - Fix bad stat() and rmdir() interaction in afs - Take a passive reference on the superblock when opening a block device so the holder is available to concurrent callers from the block layer - Clear private data pointer in fscache_begin_operation() to avoid it being falsely treated as valid" * tag 'vfs-6.9-rc1.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fscache: Fix error handling in fscache_begin_operation() fs,block: get holder during claim afs: Fix occasional rmdir-then-VNOVNODE with generic/011 afs: Don't cache preferred address afs: Revert "afs: Hide silly-rename files from userspace"
2 parents 4ae3dc8 + 449ac55 commit 0a7b0ac

File tree

7 files changed

+51
-35
lines changed

7 files changed

+51
-35
lines changed

block/bdev.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ static void bd_finish_claiming(struct block_device *bdev, void *holder,
583583
mutex_unlock(&bdev->bd_holder_lock);
584584
bd_clear_claiming(whole, holder);
585585
mutex_unlock(&bdev_lock);
586+
587+
if (hops && hops->get_holder)
588+
hops->get_holder(holder);
586589
}
587590

588591
/**
@@ -605,6 +608,7 @@ EXPORT_SYMBOL(bd_abort_claiming);
605608
static void bd_end_claim(struct block_device *bdev, void *holder)
606609
{
607610
struct block_device *whole = bdev_whole(bdev);
611+
const struct blk_holder_ops *hops = bdev->bd_holder_ops;
608612
bool unblock = false;
609613

610614
/*
@@ -627,6 +631,9 @@ static void bd_end_claim(struct block_device *bdev, void *holder)
627631
whole->bd_holder = NULL;
628632
mutex_unlock(&bdev_lock);
629633

634+
if (hops && hops->put_holder)
635+
hops->put_holder(holder);
636+
630637
/*
631638
* If this was the last claim, remove holder link and unblock evpoll if
632639
* it was a write holder.

fs/afs/dir.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,6 @@ 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-
ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent);
484-
continue;
485-
}
486-
487477
/* found the next entry */
488478
if (!dir_emit(ctx, dire->u.name, nlen,
489479
ntohl(dire->u.vnode),

fs/afs/rotate.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,16 @@ bool afs_select_fileserver(struct afs_operation *op)
602602
goto wait_for_more_probe_results;
603603

604604
alist = op->estate->addresses;
605+
best_prio = -1;
606+
addr_index = 0;
605607
for (i = 0; i < alist->nr_addrs; i++) {
606608
if (alist->addrs[i].prio > best_prio) {
607609
addr_index = i;
608610
best_prio = alist->addrs[i].prio;
609611
}
610612
}
611613

612-
addr_index = READ_ONCE(alist->preferred);
613-
if (!test_bit(addr_index, &set))
614-
addr_index = __ffs(set);
614+
alist->preferred = addr_index;
615615

616616
op->addr_index = addr_index;
617617
set_bit(addr_index, &op->addr_tried);
@@ -656,12 +656,6 @@ bool afs_select_fileserver(struct afs_operation *op)
656656
next_server:
657657
trace_afs_rotate(op, afs_rotate_trace_next_server, 0);
658658
_debug("next");
659-
ASSERT(op->estate);
660-
alist = op->estate->addresses;
661-
if (op->call_responded &&
662-
op->addr_index != READ_ONCE(alist->preferred) &&
663-
test_bit(alist->preferred, &op->addr_tried))
664-
WRITE_ONCE(alist->preferred, op->addr_index);
665659
op->estate = NULL;
666660
goto pick_server;
667661

@@ -690,14 +684,7 @@ bool afs_select_fileserver(struct afs_operation *op)
690684
failed:
691685
trace_afs_rotate(op, afs_rotate_trace_failed, 0);
692686
op->flags |= AFS_OPERATION_STOP;
693-
if (op->estate) {
694-
alist = op->estate->addresses;
695-
if (op->call_responded &&
696-
op->addr_index != READ_ONCE(alist->preferred) &&
697-
test_bit(alist->preferred, &op->addr_tried))
698-
WRITE_ONCE(alist->preferred, op->addr_index);
699-
op->estate = NULL;
700-
}
687+
op->estate = NULL;
701688
_leave(" = f [failed %d]", afs_op_error(op));
702689
return false;
703690
}

fs/afs/validation.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ bool afs_check_validity(const struct afs_vnode *vnode)
122122
const struct afs_volume *volume = vnode->volume;
123123
time64_t deadline = ktime_get_real_seconds() + 10;
124124

125+
if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
126+
return true;
127+
125128
if (atomic_read(&volume->cb_v_check) != atomic_read(&volume->cb_v_break) ||
126129
atomic64_read(&vnode->cb_expires_at) <= deadline ||
127130
volume->cb_expires_at <= deadline ||
@@ -389,12 +392,17 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
389392
key_serial(key));
390393

391394
if (afs_check_validity(vnode))
392-
return 0;
395+
return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0;
393396

394397
ret = down_write_killable(&vnode->validate_lock);
395398
if (ret < 0)
396399
goto error;
397400

401+
if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
402+
ret = -ESTALE;
403+
goto error_unlock;
404+
}
405+
398406
/* Validate a volume after the v_break has changed or the volume
399407
* callback expired. We only want to do this once per volume per
400408
* v_break change. The actual work will be done when parsing the
@@ -448,12 +456,6 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)
448456
vnode->cb_ro_snapshot = cb_ro_snapshot;
449457
vnode->cb_scrub = cb_scrub;
450458

451-
if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) {
452-
_debug("file already deleted");
453-
ret = -ESTALE;
454-
goto error_unlock;
455-
}
456-
457459
/* if the vnode's data version number changed then its contents are
458460
* different */
459461
zap |= test_and_clear_bit(AFS_VNODE_ZAP_DATA, &vnode->flags);

fs/netfs/fscache_io.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ static int fscache_begin_operation(struct netfs_cache_resources *cres,
8383
cres->debug_id = cookie->debug_id;
8484
cres->inval_counter = cookie->inval_counter;
8585

86-
if (!fscache_begin_cookie_access(cookie, why))
86+
if (!fscache_begin_cookie_access(cookie, why)) {
87+
cres->cache_priv = NULL;
8788
return -ENOBUFS;
89+
}
8890

8991
again:
9092
spin_lock(&cookie->lock);

fs/super.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,11 +1515,29 @@ static int fs_bdev_thaw(struct block_device *bdev)
15151515
return error;
15161516
}
15171517

1518+
static void fs_bdev_super_get(void *data)
1519+
{
1520+
struct super_block *sb = data;
1521+
1522+
spin_lock(&sb_lock);
1523+
sb->s_count++;
1524+
spin_unlock(&sb_lock);
1525+
}
1526+
1527+
static void fs_bdev_super_put(void *data)
1528+
{
1529+
struct super_block *sb = data;
1530+
1531+
put_super(sb);
1532+
}
1533+
15181534
const struct blk_holder_ops fs_holder_ops = {
15191535
.mark_dead = fs_bdev_mark_dead,
15201536
.sync = fs_bdev_sync,
15211537
.freeze = fs_bdev_freeze,
15221538
.thaw = fs_bdev_thaw,
1539+
.get_holder = fs_bdev_super_get,
1540+
.put_holder = fs_bdev_super_put,
15231541
};
15241542
EXPORT_SYMBOL_GPL(fs_holder_ops);
15251543

include/linux/blkdev.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,16 @@ struct blk_holder_ops {
15051505
* Thaw the file system mounted on the block device.
15061506
*/
15071507
int (*thaw)(struct block_device *bdev);
1508+
1509+
/*
1510+
* If needed, get a reference to the holder.
1511+
*/
1512+
void (*get_holder)(void *holder);
1513+
1514+
/*
1515+
* Release the holder.
1516+
*/
1517+
void (*put_holder)(void *holder);
15081518
};
15091519

15101520
/*

0 commit comments

Comments
 (0)