Skip to content

Commit b7ab39f

Browse files
author
Nick Piggin
committed
fs: dcache scale dentry refcount
Make d_count non-atomic and protect it with d_lock. This allows us to ensure a 0 refcount dentry remains 0 without dcache_lock. It is also fairly natural when we start protecting many other dentry members with d_lock. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
1 parent 2304450 commit b7ab39f

21 files changed

Lines changed: 126 additions & 69 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static void spufs_prune_dir(struct dentry *dir)
162162
spin_lock(&dcache_lock);
163163
spin_lock(&dentry->d_lock);
164164
if (!(d_unhashed(dentry)) && dentry->d_inode) {
165-
dget_locked(dentry);
165+
dget_locked_dlock(dentry);
166166
__d_drop(dentry);
167167
spin_unlock(&dentry->d_lock);
168168
simple_unlink(dir->d_inode, dentry);

‎drivers/infiniband/hw/ipath/ipath_fs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int remove_file(struct dentry *parent, char *name)
280280
spin_lock(&dcache_lock);
281281
spin_lock(&tmp->d_lock);
282282
if (!(d_unhashed(tmp) && tmp->d_inode)) {
283-
dget_locked(tmp);
283+
dget_locked_dlock(tmp);
284284
__d_drop(tmp);
285285
spin_unlock(&tmp->d_lock);
286286
spin_unlock(&dcache_lock);

‎drivers/infiniband/hw/qib/qib_fs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static int remove_file(struct dentry *parent, char *name)
456456
spin_lock(&dcache_lock);
457457
spin_lock(&tmp->d_lock);
458458
if (!(d_unhashed(tmp) && tmp->d_inode)) {
459-
dget_locked(tmp);
459+
dget_locked_dlock(tmp);
460460
__d_drop(tmp);
461461
spin_unlock(&tmp->d_lock);
462462
spin_unlock(&dcache_lock);

‎fs/autofs4/expire.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static int autofs4_tree_busy(struct vfsmount *mnt,
198198
else
199199
ino_count++;
200200

201-
if (atomic_read(&p->d_count) > ino_count) {
201+
if (p->d_count > ino_count) {
202202
top_ino->last_used = jiffies;
203203
dput(p);
204204
return 1;
@@ -347,7 +347,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
347347

348348
/* Path walk currently on this dentry? */
349349
ino_count = atomic_read(&ino->count) + 2;
350-
if (atomic_read(&dentry->d_count) > ino_count)
350+
if (dentry->d_count > ino_count)
351351
goto next;
352352

353353
/* Can we umount this guy */
@@ -369,7 +369,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
369369
if (!exp_leaves) {
370370
/* Path walk currently on this dentry? */
371371
ino_count = atomic_read(&ino->count) + 1;
372-
if (atomic_read(&dentry->d_count) > ino_count)
372+
if (dentry->d_count > ino_count)
373373
goto next;
374374

375375
if (!autofs4_tree_busy(mnt, dentry, timeout, do_now)) {
@@ -383,7 +383,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
383383
} else {
384384
/* Path walk currently on this dentry? */
385385
ino_count = atomic_read(&ino->count) + 1;
386-
if (atomic_read(&dentry->d_count) > ino_count)
386+
if (dentry->d_count > ino_count)
387387
goto next;
388388

389389
expired = autofs4_check_leaves(mnt, dentry, timeout, do_now);

‎fs/autofs4/root.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
436436
spin_lock(&active->d_lock);
437437

438438
/* Already gone? */
439-
if (atomic_read(&active->d_count) == 0)
439+
if (active->d_count == 0)
440440
goto next;
441441

442442
qstr = &active->d_name;
@@ -452,7 +452,7 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
452452
goto next;
453453

454454
if (d_unhashed(active)) {
455-
dget(active);
455+
dget_dlock(active);
456456
spin_unlock(&active->d_lock);
457457
spin_unlock(&sbi->lookup_lock);
458458
spin_unlock(&dcache_lock);
@@ -507,7 +507,7 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
507507
goto next;
508508

509509
if (d_unhashed(expiring)) {
510-
dget(expiring);
510+
dget_dlock(expiring);
511511
spin_unlock(&expiring->d_lock);
512512
spin_unlock(&sbi->lookup_lock);
513513
spin_unlock(&dcache_lock);

‎fs/ceph/dir.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ static int __dcache_readdir(struct file *filp,
150150
di = ceph_dentry(dentry);
151151
}
152152

153-
atomic_inc(&dentry->d_count);
153+
spin_lock(&dentry->d_lock);
154+
dentry->d_count++;
155+
spin_unlock(&dentry->d_lock);
154156
spin_unlock(&dcache_lock);
155157

156158
dout(" %llu (%llu) dentry %p %.*s %p\n", di->offset, filp->f_pos,

‎fs/ceph/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,8 +879,8 @@ static struct dentry *splice_dentry(struct dentry *dn, struct inode *in,
879879
} else if (realdn) {
880880
dout("dn %p (%d) spliced with %p (%d) "
881881
"inode %p ino %llx.%llx\n",
882-
dn, atomic_read(&dn->d_count),
883-
realdn, atomic_read(&realdn->d_count),
882+
dn, dn->d_count,
883+
realdn, realdn->d_count,
884884
realdn->d_inode, ceph_vinop(realdn->d_inode));
885885
dput(dn);
886886
dn = realdn;

‎fs/ceph/mds_client.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
14861486
*base = ceph_ino(temp->d_inode);
14871487
*plen = len;
14881488
dout("build_path on %p %d built %llx '%.*s'\n",
1489-
dentry, atomic_read(&dentry->d_count), *base, len, path);
1489+
dentry, dentry->d_count, *base, len, path);
14901490
return path;
14911491
}
14921492

‎fs/coda/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static int coda_dentry_revalidate(struct dentry *de, struct nameidata *nd)
559559
if (cii->c_flags & C_FLUSH)
560560
coda_flag_inode_children(inode, C_FLUSH);
561561

562-
if (atomic_read(&de->d_count) > 1)
562+
if (de->d_count > 1)
563563
/* pretend it's valid, but don't change the flags */
564564
goto out;
565565

‎fs/configfs/dir.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,7 @@ static void remove_dir(struct dentry * d)
394394
if (d->d_inode)
395395
simple_rmdir(parent->d_inode,d);
396396

397-
pr_debug(" o %s removing done (%d)\n",d->d_name.name,
398-
atomic_read(&d->d_count));
397+
pr_debug(" o %s removing done (%d)\n",d->d_name.name, d->d_count);
399398

400399
dput(parent);
401400
}

0 commit comments

Comments
 (0)