Re: [PATCH 4/7] brd: make sector size configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/14/23 14:55, Matthew Wilcox wrote:
On Wed, Jun 14, 2023 at 01:46:34PM +0200, Hannes Reinecke wrote:
@@ -43,9 +43,11 @@ struct brd_device {
  	 */
  	struct xarray	        brd_folios;
  	u64			brd_nr_folios;
+	unsigned int		brd_sector_shift;
+	unsigned int		brd_sector_size;
  };
-#define BRD_SECTOR_SHIFT(b) (PAGE_SHIFT - SECTOR_SHIFT)
+#define BRD_SECTOR_SHIFT(b) ((b)->brd_sector_shift - SECTOR_SHIFT)
static pgoff_t brd_sector_index(struct brd_device *brd, sector_t sector)
  {
@@ -85,7 +87,7 @@ static int brd_insert_folio(struct brd_device *brd, sector_t sector, gfp_t gfp)
  {
  	pgoff_t idx;
  	struct folio *folio, *cur;
-	unsigned int rd_sector_order = get_order(PAGE_SIZE);
+	unsigned int rd_sector_order = get_order(brd->brd_sector_size);

Surely max(0, brd->brd_sector_shift - PAGE_SHIFT) ?

Errm. Possibly.

@@ -346,6 +353,25 @@ static int brd_alloc(int i)
  		return -ENOMEM;
  	brd->brd_number		= i;
  	list_add_tail(&brd->brd_list, &brd_devices);
+	brd->brd_sector_shift = ilog2(rd_blksize);
+	if ((1ULL << brd->brd_sector_shift) != rd_blksize) {
+		pr_err("rd_blksize %d is not supported\n", rd_blksize);

Are you trying to require power-of-two here?  We have is_power_of_2()
for that purpose.

Ah. So let's use that, then :-)

Cheers,

Hannes




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux