@@ -1834,9 +1834,8 @@ static ssize_t recompress_store(struct device *dev,
static void zram_bio_discard(struct zram *zram, struct bio *bio)
{
size_t n = bio->bi_iter.bi_size;
- u32 index = bio->bi_iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
- u32 offset = (bio->bi_iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
- SECTOR_SHIFT;
+ u32 index = bio->bi_iter.bi_sector >> PAGE_SECTORS_SHIFT;
+ u32 offset = (bio->bi_iter.bi_sector & SECTOR_MASK) << SECTOR_SHIFT;
/*
* zram manages data in physical block size units. Because logical block
@@ -1874,9 +1873,8 @@ static void zram_bio_read(struct zram *zram, struct bio *bio)
struct bvec_iter iter = bio->bi_iter;
do {
- u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
- u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
- SECTOR_SHIFT;
+ u32 index = iter.bi_sector >> PAGE_SECTORS_SHIFT;
+ u32 offset = (iter.bi_sector & SECTOR_MASK) << SECTOR_SHIFT;
struct bio_vec bv = bio_iter_iovec(bio, iter);
bv.bv_len = min_t(u32, bv.bv_len, PAGE_SIZE - offset);
@@ -1905,9 +1903,8 @@ static void zram_bio_write(struct zram *zram, struct bio *bio)
struct bvec_iter iter = bio->bi_iter;
do {
- u32 index = iter.bi_sector >> SECTORS_PER_PAGE_SHIFT;
- u32 offset = (iter.bi_sector & (SECTORS_PER_PAGE - 1)) <<
- SECTOR_SHIFT;
+ u32 index = iter.bi_sector >> PAGE_SECTORS_SHIFT;
+ u32 offset = (iter.bi_sector & SECTOR_MASK) << SECTOR_SHIFT;
struct bio_vec bv = bio_iter_iovec(bio, iter);
bv.bv_len = min_t(u32, bv.bv_len, PAGE_SIZE - offset);
@@ -21,8 +21,6 @@
#include "zcomp.h"
-#define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
-#define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT)
#define ZRAM_LOGICAL_BLOCK_SHIFT 12
#define ZRAM_LOGICAL_BLOCK_SIZE (1 << ZRAM_LOGICAL_BLOCK_SHIFT)
#define ZRAM_SECTOR_PER_LOGICAL_BLOCK \