xfs
[Top] [All Lists]

[PATCH] Don't use hashed dentries when doing open_by_handle

To: xfs-dev@xxxxxxx
Subject: [PATCH] Don't use hashed dentries when doing open_by_handle
From: xaiki@xxxxxxx
Date: Fri, 2 May 2008 11:55:38 +1000
Cc: xfs@xxxxxxxxxxx, Niv Sardi <xaiki@xxxxxxxxxx>, Niv Sardi <xaiki@xxxxxxx>
In-reply-to: <1209693339-4861-1-git-send-email-xaiki@xxxxxxx>
References: <20080501070244.GH108924158@xxxxxxx> <1209693339-4861-1-git-send-email-xaiki@xxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
From: Niv Sardi <xaiki@xxxxxxxxxx>

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@xxxxxxx>
---
 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


<Prev in Thread] Current Thread [Next in Thread>