Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752512AbbDRKGV (ORCPT ); Sat, 18 Apr 2015 06:06:21 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:12344 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752087AbbDRKGT (ORCPT ); Sat, 18 Apr 2015 06:06:19 -0400 X-AuditID: cbfee61a-f79516d000006302-6c-55322c9a15c2 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] f2fs: use is_valid_blkaddr to verify blkaddr for readability Date: Sat, 18 Apr 2015 18:05:36 +0800 Message-id: <007c01d079bf$4e436b20$eaca4160$@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: AdB5vw2c8Lvo9rhlSk6/3u+fixy0Uw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t9jAd1ZOkahBu9niVpc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoEr4/qS3ywF v4Uqtj85wdLAeJy/i5GDQ0LARGLBPOcuRk4gU0ziwr31bF2MXBxCAosYJbbevcECkhASeMUo 0b6nCMRmE1CRWN7xnwnEFhHwkpi0/wRYDbOAh0Rjx3dWEFtYIFhiwdl9YDaLgKrEtuWLwep5 BSwldrz8xQZhC0r8mHwPqldLYv3O40wQtrzE5jVvmSEOUpDYcfY1I8QuPYm1s18wQtSIS2w8 cotlAqPALCSjZiEZNQvJqFlIWhYwsqxiFE0tSC4oTkrPNdQrTswtLs1L10vOz93ECA7oZ1I7 GFc2WBxiFOBgVOLhvfHaMFSINbGsuDL3EKMEB7OSCO9GBaNQId6UxMqq1KL8+KLSnNTiQ4zS HCxK4rxzdOVChQTSE0tSs1NTC1KLYLJMHJxSDYylb5ctjpg8RWGNrjlD27pHi5UVl1WvUC8M +rMqecuLZrnzu7bo2l9rsDZ89PDcf5vkxAhVh+91UwJXsTpk5sdUKP1dlf7C5EfgMZUzKb+c JyZ/NfNNnxPaVe/7RXv23kTbXKPieVfNs9kTBRa+yH+v6XLpV/ICyfIJfsJrTnbOMdwve89/ P4sSS3FGoqEWc1FxIgB8bufbZAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2602 Lines: 75 Export is_valid_blkaddr() and use it to replace some codes for readability. Signed-off-by: Chao Yu --- fs/f2fs/checkpoint.c | 3 +-- fs/f2fs/f2fs.h | 1 + fs/f2fs/recovery.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index a5e17a2..72f64b3 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -77,8 +77,7 @@ out: return page; } -static inline bool is_valid_blkaddr(struct f2fs_sb_info *sbi, - block_t blkaddr, int type) +bool is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type) { switch (type) { case META_NAT: diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c06a25e..5cf7e9f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1580,6 +1580,7 @@ void destroy_segment_manager_caches(void); */ struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); +bool is_valid_blkaddr(struct f2fs_sb_info *, block_t, int); int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int); void ra_meta_pages_cond(struct f2fs_sb_info *, pgoff_t); long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 8d8ea99..b80d9d4 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -174,7 +174,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head) while (1) { struct fsync_inode_entry *entry; - if (blkaddr < MAIN_BLKADDR(sbi) || blkaddr >= MAX_BLKADDR(sbi)) + if (!is_valid_blkaddr(sbi, blkaddr, META_POR)) return 0; page = get_meta_page(sbi, blkaddr); @@ -396,7 +396,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, dest = datablock_addr(page, dn.ofs_in_node); if (src != dest && dest != NEW_ADDR && dest != NULL_ADDR && - dest >= MAIN_BLKADDR(sbi) && dest < MAX_BLKADDR(sbi)) { + is_valid_blkaddr(sbi, dest, META_POR)) { if (src == NULL_ADDR) { err = reserve_new_block(&dn); @@ -454,7 +454,7 @@ static int recover_data(struct f2fs_sb_info *sbi, while (1) { struct fsync_inode_entry *entry; - if (blkaddr < MAIN_BLKADDR(sbi) || blkaddr >= MAX_BLKADDR(sbi)) + if (!is_valid_blkaddr(sbi, blkaddr, META_POR)) break; ra_meta_pages_cond(sbi, blkaddr); -- 2.3.3 -- 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/