Re: kernel 6.12-rc7 device-mapper inconsistency

2024-11-18 Thread dap581
>On Monday, November 18th, 2024 at 1:27 PM, Mikulas Patocka 
> wrote:
> Hi 
> Please apply this patch and report what it prints. So, that we can find
> out which limits cause the problem.
> Mikulas

Hello,
Sorry for the delay, with patch applied to 6.12.0 released today:
dmesg output after running luksOpen on hdd (sda)

[  109.421097] failure 4: fffe00, 1000
[  109.421112] device-mapper: table: 254:1: adding target device sda1 caused an 
alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
alignment_offset=0, start=16777216
[  109.421123] failure 4: fffe00, 1000
[  109.421126] device-mapper: table: 254:1: adding target device sda1 caused an 
alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
alignment_offset=0, start=16777216
[  109.421379] failure 4: fffe00, 1000
[  109.421384] device-mapper: table: 254:1: adding target device sda1 caused an 
alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
alignment_offset=0, start=16777216
[  109.421392] failure 4: fffe00, 1000
[  109.421395] device-mapper: table: 254:1: adding target device sda1 caused an 
alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
alignment_offset=0, start=16777216

>Hi
>Does this patch fix it?
---
 block/blk-settings.c |7 +++
 1 file changed, 7 insertions(+)

Index: linux-2.6/block/blk-settings.c
===
--- linux-2.6.orig/block/blk-settings.c 2024-11-18 15:24:18.0 +0100
+++ linux-2.6/block/blk-settings.c  2024-11-18 15:29:24.0 +0100
@@ -250,6 +250,13 @@ static int blk_validate_limits(struct qu
lim->io_min = lim->physical_block_size;
 
/*
+* The optimal I/O size may not be aligned to physical block size
+* (because it may be limited by dma engines which have no clue about
+* block size of the disks attached to them), so we round it down here.
+*/
+   lim->io_opt = round_down(lim->io_opt, lim->physical_block_size);
+
+   /*
 * max_hw_sectors has a somewhat weird default for historical reason,
 * but driver really should set their own instead of relying on this
 * value.



Yes!
With the above patch applied (blk-settings: round down io_opt to 
physical_block_size)
No more "device-mapper inconsistency" when I unlock my hdd, I also tried the 
other hdd to make sure.
All good.

lsblk -t

NAME  ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE
RA WSAME
sda   0   4096 167731204096 5121 bfq   256 
327600B
└─sda10   4096 167731204096 5121 bfq   256 
327600B
  └─raid-hdd4 0   4096 16773120409640961   
327600B
sdb   0   4096 167731204096 5121 bfq   256 
327600B
└─sdb10   4096 167731204096 5121 bfq   256 
327600B
  └─raid-hdd3 0   4096 16773120409640961   
327600B
sdc   0   4096 167731204096 5121 bfq   256 
327600B
└─sdc10   4096 167731204096 5121 bfq   256 
327600B
  └─raid-hdd2 0   4096 16773120409640961   
327600B
sdd   0   4096 167731204096 5121 bfq   256 
327600B
└─sdd10   4096 167731204096 5121 bfq   256 
327600B
  └─raid-hdd1 0   4096 16773120409640961   
327600B

Thanks!



Re: kernel 6.12-rc7 device-mapper inconsistency

2024-11-18 Thread Mikulas Patocka
Hi

Please apply this patch and report what it prints. So, that we can find 
out which limits cause the problem.

Mikulas



On Sat, 16 Nov 2024, dap581 wrote:

> Hello,
> Starting with kernel 6.11.x series up to current 6.12-rc7
> when I unlock my encrypted hdd (storage, not root) with cryptsetup:
> 
> cryptsetup luksOpen /dev/sda1 hdd5 -d keyfile_hdd5
> 
> it triggers an alignment inconsistency:
> In dmesg log, I read:
> 
> [  105.841278] device-mapper: table: 254:1: adding target device sda1 caused 
> an alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
> alignment_offset=0, start=16777216
> [  105.841292] device-mapper: table: 254:1: adding target device sda1 caused 
> an alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
> alignment_offset=0, start=16777216
> [  105.841601] device-mapper: table: 254:1: adding target device sda1 caused 
> an alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
> alignment_offset=0, start=16777216
> [  105.841607] device-mapper: table: 254:1: adding target device sda1 caused 
> an alignment inconsistency: physical_block_size=4096, logical_block_size=512, 
> alignment_offset=0, start=16777216
> 
> 
> Also, starting with Linux >6.11.x up to current 6.12-rc7, "lsblk -t" 
> returns different values than before in OPT-IO & RA column.
> 
> 
> With kernel >6.11.x
> With device closed:
> NAME ALIGNMENT MIN-IO   OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE
> RA WSAME
> sda  0   4096 167767044096 5121 bfq   256 
> 327640B
> └─sda1   0   4096 167767044096 40961 bfq   256 
> 327640B
> After luksOpen:
> sda  0   4096 167767044096 5121 bfq   256 
> 327640B
> └─sda1   0   4096 167767044096 5121 bfq   256 
> 327640B
>   └─hdd5-1   40960409640961   
> 327640B
> 
> 
> I tried to track down when this started exactly, to do so, I compiled kernel:
> 6.7.12, 6.8.12, 6.9.9, 6.10.14
> and none of them returns this device-mapper inconsistency.
> lsblk -t with kernel 6.10.14 and earlier:
> NAME ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE  RA 
> WSAME
> sda  0   4096  04096 5121 bfq   256 128   
>  0B
> └─sda1   0   4096  04096 5121 bfq   256 128   
>  0B
>   └─hdd5 0   4096  0409640961   128   
>  0B
> 
> So far, I have been able to locate this commit (part of Linux 6.11.x) 
> a23634644afc2f7c1bac98776440a1f3b161819e (block: take io_opt and io_min 
> into account for max_sectors ) that seems to trigger the change in lsblk 
> output and introduces opt-io & ra value but as a casual user, I can't 
> say for sure, I'm not a developer either. On the other hand, if I 
> compile a kernel using one or two commit before 
> a23634644afc2f7c1bac98776440a1f3b161819e then the lsblk -t output is not 
> changed and no "device-mapper inconsistency" appears so it seems at 
> least related somehow. By the way, after enteting my password (or using 
> keyfile) cryptsetup returns no error and the filesystem (btrfs) mounts 
> correctly.
> 
> Let me know if you need other info.
> See also: https://gitlab.com/cryptsetup/cryptsetup/-/issues/919
> 
> System used: Gentoo
> 
> The HDD is connected to an SAS HBA (Dell Perc H310 with IT firmware) 
> Actually, there are also 4 other HDD (same brand, model, capacity, same 
> configuration used) connected to it and they all show the exact same 
> message "device-mapper inconsistency" as soon as there are unlocked.
> 
> gdisk -l /dev/sda
> 
> Disk /dev/sda: 5860533168 sectors, 2.7 TiB
> Model: WDC WD30EZRX-00D
> Sector size (logical/physical): 512/4096 bytes
> Disk identifier (GUID): 4D31A7E7-A2A6-4A5A-8FE1-8368581B78DC
> Partition table holds up to 128 entries
> Main partition table begins at sector 2 and ends at sector 33
> First usable sector is 34, last usable sector is 5860533134
> Partitions will be aligned on 2048-sector boundaries
> Total free space is 2924 sectors (1.4 MiB)
> 
> Number  Start (sector)End (sector)  Size   Code  Name
>12048  5860532224   2.7 TiB 8300  Linux filesystem
> 
> 
> luksDump /dev/sda1
> 
> LUKS header information
> Version:   2
> Epoch: 5
> Metadata area: 16384 [bytes]
> Keyslots area: 1678 [bytes]
> UUID:   d1ff1c64-a294-4287-ab33-215327716e96
> Label: hdd5
> Subsystem: (no subsystem)
> Flags:   (no flags)
> 
> Data segments:
>   0: crypt
> offset: 16777216 [bytes]
> length: (whole device)
> cipher: serpent-xts-plain64
> sector: 4096 [bytes]
> 
> 
> 
---
 block/blk-settings.c |6 ++
 1 file changed, 6 insertions(+)

Index: linux-2.6/block/blk-settings.c
===
--- linux-2.6.orig/block/blk-