@@ -1448,12 +1448,11 @@ static int follow_dotdot(struct nameidata *nd)
1448
1448
* dir->d_inode->i_mutex must be held
1449
1449
*/
1450
1450
static struct dentry * lookup_dcache (struct qstr * name , struct dentry * dir ,
1451
- unsigned int flags , bool * need_lookup )
1451
+ unsigned int flags )
1452
1452
{
1453
1453
struct dentry * dentry ;
1454
1454
int error ;
1455
1455
1456
- * need_lookup = false;
1457
1456
dentry = d_lookup (dir , name );
1458
1457
if (dentry ) {
1459
1458
if (dentry -> d_flags & DCACHE_OP_REVALIDATE ) {
@@ -1470,14 +1469,6 @@ static struct dentry *lookup_dcache(struct qstr *name, struct dentry *dir,
1470
1469
}
1471
1470
}
1472
1471
}
1473
-
1474
- if (!dentry ) {
1475
- dentry = d_alloc (dir , name );
1476
- if (unlikely (!dentry ))
1477
- return ERR_PTR (- ENOMEM );
1478
-
1479
- * need_lookup = true;
1480
- }
1481
1472
return dentry ;
1482
1473
}
1483
1474
@@ -1509,13 +1500,15 @@ static struct dentry *lookup_real(struct inode *dir, struct dentry *dentry,
1509
1500
static struct dentry * __lookup_hash (struct qstr * name ,
1510
1501
struct dentry * base , unsigned int flags )
1511
1502
{
1512
- bool need_lookup ;
1513
- struct dentry * dentry ;
1503
+ struct dentry * dentry = lookup_dcache (name , base , flags );
1514
1504
1515
- dentry = lookup_dcache (name , base , flags , & need_lookup );
1516
- if (!need_lookup )
1505
+ if (dentry )
1517
1506
return dentry ;
1518
1507
1508
+ dentry = d_alloc (base , name );
1509
+ if (unlikely (!dentry ))
1510
+ return ERR_PTR (- ENOMEM );
1511
+
1519
1512
return lookup_real (base -> d_inode , dentry , flags );
1520
1513
}
1521
1514
@@ -3018,16 +3011,22 @@ static int lookup_open(struct nameidata *nd, struct path *path,
3018
3011
struct inode * dir_inode = dir -> d_inode ;
3019
3012
struct dentry * dentry ;
3020
3013
int error ;
3021
- bool need_lookup ;
3014
+ bool need_lookup = false ;
3022
3015
3023
3016
* opened &= ~FILE_CREATED ;
3024
- dentry = lookup_dcache (& nd -> last , dir , nd -> flags , & need_lookup );
3017
+ dentry = lookup_dcache (& nd -> last , dir , nd -> flags );
3025
3018
if (IS_ERR (dentry ))
3026
3019
return PTR_ERR (dentry );
3027
3020
3028
- /* Cached positive dentry: will open in f_op->open */
3029
- if (!need_lookup && dentry -> d_inode )
3021
+ if (!dentry ) {
3022
+ dentry = d_alloc (dir , & nd -> last );
3023
+ if (unlikely (!dentry ))
3024
+ return - ENOMEM ;
3025
+ need_lookup = true;
3026
+ } else if (dentry -> d_inode ) {
3027
+ /* Cached positive dentry: will open in f_op->open */
3030
3028
goto out_no_open ;
3029
+ }
3031
3030
3032
3031
if ((nd -> flags & LOOKUP_OPEN ) && dir_inode -> i_op -> atomic_open ) {
3033
3032
return atomic_open (nd , dentry , path , file , op , got_write ,
0 commit comments