@@ -1742,19 +1742,6 @@ void clean_bdev_aliases(struct block_device *bdev, sector_t block, sector_t len)
1742
1742
}
1743
1743
EXPORT_SYMBOL (clean_bdev_aliases );
1744
1744
1745
- /*
1746
- * Size is a power-of-two in the range 512..PAGE_SIZE,
1747
- * and the case we care about most is PAGE_SIZE.
1748
- *
1749
- * So this *could* possibly be written with those
1750
- * constraints in mind (relevant mostly if some
1751
- * architecture has a slow bit-scan instruction)
1752
- */
1753
- static inline int block_size_bits (unsigned int blocksize )
1754
- {
1755
- return ilog2 (blocksize );
1756
- }
1757
-
1758
1745
static struct buffer_head * folio_create_buffers (struct folio * folio ,
1759
1746
struct inode * inode ,
1760
1747
unsigned int b_state )
@@ -1807,7 +1794,7 @@ int __block_write_full_folio(struct inode *inode, struct folio *folio,
1807
1794
sector_t block ;
1808
1795
sector_t last_block ;
1809
1796
struct buffer_head * bh , * head ;
1810
- unsigned int blocksize , bbits ;
1797
+ size_t blocksize ;
1811
1798
int nr_underway = 0 ;
1812
1799
blk_opf_t write_flags = wbc_to_write_flags (wbc );
1813
1800
@@ -1826,10 +1813,9 @@ int __block_write_full_folio(struct inode *inode, struct folio *folio,
1826
1813
1827
1814
bh = head ;
1828
1815
blocksize = bh -> b_size ;
1829
- bbits = block_size_bits (blocksize );
1830
1816
1831
- block = ( sector_t ) folio -> index << ( PAGE_SHIFT - bbits );
1832
- last_block = (i_size_read (inode ) - 1 ) >> bbits ;
1817
+ block = div_u64 ( folio_pos ( folio ), blocksize );
1818
+ last_block = div_u64 (i_size_read (inode ) - 1 , blocksize ) ;
1833
1819
1834
1820
/*
1835
1821
* Get all the dirty buffers mapped to disk addresses and
@@ -2355,7 +2341,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
2355
2341
struct inode * inode = folio -> mapping -> host ;
2356
2342
sector_t iblock , lblock ;
2357
2343
struct buffer_head * bh , * head , * arr [MAX_BUF_PER_PAGE ];
2358
- unsigned int blocksize , bbits ;
2344
+ size_t blocksize ;
2359
2345
int nr , i ;
2360
2346
int fully_mapped = 1 ;
2361
2347
bool page_error = false;
@@ -2369,10 +2355,9 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block)
2369
2355
2370
2356
head = folio_create_buffers (folio , inode , 0 );
2371
2357
blocksize = head -> b_size ;
2372
- bbits = block_size_bits (blocksize );
2373
2358
2374
- iblock = ( sector_t ) folio -> index << ( PAGE_SHIFT - bbits );
2375
- lblock = (limit + blocksize - 1 ) >> bbits ;
2359
+ iblock = div_u64 ( folio_pos ( folio ), blocksize );
2360
+ lblock = div_u64 (limit + blocksize - 1 , blocksize ) ;
2376
2361
bh = head ;
2377
2362
nr = 0 ;
2378
2363
i = 0 ;
0 commit comments