From mboxrd@z Thu Jan 1 00:00:00 1970 From: hooanon05@yahoo.co.jp Subject: Re: ubifs, race between link and unlink/rename? Date: Tue, 19 May 2009 15:18:34 +0900 Message-ID: <13265.1242713914@jrobl> References: <9917.1242232308@jrobl> <1242380159.27996.230.camel@localhost.localdomain> <1242713370.15206.3.camel@localhost.localdomain> Cc: adrian.hunter@nokia.com, linux-fsdevel@vger.kernel.org To: dedekind@infradead.org Return-path: Received: from mtoichi14.ns.itscom.net ([219.110.2.184]:64197 "EHLO mtoichi14.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751769AbZESGTN (ORCPT ); Tue, 19 May 2009 02:19:13 -0400 In-Reply-To: <1242713370.15206.3.camel@localhost.localdomain> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Artem Bityutskiy: > > Consider a scenario when 'vfs_link(dirA/fileA)' and > > 'vfs_unlink(dirA/fileA, dirB/fileB)' race. 'vfs_link()' does not > > lock 'dirA->i_mutex', so this is possible. Both of the functions ::: > Pushing this patch to ubifs-2.6.git, thanks. Ah, I am late. We need one minor correction. > @@ -528,6 +528,25 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir, > inode->i_nlink, dir->i_ino); > ubifs_assert(mutex_is_locked(&dir->i_mutex)); > ubifs_assert(mutex_is_locked(&inode->i_mutex)); > + > + /* > + * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing > + * otherwise has the potential to corrupt the orphan inode list. > + * > + * Indeed, consider a scenario when 'vfs_link(dirA/fileA)' and > + * 'vfs_unlink(dirA/fileA, dirB/fileB)' race. 'vfs_link()' does not This comment is confusing. Need to swich vfs_unlink and vfs_link. :-) J. R. Okajima