@@ -1819,16 +1819,6 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len)
18191819 return true;
18201820}
18211821
1822- static inline u64 bytes_to_blks (struct inode * inode , u64 bytes )
1823- {
1824- return (bytes >> inode -> i_blkbits );
1825- }
1826-
1827- static inline u64 blks_to_bytes (struct inode * inode , u64 blks )
1828- {
1829- return (blks << inode -> i_blkbits );
1830- }
1831-
18321822static int f2fs_xattr_fiemap (struct inode * inode ,
18331823 struct fiemap_extent_info * fieinfo )
18341824{
@@ -1854,7 +1844,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
18541844 return err ;
18551845 }
18561846
1857- phys = blks_to_bytes ( inode , ni .blk_addr );
1847+ phys = F2FS_BLK_TO_BYTES ( ni .blk_addr );
18581848 offset = offsetof(struct f2fs_inode , i_addr ) +
18591849 sizeof (__le32 ) * (DEF_ADDRS_PER_INODE -
18601850 get_inline_xattr_addrs (inode ));
@@ -1886,7 +1876,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
18861876 return err ;
18871877 }
18881878
1889- phys = blks_to_bytes ( inode , ni .blk_addr );
1879+ phys = F2FS_BLK_TO_BYTES ( ni .blk_addr );
18901880 len = inode -> i_sb -> s_blocksize ;
18911881
18921882 f2fs_put_page (page , 1 );
@@ -1948,16 +1938,16 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
19481938 goto out ;
19491939 }
19501940
1951- if (bytes_to_blks ( inode , len ) == 0 )
1952- len = blks_to_bytes ( inode , 1 ) ;
1941+ if (F2FS_BYTES_TO_BLK ( len ) == 0 )
1942+ len = F2FS_BLKSIZE ;
19531943
1954- start_blk = bytes_to_blks ( inode , start );
1955- last_blk = bytes_to_blks ( inode , start + len - 1 );
1944+ start_blk = F2FS_BYTES_TO_BLK ( start );
1945+ last_blk = F2FS_BYTES_TO_BLK ( start + len - 1 );
19561946
19571947next :
19581948 memset (& map , 0 , sizeof (map ));
19591949 map .m_lblk = start_blk ;
1960- map .m_len = bytes_to_blks ( inode , len );
1950+ map .m_len = F2FS_BYTES_TO_BLK ( len );
19611951 map .m_next_pgofs = & next_pgofs ;
19621952 map .m_seg_type = NO_CHECK_TYPE ;
19631953
@@ -1974,7 +1964,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
19741964 if (!compr_cluster && !(map .m_flags & F2FS_MAP_FLAGS )) {
19751965 start_blk = next_pgofs ;
19761966
1977- if (blks_to_bytes ( inode , start_blk ) < maxbytes )
1967+ if (F2FS_BLK_TO_BYTES ( start_blk ) < maxbytes )
19781968 goto prep_next ;
19791969
19801970 flags |= FIEMAP_EXTENT_LAST ;
@@ -2011,28 +2001,28 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
20112001 } else if (compr_appended ) {
20122002 unsigned int appended_blks = cluster_size -
20132003 count_in_cluster + 1 ;
2014- size += blks_to_bytes ( inode , appended_blks );
2004+ size += F2FS_BLK_TO_BYTES ( appended_blks );
20152005 start_blk += appended_blks ;
20162006 compr_cluster = false;
20172007 } else {
2018- logical = blks_to_bytes ( inode , start_blk );
2008+ logical = F2FS_BLK_TO_BYTES ( start_blk );
20192009 phys = __is_valid_data_blkaddr (map .m_pblk ) ?
2020- blks_to_bytes ( inode , map .m_pblk ) : 0 ;
2021- size = blks_to_bytes ( inode , map .m_len );
2010+ F2FS_BLK_TO_BYTES ( map .m_pblk ) : 0 ;
2011+ size = F2FS_BLK_TO_BYTES ( map .m_len );
20222012 flags = 0 ;
20232013
20242014 if (compr_cluster ) {
20252015 flags = FIEMAP_EXTENT_ENCODED ;
20262016 count_in_cluster += map .m_len ;
20272017 if (count_in_cluster == cluster_size ) {
20282018 compr_cluster = false;
2029- size += blks_to_bytes ( inode , 1 ) ;
2019+ size += F2FS_BLKSIZE ;
20302020 }
20312021 } else if (map .m_flags & F2FS_MAP_DELALLOC ) {
20322022 flags = FIEMAP_EXTENT_UNWRITTEN ;
20332023 }
20342024
2035- start_blk += bytes_to_blks ( inode , size );
2025+ start_blk += F2FS_BYTES_TO_BLK ( size );
20362026 }
20372027
20382028prep_next :
@@ -2070,7 +2060,7 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
20702060 struct readahead_control * rac )
20712061{
20722062 struct bio * bio = * bio_ret ;
2073- const unsigned blocksize = blks_to_bytes ( inode , 1 ) ;
2063+ const unsigned int blocksize = F2FS_BLKSIZE ;
20742064 sector_t block_in_file ;
20752065 sector_t last_block ;
20762066 sector_t last_block_in_file ;
@@ -2080,8 +2070,8 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
20802070
20812071 block_in_file = (sector_t )index ;
20822072 last_block = block_in_file + nr_pages ;
2083- last_block_in_file = bytes_to_blks ( inode ,
2084- f2fs_readpage_limit ( inode ) + blocksize - 1 );
2073+ last_block_in_file = F2FS_BYTES_TO_BLK ( f2fs_readpage_limit ( inode ) +
2074+ blocksize - 1 );
20852075 if (last_block > last_block_in_file )
20862076 last_block = last_block_in_file ;
20872077
@@ -2181,7 +2171,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
21812171 struct bio * bio = * bio_ret ;
21822172 unsigned int start_idx = cc -> cluster_idx << cc -> log_cluster_size ;
21832173 sector_t last_block_in_file ;
2184- const unsigned blocksize = blks_to_bytes ( inode , 1 ) ;
2174+ const unsigned int blocksize = F2FS_BLKSIZE ;
21852175 struct decompress_io_ctx * dic = NULL ;
21862176 struct extent_info ei = {};
21872177 bool from_dnode = true;
@@ -2190,8 +2180,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
21902180
21912181 f2fs_bug_on (sbi , f2fs_cluster_is_empty (cc ));
21922182
2193- last_block_in_file = bytes_to_blks ( inode ,
2194- f2fs_readpage_limit ( inode ) + blocksize - 1 );
2183+ last_block_in_file = F2FS_BYTES_TO_BLK ( f2fs_readpage_limit ( inode ) +
2184+ blocksize - 1 );
21952185
21962186 /* get rid of pages beyond EOF */
21972187 for (i = 0 ; i < cc -> cluster_size ; i ++ ) {
@@ -3957,7 +3947,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
39573947 * to be very smart.
39583948 */
39593949 cur_lblock = 0 ;
3960- last_lblock = bytes_to_blks ( inode , i_size_read (inode ));
3950+ last_lblock = F2FS_BYTES_TO_BLK ( i_size_read (inode ));
39613951
39623952 while (cur_lblock < last_lblock && cur_lblock < sis -> max ) {
39633953 struct f2fs_map_blocks map ;
@@ -4200,8 +4190,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
42004190 pgoff_t next_pgofs = 0 ;
42014191 int err ;
42024192
4203- map .m_lblk = bytes_to_blks ( inode , offset );
4204- map .m_len = bytes_to_blks ( inode , offset + length - 1 ) - map .m_lblk + 1 ;
4193+ map .m_lblk = F2FS_BYTES_TO_BLK ( offset );
4194+ map .m_len = F2FS_BYTES_TO_BLK ( offset + length - 1 ) - map .m_lblk + 1 ;
42054195 map .m_next_pgofs = & next_pgofs ;
42064196 map .m_seg_type = f2fs_rw_hint_to_seg_type (F2FS_I_SB (inode ),
42074197 inode -> i_write_hint );
@@ -4212,7 +4202,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
42124202 if (err )
42134203 return err ;
42144204
4215- iomap -> offset = blks_to_bytes ( inode , map .m_lblk );
4205+ iomap -> offset = F2FS_BLK_TO_BYTES ( map .m_lblk );
42164206
42174207 /*
42184208 * When inline encryption is enabled, sometimes I/O to an encrypted file
@@ -4232,21 +4222,21 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
42324222 if (WARN_ON_ONCE (map .m_pblk == NEW_ADDR ))
42334223 return - EINVAL ;
42344224
4235- iomap -> length = blks_to_bytes ( inode , map .m_len );
4225+ iomap -> length = F2FS_BLK_TO_BYTES ( map .m_len );
42364226 iomap -> type = IOMAP_MAPPED ;
42374227 iomap -> flags |= IOMAP_F_MERGED ;
42384228 iomap -> bdev = map .m_bdev ;
4239- iomap -> addr = blks_to_bytes ( inode , map .m_pblk );
4229+ iomap -> addr = F2FS_BLK_TO_BYTES ( map .m_pblk );
42404230 } else {
42414231 if (flags & IOMAP_WRITE )
42424232 return - ENOTBLK ;
42434233
42444234 if (map .m_pblk == NULL_ADDR ) {
4245- iomap -> length = blks_to_bytes ( inode , next_pgofs ) -
4246- iomap -> offset ;
4235+ iomap -> length = F2FS_BLK_TO_BYTES ( next_pgofs ) -
4236+ iomap -> offset ;
42474237 iomap -> type = IOMAP_HOLE ;
42484238 } else if (map .m_pblk == NEW_ADDR ) {
4249- iomap -> length = blks_to_bytes ( inode , map .m_len );
4239+ iomap -> length = F2FS_BLK_TO_BYTES ( map .m_len );
42504240 iomap -> type = IOMAP_UNWRITTEN ;
42514241 } else {
42524242 f2fs_bug_on (F2FS_I_SB (inode ), 1 );
0 commit comments