public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: xaiki@sgi.com
To: xfs-dev@sgi.com
Cc: xfs@oss.sgi.com, Niv Sardi <xaiki@debian.org>, Niv Sardi <xaiki@sgi.com>
Subject: [PATCH] Don't use hashed dentries when doing open_by_handle
Date: Fri,  2 May 2008 11:55:38 +1000	[thread overview]
Message-ID: <1209693339-4861-2-git-send-email-xaiki@sgi.com> (raw)
In-Reply-To: <1209693339-4861-1-git-send-email-xaiki@sgi.com>

From: Niv Sardi <xaiki@debian.org>

Open by handle only require a handle, but that doesn't give us a file descriptor
that we require for any IO, before we used to call d_alloc_annon() that created
an annonymous disconnected but hashed dentry, from which we extracted the file
descriptor, if no one  else uses the dentry, the dput on fclose should unhash
the dentry and (if not used) tear it appart,

A repported issue is the DMAPI code was, that in some cases (as the dentry was
hashed) another thread could use the same dentry inibiting the unhash on the
first dput, and hence leaving that dentry on the unused list for ever (or untill
caches are dropped).

This cuts down d_alloc_annon to a subset that will only give us an anon
dentry, and NOT hash it.

Signed-off-by: Niv Sardi <xaiki@sgi.com>
---
 fs/xfs/linux-2.6/xfs_ioctl.c |    2 +-
 fs/xfs/linux-2.6/xfs_iops.c  |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 4c82a05..66ed268 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -311,7 +311,7 @@ xfs_open_by_handle(
 		return new_fd;
 	}
 
-	dentry = d_alloc_anon(inode);
+	dentry = xfs_d_alloc_anon(inode);
 	if (dentry == NULL) {
 		iput(inode);
 		put_unused_fd(new_fd);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index cc4abd3..cf5e83f 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -190,6 +190,23 @@ xfs_ichgtime_fast(
 		mark_inode_dirty_sync(inode);
 }
 
+struct dentry *
+xfs_d_alloc_anon(struct inode *inode)
+{
+	static const struct qstr anonstring = { .name = ""};
+	struct dentry	*res;
+
+	res = d_alloc(NULL, &anonstring);
+	if (!res)
+		return NULL;
+
+	/* attach a disconnected dentry */
+	res->d_sb = inode->i_sb;
+	res->d_parent = res;
+	res->d_inode = inode;
+
+	return res;
+}
 
 /*
  * Pull the link count and size up from the xfs inode to the linux inode
-- 
1.5.5.1

  reply	other threads:[~2008-05-02  2:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080501070244.GH108924158@sgi.com>
2008-05-02  1:55 ` Don't use d_alloc_anon for open_by_handle xaiki
2008-05-02  1:55   ` xaiki [this message]
2008-05-02  1:55     ` [PATCH] Use xfs_d_alloc_anon for DM rdwr using handle code xaiki
2008-05-02  6:06   ` Don't use d_alloc_anon for open_by_handle Christoph Hellwig
2008-05-05  6:33     ` Niv Sardi
2008-05-05  9:53       ` Christoph Hellwig
2008-05-05 18:44         ` Christoph Hellwig
2008-05-05 20:51           ` Greg Banks
2008-05-06  1:38           ` Niv Sardi

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=1209693339-4861-2-git-send-email-xaiki@sgi.com \
    --to=xaiki@sgi.com \
    --cc=xaiki@debian.org \
    --cc=xfs-dev@sgi.com \
    --cc=xfs@oss.sgi.com \
    /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