Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753638AbbGXKcF (ORCPT ); Fri, 24 Jul 2015 06:32:05 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:48724 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbbGXKb6 (ORCPT ); Fri, 24 Jul 2015 06:31:58 -0400 X-AuditID: cbfee61a-f79516d000006302-90-55b2141c2d27 From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <00f201d0c468$550aabf0$ff2003d0$@samsung.com> <20150723181522.GB23629@jaegeuk-mac02.mot.com> In-reply-to: <20150723181522.GB23629@jaegeuk-mac02.mot.com> Subject: RE: [PATCH 1/2] f2fs: reorganize __f2fs_add_link Date: Fri, 24 Jul 2015 18:31:16 +0800 Message-id: <006501d0c5fb$f6e12dc0$e4a38940$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQGjLT6tXHA+p/VzdFdl1eBBLjWEkAITz0BbnjR42bA= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsVy+t9jAV0ZkU2hBo035S2erJ/FbHFpkbvF 5V1z2ByYPTat6mTz2L3gM5PH501yAcxRXDYpqTmZZalF+nYJXBkTl69iK1grXzFh7iTWBsbd El2MnBwSAiYSl7sPskLYYhIX7q1n62Lk4hASWMQoce1ED5TzilFix7LfTCBVbAIqEss7/oPZ IgJqEr37poDZzAIeEo0d38EmCQlkSWxc9B0ozsHBKWAt8feeCEhYWMBSYkHfAbASFgFViUl7 lrCB2LxA8b73TSwQtqDEj8n3WCBGakms33kcary8xOY1b5khDlWQ2HH2NSPECVYSh46cYIeo EZfYeOQWywRGoVlIRs1CMmoWklGzkLQsYGRZxSiaWpBcUJyUnmuoV5yYW1yal66XnJ+7iREc 7s+kdjCubLA4xCjAwajEw3tg0sZQIdbEsuLK3EOMEhzMSiK8DMeAQrwpiZVVqUX58UWlOanF hxilOViUxHlP5vuECgmkJ5akZqemFqQWwWSZODilGhjLbi62vFMVlC9Svnc/r1IOL9dbof4l 73OCJ2vnrkzMVLV3zQkoufbx1tvNRnNOf/uWrSazo/Sz75MI5iK/8yGrly2yYrl2USZFYtO9 x+YB6wvnLH594vXP03260cWGLYwrjibU6d5Z4H994sXzXJvYO+LOfrtYknhpxcYWrhk3JxQv +x9YNb1OiaU4I9FQi7moOBEAV26YmnMCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4137 Lines: 126 Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Friday, July 24, 2015 2:15 AM > To: Chao Yu > Cc: linux-f2fs-devel@lists.sourceforge.net; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/2] f2fs: reorganize __f2fs_add_link > > Hi Chao, > > On Wed, Jul 22, 2015 at 06:21:52PM +0800, Chao Yu wrote: > > Firstly, spliting init_inode_metadata into two parts as below since they > > are relatively independent. > > 1) init_inode_metadata: init datas belong to newly created inode; > > 2) update_inode_metadata: update inode info for linking inode to new > > dentry. > > > > Secondly, move init_inode_metadata to the front of __f2fs_add_link, > > So the flow of __f2fs_add_link will be reorganized as: > > 1) init inode meta data for new creatation; > > 2) lookup dentry page and insert new directory entry in the page; > > 3) update meta data of inode and parent. > > > > Signed-off-by: Chao Yu > > --- > > fs/f2fs/dir.c | 129 ++++++++++++++++++++++++++++++++----------------------- > > fs/f2fs/f2fs.h | 4 +- > > fs/f2fs/inline.c | 2 +- > > 3 files changed, 78 insertions(+), 57 deletions(-) > > > > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c > > index a34ebd8..0ad9a1c 100644 > > --- a/fs/f2fs/dir.c > > +++ b/fs/f2fs/dir.c > > @@ -381,43 +381,68 @@ static int make_empty_dir(struct inode *inode, > > return 0; > > } > > > > -struct page *init_inode_metadata(struct inode *inode, struct inode *dir, > > +int init_inode_metadata(struct inode *inode, struct inode *dir, > > const struct qstr *name, struct page *dpage) > > { > > struct page *page; > > int err; > > > > - if (is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) { > > - page = new_inode_page(inode); > > - if (IS_ERR(page)) > > - return page; > > + if (!is_inode_flag_set(F2FS_I(inode), FI_NEW_INODE)) > > + return 0; > > > > - if (S_ISDIR(inode->i_mode)) { > > - err = make_empty_dir(inode, dir, page); > > - if (err) > > - goto error; > > - } > > + page = new_inode_page(inode); > > + if (IS_ERR(page)) > > + return PTR_ERR(page); > > > > - err = f2fs_init_acl(inode, dir, page, dpage); > > + if (S_ISDIR(inode->i_mode)) { > > + err = make_empty_dir(inode, dir, page); > > if (err) > > - goto put_error; > > + goto error; > > + } > > > > - err = f2fs_init_security(inode, dir, name, page); > > + err = f2fs_init_acl(inode, dir, page, dpage); > > + if (err) > > + goto put_error; > > + > > + err = f2fs_init_security(inode, dir, name, page); > > + if (err) > > + goto put_error; > > + > > + if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode)) { > > + err = f2fs_inherit_context(dir, inode, page); > > if (err) > > goto put_error; > > + } > > > > - if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode)) { > > - err = f2fs_inherit_context(dir, inode, page); > > - if (err) > > - goto put_error; > > - } > > - } else { > > - page = get_node_page(F2FS_I_SB(dir), inode->i_ino); > > - if (IS_ERR(page)) > > - return page; > > + if (f2fs_encrypted_inode(dir)) > > + file_set_enc_name(inode); > > + > > + update_inode(inode, page); > > + f2fs_put_page(page, 1); > > We should not put the inode page here. > Since checkpoint can be called and flush all the node pages with valid > NAT entres. Once power-off happens after then, we can see unreachable NAT > entries. IMO, all callers of init_inode_metadata such as __f2fs_add_link/f2fs_do_tmpfile, they are all protected well by cp_rwsem, so checkpoint & SPO will not easily bother us. 1) Lately in __f2fs_add_link, ino of ipage will be inserted into directory entry of parent's inode, this makes our nat entry of ipage reachable. 2) And also in __f2fs_tmpfile, ino will be added in orphan list, so all data resource of the inode will be evicted after CP->SPO->RFR procedure. Is there anything I missed? Thanks, > > Thanks, -- 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/