Util-Linux package development
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Istvan Gabor <suseuser04@gmail.hu>
Cc: Util linux <util-linux@vger.kernel.org>
Subject: Re: fdisk does not allow overwrite default/suggested value
Date: Tue, 16 Jul 2019 10:33:58 -0400	[thread overview]
Message-ID: <yq1k1ci1221.fsf@mkp.net> (raw)
In-Reply-To: <55e1e62f0a4c14c93245292c2a62d789@gmail.hu> (Istvan Gabor's message of "Tue, 16 Jul 2019 15:10:26 +0200")


Istvan,

> https://linux-blog.anracom.com/2018/12/03/linux-ssd-partition-alignment-problems-with-external-usb-to-sata-controllers-i/

First of all, the ATA protocol can only express logical and physical
block sizes. So the optimal I/O size is always 0 when a disk is
connected via a "native" ATA controller.

USB storage, however, is a SCSI protocol. In that configuration it is up
to the USB bridge device to translate properties reported by the
attached ATA device to the relevant fields in the SCSI protocol. And
this is where several devices get it wrong (despite a fairly
comprehensive document describing how each field should be translated).

The SCSI block storage protocol permits reporting an optimal I/O
size. Since there is no corresponding ATA parameter, it means that the
value in your case inevitably comes from the USB bridge firmware. There
is nothing to base this value on from the ATA device itself, so the
bridge firmware authors either made it up or forgot to zero the field.

As a result of reports similar to the one above, I added an additional
heuristic to the SCSI disk driver code a while ago. The kernel will now
reject a device-reported optimal transfer size if it is not a multiple
of the physical block size. So in the buggy USB-SATA bridge case above
the optimal transfer size should be reported to user space as 0 and
therefore fdisk should align on a 4096-byte (physical block size)
boundary.

Note that this is somewhat orthogonal to your request about being able
to override the reported values in fdisk. I just thought some of the
text in the links you posted warranted clarification.

The question is why your kernel does not have the patch adding this
additional heuristic?

-- 
Martin K. Petersen	Oracle Linux Engineering

  reply	other threads:[~2019-07-16 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16 13:10 fdisk does not allow overwrite default/suggested value Istvan Gabor
2019-07-16 14:33 ` Martin K. Petersen [this message]
2019-07-17  8:13 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yq1k1ci1221.fsf@mkp.net \
    --to=martin.petersen@oracle.com \
    --cc=suseuser04@gmail.hu \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox