From 6478a7f847d8fd392d04afb12a57b09d2d9417b5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 9 Aug 2010 11:14:09 -0700 Subject: [PATCH 1/3] Remove /zvol/ path component from zconfig.sh See previous commit for details. But the gist is with the removal of the zvol path component the regression tests must be updated to use the correct path name. --- scripts/zconfig.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index c671206186..2215548929 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -154,14 +154,14 @@ zconfig_test3() { # Partition the volume, for a 400M volume there will be # 812 cylinders, 16 heads, and 63 sectors per track. - zconfig_partition /dev/zvol/${FULL_NAME} 0 812 + zconfig_partition /dev/${FULL_NAME} 0 812 # Format the partition with ext3. - /sbin/mkfs.ext3 -q /dev/zvol/${FULL_NAME}1 || fail 5 + /sbin/mkfs.ext3 -q /dev/${FULL_NAME}1 || fail 5 # Mount the ext3 filesystem and copy some data to it. mkdir -p /tmp/${ZVOL_NAME} || fail 6 - mount /dev/zvol/${FULL_NAME}1 /tmp/${ZVOL_NAME} || fail 7 + mount /dev/${FULL_NAME}1 /tmp/${ZVOL_NAME} || fail 7 cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME} || fail 8 # Verify the copied files match the original files. @@ -180,10 +180,10 @@ zconfig_test3 zconfig_zvol_device_stat() { local EXPECT=$1 - local POOL_NAME=/dev/zvol/$2 - local ZVOL_NAME=/dev/zvol/$3 - local SNAP_NAME=/dev/zvol/$4 - local CLONE_NAME=/dev/zvol/$5 + local POOL_NAME=/dev/$2 + local ZVOL_NAME=/dev/$3 + local SNAP_NAME=/dev/$4 + local CLONE_NAME=/dev/$5 local COUNT=0 # Pool exists @@ -216,7 +216,7 @@ zconfig_zvol_device_stat() { zconfig_test4() { local POOL_NAME=tank local ZVOL_NAME=volume - local SNAP_NAME=snapshot + local SNAP_NAME=snap local CLONE_NAME=clone local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME} local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME} @@ -229,7 +229,7 @@ zconfig_test4() { ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3 - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 64 || fail 4 + zconfig_partition /dev/${FULL_ZVOL_NAME} 0 64 || fail 4 ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5 ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6 @@ -268,7 +268,7 @@ zconfig_test4 zconfig_test5() { POOL_NAME=tank ZVOL_NAME=volume - SNAP_NAME=snapshot + SNAP_NAME=snap CLONE_NAME=clone FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME} FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME} @@ -281,7 +281,7 @@ zconfig_test5() { ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3 - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 64 || fail 4 + zconfig_partition /dev/${FULL_ZVOL_NAME} 0 64 || fail 4 ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5 ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6 From d5168aa0895814433164d838e8ae0554a7206b77 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 9 Aug 2010 16:01:44 -0700 Subject: [PATCH 2/3] Insert small delay for udev While the zfs utilities do block until the expected device appears they can only do this for full devices, not partitions. This means that once as device appears it still may take a little bit of time before the kernel rescans the partition table, updates sysfs, udev is notified and the partition devices are created. The test case itself could block briefly waiting for the partition beause it knows what to expect. But for now the simpler thing to do is just delay. --- scripts/zconfig.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index 2215548929..dc11b9ca60 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -186,6 +186,9 @@ zconfig_zvol_device_stat() { local CLONE_NAME=/dev/$5 local COUNT=0 + # Briefly delay for udev + sleep 1 + # Pool exists stat ${POOL_NAME} &>/dev/null && let COUNT=$COUNT+1 @@ -245,7 +248,7 @@ zconfig_test4() { ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9 # Import the pool, wait 1 second for udev - ${ZPOOL} import ${POOL_NAME} && sleep 1 || fail 10 + ${ZPOOL} import ${POOL_NAME} || fail 10 # Verify the devices were created zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \ @@ -297,7 +300,7 @@ zconfig_test5() { ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9 # Load the modules, wait 1 second for udev - ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" && sleep 1 || fail 10 + ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 10 # Verify the devices were created zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \ From dfc166d174c1550dab8b4528232449e3e0d8f9e1 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 9 Aug 2010 14:48:12 -0700 Subject: [PATCH 3/3] Limit sysfs name to KOBJ_NAME_LEN It appears that in earlier kernels the maximum name length of a kobject was KOBJ_NAME_LEN (20) bytes. This was later extended to dynamically allocate enough memory if it was over KOBJ_NAME_LEN, and finally it was always made dynamic. Unfortunately, util this last step happened it doesn't look like it always safe to use names larger than KOBJ_NAME_LEN. For example, under the RHEL5 2.6.18 kernel if the kobject name length exceeds KOBJ_NAME_LEN a NULL dereference is tripped. To avoid this issue the build system has been update to check to see if KOBJ_NAME_LEN is defined. If it is we have to assume the maximum kobject name length is only 20 bytes. This 20 byte name must minimally include the following components. /[@snapshot[partition]] --- config/kernel-kobj-name-len.m4 | 21 +++++++++++++++++++++ config/kernel.m4 | 1 + 2 files changed, 22 insertions(+) create mode 100644 config/kernel-kobj-name-len.m4 diff --git a/config/kernel-kobj-name-len.m4 b/config/kernel-kobj-name-len.m4 new file mode 100644 index 0000000000..5363a41ca2 --- /dev/null +++ b/config/kernel-kobj-name-len.m4 @@ -0,0 +1,21 @@ +dnl # +dnl # 2.6.27 API change, +dnl # kobject KOBJ_NAME_LEN static limit removed. All users of this +dnl # constant were removed prior to 2.6.27, but to be on the safe +dnl # side this check ensures the constant is undefined. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_KOBJ_NAME_LEN], [ + AC_MSG_CHECKING([whether kernel defines KOBJ_NAME_LEN]) + ZFS_LINUX_TRY_COMPILE([ + #include + ],[ + int val; + val = KOBJ_NAME_LEN; + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_KOBJ_NAME_LEN, 1, + [kernel defines KOBJ_NAME_LEN]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index ca61dfd174..4c06981dcc 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -7,6 +7,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_CONFIG ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_TYPE_FMODE_T + ZFS_AC_KERNEL_KOBJ_NAME_LEN ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE ZFS_AC_KERNEL_INVALIDATE_BDEV_ARGS ZFS_AC_KERNEL_BDEV_LOGICAL_BLOCK_SIZE