@@ -1445,7 +1445,8 @@ static int follow_dotdot(struct nameidata *nd)
1445
1445
* allocates a new one if not found or not valid. In the need_lookup argument
1446
1446
* returns whether i_op->lookup is necessary.
1447
1447
*/
1448
- static struct dentry * lookup_dcache (struct qstr * name , struct dentry * dir ,
1448
+ static struct dentry * lookup_dcache (const struct qstr * name ,
1449
+ struct dentry * dir ,
1449
1450
unsigned int flags )
1450
1451
{
1451
1452
struct dentry * dentry ;
@@ -1491,7 +1492,7 @@ static struct dentry *lookup_real(struct inode *dir, struct dentry *dentry,
1491
1492
return dentry ;
1492
1493
}
1493
1494
1494
- static struct dentry * __lookup_hash (struct qstr * name ,
1495
+ static struct dentry * __lookup_hash (const struct qstr * name ,
1495
1496
struct dentry * base , unsigned int flags )
1496
1497
{
1497
1498
struct dentry * dentry = lookup_dcache (name , base , flags );
@@ -1598,21 +1599,15 @@ static int lookup_fast(struct nameidata *nd,
1598
1599
}
1599
1600
1600
1601
/* Fast lookup failed, do it the slow way */
1601
- static int lookup_slow (struct nameidata * nd , struct path * path )
1602
+ static struct dentry * lookup_slow (const struct qstr * name ,
1603
+ struct dentry * dir ,
1604
+ unsigned int flags )
1602
1605
{
1603
- struct dentry * dentry , * parent ;
1604
-
1605
- parent = nd -> path .dentry ;
1606
- BUG_ON (nd -> inode != parent -> d_inode );
1607
-
1608
- inode_lock (parent -> d_inode );
1609
- dentry = __lookup_hash (& nd -> last , parent , nd -> flags );
1610
- inode_unlock (parent -> d_inode );
1611
- if (IS_ERR (dentry ))
1612
- return PTR_ERR (dentry );
1613
- path -> mnt = nd -> path .mnt ;
1614
- path -> dentry = dentry ;
1615
- return follow_managed (path , nd );
1606
+ struct dentry * dentry ;
1607
+ inode_lock (dir -> d_inode );
1608
+ dentry = __lookup_hash (name , dir , flags );
1609
+ inode_unlock (dir -> d_inode );
1610
+ return dentry ;
1616
1611
}
1617
1612
1618
1613
static inline int may_lookup (struct nameidata * nd )
@@ -1719,15 +1714,20 @@ static int walk_component(struct nameidata *nd, int flags)
1719
1714
if (unlikely (err <= 0 )) {
1720
1715
if (err < 0 )
1721
1716
return err ;
1722
-
1723
- err = lookup_slow (nd , & path );
1724
- if (err < 0 )
1717
+ path .dentry = lookup_slow (& nd -> last , nd -> path .dentry ,
1718
+ nd -> flags );
1719
+ if (IS_ERR (path .dentry ))
1720
+ return PTR_ERR (path .dentry );
1721
+ if (unlikely (d_is_negative (path .dentry ))) {
1722
+ dput (path .dentry );
1723
+ return - ENOENT ;
1724
+ }
1725
+ path .mnt = nd -> path .mnt ;
1726
+ err = follow_managed (& path , nd );
1727
+ if (unlikely (err < 0 ))
1725
1728
return err ;
1726
1729
1727
1730
seq = 0 ; /* we are already out of RCU mode */
1728
- err = - ENOENT ;
1729
- if (d_is_negative (path .dentry ))
1730
- goto out_path_put ;
1731
1731
inode = d_backing_inode (path .dentry );
1732
1732
}
1733
1733
@@ -1740,10 +1740,6 @@ static int walk_component(struct nameidata *nd, int flags)
1740
1740
nd -> inode = inode ;
1741
1741
nd -> seq = seq ;
1742
1742
return 0 ;
1743
-
1744
- out_path_put :
1745
- path_to_nameidata (& path , nd );
1746
- return err ;
1747
1743
}
1748
1744
1749
1745
/*
@@ -2350,12 +2346,8 @@ struct dentry *lookup_one_len_unlocked(const char *name,
2350
2346
return ERR_PTR (err );
2351
2347
2352
2348
ret = lookup_dcache (& this , base , 0 );
2353
- if (ret )
2354
- return ret ;
2355
-
2356
- inode_lock (base -> d_inode );
2357
- ret = __lookup_hash (& this , base , 0 );
2358
- inode_unlock (base -> d_inode );
2349
+ if (!ret )
2350
+ ret = lookup_slow (& this , base , 0 );
2359
2351
return ret ;
2360
2352
}
2361
2353
EXPORT_SYMBOL (lookup_one_len_unlocked );
0 commit comments