linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Mallon <ryan@bluewatersys.com>
To: viro@zeniv.linux.org.uk, dchinner@redhat.com, Trond.Myklebust@netapp.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-nfs@vger.kernel.org, Ryan Mallon <ryan@bluewatersys.com>
Subject: [RFC PATCH 1/2] Add unlocked version of igrab.
Date: Mon, 28 Mar 2011 14:56:00 +1300	[thread overview]
Message-ID: <1301277361-9453-2-git-send-email-ryan@bluewatersys.com> (raw)
In-Reply-To: <1301277361-9453-1-git-send-email-ryan@bluewatersys.com>

Commit 250df6ed274d767da844a5d9f05720b804240197 "fs: protect
inode->i_state with inode->i_lock" changes igrab to acquire inode->i_lock,
however some callees, notably nfs_inode_add_request, already hold the lock
when calling igrab.

Introduce an unlocked version of igrab called __igrab which can be
called when inode->i_lock is already held.

Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
---
 fs/inode.c         |   16 ++++++++++++----
 include/linux/fs.h |    1 +
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 05a1f75..bdcfbba 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1134,14 +1134,11 @@ ino_t iunique(struct super_block *sb, ino_t max_reserved)
 }
 EXPORT_SYMBOL(iunique);
 
-struct inode *igrab(struct inode *inode)
+struct inode *__igrab(struct inode *inode)
 {
-	spin_lock(&inode->i_lock);
 	if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) {
 		__iget(inode);
-		spin_unlock(&inode->i_lock);
 	} else {
-		spin_unlock(&inode->i_lock);
 		/*
 		 * Handle the case where s_op->clear_inode is not been
 		 * called yet, and somebody is calling igrab
@@ -1149,6 +1146,17 @@ struct inode *igrab(struct inode *inode)
 		 */
 		inode = NULL;
 	}
+
+	return inode;
+}
+EXPORT_SYMBOL(__igrab);
+
+struct inode *igrab(struct inode *inode)
+{
+	spin_lock(&inode->i_lock);
+	inode = __igrab(inode);
+	spin_unlock(&inode->i_lock);
+
 	return inode;
 }
 EXPORT_SYMBOL(igrab);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b677bd7..32c4bc5 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2240,6 +2240,7 @@ extern void inode_init_once(struct inode *);
 extern void address_space_init_once(struct address_space *mapping);
 extern void ihold(struct inode * inode);
 extern void iput(struct inode *);
+extern struct inode *__igrab(struct inode *inode);
 extern struct inode * igrab(struct inode *);
 extern ino_t iunique(struct super_block *, ino_t);
 extern int inode_needs_sync(struct inode *inode);
-- 
1.7.0.4


  reply	other threads:[~2011-03-28  1:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28  1:55 [RFC PATCH 0/2] Introduce unlocked version of igrab Ryan Mallon
2011-03-28  1:56 ` Ryan Mallon [this message]
     [not found]   ` <1301277361-9453-2-git-send-email-ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2011-03-28  2:54     ` [RFC PATCH 1/2] Add " Matthew Wilcox
     [not found]       ` <20110328025423.GN13806-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
2011-03-28  4:39         ` Ryan Mallon
     [not found]           ` <4D9010F1.1040909-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2011-03-28  5:19             ` [PATCH] fs: don't use igrab() while holding i_lock (was Re: [RFC PATCH 1/2] Add unlocked version of igrab.) Dave Chinner
2011-03-28  1:56 ` [RFC PATCH 2/2] Use __igrab instead of igrab in nfs_inode_add_request Ryan Mallon
     [not found] ` <1301277361-9453-1-git-send-email-ryan-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2011-03-28  4:43   ` [RFC PATCH 0/2] Introduce unlocked version of igrab Dave Chinner
2011-03-28  4:47     ` Ryan Mallon
2011-03-28  5:03       ` Ryan Mallon
     [not found]         ` <4D9016B7.1080505-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2011-03-28  6:01           ` Dave Chinner

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=1301277361-9453-2-git-send-email-ryan@bluewatersys.com \
    --to=ryan@bluewatersys.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=dchinner@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.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;
as well as URLs for NNTP newsgroup(s).