Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933576AbbLWIBa (ORCPT ); Wed, 23 Dec 2015 03:01:30 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:32926 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933387AbbLWIB3 (ORCPT ); Wed, 23 Dec 2015 03:01:29 -0500 X-AuditID: cbfee61a-f79266d000003652-57-567a54cf8525 From: Chao Yu To: "'Jaegeuk Kim'" Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <1450832388-29118-1-git-send-email-jaegeuk@kernel.org> <1450832388-29118-3-git-send-email-jaegeuk@kernel.org> In-reply-to: <1450832388-29118-3-git-send-email-jaegeuk@kernel.org> Subject: RE: [f2fs-dev] [PATCH 3/4] f2fs: record node block allocation in dnode_of_data Date: Wed, 23 Dec 2015 16:00:36 +0800 Message-id: <010a01d13d58$1b8655a0$529300e0$@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: AQG9bRZC60cJl2SGICHadMcbSzM9lgEMl3vdnvcrgDA= Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRmVeSWpSXmKPExsVy+t9jAd3zIVVhBl1zLSyerJ/FbHFpkbvF nr0nWSwu75rD5sDisWlVJ5vH7gWfmTw+b5ILYI7isklJzcksSy3St0vgythyYjl7wTH5isOv VrA3MM6Q7GLk5JAQMJH4eq+FEcIWk7hwbz1bFyMXh5DAUkaJ1ktrWSCcV4wS725dZAepYhNQ kVje8Z8JxBYRUJPo3TcFzGYWyJSY0P8CrEZIoFpi+5r3rCA2p4CzRNu/TjYQW1ggUmLl5zNg NSwCqhLbf3cB2RwcvAKWEg+2cYGEeQUEJX5MvscCMVJLYv3O41Dj5SU2r3nLDHGogsSOs68Z QVpFBKwkVt/ghCgRl9h45BbLBEahWUgmzUIyaRaSSbOQtCxgZFnFKJFakFxQnJSea5iXWq5X nJhbXJqXrpecn7uJERz8z6R2MB7c5X6IUYCDUYmH16GtMkyINbGsuDL3EKMEB7OSCG/6O6AQ b0piZVVqUX58UWlOavEhRmkOFiVx3tpLkWFCAumJJanZqakFqUUwWSYOTqkGRv/8nhS3S2zr Vkr9mF4habn9b8ERebm1T3M/6Rucz5mi7RAyVebl6pWL1KSjxar51Ps+fbeVqhOM2KPttfmD 0WeZGy0l217Pue1ru9fTZ9Wsg67S2YcOePOx5E/qEZadLvAoQqTl5/3DlVbMx/Q+PHzDs2DC ny13p92e8DPnxpMWtuzTVf/5XJRYijMSDbWYi4oTASFWN5x6AgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4166 Lines: 122 Hi Jaegeuk, > -----Original Message----- > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org] > Sent: Wednesday, December 23, 2015 9:00 AM > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; > linux-f2fs-devel@lists.sourceforge.net > Cc: Jaegeuk Kim > Subject: [f2fs-dev] [PATCH 3/4] f2fs: record node block allocation in dnode_of_data > > This patch introduces recording node block allocation in dnode_of_data. > This information helps to figure out whether any node block is allocated during > specific file operations. > > Signed-off-by: Jaegeuk Kim > --- > fs/f2fs/data.c | 1 + > fs/f2fs/f2fs.h | 1 + > fs/f2fs/file.c | 1 + > fs/f2fs/node.c | 4 ++++ > 4 files changed, 7 insertions(+) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index cf0c9dd..a7a9a05 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -226,6 +226,7 @@ void set_data_blkaddr(struct dnode_of_data *dn) > addr_array = blkaddr_in_node(rn); > addr_array[ofs_in_node] = cpu_to_le32(dn->data_blkaddr); > set_page_dirty(node_page); > + dn->node_changed = true; > } > > int reserve_new_block(struct dnode_of_data *dn) > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 90fb970..0f4d329 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -547,6 +547,7 @@ struct dnode_of_data { > unsigned int ofs_in_node; /* data offset in the node page */ > bool inode_page_locked; /* inode page is locked or not */ Better to add node_changed here to avoid holes generated by compiler due to alignment. > block_t data_blkaddr; /* block address of the node block */ > + bool node_changed; /* is node block changed */ How about reset it in set_new_dnode? > }; > > static inline void set_new_dnode(struct dnode_of_data *dn, struct inode *inode, > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index f2effe1..10ed357 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -484,6 +484,7 @@ int truncate_data_blocks_range(struct dnode_of_data *dn, int count) > dec_valid_block_count(sbi, dn->inode, nr_free); > set_page_dirty(dn->node_page); > sync_inode_page(dn); > + dn->node_changed = true; dn->node_changed should have been set in set_data_blkaddr, so no needed to set here. Thanks, > } > dn->ofs_in_node = ofs; > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c > index 6cc8ac7..ff2acb1 100644 > --- a/fs/f2fs/node.c > +++ b/fs/f2fs/node.c > @@ -542,6 +542,7 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) > > set_nid(parent, offset[i - 1], nids[i], i == 1); > alloc_nid_done(sbi, nids[i]); > + dn->node_changed = true; > done = true; > } else if (mode == LOOKUP_NODE_RA && i == level && level > 1) { > npage[i] = get_node_page_ra(parent, offset[i - 1]); > @@ -678,6 +679,7 @@ static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs, > if (ret < 0) > goto out_err; > set_nid(page, i, 0, false); > + dn->node_changed = true; > } > } else { > child_nofs = nofs + ofs * (NIDS_PER_BLOCK + 1) + 1; > @@ -691,6 +693,7 @@ static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs, > ret = truncate_nodes(&rdn, child_nofs, 0, depth - 1); > if (ret == (NIDS_PER_BLOCK + 1)) { > set_nid(page, i, 0, false); > + dn->node_changed = true; > child_nofs += ret; > } else if (ret < 0 && ret != -ENOENT) { > goto out_err; > @@ -752,6 +755,7 @@ static int truncate_partial_nodes(struct dnode_of_data *dn, > if (err < 0) > goto fail; > set_nid(pages[idx], i, 0, false); > + dn->node_changed = true; > } > > if (offset[idx + 1] == 0) { > -- > 2.5.4 (Apple Git-61) > > > ------------------------------------------------------------------------------ > _______________________________________________ > 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/