gpart and sector size

96 views
Skip to first unread message

Alexey Tarasov

unread,
Apr 8, 2010, 9:06:55 AM4/8/10
to freebsd...@freebsd.org
Hello.

There is only one possibility to change sector size of physical disk (gnop -S 4096 ...).
May be it is possible to add such possibility to gpart? e.g. gpart create -S 4096 -t gpt ad0?
It will help all unlucky WD Advanced Format disks users. :-D

--
Alexey Tarasov

(\__/)
(='.'=)
E[: | | | | :]З
(")_(")

Dag-Erling Smørgrav

unread,
Apr 8, 2010, 9:36:37 AM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org
Alexey Tarasov <m...@lexasoft.ru> writes:
> There is only one possibility to change sector size of physical disk
> (gnop -S 4096 ...). May be it is possible to add such possibility to
> gpart? e.g. gpart create -S 4096 -t gpt ad0?

I don't quite see how that would work - do you mean gpart should
configure a gnop? AFAIK there is no "gnop label", so you can't set up a
persistent gnop; you have to set it up manually at boot time every time,
and there's a risk that the fs (or other layers higher up) will taste
the underlying device instead of the gnop.

DES
--
Dag-Erling Smørgrav - d...@des.no

Dag-Erling Smørgrav

unread,
Apr 8, 2010, 10:09:24 AM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org
Alexey Tarasov <m...@lexasoft.ru> writes:
> I mean that gpart should act like gnop presenting another sector size
> to user. I that possible at all?

That depends on the underlying partition scheme. My guess is "no".

(it all boils down to whether the desired logical sector size can
somehow be recorded on-disk)

Alexey Tarasov

unread,
Apr 8, 2010, 9:44:00 AM4/8/10
to Dag-Erling Smørgrav, freebsd...@freebsd.org
No, no.

I mean that gpart should act like gnop presenting another sector size to user.
I that possible at all?

On 08.04.2010, at 17:36, Dag-Erling Smørgrav wrote:

> I don't quite see how that would work - do you mean gpart should
> configure a gnop? AFAIK there is no "gnop label", so you can't set up a
> persistent gnop; you have to set it up manually at boot time every time,
> and there's a risk that the fs (or other layers higher up) will taste
> the underlying device instead of the gnop.

--

Alexey Tarasov

unread,
Apr 8, 2010, 10:12:22 AM4/8/10
to Dag-Erling Smørgrav, freebsd...@freebsd.org, Alexey Tarasov
Ok, in case of GPT? :-)
GPT implementation can be the simplest solution to this problem compared to implementing additional ATA commands to determine if disk is in Advanced Format.

On 08.04.2010, at 18:09, Dag-Erling Smørgrav wrote:

> Alexey Tarasov <m...@lexasoft.ru> writes:
>> I mean that gpart should act like gnop presenting another sector size
>> to user. I that possible at all?
>

> That depends on the underlying partition scheme. My guess is "no".
>
> (it all boils down to whether the desired logical sector size can
> somehow be recorded on-disk)
>

--

Dag-Erling Smørgrav

unread,
Apr 8, 2010, 10:24:12 AM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org
Alexey Tarasov <m...@lexasoft.ru> writes:
> Ok, in case of GPT? :-)

I doubt it, but I don't know for sure.

> GPT implementation can be the simplest solution to this problem
> compared to implementing additional ATA commands to determine if disk
> is in Advanced Format.

There are two issues:

1) There is already an ATA command to report both physical and logical
sector sizes, but the disk lies - it always reports 512/512.

2) The disk may have already been formatted on a system that doesn't
support 4k sectors, and may contain unaligned partitions and file
systems, which won't be visible if we forcibly and unconditionally
use 4k sectors.

Alexey Tarasov

unread,
Apr 8, 2010, 10:26:41 AM4/8/10
to Dag-Erling Smørgrav, freebsd...@freebsd.org, Alexey Tarasov
> 1) There is already an ATA command to report both physical and logical
> sector sizes, but the disk lies - it always reports 512/512.

Advanced Format disks reports 512, but there is another command in ATA standard which can tell us if it uses 4k sector.

> 2) The disk may have already been formatted on a system that doesn't
> support 4k sectors, and may contain unaligned partitions and file
> systems, which won't be visible if we forcibly and unconditionally
> use 4k sectors.

I mean that when I create *NEW* GPT scheme I can set up sector size emulation.
It will never touch existing unaligned partitions.

Dag-Erling Smørgrav

unread,
Apr 8, 2010, 10:35:18 AM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org
Alexey Tarasov <m...@lexasoft.ru> writes:
> Advanced Format disks reports 512, but there is another command in ATA
> standard which can tell us if it uses 4k sector.

Send me one and I'll look into it :)

Alexey Tarasov

unread,
Apr 8, 2010, 10:40:50 AM4/8/10
to Dag-Erling Smørgrav, freebsd...@freebsd.org, Alexey Tarasov
http://www.wdc.com/wdproducts/library/WhitePapers/ENG/2579-771430.pdf

