Skip to contentSkip to conversation

block: move some macros to blkdev.h

PATCH In review Guoqing Jiang 2 participants 3 messages Jul 21, 2021 – Aug 12, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: move some macros to blkdev.h

From: Guoqing Jiang <[email protected]>

Move them (PAGE_SECTORS_SHIFT, PAGE_SECTORS and SECTOR_MASK) to the generic header file to remove redundancy.

---
 drivers/block/brd.c           | 3 ---
 drivers/block/null_blk/main.c | 4 ----
 drivers/md/bcache/util.h      | 2 --
 include/linux/blkdev.h        | 4 ++++
 include/linux/device-mapper.h | 1 -
 5 files changed, 4 insertions(+), 10 deletions(-)
drivers/block/brd.c +0 -3
index 95694113e38e..58ec167aa018 100644
@@ -27,9 +27,6 @@
 
 #include <linux/uaccess.h>
 
-#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
-
 /*
  * Each block ramdisk device has a radix_tree brd_pages of pages that stores
  * the pages containing the block device's contents. A brd page's ->index is
drivers/block/null_blk/main.c +0 -4
index d734e9ee1546..f128242d1170 100644
@@ -11,10 +11,6 @@
 #include <linux/init.h>
 #include "null_blk.h"
 
-#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
-#define SECTOR_MASK		(PAGE_SECTORS - 1)
-
 #define FREE_BATCH		16
 
 #define TICKS_PER_SEC		50ULL
drivers/md/bcache/util.h +0 -2
index bca4a7c97da7..b64460a76267 100644
@@ -15,8 +15,6 @@
 
 #include "closure.h"
 
-#define PAGE_SECTORS		(PAGE_SIZE / 512)
-
 struct closure;
 
 #ifdef CONFIG_BCACHE_DEBUG
include/linux/blkdev.h +4 -0
index 3177181c4326..0d0b6967c954 100644
@@ -941,6 +941,10 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
 #define SECTOR_SIZE (1 << SECTOR_SHIFT)
 #endif
 
+#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
+#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
+#define SECTOR_MASK		(PAGE_SECTORS - 1)
+
 /*
  * blk_rq_pos()			: the current sector
  * blk_rq_bytes()		: bytes left in the entire request
include/linux/device-mapper.h +0 -1
index 7457d49acf9a..94f2cd6a8e83 100644
@@ -151,7 +151,6 @@ typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff,
 		void *addr, size_t bytes, struct iov_iter *i);
 typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff,
 		size_t nr_pages);
-#define PAGE_SECTORS (PAGE_SIZE / 512)
 
 void dm_error(const char *message);
 
Signature · 1 line
2.25.1
#1 lore raw

Gentle ping ...

Quoted 83 lines · Guoqing Jiang

From: Guoqing Jiang <[email protected]>

Move them (PAGE_SECTORS_SHIFT, PAGE_SECTORS and SECTOR_MASK) to the generic header file to remove redundancy.

---
  drivers/block/brd.c           | 3 ---
  drivers/block/null_blk/main.c | 4 ----
  drivers/md/bcache/util.h      | 2 --
  include/linux/blkdev.h        | 4 ++++
  include/linux/device-mapper.h | 1 -
  5 files changed, 4 insertions(+), 10 deletions(-)
drivers/block/brd.c +0 -3
index 95694113e38e..58ec167aa018 100644
@@ -27,9 +27,6 @@
 
  #include <linux/uaccess.h>
 
-#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
-
  /*
   * Each block ramdisk device has a radix_tree brd_pages of pages that stores
   * the pages containing the block device's contents. A brd page's ->index is
drivers/block/null_blk/main.c +0 -4
index d734e9ee1546..f128242d1170 100644
@@ -11,10 +11,6 @@
  #include <linux/init.h>
  #include "null_blk.h"
 
-#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
-#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
-#define SECTOR_MASK		(PAGE_SECTORS - 1)
-
  #define FREE_BATCH		16
 
  #define TICKS_PER_SEC		50ULL
drivers/md/bcache/util.h +0 -2
index bca4a7c97da7..b64460a76267 100644
@@ -15,8 +15,6 @@
 
  #include "closure.h"
 
-#define PAGE_SECTORS		(PAGE_SIZE / 512)
-
  struct closure;
 
  #ifdef CONFIG_BCACHE_DEBUG
include/linux/blkdev.h +4 -0
index 3177181c4326..0d0b6967c954 100644
@@ -941,6 +941,10 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
  #define SECTOR_SIZE (1 << SECTOR_SHIFT)
  #endif
 
+#define PAGE_SECTORS_SHIFT	(PAGE_SHIFT - SECTOR_SHIFT)
+#define PAGE_SECTORS		(1 << PAGE_SECTORS_SHIFT)
+#define SECTOR_MASK		(PAGE_SECTORS - 1)
+
  /*
   * blk_rq_pos()			: the current sector
   * blk_rq_bytes()		: bytes left in the entire request
include/linux/device-mapper.h +0 -1
index 7457d49acf9a..94f2cd6a8e83 100644
@@ -151,7 +151,6 @@ typedef size_t (*dm_dax_copy_iter_fn)(struct dm_target *ti, pgoff_t pgoff,
  		void *addr, size_t bytes, struct iov_iter *i);
  typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff,
  		size_t nr_pages);
-#define PAGE_SECTORS (PAGE_SIZE / 512)
 
  void dm_error(const char *message);
 
maintainer
#2 lore raw
In reply to Guoqing Jiang
Quoted 4 lines · Guoqing Jiang

From: Guoqing Jiang <[email protected]>

Move them (PAGE_SECTORS_SHIFT, PAGE_SECTORS and SECTOR_MASK) to the generic header file to remove redundancy.

Applied for 5.15, thanks.

Signature · 1 line
Jens Axboe