summaryrefslogtreecommitdiff
path: root/common/config
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-08-19 18:04:01 -0700
committerEryu Guan <guaneryu@gmail.com>2021-08-22 19:44:21 +0800
commitd405c21d40aa1f0ca846dd144a1a7731e55679b2 (patch)
treeaf04dbadedfc03d73fffb32a86e7d5ddcb5d925e /common/config
parent2e58996bdbcf6ce68a3286c1b36244e796dc103a (diff)
common/module: add patient module rmmod support
When we call rmmod it will fail if the refcnt is greater than 0. This is expected, however, if using test modules such as scsi_debug, userspace tests may expect that once userspace is done issuing out commands it can safely remove the module, and the module will be removed. This is not true for few reasons. First, a module might take a while to quiesce after its used. This varies module by module. For example, at least for scsi_debug there is one patch to help with this but that is not sufficient to address all the removal issues, it just helps quiesce the module faster. If something like LVM pvremove is used, as in the case of generic/108, it may take time before the module's refcnt goes to 0 even if DM_DEFERRED_REMOVE is *not* used and even if udevadm settle is used. Even *after* all this... the module refcnt is still very fickle. For example, any blkdev_open() against a block device will bump a module refcnt up and we have little control over stopping these sporadic userspace calls after a test. A failure on module removal then just becomes an inconvenience on false positives. This was first observed on scsi_debug [0]. Doug worked on a patch to help the driver quiesce [1]. Later the issue has been determined to be generic [2]. The only way to properly resolve these issues is with a patient module remover. The kernel used to support a wait for the delete_module() system call, however this was later deprecated into kmod with a 10 second userspace sleep. That 10 second sleep is long gone from kmod now though. I've posted patches now for a kmod patient module remover then [3], in light of the fact that this issue is generic and the only way to then properly deal with this is implementing a userspace patient module remover. Use the kmod patient module remover when supported, otherwise we open code our own solution inside fstests. We default to a timeout of 100 seconds. Each test can override the timeout by setting the variable MODPROBE_PATIENT_RM_TIMEOUT_SECONDS or setting it to "forever" if they wish for the patience to be infinite. This uses kmod's patient module remover if you have that feature, otherwise we open code a solution in fstests which is a simplified version of what has been proposed for kmod. [0] https://bugzilla.kernel.org/show_bug.cgi?id=212337 [1] https://lore.kernel.org/linux-scsi/20210508230745.27923-1-dgilbert@interlog.com/ [2] https://bugzilla.kernel.org/show_bug.cgi?id=214015 [3] https://lkml.kernel.org/r/20210810051602.3067384-1-mcgrof@kernel.org Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Diffstat (limited to 'common/config')
-rw-r--r--common/config31
1 files changed, 31 insertions, 0 deletions
diff --git a/common/config b/common/config
index 005fd50a..164381b7 100644
--- a/common/config
+++ b/common/config
@@ -252,6 +252,37 @@ if [[ "$UDEV_SETTLE_PROG" == "" || ! -d /proc/net ]]; then
fi
export UDEV_SETTLE_PROG
+# Set MODPROBE_PATIENT_RM_TIMEOUT_SECONDS to "forever" if you want the patient
+# modprobe removal to run forever trying to remove a module.
+MODPROBE_REMOVE_PATIENT=""
+modprobe --help | grep -q -1 "remove-patiently"
+if [[ $? -ne 0 ]]; then
+ if [[ -z "$MODPROBE_PATIENT_RM_TIMEOUT_SECONDS" ]]; then
+ # We will open code our own implementation of patient module
+ # remover in fstests. Use a 50 second default.
+ export MODPROBE_PATIENT_RM_TIMEOUT_SECONDS="50"
+ fi
+else
+ MODPROBE_RM_PATIENT_TIMEOUT_ARGS=""
+ if [[ ! -z "$MODPROBE_PATIENT_RM_TIMEOUT_SECONDS" ]]; then
+ if [[ "$MODPROBE_PATIENT_RM_TIMEOUT_SECONDS" != "forever" ]]; then
+ MODPROBE_PATIENT_RM_TIMEOUT_MS="$((MODPROBE_PATIENT_RM_TIMEOUT_SECONDS * 1000))"
+ MODPROBE_RM_PATIENT_TIMEOUT_ARGS="-t $MODPROBE_PATIENT_RM_TIMEOUT_MS"
+ fi
+ else
+ # We export MODPROBE_PATIENT_RM_TIMEOUT_SECONDS here for parity
+ # with environments without support for modprobe -p, but we
+ # only really need it exported right now for environments which
+ # don't have support for modprobe -p to implement our own
+ # patient module removal support within fstests.
+ export MODPROBE_PATIENT_RM_TIMEOUT_SECONDS="50"
+ MODPROBE_PATIENT_RM_TIMEOUT_MS="$((MODPROBE_PATIENT_RM_TIMEOUT_SECONDS * 1000))"
+ MODPROBE_RM_PATIENT_TIMEOUT_ARGS="-t $MODPROBE_PATIENT_RM_TIMEOUT_MS"
+ fi
+ MODPROBE_REMOVE_PATIENT="modprobe -p $MODPROBE_RM_TIMEOUT_ARGS"
+fi
+export MODPROBE_REMOVE_PATIENT
+
export MKFS_XFS_PROG=$(type -P mkfs.xfs)
export MKFS_EXT4_PROG=$(type -P mkfs.ext4)
export MKFS_UDF_PROG=$(type -P mkudffs)