Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932721AbbHHIdw (ORCPT ); Sat, 8 Aug 2015 04:33:52 -0400 Received: from blu004-omc1s5.hotmail.com ([65.55.116.16]:52411 "EHLO BLU004-OMC1S5.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754168AbbHHIdc convert rfc822-to-8bit (ORCPT ); Sat, 8 Aug 2015 04:33:32 -0400 X-TMN: [uLwUZYQodtDxY/EJiNFC2hJnM9/d+gQf] X-Originating-Email: [yuchaochina@hotmail.com] Message-ID: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) Subject: Re: [f2fs-dev] [PATCH] f2fs:Fix concurrent access issues in the function recover_dentry From: Chao Yu In-Reply-To: <1439003569-17358-1-git-send-email-xerofoify@gmail.com> Date: Sat, 8 Aug 2015 16:30:20 +0800 CC: jaegeuk@kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Transfer-Encoding: 8BIT References: <1439003569-17358-1-git-send-email-xerofoify@gmail.com> To: Nicholas Krause X-Mailer: Apple Mail (2.1990.1) X-OriginalArrivalTime: 08 Aug 2015 08:30:28.0001 (UTC) FILETIME=[7AE6D110:01D0D1B4] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2428 Lines: 74 > On Aug 8, 2015, at 11:12 AM, Nicholas Krause wrote: > > This fixes concurrent access issues in the function recover_dentry > by locking and locking another the block labeled retry with the > functions f2fs_lock_op/f2fs_unlock_op on a pointer of the > superblock used by the passed inode structure pointer by this Recovery and checkpoint will block each other with cp_mutex firstly, so f2fs_lock_all in its only caller checkpoint have no chance to race with any f2fs_lock_op in recovery procedure. It’s not needed to call f2fs_lock_op here. Thanks, > > Signed-off-by: Nicholas Krause > --- > fs/f2fs/recovery.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c > index 24a8c1d..b86ea29 100644 > --- a/fs/f2fs/recovery.c > +++ b/fs/f2fs/recovery.c > @@ -70,6 +70,7 @@ static struct fsync_inode_entry *get_fsync_inode(struct list_head *head, > static int recover_dentry(struct inode *inode, struct page *ipage) > { > struct f2fs_inode *raw_inode = F2FS_INODE(ipage); > + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > nid_t pino = le32_to_cpu(raw_inode->i_pino); > struct f2fs_dir_entry *de; > struct qstr name; > @@ -97,6 +98,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage) > goto out_err; > } > retry: > + f2fs_lock_op(sbi); > de = f2fs_find_entry(dir, &name, &page); > if (de && inode->i_ino == le32_to_cpu(de->ino)) > goto out_unmap_put; > @@ -117,6 +119,7 @@ retry: > } > f2fs_delete_entry(de, page, dir, einode); > iput(einode); > + f2fs_unlock_op(sbi); > goto retry; > } > err = __f2fs_add_link(dir, &name, inode, inode->i_ino, inode->i_mode); > @@ -129,7 +132,8 @@ retry: > add_dirty_dir_inode(dir); > set_inode_flag(F2FS_I(dir), FI_DELAY_IPUT); > } > - > + > + f2fs_unlock_op(sbi); > goto out; > > out_unmap_put: > -- > 2.1.4 > > > ------------------------------------------------------------------------------ > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/