> References
> The ATA8-ACS and SBC-3 standards have provisions for a disk drive to report Advanced Format sector sizes and other performance optimization information. These standards are used for SATA, SAS, USB, and IEEE 1394 based interface technologies.

> _______________________________________________
> freebsd...@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-curre...@freebsd.org"

Gary Jennejohn

unread,
Apr 8, 2010, 11:24:21 AM4/8/10
to Alexey Tarasov, Dag-Erling Smørgrav, freebsd...@freebsd.org
On Thu, 8 Apr 2010 18:40:50 +0400
Alexey Tarasov <m...@lexasoft.ru> wrote:

> http://www.wdc.com/wdproducts/library/WhitePapers/ENG/2579-771430.pdf
>
> > References
> > The ATA8-ACS and SBC-3 standards have provisions for a disk drive to report Advanced Format sector sizes and other performance optimization information. These standards are used for SATA, SAS, USB, and IEEE 1394 based interface technologies.
>

This is apparently the Long Physical Sector features set. The question is
whether it's been implemented.

--
Gary Jennejohn

Dimitry Andric

unread,
Apr 8, 2010, 11:35:47 AM4/8/10
to gary.je...@freenet.de, av, "Dag-Erling Smørgr"@freebsd.org, freebsd...@freebsd.org, Alexey Tarasov
On 2010-04-08 17:24, Gary Jennejohn wrote:
>>> References
>>> The ATA8-ACS and SBC-3 standards have provisions for a disk drive to report Advanced Format sector sizes and other performance optimization information. These standards are used for SATA, SAS, USB, and IEEE 1394 based interface technologies.
>>
>
> This is apparently the Long Physical Sector features set. The question is
> whether it's been implemented.

Isn't this already done? At least it looks like it:

http://svn.freebsd.org/viewvc/base?view=revision&revision=198897

It might even have been MFC'd... :)

Alexey Tarasov

unread,
Apr 8, 2010, 3:34:07 PM4/8/10
to Dimitry Andric, freebsd...@freebsd.org, Alexey Tarasov
Hello.

Thank you for the information.
In 8-STABLE snapshot 201002 diskinfo shows 512k sector size yet.
I will try CURRENT tomorrow.

Marcel Moolenaar

unread,
Apr 8, 2010, 3:30:01 PM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org

On Apr 8, 2010, at 6:06 AM, Alexey Tarasov wrote:

> Hello.
>
> There is only one possibility to change sector size of physical disk (gnop -S 4096 ...).
> May be it is possible to add such possibility to gpart? e.g. gpart create -S 4096 -t gpt ad0?
> It will help all unlucky WD Advanced Format disks users. :-D

A better approach is to have tunables for geom_disk to do this. This should absolutely
not be part of a partitioning tool. It violates everything there is to violate AFAICT.
FYI,

--
Marcel Moolenaar
xcl...@mac.com

Dimitry Andric

unread,
Apr 8, 2010, 4:44:34 PM4/8/10
to Alexey Tarasov, freebsd...@freebsd.org
On 2010-04-08 21:34, Alexey Tarasov wrote:
> Thank you for the information.
> In 8-STABLE snapshot 201002 diskinfo shows 512k sector size yet.
> I will try CURRENT tomorrow.

It looks like the code was MFC'd to stable/8 in r199443. However, even
in -CURRENT, the sector size you see in diskinfo will also be 512B.

For ada(4) disks, it seems the d_sectorsize field of geom_disk's struct
disk is initialized using the _logical_ sector size, not the physical
sector size (which may be a multiple of the logical sector size).

That said, if the physical sector size is larger than the logical
sector size, the d_stripesize field is initialized with it. So if you
run "diskinfo -v" on the disk, what is the output for stripesize?

Alexey Tarasov

unread,
Apr 9, 2010, 7:27:09 AM4/9/10
to Andriy Gapon, freebsd...@freebsd.org, Alexey Tarasov

> Or the disk doesn't actually report 4096 anywhere anyhow... Have you considered
> that? If yes, can you verify using any tools of any OS that the disk reports 4K
> in any way?

In the previous discussion we found that the disk reports 512 sector size, but there are additional ATA commands to determine if it has real sector size larger than 4k.
I will try to confirm this.

> P.S. DES's name looks strange in headers :-)

Really. :-)

> P.P.S.
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing in e-mail?

Sorry, to few experience. =)

Andriy Gapon

unread,
Apr 9, 2010, 7:32:03 AM4/9/10
to Alexey Tarasov, freebsd...@freebsd.org
on 09/04/2010 14:27 Alexey Tarasov said the following:

>> Or the disk doesn't actually report 4096 anywhere anyhow... Have you
>> considered that? If yes, can you verify using any tools of any OS that the
>> disk reports 4K in any way?
>
> In the previous discussion we found that the disk reports 512 sector size, but
> there are additional ATA commands to determine if it has real sector size
> larger than 4k. I will try to confirm this.

Thank you. I think that this would be an interesting detail.

--
Andriy Gapon

Andriy Gapon

unread,
Apr 9, 2010, 7:41:09 AM4/9/10
to Alexey Tarasov, freebsd...@freebsd.org
on 09/04/2010 14:33 Alexey Tarasov said the following:
> Here is the reference:
>
> http://www.wdc.com/wdproducts/library/WhitePapers/ENG/2579-771430.pdf

I saw it, but I want to see what's reported in reality.

--
Andriy Gapon

Alexey Tarasov

unread,
Apr 9, 2010, 7:45:19 AM4/9/10
to Andriy Gapon, freebsd...@freebsd.org, Alexey Tarasov

> I saw it, but I want to see what's reported in reality.

Installing Windows 7 now. How can OS installation be so long? :-)

Alexey Tarasov

unread,
Apr 9, 2010, 7:33:55 AM4/9/10
to Andriy Gapon, freebsd...@freebsd.org, Alexey Tarasov

On 09.04.2010, at 15:32, Andriy Gapon wrote:

Here is the reference:

http://www.wdc.com/wdproducts/library/WhitePapers/ENG/2579-771430.pdf

> References


> The ATA8-ACS and SBC-3 standards have provisions for a disk drive to report Advanced Format sector sizes and other performance optimization information. These standards are used for SATA, SAS, USB, and IEEE 1394 based interface technologies.

--

Alexey Tarasov

unread,
Apr 9, 2010, 8:37:02 AM4/9/10
to Dimitry Andric, freebsd...@freebsd.org, Andriy Gapon, Alexey Tarasov

> No, the problem is that you must use the ada(4) driver instead of ad(4).
> The new physical and logical sector support has only been implemented
> for the newer AHCI-over-CAM stack.

pass0: Raw identify data:
0: 427a 3fff c837 0010 0000 0000 003f 0000
8: 0000 0000 2020 2020 2057 442d 574d 4156
16: 5531 3531 3235 3739 0000 0000 0032 3830
24: 2e30 3041 3830 5744 4320 5744 3135 4541
32: 5253 2d30 305a 3542 3120 2020 2020 2020
40: 2020 2020 2020 2020 2020 2020 2020 8010
48: 0000 2f00 4001 0000 0000 0007 3fff 0010
56: 003f fc10 00fb 0110 ffff 0fff 0000 0007
64: 0003 0078 0078 0078 0078 0000 0000 0000
72: 0000 0000 0000 001f 1706 0000 0044 0040
80: 01fe 0000 746b 7f61 4123 7469 bc41 4123
88: 407f 00ab 00ab 0000 fffe 0000 80fe 0000
96: 0000 0000 0000 0000 7b30 aea8 0000 0000
104: 0000 0000 0000 0000 5001 4ee0 5743 482f
112: 0000 0000 0000 0000 0000 0000 0000 4018
120: 4018 0000 0000 0000 0000 0000 0000 0000
128: 0021 0000 0000 0000 0000 16db 0000 0000
136: 0000 0000 0000 0000 0000 0000 0004 0000
144: 0000 0000 0000 0000 0000 0000 0000 0000
152: 0000 0000 0000 0000 0000 0000 0000 0000
160: 0000 0000 0000 0000 0000 0000 0000 0000
168: 0000 0000 0000 0000 0000 0000 0000 0000
176: 0000 0000 0000 0000 0000 0000 0000 0000
184: 0000 0000 0000 0000 0000 0000 0000 0000
192: 0000 0000 0000 0000 0000 0000 0000 0000
200: 0000 0000 0000 0000 0000 0000 3031 0000
208: 0000 0000 0000 0000 0000 0000 0000 0000
216: 0000 0000 0000 0000 0000 0000 101e 0000
224: 0000 0000 0000 0000 0000 0000 0000 0000
232: 0000 0000 0001 1000 0000 0000 0000 0000
240: 0000 0000 0000 0000 0000 0000 0000 0000
248: 0000 0000 0000 0000 0000 0000 0000 3aa5
pass0: <WDC WD15EARS-00Z5B1 80.00A80> ATA-8 SATA 2.x device
pass0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)

protocol ATA/ATAPI-8 SATA 2.x
device model WDC WD15EARS-00Z5B1
firmware revision 80.00A80
serial number WD-WMAVU1512579
WWN 50014ee05743482f
cylinders 16383
heads 16
sectors/track 63
sector size logical 512, physical 512, offset 0
LBA supported 268435455 sectors
LBA48 supported 2930277168 sectors
PIO supported PIO4
DMA supported WDMA2 UDMA6

Feature Support Enable Value Vendor
read ahead yes yes
write cache yes yes
flush cache yes yes
overlap no
Tagged Command Queuing (TCQ) no no
Native Command Queuing (NCQ) yes 32 tags
SMART yes yes
microcode download yes yes
security yes no
power management yes yes
advanced power management no no 0/0x00
automatic acoustic management yes no 254/0xFE 128/0x80
media status notification no no
power-up in Standby yes no
write-read-verify no no 0/0x0
unload no no
free-fall no no
data set management (TRIM) no

Seems that the only possible way to use this disks is adding permanent (not like gnop) sector size emulation to some part of GEOM.

Reply all
Reply to author
Forward
0 new messages