linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Sector size changes creating filesystem problems
@ 2025-07-16 14:30 Filipe Maia
  2025-07-16 16:21 ` Yu Kuai
  2025-07-16 17:10 ` Roman Mamedov
  0 siblings, 2 replies; 7+ messages in thread
From: Filipe Maia @ 2025-07-16 14:30 UTC (permalink / raw)
  To: linux-raid

Hi,

When a 4Kn disk is added to an mdadm array with sector size 512, its
sector size changes to 4096 to accommodate the new disk.

Here's an example:

```
truncate -s 1G /tmp/loop512a
truncate -s 1G /tmp/loop512b
truncate -s 1G /tmp/loop512c
truncate -s 1G /tmp/loop4Ka
losetup --sector-size 512  --direct-io=on /dev/loop0  /tmp/loop512a
losetup --sector-size 512  --direct-io=on /dev/loop1  /tmp/loop512b
losetup --sector-size 512  --direct-io=on /dev/loop2  /tmp/loop512c
losetup --sector-size 4096  --direct-io=on /dev/loop3  /tmp/loop4Ka
mdadm --create /dev/md2 --level=5 --raid-devices=3 /dev/loop[0-2]
# blockdev returns 512
blockdev --getss /dev/md2
mdadm /dev/md2 -a /dev/loop3
mdadm /dev/md2 -f /dev/loop2
# blockdev still returns 512
blockdev --getss /dev/md2
mdadm -S /dev/md2
mdadm -A /dev/md2 /dev/loop0 /dev/loop1 /dev/loop3
# blockdev now returns 4096
blockdev --getss /dev/md2
```

This breaks filesystems like XFS, with new mounts failing with:
`mount: /mnt: mount(2) system call failed: Function not implemented.`

Shouldn't the user be warned when this can happen?

Cheers,
Filipe

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

* Re: Sector size changes creating filesystem problems
  2025-07-16 14:30 Sector size changes creating filesystem problems Filipe Maia
@ 2025-07-16 16:21 ` Yu Kuai
  2025-07-17  1:07   ` Yu Kuai
  2025-07-17 21:07   ` Martin K. Petersen
  2025-07-16 17:10 ` Roman Mamedov
  1 sibling, 2 replies; 7+ messages in thread
From: Yu Kuai @ 2025-07-16 16:21 UTC (permalink / raw)
  To: Filipe Maia, linux-raid

Hi,

在 2025/7/16 22:30, Filipe Maia 写道:
> Hi,
>
> When a 4Kn disk is added to an mdadm array with sector size 512, its
> sector size changes to 4096 to accommodate the new disk.
>
> Here's an example:
>
> ```
> truncate -s 1G /tmp/loop512a
> truncate -s 1G /tmp/loop512b
> truncate -s 1G /tmp/loop512c
> truncate -s 1G /tmp/loop4Ka
> losetup --sector-size 512  --direct-io=on /dev/loop0  /tmp/loop512a
> losetup --sector-size 512  --direct-io=on /dev/loop1  /tmp/loop512b
> losetup --sector-size 512  --direct-io=on /dev/loop2  /tmp/loop512c
> losetup --sector-size 4096  --direct-io=on /dev/loop3  /tmp/loop4Ka
> mdadm --create /dev/md2 --level=5 --raid-devices=3 /dev/loop[0-2]
> # blockdev returns 512
> blockdev --getss /dev/md2
> mdadm /dev/md2 -a /dev/loop3
> mdadm /dev/md2 -f /dev/loop2
> # blockdev still returns 512
> blockdev --getss /dev/md2
> mdadm -S /dev/md2
> mdadm -A /dev/md2 /dev/loop0 /dev/loop1 /dev/loop3
> # blockdev now returns 4096
> blockdev --getss /dev/md2
> ```
>
> This breaks filesystems like XFS, with new mounts failing with:
> `mount: /mnt: mount(2) system call failed: Function not implemented.`
Yes, this is a known problem. Li Nan was trying to fix this long time ago.
>
> Shouldn't the user be warned when this can happen?
Kernel should forbid larger lbs new disk, however, this is still a missing
feature for now.

Thanks,

Kuai
>
> Cheers,
> Filipe
>

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

* Re: Sector size changes creating filesystem problems
  2025-07-16 14:30 Sector size changes creating filesystem problems Filipe Maia
  2025-07-16 16:21 ` Yu Kuai
@ 2025-07-16 17:10 ` Roman Mamedov
  2025-07-16 17:46   ` Filipe Maia
  2025-07-17  4:30   ` Christoph Hellwig
  1 sibling, 2 replies; 7+ messages in thread
From: Roman Mamedov @ 2025-07-16 17:10 UTC (permalink / raw)
  To: Filipe Maia; +Cc: linux-raid, linux-xfs

On Wed, 16 Jul 2025 15:30:20 +0100
Filipe Maia <filipe.c.maia@gmail.com> wrote:

> Hi,
> 
> When a 4Kn disk is added to an mdadm array with sector size 512, its
> sector size changes to 4096 to accommodate the new disk.
> 
> Here's an example:
> 
> ```
> truncate -s 1G /tmp/loop512a
> truncate -s 1G /tmp/loop512b
> truncate -s 1G /tmp/loop512c
> truncate -s 1G /tmp/loop4Ka
> losetup --sector-size 512  --direct-io=on /dev/loop0  /tmp/loop512a
> losetup --sector-size 512  --direct-io=on /dev/loop1  /tmp/loop512b
> losetup --sector-size 512  --direct-io=on /dev/loop2  /tmp/loop512c
> losetup --sector-size 4096  --direct-io=on /dev/loop3  /tmp/loop4Ka
> mdadm --create /dev/md2 --level=5 --raid-devices=3 /dev/loop[0-2]
> # blockdev returns 512
> blockdev --getss /dev/md2
> mdadm /dev/md2 -a /dev/loop3
> mdadm /dev/md2 -f /dev/loop2
> # blockdev still returns 512
> blockdev --getss /dev/md2
> mdadm -S /dev/md2
> mdadm -A /dev/md2 /dev/loop0 /dev/loop1 /dev/loop3
> # blockdev now returns 4096
> blockdev --getss /dev/md2
> ```
> 
> This breaks filesystems like XFS, with new mounts failing with:
> `mount: /mnt: mount(2) system call failed: Function not implemented.`

If you dd the XFS image from an old 512b disk onto a newly bought large
4K-sector HDD, would it also stop mounting on the new disk in the same way?

Perhaps something to be improved on the XFS side?

-- 
With respect,
Roman

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

* Re: Sector size changes creating filesystem problems
  2025-07-16 17:10 ` Roman Mamedov
@ 2025-07-16 17:46   ` Filipe Maia
  2025-07-17  4:30   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Filipe Maia @ 2025-07-16 17:46 UTC (permalink / raw)
  To: Roman Mamedov; +Cc: linux-raid, linux-xfs

> If you dd the XFS image from an old 512b disk onto a newly bought large
> 4K-sector HDD, would it also stop mounting on the new disk in the same way?
Yes, it causes exactly the same problem.
>
> Perhaps something to be improved on the XFS side?
Indeed!

Cheers,
Filipe

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

* Re: Sector size changes creating filesystem problems
  2025-07-16 16:21 ` Yu Kuai
@ 2025-07-17  1:07   ` Yu Kuai
  2025-07-17 21:07   ` Martin K. Petersen
  1 sibling, 0 replies; 7+ messages in thread
From: Yu Kuai @ 2025-07-17  1:07 UTC (permalink / raw)
  To: yukuai, Filipe Maia, linux-raid, yukuai (C)

+CC Li Nan

在 2025/07/17 0:21, Yu Kuai 写道:
> Hi,
> 
> 在 2025/7/16 22:30, Filipe Maia 写道:
>> Hi,
>>
>> When a 4Kn disk is added to an mdadm array with sector size 512, its
>> sector size changes to 4096 to accommodate the new disk.
>>
>> Here's an example:
>>
>> ```
>> truncate -s 1G /tmp/loop512a
>> truncate -s 1G /tmp/loop512b
>> truncate -s 1G /tmp/loop512c
>> truncate -s 1G /tmp/loop4Ka
>> losetup --sector-size 512  --direct-io=on /dev/loop0  /tmp/loop512a
>> losetup --sector-size 512  --direct-io=on /dev/loop1  /tmp/loop512b
>> losetup --sector-size 512  --direct-io=on /dev/loop2  /tmp/loop512c
>> losetup --sector-size 4096  --direct-io=on /dev/loop3  /tmp/loop4Ka
>> mdadm --create /dev/md2 --level=5 --raid-devices=3 /dev/loop[0-2]
>> # blockdev returns 512
>> blockdev --getss /dev/md2
>> mdadm /dev/md2 -a /dev/loop3
>> mdadm /dev/md2 -f /dev/loop2
>> # blockdev still returns 512
>> blockdev --getss /dev/md2
>> mdadm -S /dev/md2
>> mdadm -A /dev/md2 /dev/loop0 /dev/loop1 /dev/loop3
>> # blockdev now returns 4096
>> blockdev --getss /dev/md2
>> ```
>>
>> This breaks filesystems like XFS, with new mounts failing with:
>> `mount: /mnt: mount(2) system call failed: Function not implemented.`
> Yes, this is a known problem. Li Nan was trying to fix this long time ago.
>>
>> Shouldn't the user be warned when this can happen?
> Kernel should forbid larger lbs new disk, however, this is still a missing
> feature for now.

You can try this set:

https://lore.kernel.org/all/20250304121918.3159388-1-linan666@huaweicloud.com/

> 
> Thanks,
> 
> Kuai
>>
>> Cheers,
>> Filipe
>>
> 
> .
> 


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

* Re: Sector size changes creating filesystem problems
  2025-07-16 17:10 ` Roman Mamedov
  2025-07-16 17:46   ` Filipe Maia
@ 2025-07-17  4:30   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-07-17  4:30 UTC (permalink / raw)
  To: Roman Mamedov; +Cc: Filipe Maia, linux-raid, linux-xfs

On Wed, Jul 16, 2025 at 10:10:03PM +0500, Roman Mamedov wrote:
> If you dd the XFS image from an old 512b disk onto a newly bought large
> 4K-sector HDD, would it also stop mounting on the new disk in the same way?
> 
> Perhaps something to be improved on the XFS side?

Nothing to be improved, as the sector size obviously matters.  It is
part of the hardware geometry that is fixed, as XFS can read and write
down to the sector size boundary.  Both for internal metadata, and
through direct I/O also for applications.  The latter is true for other
file systems to, so even when you can change the sector size for some
file systems, you will be subtly breaking applications instead.

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

* Re: Sector size changes creating filesystem problems
  2025-07-16 16:21 ` Yu Kuai
  2025-07-17  1:07   ` Yu Kuai
@ 2025-07-17 21:07   ` Martin K. Petersen
  1 sibling, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-07-17 21:07 UTC (permalink / raw)
  To: Yu Kuai; +Cc: Filipe Maia, linux-raid


>> Shouldn't the user be warned when this can happen?

> Kernel should forbid larger lbs new disk,

This is really something mdadm should validate prior to adding a new
device to an existing array.

-- 
Martin K. Petersen

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

end of thread, other threads:[~2025-07-17 21:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16 14:30 Sector size changes creating filesystem problems Filipe Maia
2025-07-16 16:21 ` Yu Kuai
2025-07-17  1:07   ` Yu Kuai
2025-07-17 21:07   ` Martin K. Petersen
2025-07-16 17:10 ` Roman Mamedov
2025-07-16 17:46   ` Filipe Maia
2025-07-17  4:30   ` Christoph Hellwig

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).