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

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

 



> @@ -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) 

>  
>  	/*
>  	 * 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;
 }

>  
>  	spin_lock_init(&brd->brd_lock);
>  	INIT_RADIX_TREE(&brd->brd_folios, GFP_ATOMIC);
> @@ -418,6 +426,7 @@ static int brd_alloc(int i)
>  		goto out_cleanup_disk;
>  	}
>  	blk_queue_physical_block_size(disk->queue, rd_blksize);
> +	blk_queue_logical_block_size(disk->queue, rd_logical_blksize);
>  	blk_queue_max_hw_sectors(disk->queue, RD_MAX_SECTOR_SIZE);
>  
>  	/* Tell the block layer that this is not a rotational device */
> -- 
> 2.35.3
> 



[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