[PATCH 01/10] ovl: small optimisation for ovl_lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we find a non-directory in the upper layer, there is no point
performing a lookup in the lower layer as whatever is found will just
be ignored anyway.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---
 fs/overlayfs/overlayfs.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/fs/overlayfs/overlayfs.c b/fs/overlayfs/overlayfs.c
index 0fe3944..0ddfeec 100644
--- a/fs/overlayfs/overlayfs.c
+++ b/fs/overlayfs/overlayfs.c
@@ -495,7 +495,8 @@ static struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 				dput(upperdentry);
 				upperdentry = NULL;
 				ue->opaque = true;
-			}
+			} else if (!S_ISDIR(upperdentry->d_inode->i_mode))
+				ue->opaque = true;
 			revert_creds(old_cred);
 			put_cred(override_cred);
 		}
@@ -507,14 +508,12 @@ static struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
 			dput(upperdentry);
 			goto out_free;
 		}
-	}
-
-	if (lowerdentry && upperdentry &&
-	    (!S_ISDIR(upperdentry->d_inode->i_mode) ||
-	     !S_ISDIR(lowerdentry->d_inode->i_mode))) {
-		dput(lowerdentry);
-		lowerdentry = NULL;
-		ue->opaque = true;
+		if (lowerdentry && upperdentry &&
+		    !S_ISDIR(lowerdentry->d_inode->i_mode)) {
+			dput(lowerdentry);
+			lowerdentry = NULL;
+			ue->opaque = true;
+		}
 	}
 
 	if (lowerdentry || upperdentry) {


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux