public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dcache: extrace and use d_unlinked()
@ 2009-05-03 23:32 Alexey Dobriyan
  2009-05-08 19:28 ` Serge E. Hallyn
  0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2009-05-03 23:32 UTC (permalink / raw)
  To: akpm, viro; +Cc: linux-kernel, containers

d_unlinked() will be used in middle-term to ban checkpointing when opened
but unlinked file is detected, and in long term, to detect such situation
and special case on it.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/dcache.c            |    7 +++----
 fs/namespace.c         |    8 ++++----
 include/linux/dcache.h |    5 +++++
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index 1fcffeb..86cb34f 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1910,7 +1910,7 @@ char *__d_path(const struct path *path, struct path *root,
 
 	spin_lock(&vfsmount_lock);
 	prepend(&end, &buflen, "\0", 1);
-	if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
+	if (d_unlinked(dentry) &&
 		(prepend(&end, &buflen, " (deleted)", 10) != 0))
 			goto Elong;
 
@@ -2035,7 +2035,7 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen)
 
 	spin_lock(&dcache_lock);
 	prepend(&end, &buflen, "\0", 1);
-	if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
+	if (d_unlinked(dentry) &&
 		(prepend(&end, &buflen, "//deleted", 9) != 0))
 			goto Elong;
 	if (buflen < 1)
@@ -2097,9 +2097,8 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
 	read_unlock(&current->fs->lock);
 
 	error = -ENOENT;
-	/* Has the current directory has been unlinked? */
 	spin_lock(&dcache_lock);
-	if (IS_ROOT(pwd.dentry) || !d_unhashed(pwd.dentry)) {
+	if (!d_unlinked(pwd.dentry)) {
 		unsigned long len;
 		struct path tmp = root;
 		char * cwd;
diff --git a/fs/namespace.c b/fs/namespace.c
index 4119620..b2bd687 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1417,7 +1417,7 @@ static int graft_tree(struct vfsmount *mnt, struct path *path)
 		goto out_unlock;
 
 	err = -ENOENT;
-	if (IS_ROOT(path->dentry) || !d_unhashed(path->dentry))
+	if (!d_unlinked(path->dentry))
 		err = attach_recursive_mnt(mnt, path, NULL);
 out_unlock:
 	mutex_unlock(&path->dentry->d_inode->i_mutex);
@@ -1599,7 +1599,7 @@ static int do_move_mount(struct path *path, char *old_name)
 	if (IS_DEADDIR(path->dentry->d_inode))
 		goto out1;
 
-	if (!IS_ROOT(path->dentry) && d_unhashed(path->dentry))
+	if (d_unlinked(path->dentry))
 		goto out1;
 
 	err = -EINVAL;
@@ -2162,9 +2162,9 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
 	error = -ENOENT;
 	if (IS_DEADDIR(new.dentry->d_inode))
 		goto out2;
-	if (d_unhashed(new.dentry) && !IS_ROOT(new.dentry))
+	if (d_unlinked(new.dentry))
 		goto out2;
-	if (d_unhashed(old.dentry) && !IS_ROOT(old.dentry))
+	if (d_unlinked(old.dentry))
 		goto out2;
 	error = -EBUSY;
 	if (new.mnt == root.mnt ||
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 1515636..f8488bd 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -351,6 +351,11 @@ static inline int d_unhashed(struct dentry *dentry)
 	return (dentry->d_flags & DCACHE_UNHASHED);
 }
 
+static inline int d_unlinked(struct dentry *dentry)
+{
+	return d_unhashed(dentry) && !IS_ROOT(dentry);
+}
+
 static inline struct dentry *dget_parent(struct dentry *dentry)
 {
 	struct dentry *ret;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dcache: extrace and use d_unlinked()
  2009-05-03 23:32 [PATCH] dcache: extrace and use d_unlinked() Alexey Dobriyan
@ 2009-05-08 19:28 ` Serge E. Hallyn
  0 siblings, 0 replies; 2+ messages in thread
From: Serge E. Hallyn @ 2009-05-08 19:28 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: akpm, viro, containers, linux-kernel

Quoting Alexey Dobriyan (adobriyan@gmail.com):
> d_unlinked() will be used in middle-term to ban checkpointing when opened
> but unlinked file is detected, and in long term, to detect such situation
> and special case on it.
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>

Well I see no errors.

Acked-by: Serge Hallyn <serue@us.ibm.com>

Though is it just me, or  do d_unhashed and d_unlinked seem too close to
not end up getting confused at some point?

-serge

> ---
>  fs/dcache.c            |    7 +++----
>  fs/namespace.c         |    8 ++++----
>  include/linux/dcache.h |    5 +++++
>  3 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 1fcffeb..86cb34f 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -1910,7 +1910,7 @@ char *__d_path(const struct path *path, struct path *root,
> 
>  	spin_lock(&vfsmount_lock);
>  	prepend(&end, &buflen, "\0", 1);
> -	if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
> +	if (d_unlinked(dentry) &&
>  		(prepend(&end, &buflen, " (deleted)", 10) != 0))
>  			goto Elong;
> 
> @@ -2035,7 +2035,7 @@ char *dentry_path(struct dentry *dentry, char *buf, int buflen)
> 
>  	spin_lock(&dcache_lock);
>  	prepend(&end, &buflen, "\0", 1);
> -	if (!IS_ROOT(dentry) && d_unhashed(dentry) &&
> +	if (d_unlinked(dentry) &&
>  		(prepend(&end, &buflen, "//deleted", 9) != 0))
>  			goto Elong;
>  	if (buflen < 1)
> @@ -2097,9 +2097,8 @@ SYSCALL_DEFINE2(getcwd, char __user *, buf, unsigned long, size)
>  	read_unlock(&current->fs->lock);
> 
>  	error = -ENOENT;
> -	/* Has the current directory has been unlinked? */
>  	spin_lock(&dcache_lock);
> -	if (IS_ROOT(pwd.dentry) || !d_unhashed(pwd.dentry)) {
> +	if (!d_unlinked(pwd.dentry)) {
>  		unsigned long len;
>  		struct path tmp = root;
>  		char * cwd;
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 4119620..b2bd687 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1417,7 +1417,7 @@ static int graft_tree(struct vfsmount *mnt, struct path *path)
>  		goto out_unlock;
> 
>  	err = -ENOENT;
> -	if (IS_ROOT(path->dentry) || !d_unhashed(path->dentry))
> +	if (!d_unlinked(path->dentry))
>  		err = attach_recursive_mnt(mnt, path, NULL);
>  out_unlock:
>  	mutex_unlock(&path->dentry->d_inode->i_mutex);
> @@ -1599,7 +1599,7 @@ static int do_move_mount(struct path *path, char *old_name)
>  	if (IS_DEADDIR(path->dentry->d_inode))
>  		goto out1;
> 
> -	if (!IS_ROOT(path->dentry) && d_unhashed(path->dentry))
> +	if (d_unlinked(path->dentry))
>  		goto out1;
> 
>  	err = -EINVAL;
> @@ -2162,9 +2162,9 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
>  	error = -ENOENT;
>  	if (IS_DEADDIR(new.dentry->d_inode))
>  		goto out2;
> -	if (d_unhashed(new.dentry) && !IS_ROOT(new.dentry))
> +	if (d_unlinked(new.dentry))
>  		goto out2;
> -	if (d_unhashed(old.dentry) && !IS_ROOT(old.dentry))
> +	if (d_unlinked(old.dentry))
>  		goto out2;
>  	error = -EBUSY;
>  	if (new.mnt == root.mnt ||
> diff --git a/include/linux/dcache.h b/include/linux/dcache.h
> index 1515636..f8488bd 100644
> --- a/include/linux/dcache.h
> +++ b/include/linux/dcache.h
> @@ -351,6 +351,11 @@ static inline int d_unhashed(struct dentry *dentry)
>  	return (dentry->d_flags & DCACHE_UNHASHED);
>  }
> 
> +static inline int d_unlinked(struct dentry *dentry)
> +{
> +	return d_unhashed(dentry) && !IS_ROOT(dentry);
> +}
> +
>  static inline struct dentry *dget_parent(struct dentry *dentry)
>  {
>  	struct dentry *ret;
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-08 19:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-03 23:32 [PATCH] dcache: extrace and use d_unlinked() Alexey Dobriyan
2009-05-08 19:28 ` Serge E. Hallyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox