mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: jblunck@suse.de, bharata@in.ibm.com, vaurora@redhat.com,
	viro@zeniv.linux.org.uk
Subject: [patch 4/5] union-directory: Make lookup continue in overlayed directories
Date: Thu, 21 May 2009 11:22:35 +0200	[thread overview]
Message-ID: <20090521092251.319505534@szeredi.hu> (raw)
In-Reply-To: <20090521092231.979256687@szeredi.hu>

[-- Attachment #1: union-directory-lookup.diff --]
[-- Type: text/plain, Size: 2450 bytes --]

From: Jan Blunck <jblunck@suse.de>

This patch lets adds support for union-directory lookup to lookups from dentry
cache and real lookups. On union-directories a lookup must continue on
overlayed directories of the union. The lookup continues until the first
no-negative dentry is found. Otherwise the topmost negative dentry is
returned.

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/namei.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2009-05-20 15:05:15.000000000 +0200
+++ linux-2.6/fs/namei.c	2009-05-20 15:10:09.000000000 +0200
@@ -34,6 +34,7 @@
 #include <linux/device_cgroup.h>
 #include <linux/fs_struct.h>
 #include <asm/uaccess.h>
+#include "union.h"
 
 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
 
@@ -778,6 +779,49 @@ static __always_inline void follow_dotdo
 	follow_mount(&nd->path.mnt, &nd->path.dentry);
 }
 
+static int do_lookup_union(struct nameidata *nd, struct qstr *name,
+			   struct path *path)
+{
+	int err;
+	struct path save;
+
+	save = nd->path;
+	path_get(&save);
+	while (follow_union_up(&nd->path)) {
+		struct dentry *dentry;
+
+		dentry = d_hash_and_lookup(nd->path.dentry, name);
+		if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
+			dentry = do_revalidate(dentry, nd);
+			err = PTR_ERR(dentry);
+			if (IS_ERR(dentry))
+				goto out;
+		}
+		if (!dentry) {
+			dentry = real_lookup(nd->path.dentry, name, nd);
+			err = PTR_ERR(dentry);
+			if (IS_ERR(dentry))
+				goto out;
+		}
+		if (dentry->d_inode) {
+			dput(path->dentry);
+			path->dentry = dentry;
+			path->mnt = mntget(nd->path.mnt);
+			follow_mount(&path->mnt, &path->dentry);
+			err = 0;
+			goto out;
+		}
+		dput(dentry);
+	}
+	__follow_mount(path);
+	err = 0;
+out:
+	path_put(&nd->path);
+	nd->path = save;
+
+	return err;
+}
+
 /*
  *  It's more convoluted than I'd like it to be, but... it's still fairly
  *  small and for now I'd prefer to have fast path as straight as possible.
@@ -796,6 +840,11 @@ static int do_lookup(struct nameidata *n
 done:
 	path->mnt = mnt;
 	path->dentry = dentry;
+	if (IS_MNT_UNION(mnt) && !dentry->d_inode &&
+	    nd->path.dentry == nd->path.mnt->mnt_root) {
+		return do_lookup_union(nd, name, path);
+	}
+
 	__follow_mount(path);
 	return 0;
 

--

  parent reply	other threads:[~2009-05-21  9:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-21  9:22 [patch 0/5] union-directory implementation Miklos Szeredi
2009-05-21  9:22 ` [patch 1/5] union-directory: Introduce MNT_UNION and MS_UNION flags Miklos Szeredi
2009-05-21  9:22 ` [patch 2/5] union-directory: Support for traversing the layers of a union-directory Miklos Szeredi
2009-05-21  9:22 ` [patch 3/5] union-directory: Some checks during namespace changes Miklos Szeredi
2009-05-21  9:22 ` Miklos Szeredi [this message]
2009-05-21  9:22 ` [patch 5/5] union-directory: Simple union-mount readdir implementation Miklos Szeredi
2009-05-21  9:56 ` [patch 0/5] union-directory implementation Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090521092251.319505534@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=bharata@in.ibm.com \
    --cc=jblunck@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vaurora@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®