Skip to content

Commit 1d0b929

Browse files
committed
afs: Change dynroot to create contents on demand
Change the AFS dynamic root to do things differently: (1) Rather than having the creation of cell records create inodes and dentries for cell mountpoints, create them on demand during lookup. This simplifies cell management and locking as we no longer have to create these objects in advance *and* on speculative lookup by the user for a cell that isn't precreated. (2) Rather than using the libfs dentry-based readdir (the dentries now no longer exist until accessed from (1)), have readdir generate the contents by reading the list of cells. The @cell symlinks get pushed in positions 2 and 3 if rootcell has been configured. (3) Make the @cell symlink dentries persist for the life of the superblock or until reclaimed, but make cell mountpoints disappear immediately if unused. It's not perfect as someone doing an "ls -l /afs" may create a whole bunch of dentries which will be garbage collected immediately. But any dentry that gets automounted will be pinned by the mount, so it shouldn't be too bad. (4) Allocate the inode numbers for the cell mountpoints from an IDR to prevent duplicates appearing in the event it cycles round. The number allocated from the IDR is doubled to provide two inode numbers - one for the normal cell name (RO) and one for the dotted cell name (RW). 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 Link: https://lore.kernel.org/r/20250224234154.2014840-8-dhowells@redhat.com/ # v1 Link: https://lore.kernel.org/r/20250310094206.801057-4-dhowells@redhat.com/ # v4
1 parent 4c5ad63 commit 1d0b929

6 files changed

Lines changed: 213 additions & 299 deletions

File tree

fs/afs/cell.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ static struct afs_cell *afs_alloc_cell(struct afs_net *net,
204204
cell->dns_status = vllist->status;
205205
smp_store_release(&cell->dns_lookup_count, 1); /* vs source/status */
206206
atomic_inc(&net->cells_outstanding);
207+
ret = idr_alloc_cyclic(&net->cells_dyn_ino, cell,
208+
2, INT_MAX / 2, GFP_KERNEL);
209+
if (ret < 0)
210+
goto error;
211+
cell->dynroot_ino = ret;
207212
cell->debug_id = atomic_inc_return(&cell_debug_id);
213+
208214
trace_afs_cell(cell->debug_id, 1, 0, afs_cell_trace_alloc);
209215

210216
_leave(" = %p", cell);
@@ -513,6 +519,7 @@ static void afs_cell_destroy(struct rcu_head *rcu)
513519
afs_put_vlserverlist(net, rcu_access_pointer(cell->vl_servers));
514520
afs_unuse_cell(net, cell->alias_of, afs_cell_trace_unuse_alias);
515521
key_put(cell->anonymous_key);
522+
idr_remove(&net->cells_dyn_ino, cell->dynroot_ino);
516523
kfree(cell->name - 1);
517524
kfree(cell);
518525

@@ -706,7 +713,6 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell)
706713
if (cell->proc_link.next)
707714
cell->proc_link.next->pprev = &cell->proc_link.next;
708715

709-
afs_dynroot_mkdir(net, cell);
710716
mutex_unlock(&net->proc_cells_lock);
711717
return 0;
712718
}
@@ -723,7 +729,6 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)
723729
mutex_lock(&net->proc_cells_lock);
724730
if (!hlist_unhashed(&cell->proc_link))
725731
hlist_del_rcu(&cell->proc_link);
726-
afs_dynroot_rmdir(net, cell);
727732
mutex_unlock(&net->proc_cells_lock);
728733

729734
_leave("");

0 commit comments

Comments
 (0)