Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753599AbbBEJpZ (ORCPT ); Thu, 5 Feb 2015 04:45:25 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:41588 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750823AbbBEJpV (ORCPT ); Thu, 5 Feb 2015 04:45:21 -0500 X-AuditID: cbfee61b-f79d76d0000024d6-76-54d33baf1dc9 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: merge {invalidate,release}page for meta/node/data pages Date: Thu, 05 Feb 2015 17:44:29 +0800 Message-id: <006401d04128$7349ad50$59dd07f0$@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: AdBBJ9CEInOyxDX1Rhiy21DzmXYtaw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsVy+t9jQd311pdDDP4sl7W4tq+RyeLJ+lnM FpcWuVtc3jWHzYHFY9OqTjaP3Qs+M3n0bVnF6PF5k1wASxSXTUpqTmZZapG+XQJXxpunXAVP 1Cv2rTjF0sD4W6GLkYNDQsBE4s8Dti5GTiBTTOLCvfVANheHkMB0Ron7M36yQjg/GCV2T2lg AaliE1CRWN7xnwnEFhHwkpi0/wRYnFnAQ6Kx4zsriC0s4CfRe6aPEcRmEVCVuP7sC9gGXgFL iZWN+1ggbEGJH5PvQfVqSazfeZwJwpaX2LzmLTPERQoSO86+ZgQ5VERAT+LtVUeIEnGJjUdu sUxgFJiFZNIsJJNmIZk0C0nLAkaWVYyiqQXJBcVJ6blGesWJucWleel6yfm5mxjB4fxMegfj qgaLQ4wCHIxKPLwW+y6FCLEmlhVX5h5ilOBgVhLh1eS4HCLEm5JYWZValB9fVJqTWnyIUZqD RUmcV8m+LURIID2xJDU7NbUgtQgmy8TBKdXAWPcz30uBSfyv92Veu/TmBerVgeWHr63Ytqn9 bJeAfFiUIIuNwsUNXEfDdlytvOv+vvxAwr+I/8/2+sUtM/Pf0qp/nG2KzoRV3bpKZ5ddOXFo ylqu6H19Yg2vNPevWHfh86vy544zev2+35ss9Nls4v/lOjUf3Fa31DZqLX25fR3/RM/sbQGn w5VYijMSDbWYi4oTATsS6BVjAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5178 Lines: 164 This patch merges ->{invalidate,release}page function for meta/node/data pages. After this, duplication of codes could be removed. Signed-off-by: Chao Yu --- fs/f2fs/checkpoint.c | 24 ++---------------------- fs/f2fs/data.c | 24 ++++++++++++++++-------- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/node.c | 23 ++--------------------- 4 files changed, 22 insertions(+), 51 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 470fa58..31a715b 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -309,32 +309,12 @@ static int f2fs_set_meta_page_dirty(struct page *page) return 0; } -static void f2fs_invalidate_meta_page(struct page *page, unsigned int offset, - unsigned int length) -{ - struct inode *inode = page->mapping->host; - - if (PageDirty(page)) - dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_META); - ClearPagePrivate(page); -} - -static int f2fs_release_meta_page(struct page *page, gfp_t wait) -{ - /* If this is dirty page, keep PagePrivate */ - if (PageDirty(page)) - return 0; - - ClearPagePrivate(page); - return 1; -} - const struct address_space_operations f2fs_meta_aops = { .writepage = f2fs_write_meta_page, .writepages = f2fs_write_meta_pages, .set_page_dirty = f2fs_set_meta_page_dirty, - .invalidatepage = f2fs_invalidate_meta_page, - .releasepage = f2fs_release_meta_page, + .invalidatepage = f2fs_invalidate_page, + .releasepage = f2fs_release_page, }; static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 27dc3fd..d166557 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1115,20 +1115,28 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb, return err; } -static void f2fs_invalidate_data_page(struct page *page, unsigned int offset, - unsigned int length) +void f2fs_invalidate_page(struct page *page, unsigned int offset, + unsigned int length) { struct inode *inode = page->mapping->host; + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - if (offset % PAGE_CACHE_SIZE || length != PAGE_CACHE_SIZE) + if (inode->i_ino >= F2FS_ROOT_INO(sbi) && + (offset % PAGE_CACHE_SIZE || length != PAGE_CACHE_SIZE)) return; - if (PageDirty(page)) - inode_dec_dirty_pages(inode); + if (PageDirty(page)) { + if (inode->i_ino == F2FS_META_INO(sbi)) + dec_page_count(sbi, F2FS_DIRTY_META); + else if (inode->i_ino == F2FS_NODE_INO(sbi)) + dec_page_count(sbi, F2FS_DIRTY_NODES); + else + inode_dec_dirty_pages(inode); + } ClearPagePrivate(page); } -static int f2fs_release_data_page(struct page *page, gfp_t wait) +int f2fs_release_page(struct page *page, gfp_t wait) { /* If this is dirty page, keep PagePrivate */ if (PageDirty(page)) @@ -1183,8 +1191,8 @@ const struct address_space_operations f2fs_dblock_aops = { .write_begin = f2fs_write_begin, .write_end = f2fs_write_end, .set_page_dirty = f2fs_set_data_page_dirty, - .invalidatepage = f2fs_invalidate_data_page, - .releasepage = f2fs_release_data_page, + .invalidatepage = f2fs_invalidate_page, + .releasepage = f2fs_release_page, .direct_IO = f2fs_direct_IO, .bmap = f2fs_bmap, }; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 47a8857..03929dc 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1522,6 +1522,8 @@ struct page *get_lock_data_page(struct inode *, pgoff_t); struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool); int do_write_data_page(struct page *, struct f2fs_io_info *); int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64); +void f2fs_invalidate_page(struct page *, unsigned int, unsigned int); +int f2fs_release_page(struct page *, gfp_t); /* * gc.c diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 9feda38..ea22c32 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1370,25 +1370,6 @@ static int f2fs_set_node_page_dirty(struct page *page) return 0; } -static void f2fs_invalidate_node_page(struct page *page, unsigned int offset, - unsigned int length) -{ - struct inode *inode = page->mapping->host; - if (PageDirty(page)) - dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_NODES); - ClearPagePrivate(page); -} - -static int f2fs_release_node_page(struct page *page, gfp_t wait) -{ - /* If this is dirty page, keep PagePrivate */ - if (PageDirty(page)) - return 0; - - ClearPagePrivate(page); - return 1; -} - /* * Structure of the f2fs node operations */ @@ -1396,8 +1377,8 @@ const struct address_space_operations f2fs_node_aops = { .writepage = f2fs_write_node_page, .writepages = f2fs_write_node_pages, .set_page_dirty = f2fs_set_node_page_dirty, - .invalidatepage = f2fs_invalidate_node_page, - .releasepage = f2fs_release_node_page, + .invalidatepage = f2fs_invalidate_page, + .releasepage = f2fs_release_page, }; static struct free_nid *__lookup_free_nid_list(struct f2fs_nm_info *nm_i, -- 2.2.1 -- 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/