public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: viro@ftp.linux.org.uk, akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Howells <dhowells@redhat.com>
Subject: [PATCH 1/7] cachefiles: use path_get instead of lone dget
Date: Tue, 06 Jul 2010 19:40:29 +0200	[thread overview]
Message-ID: <20100706174049.225684132@szeredi.hu> (raw)
In-Reply-To: 20100706174028.287568350@szeredi.hu

[-- Attachment #1: cachefiles-fix-lone-dentry-ref.patch --]
[-- Type: text/plain, Size: 2510 bytes --]

Dentry references should not be acquired without a corresponding
vfsmount ref.

CC: David Howells <dhowells@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/cachefiles/daemon.c |   26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

Index: linux-2.6/fs/cachefiles/daemon.c
===================================================================
--- linux-2.6.orig/fs/cachefiles/daemon.c	2010-07-05 15:44:37.000000000 +0200
+++ linux-2.6/fs/cachefiles/daemon.c	2010-07-05 15:47:40.000000000 +0200
@@ -553,7 +553,7 @@ static int cachefiles_daemon_tag(struct
 static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
 {
 	struct fs_struct *fs;
-	struct dentry *dir;
+	struct path path;
 	const struct cred *saved_cred;
 	int ret;
 
@@ -575,22 +575,23 @@ static int cachefiles_daemon_cull(struct
 	/* extract the directory dentry from the cwd */
 	fs = current->fs;
 	read_lock(&fs->lock);
-	dir = dget(fs->pwd.dentry);
+	path = fs->pwd;
+	path_get(&path);
 	read_unlock(&fs->lock);
 
-	if (!S_ISDIR(dir->d_inode->i_mode))
+	if (!S_ISDIR(path.dentry->d_inode->i_mode))
 		goto notdir;
 
 	cachefiles_begin_secure(cache, &saved_cred);
-	ret = cachefiles_cull(cache, dir, args);
+	ret = cachefiles_cull(cache, path.dentry, args);
 	cachefiles_end_secure(cache, saved_cred);
 
-	dput(dir);
+	path_put(&path);
 	_leave(" = %d", ret);
 	return ret;
 
 notdir:
-	dput(dir);
+	path_put(&path);
 	kerror("cull command requires dirfd to be a directory");
 	return -ENOTDIR;
 
@@ -629,7 +630,7 @@ inval:
 static int cachefiles_daemon_inuse(struct cachefiles_cache *cache, char *args)
 {
 	struct fs_struct *fs;
-	struct dentry *dir;
+	struct path path;
 	const struct cred *saved_cred;
 	int ret;
 
@@ -651,22 +652,23 @@ static int cachefiles_daemon_inuse(struc
 	/* extract the directory dentry from the cwd */
 	fs = current->fs;
 	read_lock(&fs->lock);
-	dir = dget(fs->pwd.dentry);
+	path = fs->pwd;
+	path_get(&path);
 	read_unlock(&fs->lock);
 
-	if (!S_ISDIR(dir->d_inode->i_mode))
+	if (!S_ISDIR(path.dentry->d_inode->i_mode))
 		goto notdir;
 
 	cachefiles_begin_secure(cache, &saved_cred);
-	ret = cachefiles_check_in_use(cache, dir, args);
+	ret = cachefiles_check_in_use(cache, path.dentry, args);
 	cachefiles_end_secure(cache, saved_cred);
 
-	dput(dir);
+	path_put(&path);
 	//_leave(" = %d", ret);
 	return ret;
 
 notdir:
-	dput(dir);
+	path_put(&path);
 	kerror("inuse command requires dirfd to be a directory");
 	return -ENOTDIR;
 

-- 

  reply	other threads:[~2010-07-06 17:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06 17:40 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-07-06 17:40 ` Miklos Szeredi [this message]
2010-07-06 17:40 ` [PATCH 2/7] vfs: add helpers to get root and pwd Miklos Szeredi
2010-07-06 17:40 ` [PATCH 3/7] ia64: perfmon: add d_dname method Miklos Szeredi
2010-07-06 17:40 ` [PATCH 4/7] vfs: __d_path: dont prepend the name of the root dentry Miklos Szeredi
2010-07-06 17:40 ` [PATCH 5/7] vfs: add prepend_path() helper Miklos Szeredi
2010-07-06 17:40 ` [PATCH 6/7] vfs: only add " (deleted)" where necessary Miklos Szeredi
2010-07-06 17:40 ` [PATCH 7/7] vfs: show unreachable paths in getcwd and proc Miklos Szeredi
     [not found] <20100706172926.065118640@szeredi.hu>
     [not found] ` <20100706172913.165416302@szeredi.hu>
     [not found]   ` <26200.1278439363@redhat.com>
2010-07-06 19:24     ` [PATCH 1/7] cachefiles: use path_get instead of lone dget Miklos Szeredi
  -- strict thread matches above, loose matches on Subject: below --
2010-08-02 11:19 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-08-02 11:19 ` [PATCH 1/7] cachefiles: use path_get instead of lone dget Miklos Szeredi
2010-08-04 10:23   ` David Howells
2010-08-10  9:41 [PATCH 0/7] dcache fixes and cleanups Miklos Szeredi
2010-08-10  9:41 ` [PATCH 1/7] cachefiles: use path_get instead of lone dget 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=20100706174049.225684132@szeredi.hu \
    --to=miklos@szeredi.hu \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ftp.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