@@ -1819,16 +1819,6 @@ bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len)
1819
1819
return true;
1820
1820
}
1821
1821
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
-
1832
1822
static int f2fs_xattr_fiemap (struct inode * inode ,
1833
1823
struct fiemap_extent_info * fieinfo )
1834
1824
{
@@ -1854,7 +1844,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
1854
1844
return err ;
1855
1845
}
1856
1846
1857
- phys = blks_to_bytes ( inode , ni .blk_addr );
1847
+ phys = F2FS_BLK_TO_BYTES ( ni .blk_addr );
1858
1848
offset = offsetof(struct f2fs_inode , i_addr ) +
1859
1849
sizeof (__le32 ) * (DEF_ADDRS_PER_INODE -
1860
1850
get_inline_xattr_addrs (inode ));
@@ -1886,7 +1876,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
1886
1876
return err ;
1887
1877
}
1888
1878
1889
- phys = blks_to_bytes ( inode , ni .blk_addr );
1879
+ phys = F2FS_BLK_TO_BYTES ( ni .blk_addr );
1890
1880
len = inode -> i_sb -> s_blocksize ;
1891
1881
1892
1882
f2fs_put_page (page , 1 );
@@ -1948,16 +1938,16 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
1948
1938
goto out ;
1949
1939
}
1950
1940
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 ;
1953
1943
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 );
1956
1946
1957
1947
next :
1958
1948
memset (& map , 0 , sizeof (map ));
1959
1949
map .m_lblk = start_blk ;
1960
- map .m_len = bytes_to_blks ( inode , len );
1950
+ map .m_len = F2FS_BYTES_TO_BLK ( len );
1961
1951
map .m_next_pgofs = & next_pgofs ;
1962
1952
map .m_seg_type = NO_CHECK_TYPE ;
1963
1953
@@ -1974,7 +1964,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
1974
1964
if (!compr_cluster && !(map .m_flags & F2FS_MAP_FLAGS )) {
1975
1965
start_blk = next_pgofs ;
1976
1966
1977
- if (blks_to_bytes ( inode , start_blk ) < maxbytes )
1967
+ if (F2FS_BLK_TO_BYTES ( start_blk ) < maxbytes )
1978
1968
goto prep_next ;
1979
1969
1980
1970
flags |= FIEMAP_EXTENT_LAST ;
@@ -2011,28 +2001,28 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2011
2001
} else if (compr_appended ) {
2012
2002
unsigned int appended_blks = cluster_size -
2013
2003
count_in_cluster + 1 ;
2014
- size += blks_to_bytes ( inode , appended_blks );
2004
+ size += F2FS_BLK_TO_BYTES ( appended_blks );
2015
2005
start_blk += appended_blks ;
2016
2006
compr_cluster = false;
2017
2007
} else {
2018
- logical = blks_to_bytes ( inode , start_blk );
2008
+ logical = F2FS_BLK_TO_BYTES ( start_blk );
2019
2009
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 );
2022
2012
flags = 0 ;
2023
2013
2024
2014
if (compr_cluster ) {
2025
2015
flags = FIEMAP_EXTENT_ENCODED ;
2026
2016
count_in_cluster += map .m_len ;
2027
2017
if (count_in_cluster == cluster_size ) {
2028
2018
compr_cluster = false;
2029
- size += blks_to_bytes ( inode , 1 ) ;
2019
+ size += F2FS_BLKSIZE ;
2030
2020
}
2031
2021
} else if (map .m_flags & F2FS_MAP_DELALLOC ) {
2032
2022
flags = FIEMAP_EXTENT_UNWRITTEN ;
2033
2023
}
2034
2024
2035
- start_blk += bytes_to_blks ( inode , size );
2025
+ start_blk += F2FS_BYTES_TO_BLK ( size );
2036
2026
}
2037
2027
2038
2028
prep_next :
@@ -2070,7 +2060,7 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
2070
2060
struct readahead_control * rac )
2071
2061
{
2072
2062
struct bio * bio = * bio_ret ;
2073
- const unsigned blocksize = blks_to_bytes ( inode , 1 ) ;
2063
+ const unsigned int blocksize = F2FS_BLKSIZE ;
2074
2064
sector_t block_in_file ;
2075
2065
sector_t last_block ;
2076
2066
sector_t last_block_in_file ;
@@ -2080,8 +2070,8 @@ static int f2fs_read_single_page(struct inode *inode, struct folio *folio,
2080
2070
2081
2071
block_in_file = (sector_t )index ;
2082
2072
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 );
2085
2075
if (last_block > last_block_in_file )
2086
2076
last_block = last_block_in_file ;
2087
2077
@@ -2181,7 +2171,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
2181
2171
struct bio * bio = * bio_ret ;
2182
2172
unsigned int start_idx = cc -> cluster_idx << cc -> log_cluster_size ;
2183
2173
sector_t last_block_in_file ;
2184
- const unsigned blocksize = blks_to_bytes ( inode , 1 ) ;
2174
+ const unsigned int blocksize = F2FS_BLKSIZE ;
2185
2175
struct decompress_io_ctx * dic = NULL ;
2186
2176
struct extent_info ei = {};
2187
2177
bool from_dnode = true;
@@ -2190,8 +2180,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
2190
2180
2191
2181
f2fs_bug_on (sbi , f2fs_cluster_is_empty (cc ));
2192
2182
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 );
2195
2185
2196
2186
/* get rid of pages beyond EOF */
2197
2187
for (i = 0 ; i < cc -> cluster_size ; i ++ ) {
@@ -3957,7 +3947,7 @@ static int check_swap_activate(struct swap_info_struct *sis,
3957
3947
* to be very smart.
3958
3948
*/
3959
3949
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 ));
3961
3951
3962
3952
while (cur_lblock < last_lblock && cur_lblock < sis -> max ) {
3963
3953
struct f2fs_map_blocks map ;
@@ -4200,8 +4190,8 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
4200
4190
pgoff_t next_pgofs = 0 ;
4201
4191
int err ;
4202
4192
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 ;
4205
4195
map .m_next_pgofs = & next_pgofs ;
4206
4196
map .m_seg_type = f2fs_rw_hint_to_seg_type (F2FS_I_SB (inode ),
4207
4197
inode -> i_write_hint );
@@ -4212,7 +4202,7 @@ static int f2fs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
4212
4202
if (err )
4213
4203
return err ;
4214
4204
4215
- iomap -> offset = blks_to_bytes ( inode , map .m_lblk );
4205
+ iomap -> offset = F2FS_BLK_TO_BYTES ( map .m_lblk );
4216
4206
4217
4207
/*
4218
4208
* 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,
4232
4222
if (WARN_ON_ONCE (map .m_pblk == NEW_ADDR ))
4233
4223
return - EINVAL ;
4234
4224
4235
- iomap -> length = blks_to_bytes ( inode , map .m_len );
4225
+ iomap -> length = F2FS_BLK_TO_BYTES ( map .m_len );
4236
4226
iomap -> type = IOMAP_MAPPED ;
4237
4227
iomap -> flags |= IOMAP_F_MERGED ;
4238
4228
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 );
4240
4230
} else {
4241
4231
if (flags & IOMAP_WRITE )
4242
4232
return - ENOTBLK ;
4243
4233
4244
4234
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 ;
4247
4237
iomap -> type = IOMAP_HOLE ;
4248
4238
} 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 );
4250
4240
iomap -> type = IOMAP_UNWRITTEN ;
4251
4241
} else {
4252
4242
f2fs_bug_on (F2FS_I_SB (inode ), 1 );
0 commit comments