Re: set_capacity question

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lal wrote:
> Reposting as first post didn't make to the list :)
> 
> 
> ATAPI block devices support a command READ_CAPACITY that returns "Last
> Logical Block Address" and "Block Length in Bytes".
> 
> Given that "Block Length in Bytes" is returned 512 which is equal to
> kernel sector size; is value returned by "Last Logical Block Address"
> used in set_capacity function of the block device driver?
> 
> My 512 MB mass storage device returns "Last Logical Block Address" as
> 0xF5FFF. But if I use this value as
> 
> set_capacity(my_disk, 0xF5FFF);
> 
> I get following kinds of error/warning messages:
> p1 exceeds device capacity
> attempt to access beyond end of device
> MY_DEVICE: rw=0, want=1007616, limit=1007615
> 
> I tried to analyze kernel source code printing these messages. These
> messages are from fs/partitions/check.c file. In this file a piece of
> source code evaluates following expression:
> 
> if (from + size > get_capacity(disk)) {
> printk(" %s: p%d exceeds device capacity\n", disk->disk_name, p);
> }
> 
> 'from' and 'size' are sector start address and sector size
> respectively. These values are read from partition on the device
> (partition was created by a working driver on Linux). Since my device
> driver is able to find partition correctly, I believe 'from' and
> 'size' should also be read correctly. Therefore possibility is that
> get_capacity is returning lesser disk capacity than actual which was
> set by set_capacity.
> 
> How to determine what argument value should be used in set_capacity function?
> 
> Thanks
> -Lal
> 
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ
> 

0xF5FFF is 1007615 in decimal, so it seems that setting capacity to 0xF5FFF-1
will solve the problem.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFITjBh3LCeUQetfe4RAsH7AJ43ALAzQn6FDaEype6rBgQrl9nvxQCfenmB
lU/xGFjFO9noZ4LtVoGDG/M=
=6h2r
-----END PGP SIGNATURE-----

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux