Re: Newbie device mapper questions

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

 



On 06/16/15 at 08:55P, Minfei Huang wrote:
> On Tue, Jun 16, 2015 at 6:20 AM, Vivek Goyal <vgoyal@xxxxxxxxxx> wrote:
> > On Mon, Jun 15, 2015 at 12:52:57PM -0700, Doug Dumitru wrote:
> >> >
> >> > - Is i_size_read(lc->src1dev->bdev->bd_inode) the correct way of
> >> > determining the size of the underlying block device? If not, which
> >> > function is?
> >> >
> >
> > I believe that's correct. Look at block/blk-core.c
> >
> > handle_bad_sector(struct bio *bio)
> > {
> > }
> >
> 
> Kernel will call i_size_write to assign the device capacity, when the
> device try to be registered(register_disk). During the period of
> register, the function blkdev_get will call bd_set_size to set the
> capacity.
> 
> So it is correct that you can call i_size_read to determine the device's
> capacity.
> 
> >>
> >> ... I am happy to leave out answers that I don't know ...
> >>
> >>
> >> >
> >> > - Can I safely assume the logical sector size is fixed to be 512 bytes
> >> > in all cases?
> >> >
> >>
> >> Probably not, but maybe.  You are in control of the hardware.
> >
> > You mean block size or sector size? I think sector sizes can vary and
> > targets can allow user space to specify one. Typically metadata is per
> > block can lead to smaller metadata foot print.
> >
> 
> For now, the minimum align unit is 512 bytes. But as I know, a lot of
> devices start to support 4KB align unit.

Correct it.

Although the device supports the physical sector to extend to 4KB, the
device will divide physical sector into 8 pieces (one pieces is 512
bytes, call logical sector).

$ sudo hdparm -I /dev/sda | egrep -i "physical|logical|device size with M"
Logical		max	current
Logical  Sector size:                   512 bytes
Physical Sector size:                  4096 bytes
Logical Sector-0 offset:                  0 bytes
device size with M = 1024*1024:      953869 MBytes
device size with M = 1000*1000:     1000204 MBytes (1000 GB)

So I think you can use logical sector(512 bytes) to align the start
position and count.

Thanks
Minfei

> 
> Please correct me if there is something wrong in the comment.
> 
> Thanks
> Minfei

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux