@@ -1512,40 +1512,37 @@ static struct dentry *__lookup_hash(struct qstr *name,
1512
1512
return lookup_real (base -> d_inode , dentry , flags );
1513
1513
}
1514
1514
1515
- /*
1516
- * It's more convoluted than I'd like it to be, but... it's still fairly
1517
- * small and for now I'd prefer to have fast path as straight as possible.
1518
- * It _is_ time-critical.
1519
- */
1520
1515
static int lookup_fast (struct nameidata * nd ,
1521
1516
struct path * path , struct inode * * inode ,
1522
1517
unsigned * seqp )
1523
1518
{
1524
1519
struct vfsmount * mnt = nd -> path .mnt ;
1525
1520
struct dentry * dentry , * parent = nd -> path .dentry ;
1526
- int need_reval = 1 ;
1527
1521
int status = 1 ;
1528
1522
int err ;
1529
1523
1530
1524
/*
1531
1525
* Rename seqlock is not required here because in the off chance
1532
- * of a false negative due to a concurrent rename, we're going to
1533
- * do the non-racy lookup, below .
1526
+ * of a false negative due to a concurrent rename, the caller is
1527
+ * going to fall back to non-racy lookup.
1534
1528
*/
1535
1529
if (nd -> flags & LOOKUP_RCU ) {
1536
1530
unsigned seq ;
1537
1531
bool negative ;
1538
1532
dentry = __d_lookup_rcu (parent , & nd -> last , & seq );
1539
- if (!dentry )
1540
- goto unlazy ;
1533
+ if (unlikely (!dentry )) {
1534
+ if (unlazy_walk (nd , NULL , 0 ))
1535
+ return - ECHILD ;
1536
+ return 1 ;
1537
+ }
1541
1538
1542
1539
/*
1543
1540
* This sequence count validates that the inode matches
1544
1541
* the dentry name information from lookup.
1545
1542
*/
1546
1543
* inode = d_backing_inode (dentry );
1547
1544
negative = d_is_negative (dentry );
1548
- if (read_seqcount_retry (& dentry -> d_seq , seq ))
1545
+ if (unlikely ( read_seqcount_retry (& dentry -> d_seq , seq ) ))
1549
1546
return - ECHILD ;
1550
1547
1551
1548
/*
@@ -1555,63 +1552,57 @@ static int lookup_fast(struct nameidata *nd,
1555
1552
* The memory barrier in read_seqcount_begin of child is
1556
1553
* enough, we can use __read_seqcount_retry here.
1557
1554
*/
1558
- if (__read_seqcount_retry (& parent -> d_seq , nd -> seq ))
1555
+ if (unlikely ( __read_seqcount_retry (& parent -> d_seq , nd -> seq ) ))
1559
1556
return - ECHILD ;
1560
1557
1561
1558
* seqp = seq ;
1562
- if (unlikely (dentry -> d_flags & DCACHE_OP_REVALIDATE )) {
1559
+ if (unlikely (dentry -> d_flags & DCACHE_OP_REVALIDATE ))
1563
1560
status = d_revalidate (dentry , nd -> flags );
1564
- if (unlikely (status <= 0 )) {
1565
- if (status != - ECHILD )
1566
- need_reval = 0 ;
1567
- goto unlazy ;
1568
- }
1561
+ if (unlikely (status <= 0 )) {
1562
+ if (unlazy_walk (nd , dentry , seq ))
1563
+ return - ECHILD ;
1564
+ if (status == - ECHILD )
1565
+ status = d_revalidate (dentry , nd -> flags );
1566
+ } else {
1567
+ /*
1568
+ * Note: do negative dentry check after revalidation in
1569
+ * case that drops it.
1570
+ */
1571
+ if (unlikely (negative ))
1572
+ return - ENOENT ;
1573
+ path -> mnt = mnt ;
1574
+ path -> dentry = dentry ;
1575
+ if (likely (__follow_mount_rcu (nd , path , inode , seqp )))
1576
+ return 0 ;
1577
+ if (unlazy_walk (nd , dentry , seq ))
1578
+ return - ECHILD ;
1569
1579
}
1570
- /*
1571
- * Note: do negative dentry check after revalidation in
1572
- * case that drops it.
1573
- */
1574
- if (negative )
1575
- return - ENOENT ;
1576
- path -> mnt = mnt ;
1577
- path -> dentry = dentry ;
1578
- if (likely (__follow_mount_rcu (nd , path , inode , seqp )))
1579
- return 0 ;
1580
- unlazy :
1581
- if (unlazy_walk (nd , dentry , seq ))
1582
- return - ECHILD ;
1583
1580
} else {
1584
1581
dentry = __d_lookup (parent , & nd -> last );
1582
+ if (unlikely (!dentry ))
1583
+ return 1 ;
1584
+ if (unlikely (dentry -> d_flags & DCACHE_OP_REVALIDATE ))
1585
+ status = d_revalidate (dentry , nd -> flags );
1585
1586
}
1586
-
1587
- if (unlikely (!dentry ))
1588
- goto need_lookup ;
1589
-
1590
- if (unlikely (dentry -> d_flags & DCACHE_OP_REVALIDATE ) && need_reval )
1591
- status = d_revalidate (dentry , nd -> flags );
1592
1587
if (unlikely (status <= 0 )) {
1593
- if (status < 0 ) {
1594
- dput (dentry );
1595
- return status ;
1588
+ if (! status ) {
1589
+ d_invalidate (dentry );
1590
+ status = 1 ;
1596
1591
}
1597
- d_invalidate (dentry );
1598
1592
dput (dentry );
1599
- goto need_lookup ;
1593
+ return status ;
1600
1594
}
1601
-
1602
1595
if (unlikely (d_is_negative (dentry ))) {
1603
1596
dput (dentry );
1604
1597
return - ENOENT ;
1605
1598
}
1599
+
1606
1600
path -> mnt = mnt ;
1607
1601
path -> dentry = dentry ;
1608
1602
err = follow_managed (path , nd );
1609
1603
if (likely (!err ))
1610
1604
* inode = d_backing_inode (path -> dentry );
1611
1605
return err ;
1612
-
1613
- need_lookup :
1614
- return 1 ;
1615
1606
}
1616
1607
1617
1608
/* Fast lookup failed, do it the slow way */
0 commit comments