Skip to content

Commit 88d8331

Browse files
author
Al Viro
committed
new helper: __lookup_slow()
lookup_slow() sans locking/unlocking the directory Signed-off-by: Al Viro <[email protected]>
1 parent 3c95f0d commit 88d8331

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

fs/namei.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,22 +1593,21 @@ static int lookup_fast(struct nameidata *nd,
15931593
}
15941594

15951595
/* Fast lookup failed, do it the slow way */
1596-
static struct dentry *lookup_slow(const struct qstr *name,
1597-
struct dentry *dir,
1598-
unsigned int flags)
1596+
static struct dentry *__lookup_slow(const struct qstr *name,
1597+
struct dentry *dir,
1598+
unsigned int flags)
15991599
{
1600-
struct dentry *dentry = ERR_PTR(-ENOENT), *old;
1600+
struct dentry *dentry, *old;
16011601
struct inode *inode = dir->d_inode;
16021602
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
16031603

1604-
inode_lock_shared(inode);
16051604
/* Don't go there if it's already dead */
16061605
if (unlikely(IS_DEADDIR(inode)))
1607-
goto out;
1606+
return ERR_PTR(-ENOENT);
16081607
again:
16091608
dentry = d_alloc_parallel(dir, name, &wq);
16101609
if (IS_ERR(dentry))
1611-
goto out;
1610+
return dentry;
16121611
if (unlikely(!d_in_lookup(dentry))) {
16131612
if (!(flags & LOOKUP_NO_REVAL)) {
16141613
int error = d_revalidate(dentry, flags);
@@ -1630,11 +1629,21 @@ static struct dentry *lookup_slow(const struct qstr *name,
16301629
dentry = old;
16311630
}
16321631
}
1633-
out:
1634-
inode_unlock_shared(inode);
16351632
return dentry;
16361633
}
16371634

1635+
static struct dentry *lookup_slow(const struct qstr *name,
1636+
struct dentry *dir,
1637+
unsigned int flags)
1638+
{
1639+
struct inode *inode = dir->d_inode;
1640+
struct dentry *res;
1641+
inode_lock_shared(inode);
1642+
res = __lookup_slow(name, dir, flags);
1643+
inode_unlock_shared(inode);
1644+
return res;
1645+
}
1646+
16381647
static inline int may_lookup(struct nameidata *nd)
16391648
{
16401649
if (nd->flags & LOOKUP_RCU) {

0 commit comments

Comments
 (0)