Re: [PATCH 5/5] brd: make logical sector size configurable

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

 



On 3/7/23 10:01, Pankaj Raghav wrote:
@@ -57,7 +59,7 @@ static struct folio *brd_lookup_folio(struct brd_device *brd, sector_t sector)
  {
  	pgoff_t idx;
  	struct folio *folio;
-	unsigned int rd_sector_shift = brd->brd_sector_shift - SECTOR_SHIFT;
+	unsigned int rd_sector_shift = brd->brd_sector_shift - brd->brd_logical_sector_shift;

Could we create a simple macro instead of repeating this everywhere?
#define RD_SECTOR_SHIFT(brd) (brd->brd_sector_shift - brd->brd_logical_sector_shift)

Yeah, I'm not utterly happy with that one, too; this patchset is primarily a mechanical conversion to avoid errors.
Will be changing it.

/*
  	 * The folio lifetime is protected by the fact that we have opened the
  			bio_io_error(bio);
  			return;
  		}
-		sector += len >> SECTOR_SHIFT;
+		sector += len >> brd->brd_logical_sector_shift;
  	}
bio_endio(bio);
@@ -353,6 +355,10 @@ static unsigned int rd_blksize = PAGE_SIZE;
  module_param(rd_blksize, uint, 0444);
  MODULE_PARM_DESC(rd_blksize, "Blocksize of each RAM disk in bytes.");
+static unsigned int rd_logical_blksize = SECTOR_SIZE;
+module_param(rd_logical_blksize, uint, 0444);
+MODULE_PARM_DESC(rd_logical_blksize, "Logical blocksize of each RAM disk in bytes.");
+
  MODULE_LICENSE("GPL");
  MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
  MODULE_ALIAS("rd");
@@ -391,6 +397,8 @@ static int brd_alloc(int i)
  	list_add_tail(&brd->brd_list, &brd_devices);
  	brd->brd_sector_shift = ilog2(rd_blksize);
  	brd->brd_sector_size = rd_blksize;
+	brd->brd_logical_sector_shift = ilog2(rd_logical_blksize);
+	brd->brd_logical_sector_size = rd_logical_blksize;

We should a check here to see if logical block > rd_blksize similar
to what is done in blk_queue_logical_block_size()?
 > // physical block size should not be less than the logical block size
if (rd_blksize < rd_logical_blksize) {
	brd->brd_logical_sector_shift = ilog2(rd_blksize);
	brd->brd_logical_sector_size = rd_blksize;
  }

Sure. Keith already complained about it.

Cheers,

Hannes
--
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@xxxxxxx			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Frankenstr. 146, 90461 Nürnberg
Managing Directors: I. Totev, A. Myers, A. McDonald, M. B. Moerman
(HRB 36809, AG Nürnberg)




[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