Loading fs/f2fs/data.c +21 −14 Original line number Original line Diff line number Diff line Loading @@ -248,8 +248,23 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index) return err; return err; } } static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs, struct extent_info *ei, struct buffer_head *bh_result) { unsigned int blkbits = sb->s_blocksize_bits; size_t count; set_buffer_new(bh_result); map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs); count = ei->fofs + ei->len - pgofs; if (count < (UINT_MAX >> blkbits)) bh_result->b_size = (count << blkbits); else bh_result->b_size = UINT_MAX; } static int check_extent_cache(struct inode *inode, pgoff_t pgofs, static int check_extent_cache(struct inode *inode, pgoff_t pgofs, struct buffer_head *bh_result) struct extent_info *ei) { { struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode); pgoff_t start_fofs, end_fofs; pgoff_t start_fofs, end_fofs; Loading @@ -271,18 +286,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs, start_blkaddr = fi->ext.blk; start_blkaddr = fi->ext.blk; if (pgofs >= start_fofs && pgofs <= end_fofs) { if (pgofs >= start_fofs && pgofs <= end_fofs) { unsigned int blkbits = inode->i_sb->s_blocksize_bits; *ei = fi->ext; size_t count; set_buffer_new(bh_result); map_bh(bh_result, inode->i_sb, start_blkaddr + pgofs - start_fofs); count = end_fofs - pgofs + 1; if (count < (UINT_MAX >> blkbits)) bh_result->b_size = (count << blkbits); else bh_result->b_size = UINT_MAX; stat_inc_read_hit(inode->i_sb); stat_inc_read_hit(inode->i_sb); read_unlock(&fi->ext_lock); read_unlock(&fi->ext_lock); return 1; return 1; Loading Loading @@ -658,13 +662,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock, int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA; int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA; pgoff_t pgofs, end_offset; pgoff_t pgofs, end_offset; int err = 0, ofs = 1; int err = 0, ofs = 1; struct extent_info ei; bool allocated = false; bool allocated = false; /* Get the page offset from the block offset(iblock) */ /* Get the page offset from the block offset(iblock) */ pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits)); pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits)); if (check_extent_cache(inode, pgofs, bh_result)) if (check_extent_cache(inode, pgofs, &ei)) { f2fs_map_bh(inode->i_sb, pgofs, &ei, bh_result); goto out; goto out; } if (create) if (create) f2fs_lock_op(F2FS_I_SB(inode)); f2fs_lock_op(F2FS_I_SB(inode)); Loading Loading
fs/f2fs/data.c +21 −14 Original line number Original line Diff line number Diff line Loading @@ -248,8 +248,23 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index) return err; return err; } } static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs, struct extent_info *ei, struct buffer_head *bh_result) { unsigned int blkbits = sb->s_blocksize_bits; size_t count; set_buffer_new(bh_result); map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs); count = ei->fofs + ei->len - pgofs; if (count < (UINT_MAX >> blkbits)) bh_result->b_size = (count << blkbits); else bh_result->b_size = UINT_MAX; } static int check_extent_cache(struct inode *inode, pgoff_t pgofs, static int check_extent_cache(struct inode *inode, pgoff_t pgofs, struct buffer_head *bh_result) struct extent_info *ei) { { struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode); pgoff_t start_fofs, end_fofs; pgoff_t start_fofs, end_fofs; Loading @@ -271,18 +286,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs, start_blkaddr = fi->ext.blk; start_blkaddr = fi->ext.blk; if (pgofs >= start_fofs && pgofs <= end_fofs) { if (pgofs >= start_fofs && pgofs <= end_fofs) { unsigned int blkbits = inode->i_sb->s_blocksize_bits; *ei = fi->ext; size_t count; set_buffer_new(bh_result); map_bh(bh_result, inode->i_sb, start_blkaddr + pgofs - start_fofs); count = end_fofs - pgofs + 1; if (count < (UINT_MAX >> blkbits)) bh_result->b_size = (count << blkbits); else bh_result->b_size = UINT_MAX; stat_inc_read_hit(inode->i_sb); stat_inc_read_hit(inode->i_sb); read_unlock(&fi->ext_lock); read_unlock(&fi->ext_lock); return 1; return 1; Loading Loading @@ -658,13 +662,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock, int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA; int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA; pgoff_t pgofs, end_offset; pgoff_t pgofs, end_offset; int err = 0, ofs = 1; int err = 0, ofs = 1; struct extent_info ei; bool allocated = false; bool allocated = false; /* Get the page offset from the block offset(iblock) */ /* Get the page offset from the block offset(iblock) */ pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits)); pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits)); if (check_extent_cache(inode, pgofs, bh_result)) if (check_extent_cache(inode, pgofs, &ei)) { f2fs_map_bh(inode->i_sb, pgofs, &ei, bh_result); goto out; goto out; } if (create) if (create) f2fs_lock_op(F2FS_I_SB(inode)); f2fs_lock_op(F2FS_I_SB(inode)); Loading