Bug 569949

Summary: must properly align luks device relative to Linux "topology" info
Product: Red Hat Enterprise Linux 6 Reporter: Mike Snitzer <msnitzer>
Component: cryptsetup-luksAssignee: Milan Broz <mbroz>
Status: CLOSED CURRENTRELEASE QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: agk, borgan, dwysocha, mbroz, prockai, pvrabec, qcai, syeghiay, yanwang
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: cryptsetup-luks-1.1.2-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-11-10 20:04:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 598523, 621684    
Bug Blocks: 519834    

Description Mike Snitzer 2010-03-02 19:21:35 UTC
Description of problem:
luks devices may be misaligned if they are layered on a device that has an alignment_offset != 0.

Actual results:
Users have seen issues stemming from luks being unaware of Linux's "topology"-provided alignment_offset:
https://bugzilla.redhat.com/show_bug.cgi?id=569021#c9

Expected results:
When creating a luks device the alignment_offset should be used to properly align the device.

Comment 1 Milan Broz 2010-05-03 13:24:52 UTC
Device alignment code is now upstream and in rawhide (1.1.1-rc1), I'll respin update in RHEL6 later.

Comment 2 Milan Broz 2010-05-05 14:46:40 UTC
Fixed in cryptsetup-luks-1.1.1-0.2.el6.

Comment 4 yanfu,wang 2010-05-27 14:12:59 UTC
verified on kernel 2.6.32-29 on x86_64 and i386 arch used http://code.google.com/p/cryptsetup/source/browse/trunk/tests/align-test, which will integrated to exist rhts testcase.
here is result:
# Create desktop-class 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced offset 8192 (256 bits key)...PASSED
Formatting using forced offset 8192 (128 bits key)...PASSED
# Create desktop-class 4K drive w/ 63-sector DOS partition compensation
# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)
Formatting using topology info (256 bits key)....PASSED
Formatting using topology info (128 bits key)....PASSED
# Create enterprise-class 4K drive
# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using topology info (128 bits key)....PASSED
# Create classic 512b drive and stack dm-linear
# (logical_block_size=512, physical_block_size=512, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced offset 8192 (128 bits key)...PASSED

Comment 5 Milan Broz 2010-06-01 12:32:06 UTC
Seems that it is broken on PPC at least, self-returning back to ASSIGNED:-)

# Formatting device /dev/sdb as type LUKS1.
# Initializing crypto backend (using secure memory).
# Topology: IO (17592186044416/140737488355328), offset = 0; Required alignment is 140737488355328 bytes.

(But then it use default.)

Comment 7 Milan Broz 2010-06-07 08:25:34 UTC
Fixed in cryptsetup-luks-1.1.2-1.el6.

Comment 8 yanfu,wang 2010-06-18 03:06:06 UTC
verified on rhel6-snapshot-6:
[root@ibm-js22-vios-01-lp1 4k_disk_sectors]# uname -a
Linux ibm-js22-vios-01-lp1.rhts.eng.bos.redhat.com 2.6.32-30.el6.ppc64 #1 SMP Tue May 25 18:03:33 EDT 2010 ppc64 ppc64 ppc64 GNU/Linux
[root@ibm-js22-vios-01-lp1 4k_disk_sectors]# rpm -qa|grep cryptsetup
cryptsetup-luks-1.1.2-1.el6.ppc64
cryptsetup-luks-libs-1.1.2-1.el6.ppc64

