Skip to content

Commit 499aa1c

Browse files
committed
Merge tag 'pull-dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull dcache updates from Al Viro: "Change of locking rules for __dentry_kill(), regularized refcounting rules in that area, assorted cleanups and removal of weird corner cases (e.g. now ->d_iput() on child is always called before the parent might hit __dentry_kill(), etc)" * tag 'pull-dcache' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (40 commits) dcache: remove unnecessary NULL check in dget_dlock() kill DCACHE_MAY_FREE __d_unalias() doesn't use inode argument d_alloc_parallel(): in-lookup hash insertion doesn't need an RCU variant get rid of DCACHE_GENOCIDE d_genocide(): move the extern into fs/internal.h simple_fill_super(): don't bother with d_genocide() on failure nsfs: use d_make_root() d_alloc_pseudo(): move setting ->d_op there from the (sole) caller kill d_instantate_anon(), fold __d_instantiate_anon() into remaining caller retain_dentry(): introduce a trimmed-down lockless variant __dentry_kill(): new locking scheme d_prune_aliases(): use a shrink list switch select_collect{,2}() to use of to_shrink_list() to_shrink_list(): call only if refcount is 0 fold dentry_kill() into dput() don't try to cut corners in shrink_lock_dentry() fold the call of retain_dentry() into fast_dput() Call retain_dentry() with refcount 0 dentry_kill(): don't bother with retain_dentry() on slow path ...
2 parents bf4e708 + 1b6ae9f commit 499aa1c

File tree

17 files changed

+425
-657
lines changed

17 files changed

+425
-657
lines changed

Documentation/filesystems/porting.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,40 @@ would need to do so.
10911091

10921092
---
10931093

1094+
**mandatory**
1095+
1096+
The list of children anchored in parent dentry got turned into hlist now.
1097+
Field names got changed (->d_children/->d_sib instead of ->d_subdirs/->d_child
1098+
for anchor/entries resp.), so any affected places will be immediately caught
1099+
by compiler.
1100+
1101+
---
1102+
1103+
**mandatory**
1104+
1105+
->d_delete() instances are now called for dentries with ->d_lock held
1106+
and refcount equal to 0. They are not permitted to drop/regain ->d_lock.
1107+
None of in-tree instances did anything of that sort. Make sure yours do not...
1108+
1109+
---
1110+
1111+
**mandatory**
1112+
1113+
->d_prune() instances are now called without ->d_lock held on the parent.
1114+
->d_lock on dentry itself is still held; if you need per-parent exclusions (none
1115+
of the in-tree instances did), use your own spinlock.
1116+
1117+
->d_iput() and ->d_release() are called with victim dentry still in the
1118+
list of parent's children. It is still unhashed, marked killed, etc., just not
1119+
removed from parent's ->d_children yet.
1120+
1121+
Anyone iterating through the list of children needs to be aware of the
1122+
half-killed dentries that might be seen there; taking ->d_lock on those will
1123+
see them negative, unhashed and with negative refcount, which means that most
1124+
of the in-kernel users would've done the right thing anyway without any adjustment.
1125+
1126+
---
1127+
10941128
**recommended**
10951129

10961130
Block device freezing and thawing have been moved to holder operations.

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ spufs_evict_inode(struct inode *inode)
145145

146146
static void spufs_prune_dir(struct dentry *dir)
147147
{
148-
struct dentry *dentry, *tmp;
148+
struct dentry *dentry;
149+
struct hlist_node *n;
149150

150151
inode_lock(d_inode(dir));
151-
list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_child) {
152+
hlist_for_each_entry_safe(dentry, n, &dir->d_children, d_sib) {
152153
spin_lock(&dentry->d_lock);
153154
if (simple_positive(dentry)) {
154155
dget_dlock(dentry);

fs/afs/dynroot.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ int afs_dynroot_populate(struct super_block *sb)
373373
void afs_dynroot_depopulate(struct super_block *sb)
374374
{
375375
struct afs_net *net = afs_sb2net(sb);
376-
struct dentry *root = sb->s_root, *subdir, *tmp;
376+
struct dentry *root = sb->s_root, *subdir;
377377

378378
/* Prevent more subdirs from being created */
379379
mutex_lock(&net->proc_cells_lock);
@@ -382,10 +382,11 @@ void afs_dynroot_depopulate(struct super_block *sb)
382382
mutex_unlock(&net->proc_cells_lock);
383383

384384
if (root) {
385+
struct hlist_node *n;
385386
inode_lock(root->d_inode);
386387

387388
/* Remove all the pins for dirs created for manually added cells */
388-
list_for_each_entry_safe(subdir, tmp, &root->d_subdirs, d_child) {
389+
hlist_for_each_entry_safe(subdir, n, &root->d_children, d_sib) {
389390
if (subdir->d_fsdata) {
390391
subdir->d_fsdata = NULL;
391392
dput(subdir);

fs/autofs/expire.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,9 @@ static int autofs_mount_busy(struct vfsmount *mnt,
7373
/* p->d_lock held */
7474
static struct dentry *positive_after(struct dentry *p, struct dentry *child)
7575
{
76-
if (child)
77-
child = list_next_entry(child, d_child);
78-
else
79-
child = list_first_entry(&p->d_subdirs, struct dentry, d_child);
76+
child = child ? d_next_sibling(child) : d_first_child(p);
8077

81-
list_for_each_entry_from(child, &p->d_subdirs, d_child) {
78+
hlist_for_each_entry_from(child, d_sib) {
8279
spin_lock_nested(&child->d_lock, DENTRY_D_LOCK_NESTED);
8380
if (simple_positive(child)) {
8481
dget_dlock(child);

fs/ceph/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ __dcache_find_get_entry(struct dentry *parent, u64 idx,
174174
/*
175175
* When possible, we try to satisfy a readdir by peeking at the
176176
* dcache. We make this work by carefully ordering dentries on
177-
* d_child when we initially get results back from the MDS, and
177+
* d_children when we initially get results back from the MDS, and
178178
* falling back to a "normal" sync readdir if any dentries in the dir
179179
* are dropped.
180180
*

fs/ceph/mds_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ static bool drop_negative_children(struct dentry *dentry)
21282128
goto out;
21292129

21302130
spin_lock(&dentry->d_lock);
2131-
list_for_each_entry(child, &dentry->d_subdirs, d_child) {
2131+
hlist_for_each_entry(child, &dentry->d_children, d_sib) {
21322132
if (d_really_is_positive(child)) {
21332133
all_negative = false;
21342134
break;

fs/coda/cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ static void coda_flag_children(struct dentry *parent, int flag)
9393
struct dentry *de;
9494

9595
spin_lock(&parent->d_lock);
96-
list_for_each_entry(de, &parent->d_subdirs, d_child) {
96+
hlist_for_each_entry(de, &parent->d_children, d_sib) {
97+
struct inode *inode = d_inode_rcu(de);
9798
/* don't know what to do with negative dentries */
98-
if (d_inode(de) )
99-
coda_flag_inode(d_inode(de), flag);
99+
if (inode)
100+
coda_flag_inode(inode, flag);
100101
}
101102
spin_unlock(&parent->d_lock);
102-
return;
103103
}
104104

105105
void coda_flag_inode_children(struct inode *inode, int flag)

0 commit comments

Comments
 (0)