Merge commit 'refs/top-bases/linux-legacy' into linux-legacy

This commit is contained in:
Brian Behlendorf 2009-10-27 15:03:29 -07:00
commit a8d302ff83
3 changed files with 47 additions and 30 deletions

View File

@ -15,10 +15,21 @@ LVCREATE=${LVCREATE:-/sbin/lvcreate}
LVREMOVE=${LVREMOVE:-/sbin/lvremove} LVREMOVE=${LVREMOVE:-/sbin/lvremove}
LVNAME=${LVNAME:-"lv_tank"} LVNAME=${LVNAME:-"lv_tank"}
LVSTRIPES=${LVSTRIPES:-4} LVSTRIPES=${LVSTRIPES:-4}
LVSIZE=${LVSIZE:-4G} LVSIZE=${LVSIZE:-32G}
DEVICES="/dev/${VGNAME}/${LVNAME}" DEVICES="/dev/${VGNAME}/${LVNAME}"
zpool_dm_destroy() {
msg ${LVREMOVE} -f ${VGNAME}/${LVNAME}
${LVREMOVE} -f ${VGNAME}/${LVNAME} >/dev/null
msg ${VGREMOVE} -f ${VGNAME}
${VGREMOVE} -f ${VGNAME} >/dev/null
msg ${PVREMOVE} ${PVDEVICES}
${PVREMOVE} ${PVDEVICES} >/dev/null
}
zpool_create() { zpool_create() {
# Remove EFI labels which cause pvcreate failure # Remove EFI labels which cause pvcreate failure
for DEVICE in ${PVDEVICES}; do for DEVICE in ${PVDEVICES}; do
@ -26,30 +37,24 @@ zpool_create() {
done done
msg ${PVCREATE} -f ${PVDEVICES} msg ${PVCREATE} -f ${PVDEVICES}
${PVCREATE} -f ${PVDEVICES} || exit 1 ${PVCREATE} -f ${PVDEVICES} >/dev/null || exit 1
msg ${VGCREATE} ${VGNAME} ${PVDEVICES} msg ${VGCREATE} ${VGNAME} ${PVDEVICES}
${VGCREATE} ${VGNAME} ${PVDEVICES} || exit 2 ${VGCREATE} ${VGNAME} ${PVDEVICES} >/dev/null || exit 2
msg ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \ msg ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
--name=${LVNAME} ${VGNAME} --name=${LVNAME} ${VGNAME}
${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \ ${LVCREATE} --size=${LVSIZE} --stripes=${LVSTRIPES} \
--name=${LVNAME} ${VGNAME} || exit 3 --name=${LVNAME} ${VGNAME} >/dev/null || exit 3
msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 4 ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
${DEVICES} || (zpool_dm_destroy && exit 4)
} }
zpool_destroy() { zpool_destroy() {
msg ${ZPOOL} destroy ${ZPOOL_NAME} msg ${ZPOOL} destroy ${ZPOOL_NAME}
${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 ${ZPOOL} destroy ${ZPOOL_NAME}
msg ${LVREMOVE} -f ${VGNAME}/${LVNAME} zpool_dm_destroy
${LVREMOVE} -f ${VGNAME}/${LVNAME} || exit 2
msg ${VGREMOVE} -f ${VGNAME}
${VGREMOVE} -f ${VGNAME} || exit 3
msg ${PVREMOVE} ${PVDEVICES}
${PVREMOVE} ${PVDEVICES} || exit 4
} }

View File

@ -10,23 +10,29 @@ MDRAID=${MDRAID:-10}
DEVICES="/dev/md0" DEVICES="/dev/md0"
zpool_md_destroy() {
msg ${MDADM} --manage --stop ${DEVICES}
${MDADM} --manage --stop ${DEVICES} &>/dev/null
msg ${MDADM} --zero-superblock ${MDDEVICES}
${MDADM} --zero-superblock ${MDDEVICES} >/dev/null
}
zpool_create() { zpool_create() {
msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \ msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \
--raid-devices=${MDCOUNT} ${MDDEVICES} --raid-devices=${MDCOUNT} ${MDDEVICES}
${MDADM} --create ${DEVICES} --level=${MDRAID} \ ${MDADM} --create ${DEVICES} --level=${MDRAID} \
--raid-devices=${MDCOUNT} ${MDDEVICES} || exit 1 --raid-devices=${MDCOUNT} ${MDDEVICES} \
&>/dev/null || (zpool_md_destroy && exit 1)
msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 2 ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
${DEVICES} || (zpool_md_destroy && exit 2)
} }
zpool_destroy() { zpool_destroy() {
msg ${ZPOOL} destroy ${ZPOOL_NAME} msg ${ZPOOL} destroy ${ZPOOL_NAME}
${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 ${ZPOOL} destroy ${ZPOOL_NAME}
msg ${MDADM} --manage --stop ${DEVICES} zpool_md_destroy
${MDADM} --manage --stop ${DEVICES} || exit 2
msg ${MDADM} --zero-superblock ${MDDEVICES}
${MDADM} --zero-superblock ${MDDEVICES} || exit 3
} }

View File

@ -10,23 +10,29 @@ MDRAID=${MDRAID:-5}
DEVICES="/dev/md0" DEVICES="/dev/md0"
zpool_md_destroy() {
msg ${MDADM} --manage --stop ${DEVICES}
${MDADM} --manage --stop ${DEVICES} &>/dev/null
msg ${MDADM} --zero-superblock ${MDDEVICES}
${MDADM} --zero-superblock ${MDDEVICES} >/dev/null
}
zpool_create() { zpool_create() {
msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \ msg ${MDADM} --create ${DEVICES} --level=${MDRAID} \
--raid-devices=${MDCOUNT} ${MDDEVICES} --raid-devices=${MDCOUNT} ${MDDEVICES}
${MDADM} --create ${DEVICES} --level=${MDRAID} \ ${MDADM} --create ${DEVICES} --level=${MDRAID} \
--raid-devices=${MDCOUNT} ${MDDEVICES} || exit 1 --raid-devices=${MDCOUNT} ${MDDEVICES} \
&>/dev/null || (zpool_md_destroy && exit 1)
msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} msg ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES}
${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} ${DEVICES} || exit 2 ${ZPOOL} create ${FORCE_FLAG} ${ZPOOL_NAME} \
${DEVICES} || (zpool_md_destroy && exit 2)
} }
zpool_destroy() { zpool_destroy() {
msg ${ZPOOL} destroy ${ZPOOL_NAME} msg ${ZPOOL} destroy ${ZPOOL_NAME}
${ZPOOL} destroy ${ZPOOL_NAME} || exit 1 ${ZPOOL} destroy ${ZPOOL_NAME}
msg ${MDADM} --manage --stop ${DEVICES} zpool_md_destroy
${MDADM} --manage --stop ${DEVICES} || exit 2
msg ${MDADM} --zero-superblock ${MDDEVICES}
${MDADM} --zero-superblock ${MDDEVICES} || exit 3
} }