Debian Codegraph @

tests/ts/fdisk/align-512-4K-md

raw
1 #!/bin/bash
2
3 #
4 # This file is part of util-linux.
5 #
6 # This file is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This file is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16
17
18 #
19 # Test alignment for 512/512 disk *with* topology -- aligned to optimal
20 # I/O size (32KiB)
21 #
22
23 TS_TOPDIR="${0%/*}/../.."
24 TS_DESC="align 512/4K +MD"
25
26 . "$TS_TOPDIR"/functions.sh
27 ts_init "$*"
28
29 ts_check_test_command "$TS_CMD_FDISK"
30
31 ts_skip_nonroot
32 ts_check_prog "mdadm"
33
34 # rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1
35 TS_KNOWN_FAIL="yes"
36
37 # set global variable TS_DEVICE
38 ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3
39 DEVNAME=$(basename $TS_DEVICE)
40
41 ts_log "Create partitions"
42 $TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
43 o
44 n
45 p
46 1
47
48 +49150
49 n
50 p
51 2
52
53 +49150
54 p
55 w
56 q
57 EOF
58
59 udevadm settle
60 ts_log "Alignment offsets:"
61 cat /sys/block/${DEVNAME}/${DEVNAME}{1,2}/alignment_offset >> $TS_OUTPUT 2>> $TS_ERRLOG
62
63 ts_lock "md"
64
65 MD_DEVNAME=md8
66 MD_DEVICE=/dev/${MD_DEVNAME}
67
68 mdadm -q -S ${MD_DEVICE} &> /dev/null
69 udevadm settle
70
71 mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 \
72 --level=0 --raid-devices=2 ${TS_DEVICE}1 ${TS_DEVICE}2 >> $TS_OUTPUT 2>> $TS_ERRLOG
73 udevadm settle
74
75 ts_log "Create partitions (MD)"
76 $TS_CMD_FDISK ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF
77 n
78 p
79 1
80
81 +10M
82 n
83 p
84 2
85
86 +10M
87 p
88 w
89 q
90 EOF
91
92 udevadm settle
93 ts_log "Alignment offsets (MD):"
94 cat /sys/block/${MD_DEVNAME}/${MD_DEVNAME}p{1,2}/alignment_offset >> $TS_OUTPUT 2>> $TS_ERRLOG
95
96 mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG
97
98 udevadm settle
99 ts_unlock "md"
100
101 ts_fdisk_clean $TS_DEVICE
102 ts_fdisk_clean $MD_DEVICE
103
104 ts_finalize