Re: [PATCH v2 0/7] Rename scsi_get_lba() into scsi_get_pos()

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

 



On 5/12/21 3:10 PM, James Bottomley wrote:
On Wed, 2021-05-12 at 13:08 -0700, Bart Van Assche wrote:
This patch series renames scsi_get_lba() into scsi_get_pos(). The
name of scsi_get_lba() is confusing since it does not return an LBA
but instead the start offset divided by 512.

OK, I'll bite: given the logical block size for all drives is 512 why
is logical block address not the start offset in bytes divided by 512?

My understanding is that LBA = logical block address = (start offset in bytes) / (logical block size) and also that the Linux kernel supports logical block sizes between 512 bytes and 4 KiB. From drivers/scsi/sd.c (sector_size represents the logical block size):

	if (sector_size != 512 &&
	    sector_size != 1024 &&
	    sector_size != 2048 &&
	    sector_size != 4096) {
		sd_printk(KERN_NOTICE, sdkp,
			 "Unsupported sector size %d.\n",
			  sector_size);
		/*
		 * The user might want to re-format the drive with
		 * a supported sectorsize.  Once this happens, it
		 * would be relatively trivial to set the thing up.
		 * For this reason, we leave the thing in the table.
		 */
		sdkp->capacity = 0;
		/*
		 * set a bogus sector size so the normal read/write
		 * logic in the block layer will eventually refuse any
		 * request on this device without tripping over power
		 * of two sector size assumptions
		 */
		sector_size = 512;
	}

Thanks,

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux