linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* UAS driver seems to be reporting a 4k sector size for a 512 byte sector device?
@ 2016-09-26 16:19 Theodore Ts'o
  2016-09-26 16:25 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Theodore Ts'o @ 2016-09-26 16:19 UTC (permalink / raw)
  To: linux-scsi, usb-storage

Hi, I have a Samsung 850 Pro SSD which is currently in a USB 3.0 / UAS
external enclosure.  The Samsung SSD uses a 512 byte physical and logical
sector size, and when it is accessed via the usb-storage device, this
is what I get.

In a vain hope that I could get discard working, I built a kernel that
included the uas driver, and discovered that when I accessed the drive
using the uas driver, it showed up as a 4k physical sector device, and
this caused device-mapper to complain that the dm-crypt partition was
misaligned.

Is this a problem with the hardware, or with the UAS driver?

						- Ted

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: UAS driver seems to be reporting a 4k sector size for a 512 byte sector device?
  2016-09-26 16:19 UAS driver seems to be reporting a 4k sector size for a 512 byte sector device? Theodore Ts'o
@ 2016-09-26 16:25 ` Christoph Hellwig
  2016-09-26 21:52   ` Theodore Ts'o
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2016-09-26 16:25 UTC (permalink / raw)
  To: Theodore Ts'o, linux-scsi, usb-storage

On Mon, Sep 26, 2016 at 12:19:26PM -0400, Theodore Ts'o wrote:
> Is this a problem with the hardware, or with the UAS driver?

UAS is just SCSI transport, and doesn't touch the content of command,
so it's a very unlikely culprit.  The SCSI layer intreprets it, but I
don't really think it's doing any of this either..  Your bridge most
likely always reports 4k sectors when using UAS for some reason.

To verify this call sg_readcap on the device node for both the
usb-storage and uas mode.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: UAS driver seems to be reporting a 4k sector size for a 512 byte sector device?
  2016-09-26 16:25 ` Christoph Hellwig
@ 2016-09-26 21:52   ` Theodore Ts'o
  2016-09-27  1:24     ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Theodore Ts'o @ 2016-09-26 21:52 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-scsi, usb-storage

On Mon, Sep 26, 2016 at 09:25:11AM -0700, Christoph Hellwig wrote:
> On Mon, Sep 26, 2016 at 12:19:26PM -0400, Theodore Ts'o wrote:
> > Is this a problem with the hardware, or with the UAS driver?
> 
> UAS is just SCSI transport, and doesn't touch the content of command,
> so it's a very unlikely culprit.  The SCSI layer intreprets it, but I
> don't really think it's doing any of this either..  Your bridge most
> likely always reports 4k sectors when using UAS for some reason.
> 
> To verify this call sg_readcap on the device node for both the
> usb-storage and uas mode.

sg_readcap doesn't report the physical sector size, just the logical
block size:

# sg_readcap  /dev/sdd
Read Capacity results:
   Last logical block address=4000797359 (0xee7752af), Number of blocks=4000797360
   Logical block length=512 bytes
Hence:
   Device size: 2048408248320 bytes, 1953514.3 MiB, 2048.41 GB

And this is the same for both with and with UAS.

So with UAS we get:

# blockdev --getpbsz /dev/sdd
4096

...even though hdparm -I reports:

	Logical  Sector size:                   512 bytes
	Physical Sector size:                   512 bytes

I guess this is mostly cosmetic, since although lsblk -t reports:

# lsblk -t
NAME                    ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE  RA WSAME
sdd                             0   4096 33553920    4096     512    1 cfq       128 128   32M
├─sdd2                          0   4096 33553920    4096     512    1 cfq       128 128   32M
│ └─callcc_crypt               -1   4096        0    4096     512    1           128 128    0B

nothing is actually _breaking_ since the logical sector size is still
512, and the minimum I/O and physical sector size are performance
hints.

							- Ted


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: UAS driver seems to be reporting a 4k sector size for a 512 byte sector device?
  2016-09-26 21:52   ` Theodore Ts'o
@ 2016-09-27  1:24     ` Martin K. Petersen
  0 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2016-09-27  1:24 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Christoph Hellwig, linux-scsi, usb-storage

>>>>> "Ted" == Theodore Ts'o <tytso@mit.edu> writes:

Ted,

Ted> sg_readcap doesn't report the physical sector size, just the
Ted> logical block size:

Ted> # sg_readcap /dev/sdd
Ted> Read Capacity results:
Ted>    Last logical block address=4000797359 (0xee7752af), Number of
Ted>    blocks=4000797360 Logical block length=512 bytes
Ted> Hence:
Ted>    Device size: 2048408248320 bytes, 1953514.3 MiB, 2048.41 GB

You need to run sg_readcap with the -l option to get to the physical
block size exponent. Please let us know if that makes a difference.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-27  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-26 16:19 UAS driver seems to be reporting a 4k sector size for a 512 byte sector device? Theodore Ts'o
2016-09-26 16:25 ` Christoph Hellwig
2016-09-26 21:52   ` Theodore Ts'o
2016-09-27  1:24     ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).