blktests: replace module removal with patient module removal
PATCH 1/1 blktests: replace module removal with patient module removal
A long time ago, in a galaxy far, far away...
I ran into some odd scsi_debug false positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.
I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with scsi_debug there were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].
Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe blkdev_open() will easily bump a module refcnt, and these days many thing scan do that sort of thing.
The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015
--- common/multipath-over-rdma | 11 +-- common/null_blk | 9 ++- common/rc | 148 ++++++++++++++++++++++++++++++++++--- common/scsi_debug | 9 ++- tests/nvme/rc | 6 +- tests/nvmeof-mp/rc | 15 ++-- tests/srp/rc | 17 +---- 7 files changed, 166 insertions(+), 49 deletions(-)
common/multipath-over-rdma +3 -8
@@ -4,6 +4,7 @@ # # Functions and global variables used by both the srp and nvmeof-mp tests. +. common/rc . common/shellcheck . common/null_blk
@@ -427,14 +428,8 @@ stop_soft_rdma() { echo "$i ..." rdma link del "${i}" || echo "Failed to remove ${i}" done - if ! unload_module rdma_rxe 10; then - echo "Unloading rdma_rxe failed" - return 1 - fi - if ! unload_module siw 10; then - echo "Unloading siw failed" - return 1 - fi + _patient_rmmod rdma_rxe || return 1 + _patient_rmmod 1siw || return 1 } >>"$FULL" }
common/null_blk +5 -4
@@ -4,6 +4,8 @@ # # null_blk helper functions. +. common/rc + _have_null_blk() { _have_modules null_blk }
@@ -21,9 +23,8 @@ _init_null_blk() { local zoned="" if (( RUN_FOR_ZONED )); then zoned="zoned=1"; fi - if ! modprobe -r null_blk || ! modprobe null_blk "$@" "${zoned}" ; then - return 1 - fi + _patient_rmmod null_blk || return 1 + modprobe null_blk "$@" "${zoned}" || 1 udevadm settle return 0
@@ -46,5 +47,5 @@ _configure_null_blk() { _exit_null_blk() { _remove_null_blk_devices udevadm settle - modprobe -r null_blk + _patient_rmmod null_blk }
common/rc +138 -10
153 lines not on this page · raw message
common/scsi_debug +5 -4
@@ -4,14 +4,15 @@ # # scsi_debug helper functions. +. common/rc + _have_scsi_debug() { _have_modules scsi_debug } _init_scsi_debug() { - if ! modprobe -r scsi_debug || ! modprobe scsi_debug "$@"; then - return 1 - fi + _patient_rmmod scsi_debug || return 1 + modprobe scsi_debug "$@" || return 1 udevadm settle
@@ -51,5 +52,5 @@ _exit_scsi_debug() { unset SCSI_DEBUG_TARGETS unset SCSI_DEBUG_DEVICES udevadm settle - modprobe -r scsi_debug + _patient_rmmod scsi_debug }
tests/nvme/rc +3 -3
@@ -125,11 +125,11 @@ _cleanup_nvmet() { shopt -u nullglob trap SIGINT - modprobe -r nvme-"${nvme_trtype}" 2>/dev/null + _patient_rmmod nvme-"${nvme_trtype}" 2>/dev/null if [[ "${nvme_trtype}" != "loop" ]]; then - modprobe -r nvmet-"${nvme_trtype}" 2>/dev/null + _patient_rmmod nvmet-"${nvme_trtype}" 2>/dev/null fi - modprobe -r nvmet 2>/dev/null + _patient_rmmod nvmet 2>/dev/null if [[ "${nvme_trtype}" == "rdma" ]]; then stop_soft_rdma fi
tests/nvmeof-mp/rc +8 -7
@@ -164,12 +164,13 @@ start_nvme_client() { } stop_nvme_client() { - unload_module nvme-rdma || return $? - unload_module nvme-fabrics || return $? + _patient_rmmod nvme-rdma || return 1 + _patient_rmmod nvme-fabrics || return 1 # Ignore nvme and nvme-core unload errors - this test may be run on a # system equipped with one or more NVMe SSDs. - unload_module nvme >&/dev/null - unload_module nvme-core >&/dev/null + export MODPROBE_PATIENT_RM_TIMEOUT_SECONDS=5 + _patient_rmmod nvme + _patient_rmmod nvme-core return 0 }
@@ -269,9 +270,9 @@ stop_nvme_target() { rmdir "$d" done ) - unload_module nvmet_rdma && - unload_module nvmet && - _exit_null_blk + _patient_rmmod nvmet_rdma || return 1 + _patient_rmmod nvmet || return 1 + _exit_null_blk } start_target() {
tests/srp/rc +4 -13
@@ -326,16 +326,9 @@ stop_srp_ini() { local i log_out - for ((i=40;i>=0;i--)); do - remove_mpath_devs || return $? - unload_module ib_srp >/dev/null 2>&1 && break - sleep 1 - done - if [ -e /sys/module/ib_srp ]; then - echo "Error: unloading kernel module ib_srp failed" - return 1 - fi - unload_module scsi_transport_srp || return $? + remove_mpath_devs || return $? + _patient_rmmod ib_srp || return 1 + _patient_rmmod scsi_transport_srp || return $1 } # Associate the LIO device with name $1/$2 with file $3 and SCSI serial $4.
@@ -554,9 +547,7 @@ stop_lio_srpt() { for m in ib_srpt iscsi_target_mod target_core_pscsi target_core_iblock \ target_core_file target_core_stgt target_core_user \ target_core_mod - do - unload_module $m 10 || return $? - done + _patient_rmmod $m || return $1 } # Load and configure the SRP target driver
Signature · 1 line
2.33.0
Quoted 30 lines · Luis Chamberlain
A long time ago, in a galaxy far, far away...
I ran into some odd
scsi_debugfalse positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with
scsi_debugthere were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe
blkdev_open()will easily bump a module refcnt, and these days many thing scan do that sort of thing.The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
Quoted 7 lines
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015Signed-off-by Luis Chamberlain <[email protected]>
Thanks for having this work done and explaining the importance of it.
Give me couple of days, I'll provide you a feedback after I finish my testing of your patch.
Quoted 39 lines · Chaitanya Kulkarni
Quoted 30 lines · Luis Chamberlain
A long time ago, in a galaxy far, far away...
I ran into some odd
scsi_debugfalse positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with
scsi_debugthere were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe
blkdev_open()will easily bump a module refcnt, and these days many thing scan do that sort of thing.The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
Quoted 7 lines
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015Signed-off-by Luis Chamberlain <[email protected]>
Quoted 4 lines
Thanks for having this work done and explaining the importance of it.
Give me couple of days, I'll provide you a feedback after I finish my testing of your patch.
How did testing go?
Luis
Quoted 40 lines · Luis Chamberlain
Quoted 39 lines · Chaitanya Kulkarni
Quoted 37 lines · Luis Chamberlain
A long time ago, in a galaxy far, far away...
I ran into some odd
scsi_debugfalse positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with
scsi_debugthere were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe
blkdev_open()will easily bump a module refcnt, and these days many thing scan do that sort of thing.The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015Signed-off-by Luis Chamberlain <[email protected]>
Quoted 6 lines
Quoted 4 lines
Thanks for having this work done and explaining the importance of it.
Give me couple of days, I'll provide you a feedback after I finish my testing of your patch.
How did testing go?
*Friendly poke*
Luis
Quoted 30 lines · Luis Chamberlain
A long time ago, in a galaxy far, far away...
I ran into some odd
scsi_debugfalse positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with
scsi_debugthere were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe
blkdev_open()will easily bump a module refcnt, and these days many thing scan do that sort of thing.The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
Quoted 7 lines
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015Signed-off-by Luis Chamberlain <[email protected]>---
This looks good to me, I'd wait Bart (CCd here) to review the srp side.
Looks good.
Quoted 40 lines · Chaitanya Kulkarni
Quoted 30 lines · Luis Chamberlain
A long time ago, in a galaxy far, far away...
I ran into some odd
scsi_debugfalse positives with fstests. This prompted me to look into them given these false positives prevents me from moving forward with establishing a test baseline with high number of cycles. That is, this stupid issue was prevening creating high confidence in testing.I reported it [0] and exchanged some ideas with Doug. However, in the end, despite efforts to help things with
scsi_debugthere were still issues lingering which seemed to defy our expectations upstream. One of the last hanging fruit issues is and always has been that userspace expectations for proper module removal has been broken, so in the end I have demonstrated this is a generic issue [1].Long ago a WAIT option for module removal was added... that was then removed as it was deemed not needed as folks couldn't figure out when these races happened. The races are actually pretty easy to trigger, it was just never properly documented. A simpe
blkdev_open()will easily bump a module refcnt, and these days many thing scan do that sort of thing.The proper solution is to implement then a patient module removal on kmod and patches have been sent for that and those patches are under review. In the meantime we need a work around to open code a similar solution for users of old versions of kmod. I sent an open coded solution for fstests about since August 19th and has been used there for a few months now. Now that that stuff is merged and tested in fstests with more exposure, its time to match parity on blktests.
Quoted 7 lines
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
[0] https://bugzilla.kernel.org/show_bug.cgi?id=212337
[1] https://bugzilla.kernel.org/show_bug.cgi?id=214015Signed-off-by Luis Chamberlain <[email protected]>---
Quoted 6 lines
This looks good to me, I'd wait Bart (CCd here) to review the srp side.
Looks good.
Reviewed-by Chaitanya Kulkarni <[email protected]>
Bart, *poke*
Luis
Quoted 1 line · Luis Chamberlain
Bart, *poke*
My 2y old son is really good at taking up most of my spare time. Anyway, I will try to find some time to review this patch.
Bart.
Quoted 11 lines · Luis Chamberlain
common/rc +0
-3@@ -321,15 +321,143 @@ _uptime_s() { awk '{ print int($1) }' /proc/uptime } -# Arguments: module to unload ($1) and retry count ($2). -unload_module() { - local i m=$1 rc=${2:-1}
common/rc _uptime_s() { · line 327
Quoted 10 lines
common/rc +4
-6- - [ ! -e "/sys/module/$m" ] && return 0 - for ((i=rc;i>0;i--)); do - modprobe -r "$m" - [ ! -e "/sys/module/$m" ] && return 0 - sleep .1 +# 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"
Could you add the same guard I suggested for fstests for ancient versions of modprobe? e.g.,:
modprobe --help >& /dev/null && modprobe --help | grep -q -1 "remove-patiently"
Thanks!
- Ted
Quoted 1 line · Luis Chamberlain
for a while now. More wider testig is welcomed.
^^^^^^
testing?Quoted 4 lines
common/multipath-over-rdma +0
-0@@ -427,14 +428,8 @@ stop_soft_rdma() { echo "$i ..." rdma link del "${i}" || echo "Failed to remove ${i}" done
common/multipath-over-rdma stop_soft_rdma() { · line 432
Quoted 10 lines
common/multipath-over-rdma +2
-8- if ! unload_module rdma_rxe 10; then - echo "Unloading rdma_rxe failed" - return 1 - fi - if ! unload_module siw 10; then - echo "Unloading siw failed" - return 1 - fi + _patient_rmmod rdma_rxe || return 1 + _patient_rmmod 1siw || return 1
The above clearly has not been tested. There is an easy to spot typo in the above change. Please test your changes before publishing these.
common/rc _uptime_s() { · line 336
Quoted 1 line
common/rc +1
-0+ if [[ ! -z "$MODPROBE_PATIENT_RM_TIMEOUT_SECONDS" ]]; then
Please use -n instead of ! -z.
common/rc _uptime_s() { · line 364
Quoted 1 line
common/rc +1
-0+ if [[ -f /sys/module/$module/refcnt ]]; then
Has this patch been analyzed with 'make check'? I expect checkpatch to complain about missing double quotes for the above statement.
common/rc _uptime_s() { · line 374
Quoted 1 line
common/rc +1
-0+# Patiently tries to wait to remove a module by ensuring first
^^^^^^^^^^^^^^^^^^^^^^^
Tries to wait patiently?
common/rc _uptime_s() { · line 393
Quoted 1 line
common/rc +1
-0+ if [[ ! -z $MODPROBE_REMOVE_PATIENT ]]; then
Please use -n instead of ! -z and surround the variable expansion with double quotes.
common/rc _uptime_s() { · line 433
Quoted 2 lines
common/rc +2
-0+ # If we have extra time left. Use the time left to now try to + # persistently remove the module. We do this because although through
What is persistent module removal? Is that perhaps removing a module such that it cannot be loaded again?
tests/srp/rc stop_lio_srpt() { · line 550
Quoted 7 lines
for m in ib_srpt iscsi_target_mod target_core_pscsi target_core_iblock \ target_core_file target_core_stgt target_core_user \ target_core_modtests/srp/rc +1
-3- do - unload_module $m 10 || return $? - done + _patient_rmmod $m || return $1
Please proofread your changes and test your changes before posting these. I think that both "do" and "done" should have been preserved above.
Thanks,
Bart.
Quoted 14 lines · Bart Van Assche
Quoted 1 line · Luis Chamberlain
for a while now. More wider testig is welcomed.
^^^^^^ testing?Quoted 9 lines
common/multipath-over-rdma +0
-5@@ -427,14 +428,8 @@ stop_soft_rdma() { echo "$i ..." rdma link del "${i}" || echo "Failed to remove ${i}" done - if ! unload_module rdma_rxe 10; then - echo "Unloading rdma_rxe failed" - return 1 - fi - if ! unload_module siw 10; then
Quoted 8 lines
common/multipath-over-rdma stop_soft_rdma() { · line 432
Quoted 5 lines
common/multipath-over-rdma +2
-3- echo "Unloading siw failed" - return 1 - fi + _patient_rmmod rdma_rxe || return 1 + _patient_rmmod 1siw || return 1The above clearly has not been tested. There is an easy to spot typo in the above change. Please test your changes before publishing these.
Thanks, fixed. Please I stated:
I've tested blktests with this for things which I can run virtually for a while now. More wider testig is welcomed.
Quoted 3 lines
common/rc _uptime_s() { · line 336
Quoted 1 line
common/rc +1
-0+ if [[ ! -z "$MODPROBE_PATIENT_RM_TIMEOUT_SECONDS" ]]; thenPlease use -n instead of ! -z.
Sure...
Quoted 4 lines
common/rc _uptime_s() { · line 364
Quoted 1 line
common/rc +1
-0+ if [[ -f /sys/module/$module/refcnt ]]; thenHas this patch been analyzed with 'make check'? I expect checkpatch to complain about missing double quotes for the above statement.
No, I was not aware this was a thing. I fixed all the stupid complaints however I should note at least tests/srp/rc has existing complaints before my changes. I won't address those.
I can't say I agree with the changes to remove checks for $?, but whatever. Consinstancy is better than not having one. Perhaps we should embrace this on fstests as well. Who knows how many crufty bugs lie there.
Quoted 3 lines
common/rc _uptime_s() { · line 374
Quoted 1 line
common/rc +1
-0+# Patiently tries to wait to remove a module by ensuring first^^^^^^^^^^^^^^^^^^^^^^^Tries to wait patiently?
Sure..
Quoted 4 lines
common/rc _uptime_s() { · line 393
Quoted 1 line
common/rc +1
-0+ if [[ ! -z $MODPROBE_REMOVE_PATIENT ]]; thenPlease use -n instead of ! -z and surround the variable expansion with double quotes.
Sure..
Quoted 5 lines
common/rc _uptime_s() { · line 433
Quoted 2 lines
common/rc +2
-0+ # If we have extra time left. Use the time left to now try to + # persistently remove the module. We do this because although throughWhat is persistent module removal? Is that perhaps removing a module such that it cannot be loaded again?
No, I'll clarify to this:
# Tries to wait patiently to remove a module by ensuring first
# the refcnt is 0 and then trying to remove the module over and over # again within the time allowed
Quoted 10 lines
tests/srp/rc stop_lio_srpt() { · line 550
Quoted 7 lines
for m in ib_srpt iscsi_target_mod target_core_pscsi target_core_iblock \ target_core_file target_core_stgt target_core_user \ target_core_modtests/srp/rc +1
-3- do - unload_module $m 10 || return $? - done + _patient_rmmod $m || return $1Please proofread your changes and test your changes before posting these. I think that both "do" and "done" should have been preserved above.
And the return value shoudl be $? not $1. I couldn't test srp so wanted someone who would to help review, but sure, I should have caught this.
Thanks for the review, I'll post a v2.
Luis
Quoted 10 lines · Luis Chamberlain
Quoted 5 lines · Bart Van Assche
common/rc _uptime_s() { · line 364
Quoted 1 line · Luis Chamberlain
common/rc +1
-0+ if [[ -f /sys/module/$module/refcnt ]]; thenHas this patch been analyzed with 'make check'? I expect checkpatch to complain about missing double quotes for the above statement.
No, I was not aware this was a thing. I fixed all the stupid complaints however I should note at least tests/srp/rc has existing complaints before my changes. I won't address those.
Please consider opening a pull request for the https://github.com/osandov/blktests repository. That will cause the blktests presubmit tests to be run. See also .github/workflows/ci.yml in the blktests source code.
Quoted 3 lines
I can't say I agree with the changes to remove checks for $?, but whatever. Consinstancy is better than not having one. Perhaps we should embrace this on fstests as well.
+1
Quoted 5 lines
No, I'll clarify to this:
# Tries to wait patiently to remove a module by ensuring first
# the refcnt is 0 and then trying to remove the module over and over # again within the time allowed
Looks better to me :-)
Quoted 11 lines
Quoted 10 lines
tests/srp/rc stop_lio_srpt() { · line 550
Quoted 7 lines
for m in ib_srpt iscsi_target_mod target_core_pscsi target_core_iblock \ target_core_file target_core_stgt target_core_user \ target_core_modtests/srp/rc +1
-3- do - unload_module $m 10 || return $? - done + _patient_rmmod $m || return $1Please proofread your changes and test your changes before posting these. I think that both "do" and "done" should have been preserved above.
Quoted 2 lines
And the return value shoudl be $? not $1. I couldn't test srp so wanted someone who would to help review, but sure, I should have caught this.
Hmm ... the SRP tests can be run inside a virtual machine so it is not clear to me what prevents to run these tests?
Thanks,
Bart.
Quoted 6 lines · Bart Van Assche
Quoted 2 lines · Luis Chamberlain
And the return value shoudl be $? not $1. I couldn't test srp so wanted someone who would to help review, but sure, I should have caught this.
Hmm ... the SRP tests can be run inside a virtual machine so it is not clear to me what prevents to run these tests?
OK I've managed to get time to run SRP tests on a virtual environement but I'm a bit surprised as to the failures found. I need this baseline to ensure the change does not regress anything. I'll report the failures next..
Luis