[root@ibm-js22-vios-01-lp1 4k_disk_sectors]# ./align-test.sh 
# Create desktop-class 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....semid 360448: semop failed for cookie 0xd4d7ba9: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223181737 (0xd4d7ba9) to initialize waiting for incoming notifications.
PASSED
Formatting using topology info (128 bits key)....semid 425984: semop failed for cookie 0xd4d5ea6: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223174310 (0xd4d5ea6) to initialize waiting for incoming notifications.
PASSED
Formatting using forced offset 8192 (256 bits key)...semid 491520: semop failed for cookie 0xd4d6314: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223175444 (0xd4d6314) to initialize waiting for incoming notifications.
PASSED
Formatting using forced offset 8192 (128 bits key)...semid 557056: semop failed for cookie 0xd4dfa37: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223214135 (0xd4dfa37) to initialize waiting for incoming notifications.
PASSED
# Create desktop-class 4K drive w/ 63-sector DOS partition compensation
# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)
Formatting using topology info (256 bits key)....semid 622592: semop failed for cookie 0xd4d107e: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223154302 (0xd4d107e) to initialize waiting for incoming notifications.
PASSED
Formatting using topology info (128 bits key)....semid 688128: semop failed for cookie 0xd4d6468: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223175784 (0xd4d6468) to initialize waiting for incoming notifications.
PASSED
# Create enterprise-class 4K drive
# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....semid 753664: semop failed for cookie 0xd4d7141: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223179073 (0xd4d7141) to initialize waiting for incoming notifications.
PASSED
Formatting using topology info (128 bits key)....semid 819200: semop failed for cookie 0xd4dd277: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223203959 (0xd4dd277) to initialize waiting for incoming notifications.
PASSED
# Create classic 512b drive and stack dm-linear
# (logical_block_size=512, physical_block_size=512, alignment_offset=0)
/dev/mapper/luks0xbabe not set up by udev: Falling back to direct node creation.
Formatting using topology info (256 bits key)....semid 917504: semop failed for cookie 0xd4d6269: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223175273 (0xd4d6269) to initialize waiting for incoming notifications.
PASSED
Formatting using topology info (128 bits key)....semid 983040: semop failed for cookie 0xd4d4779: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223168377 (0xd4d4779) to initialize waiting for incoming notifications.
PASSED
Formatting using forced offset 8192 (128 bits key)...semid 1048576: semop failed for cookie 0xd4d6354: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223175508 (0xd4d6354) to initialize waiting for incoming notifications.
PASSED
semid 1081344: semop failed for cookie 0xd4ddc15: incorrect semaphore state
Failed to set a proper state for notification semaphore identified by cookie value 223206421 (0xd4ddc15) to initialize waiting for incoming notifications.

Comment 9 Mike Snitzer 2010-07-15 15:18:58 UTC
*** Bug 533894 has been marked as a duplicate of this bug. ***

Comment 10 yanfu,wang 2010-09-10 02:45:24 UTC
seems there's regression problem occurs on all arch on rhel6-rc1 when I schedule rhts job to test 4K topology aware feature:
https://beaker.engineering.redhat.com/logs/2010/24/15624/29666/367763///TESTOUT.log

and I test it by manual and failed again:
# uname -a
Linux dell-per805-01.rhts.eng.bos.redhat.com 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
# rpm -qa|grep cryptsetup-luks
cryptsetup-luks-libs-1.1.2-2.el6.x86_64
cryptsetup-luks-1.1.2-2.el6.x86_64
# ./align-test.sh 
# Create desktop-class 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....FAIL
Expected alignment differs: expected 2112 != detected 4096

Comment 11 Milan Broz 2010-09-10 13:36:27 UTC
This is not bug at all, just we are using default alignment to !1MiB now, please fix you test case, needed patch for ustream testcase is part of src.rpm already  (cryptsetup-align-1MiB.patch )

Changes because of bug 621673. (I said somewhere it will need test changes, probably it lost somewhere.)

Comment 13 yanfu,wang 2010-09-14 03:41:58 UTC
verified use the new cryptsetup-align testcase and pass:
# ./align-test
# Create desktop-class 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using forced sector alignment 8 (256 bits key)...PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced sector alignment 8 (128 bits key)...PASSED
Formatting using forced sector alignment 8192 (256 bits key)...PASSED
Formatting using forced sector alignment 8192 (128 bits key)...PASSED
# Create desktop-class 4K drive w/ 63-sector DOS partition compensation
# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584)
Formatting using topology info (256 bits key)....PASSED
Formatting using forced sector alignment 8 (256 bits key)...PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced sector alignment 8 (128 bits key)...PASSED
# Create enterprise-class 4K drive
# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using forced sector alignment 8 (256 bits key)...PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced sector alignment 8 (128 bits key)...PASSED
# Create classic 512b drive and stack dm-linear
# (logical_block_size=512, physical_block_size=512, alignment_offset=0)
Formatting using topology info (256 bits key)....PASSED
Formatting using forced sector alignment 8 (256 bits key)...PASSED
Formatting using topology info (128 bits key)....PASSED
Formatting using forced sector alignment 8 (128 bits key)...PASSED
Formatting using forced sector alignment 8192 (128 bits key)...PASSED

Comment 14 releng-rhel@redhat.com 2010-11-10 20:04:57 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.