Skip to content

Commit

Permalink
f2fs: use is_valid_blkaddr to verify blkaddr for readability
Browse files Browse the repository at this point in the history
Export is_valid_blkaddr() and use it to replace some codes for readability.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed May 7, 2015
1 parent 272e083 commit f0c9cad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
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:
Expand Down
1 change: 1 addition & 0 deletions fs/f2fs/f2fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,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);
Expand Down
6 changes: 3 additions & 3 deletions fs/f2fs/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f0c9cad

Please sign in to comment.