xfs
[Top] [All Lists]

[PATCH 03/10] stop using igrab in xfs_vn_link

To: xfs@xxxxxxxxxxx
Subject: [PATCH 03/10] stop using igrab in xfs_vn_link
From: Christoph Hellwig <hch@xxxxxx>
Date: Sun, 26 Oct 2008 16:35:59 -0400
Sender: Christoph Hellwig <hch@xxxxxxxxxxxxx>
User-agent: quilt/0.46-1
->link is guranteed to get an already reference inode passed so we
can do a simple increment of i_count instead of using igrab and thus
avoid banging on the global inode_lock.  This is what most filesystems
already do.

Also move the increment after the call to xfs_link to simplify error
handling.

(First sent on July 26th)


Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c
===================================================================
--- linux-2.6-xfs.orig/fs/xfs/linux-2.6/xfs_iops.c      2008-10-25 
13:00:29.000000000 +0200
+++ linux-2.6-xfs/fs/xfs/linux-2.6/xfs_iops.c   2008-10-25 13:13:24.000000000 
+0200
@@ -366,21 +366,18 @@ xfs_vn_link(
        struct inode    *dir,
        struct dentry   *dentry)
 {
-       struct inode    *inode; /* inode of guy being linked to */
+       struct inode    *inode = old_dentry->d_inode;
        struct xfs_name name;
        int             error;
 
-       inode = old_dentry->d_inode;
        xfs_dentry_to_name(&name, dentry);
 
-       igrab(inode);
        error = xfs_link(XFS_I(dir), XFS_I(inode), &name);
-       if (unlikely(error)) {
-               iput(inode);
+       if (unlikely(error))
                return -error;
-       }
 
        xfs_iflags_set(XFS_I(dir), XFS_IMODIFIED);
+       atomic_inc(&inode->i_count);
        d_instantiate(dentry, inode);
        return 0;
 }

-- 

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