lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 13 May 2024 22:08:43 +0900
From: Damien Le Moal <dlemoal@...nel.org>
To: Andreas Hindborg <nmi@...aspace.dk>, Bart Van Assche <bvanassche@....org>
Cc: Jens Axboe <axboe@...nel.dk>, Christoph Hellwig <hch@....de>,
 Keith Busch <kbusch@...nel.org>, Damien Le Moal <Damien.LeMoal@....com>,
 Hannes Reinecke <hare@...e.de>, Ming Lei <ming.lei@...hat.com>,
 "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
 Andreas Hindborg <a.hindborg@...sung.com>,
 Wedson Almeida Filho <wedsonaf@...il.com>,
 Greg KH <gregkh@...uxfoundation.org>, Matthew Wilcox <willy@...radead.org>,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 Benno Lossin <benno.lossin@...ton.me>, Alice Ryhl <aliceryhl@...gle.com>,
 Chaitanya Kulkarni <chaitanyak@...dia.com>,
 Luis Chamberlain <mcgrof@...nel.org>, Yexuan Yang <1182282462@...t.edu.cn>,
 Sergio González Collado <sergio.collado@...il.com>,
 Joel Granados <j.granados@...sung.com>,
 "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>,
 Daniel Gomez <da.gomez@...sung.com>, Niklas Cassel <Niklas.Cassel@....com>,
 Philipp Stanner <pstanner@...hat.com>, Conor Dooley <conor@...nel.org>,
 Johannes Thumshirn <Johannes.Thumshirn@....com>,
 Matias Bjørling <m@...rling.me>,
 open list <linux-kernel@...r.kernel.org>,
 "rust-for-linux@...r.kernel.org" <rust-for-linux@...r.kernel.org>,
 "lsf-pc@...ts.linux-foundation.org" <lsf-pc@...ts.linux-foundation.org>,
 "gost.dev@...sung.com" <gost.dev@...sung.com>
Subject: Re: [PATCH 1/3] rust: block: introduce `kernel::block::mq` module

On 2024/05/13 21:48, Andreas Hindborg wrote:
> 
> Hi Bart,
> 
> Bart Van Assche <bvanassche@....org> writes:
> 
>> On 5/12/24 11:39, Andreas Hindborg wrote:
>>> +    /// Set the logical block size of the device.
>>> +    ///
>>> +    /// This is the smallest unit the storage device can address. It is
>>> +    /// typically 512 bytes.
>>
>> Hmm ... all block devices that I have encountered recently have a
>> logical block size of 4096 bytes. Isn't this the preferred logical
>> block size for SSDs and for SMR hard disks?
> 
> Yes, that is probably true. This text was lifted from the entry on the
> sysfs attribute in `Documentation/ABI/stable/sysfs-block`, but maybe
> that needs to be updated as well.
> 
>>
>>> +    /// Set the physical block size of the device.
>>> +    ///
>>> +    /// This is the smallest unit a physical storage device can write
>>> +    /// atomically. It is usually the same as the logical block size but may be
>>> +    /// bigger. One example is SATA drives with 4KB sectors that expose a
>>> +    /// 512-byte logical block size to the operating system.
>>
>> Please be consistent and change "4 KB sectors" into "4 KB physical block
>> size".
> 
> OK, I will. I can CC the changes to
> `Documentation/ABI/stable/sysfs-block` then'
> 
>>
>> I think that the physical block size can also be smaller than the
>> logical block size. From the SCSI SBC standard:
>>
>> Table 91 — LOGICAL BLOCKS PER PHYSICAL BLOCK EXPONENT field
>> -----  ------------------------------------------------------------
>> Code   Description
>> -----  ------------------------------------------------------------
>> 0      One or more physical blocks per logical block (the number of
>>        physical blocks per logical block is not reported).
>> n > 0  2**n logical blocks per physical block
>> -----  ------------------------------------------------------------

That text is bad. 0 really means physical == logical. Otherwise, there is no way
to know how to access the drive because the logical size is the unit for
accessing the drive. In practice, the logical block size is always smaller or
equal to the physical block size. The physical block size is always a power of 2
number of logical blocks.

> How does that work? Would the drive do a read/modify/write internally?

Yes.

> Would that not make the physical block size as seen from the OS equal to
> the smaller logical block size?

Not necessarily. There are a lot of 512e drives out there: 4K physical, 512B
logical. So applications/hosts can still do 512B accesses for compatibility but
performance may be bad. For such drive, the user should really do 4K aligned
accesses.

> 
>>
>>> +impl<T: Operations, S: GenDiskState> GenDisk<T, S> {
>>> +    /// Call to tell the block layer the capacity of the device in sectors (512B).
>>
>> Why to use any other unit than bytes in Rust block::mq APIs? sector_t
>> was introduced before 64-bit CPUs became available to reduce the number
>> of bytes required to represent offsets. I don't think that this is still
>> a concern today. Hence my proposal to be consistent in the Rust block::mq API
>> and to use bytes as the unit in all APIs.
> 
> I think that is very good idea. How do others feel about this?
> 
> BR Andreas
> 
> 

-- 
Damien Le Moal
Western Digital Research


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