From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH 1/4] fs: protect inode->i_state with inode->i_lock Date: Wed, 27 Oct 2010 04:58:26 -0400 Message-ID: <20101027085826.GA16443@infradead.org> References: <1288153384-8878-1-git-send-email-david@fromorbit.com> <1288153384-8878-2-git-send-email-david@fromorbit.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: viro@ZenIV.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Dave Chinner Return-path: Content-Disposition: inline In-Reply-To: <1288153384-8878-2-git-send-email-david@fromorbit.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Oct 27, 2010 at 03:23:01PM +1100, Dave Chinner wrote: > spin_lock(&inode_lock); > list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { > - if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) > + spin_lock(&inode->i_lock); > + if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) { > + spin_unlock(&inode->i_lock); > continue; > + } > + spin_unlock(&inode->i_lock); > if (inode->i_mapping->nrpages == 0) > continue; > __iget(inode); If you want to remove inode_lock from the lru scanning later you already need to extend i_lock coverage to include __iget here. Otherwise we could race to mark the inode as I_FREEING or I_WILL_FREE before we grabbed a reference after your patchset.