Message ID | 20220530130811.3006554-10-hch@lst.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [blktests,1/9] nvme: use _have_loop instead of _have_modules loop | expand |
On May 30, 2022 / 15:08, Christoph Hellwig wrote: > Use _have_driver instead of _have_modules in _have_scsi_debug for the > basic scsi_debug check, and instead only require an actual module in > _init_null_blk when specific module parameters are passed. > > Signed-off-by: Christoph Hellwig <hch@lst.de> > --- > common/scsi_debug | 14 ++++++++++---- > tests/block/001 | 4 +++- > 2 files changed, 13 insertions(+), 5 deletions(-) > > diff --git a/common/scsi_debug b/common/scsi_debug > index 95da14e..e9161d3 100644 > --- a/common/scsi_debug > +++ b/common/scsi_debug > @@ -5,7 +5,7 @@ > # scsi_debug helper functions. > > _have_scsi_debug() { > - _have_modules scsi_debug > + _have_driver scsi_debug > } > > _init_scsi_debug() { > @@ -18,8 +18,14 @@ _init_scsi_debug() { > args+=(zbc=host-managed zone_nr_conv=0) > fi > > - if ! modprobe -r scsi_debug || ! modprobe scsi_debug "${args[@]}"; then > - return 1 > + if ((${#args[@]})); then > + if ! modprobe -qr scsi_debug; then > + exit 1 > + fi > + if ! modprobe scsi_debug "${args[@]}"; then > + SKIP_REASON="scsi_debug not modular" I tried scsi_debug built-in kernel and observed that 'modprobe -qr scsi_debug' command fails, and the script exits at the line of "exit 1". The SKIP_REASON comment above will not be printed. I think we need to check the scsi_debug is not built-in. As I commented for _init_null_blk, _have_modules needs modification to check if the module is not built-in. I guess it can be used for scsi_debug also.
On May 31, 2022 / 12:21, Shinichiro Kawasaki wrote: > On May 30, 2022 / 15:08, Christoph Hellwig wrote: > > Use _have_driver instead of _have_modules in _have_scsi_debug for the > > basic scsi_debug check, and instead only require an actual module in > > _init_null_blk when specific module parameters are passed. > > > > Signed-off-by: Christoph Hellwig <hch@lst.de> > > --- > > common/scsi_debug | 14 ++++++++++---- > > tests/block/001 | 4 +++- > > 2 files changed, 13 insertions(+), 5 deletions(-) > > > > diff --git a/common/scsi_debug b/common/scsi_debug > > index 95da14e..e9161d3 100644 > > --- a/common/scsi_debug > > +++ b/common/scsi_debug > > @@ -5,7 +5,7 @@ > > # scsi_debug helper functions. > > > > _have_scsi_debug() { > > - _have_modules scsi_debug > > + _have_driver scsi_debug > > } > > > > _init_scsi_debug() { > > @@ -18,8 +18,14 @@ _init_scsi_debug() { > > args+=(zbc=host-managed zone_nr_conv=0) > > fi > > > > - if ! modprobe -r scsi_debug || ! modprobe scsi_debug "${args[@]}"; then > > - return 1 > > + if ((${#args[@]})); then > > + if ! modprobe -qr scsi_debug; then > > + exit 1 > > + fi > > + if ! modprobe scsi_debug "${args[@]}"; then > > + SKIP_REASON="scsi_debug not modular" > > I tried scsi_debug built-in kernel and observed that 'modprobe -qr scsi_debug' > command fails, and the script exits at the line of "exit 1". The SKIP_REASON > comment above will not be printed. I think we need to check the scsi_debug is > not built-in. As I commented for _init_null_blk, _have_modules needs > modification to check if the module is not built-in. I guess it can be used for > scsi_debug also. Another nit: the SKIP_REASON value update will make shellcheck complain: common/scsi_debug:26:4: warning: SKIP_REASON appears unused. Verify use (or export if used externally). [SC2034] As some of other common/* does, sourcing common/shellcheck at beginning of common/scsi_debug will avoid it.
diff --git a/common/scsi_debug b/common/scsi_debug index 95da14e..e9161d3 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -5,7 +5,7 @@ # scsi_debug helper functions. _have_scsi_debug() { - _have_modules scsi_debug + _have_driver scsi_debug } _init_scsi_debug() { @@ -18,8 +18,14 @@ _init_scsi_debug() { args+=(zbc=host-managed zone_nr_conv=0) fi - if ! modprobe -r scsi_debug || ! modprobe scsi_debug "${args[@]}"; then - return 1 + if ((${#args[@]})); then + if ! modprobe -qr scsi_debug; then + exit 1 + fi + if ! modprobe scsi_debug "${args[@]}"; then + SKIP_REASON="scsi_debug not modular" + return 1 + fi fi udevadm settle @@ -60,5 +66,5 @@ _exit_scsi_debug() { unset SCSI_DEBUG_TARGETS unset SCSI_DEBUG_DEVICES udevadm settle - modprobe -r scsi_debug + modprobe -rq scsi_debug } diff --git a/tests/block/001 b/tests/block/001 index 5f05fa8..fb93932 100755 --- a/tests/block/001 +++ b/tests/block/001 @@ -13,7 +13,9 @@ DESCRIPTION="stress device hotplugging" TIMED=1 requires() { - _have_scsi_debug && _have_modules sd_mod sr_mod + _have_scsi_debug + _have_driver sd_mod + _have_driver sr_mod } stress_scsi_debug() {
Use _have_driver instead of _have_modules in _have_scsi_debug for the basic scsi_debug check, and instead only require an actual module in _init_null_blk when specific module parameters are passed. Signed-off-by: Christoph Hellwig <hch@lst.de> --- common/scsi_debug | 14 ++++++++++---- tests/block/001 | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-)