Just spinning these low hanging fruit patches I forgot about.
Changes on v3:
o Add tags for Reviews/acks
o rebase onto next-20230914
o Fixes as suggested by Johannes Thumshirn:
- drop not-needed parens on dm bufio
- use SECTOR_MASK instead of PAGE_SECTORS - 1 for the zram driver
o Drop shmem patches as they are already merged / modified
Changes on v2:
o keep iomap math visibly simple
o Add tags for Reviews/acks
o rebase onto next-20230525
Luis Chamberlain (4):
drbd: use PAGE_SECTORS_SHIFT and PAGE_SECTORS
iomap: simplify iomap_init() with PAGE_SECTORS
dm bufio: simplify by using PAGE_SECTORS_SHIFT
zram: use generic PAGE_SECTORS and PAGE_SECTORS_SHIFT
drivers/block/drbd/drbd_bitmap.c | 4 ++--
drivers/block/zram/zram_drv.c | 15 ++++++---------
drivers/block/zram/zram_drv.h | 2 --
drivers/md/dm-bufio.c | 4 ++--
fs/iomap/buffered-io.c | 2 +-
5 files changed, 11 insertions(+), 16 deletions(-)
--
2.39.2
Instead of re-defining the already existing constants use the provided ones:
So replace:
o SECTORS_PER_PAGE_SHIFT with PAGE_SECTORS_SHIFT
o SECTORS_PER_PAGE with PAGE_SECTORS
o SECTORS_PER_PAGE - 1 with SECTOR_MASK
This produces no functional changes.
Reviewed-by: Sergey Senozhatsky <[email protected]>
Signed-off-by: Luis Chamberlain <[email protected]>
---
drivers/block/zram/zram_drv.c | 15 ++++++---------
drivers/block/zram/zram_drv.h | 2 --
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 06673c6ca255..58d36c8574d4 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -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);
diff --git a/drivers/block/zram/zram_drv.h b/drivers/block/zram/zram_drv.h
index ca7a15bd4845..9f2543af5c76 100644
--- a/drivers/block/zram/zram_drv.h
+++ b/drivers/block/zram/zram_drv.h
@@ -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 \
--
2.39.2
Looks good,
Reviewed-by: Johannes Thumshirn <[email protected]>