linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eryu Guan <eguan@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH 5/6] misc: add module reloading helpers
Date: Thu, 26 Oct 2017 14:43:13 +0800	[thread overview]
Message-ID: <20171026064313.GJ3235@eguan.usersys.redhat.com> (raw)
In-Reply-To: <150899712429.18389.5159489339127196469.stgit@magnolia>

On Wed, Oct 25, 2017 at 10:52:04PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Add some helper functions to require that we can reload a given module,
> and add a helper to actually do that.  Refactor the existing users to
> use the generics.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  common/btrfs    |   12 ------------
>  common/rc       |   15 +++++++++++++++
>  tests/btrfs/124 |    9 +++------
>  tests/btrfs/125 |    9 +++------
>  4 files changed, 21 insertions(+), 24 deletions(-)
> 
> 
> diff --git a/common/btrfs b/common/btrfs
> index fd762ef..c09206c 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -349,18 +349,6 @@ _btrfs_qgroup_units()
>  	$BTRFS_UTIL_PROG qgroup show --help 2>&1 | grep -q -- --raw && echo "--raw"
>  }
>  
> -_require_btrfs_loadable()
> -{
> -	modprobe -r btrfs || _notrun "btrfs unloadable"
> -	modprobe btrfs || _notrun "Can't load btrfs"
> -}
> -
> -_reload_btrfs_ko()
> -{
> -	modprobe -r btrfs || _fail "btrfs unload failed"
> -	modprobe btrfs || _fail "btrfs load failed"
> -}
> -
>  _btrfs_compression_algos()
>  {
>  	echo zlib
> diff --git a/common/rc b/common/rc
> index 83aaced..5375f7b 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -3580,6 +3580,21 @@ _require_scratch_feature()
>  	esac
>  }
>  
> +# Check that we have a module that can be loaded.
> +_require_loadable_module()
> +{
> +	module="$1"
> +	modinfo "$module" > /dev/null 2>&1 || _notrun "${module}: must be a module."

I think we should try to unload the given module too to see if we really
could unload it, otherwise a later _reload_module() still fails if
rootfs is mounted as $module type, even if we already umounted TEST_DEV
and SCRATCH_DEV.

> +}
> +
> +# Reload a particular module.
> +_reload_module()
> +{
> +	module="$1"
> +
> +	modprobe -r "${module}" || _fail "${module} unload failed"
> +	modprobe "${module}" || _fail "${module} load failed"
> +}
>  
>  init_rc
>  
> diff --git a/tests/btrfs/124 b/tests/btrfs/124
> index 7206094..1b6cb24 100755
> --- a/tests/btrfs/124
> +++ b/tests/btrfs/124
> @@ -64,10 +64,7 @@ rm -f $seqres.full
>  _supported_fs btrfs
>  _supported_os Linux
>  _require_scratch_dev_pool 2
> -
> -# the mounted test dir prevent btrfs unload, we need to unmount
> -_test_unmount
> -_require_btrfs_loadable
> +_require_loadable_module "btrfs"

Then keep the above comments and _test_unmount?

Thanks,
Eryu

>  
>  _scratch_dev_pool_get 2
>  
> @@ -102,7 +99,7 @@ echo "clean btrfs ko" >> $seqres.full
>  _scratch_unmount
>  
>  # un-scan the btrfs devices
> -_reload_btrfs_ko
> +_reload_module "btrfs"
>  
>  echo >> $seqres.full
>  echo "-----Write degraded mount fill upto $max_fs_sz bytes-----" >> $seqres.full
> @@ -141,7 +138,7 @@ echo
>  echo "Mount degraded with the other dev"
>  _scratch_unmount
>  # un-scan the btrfs devices
> -_reload_btrfs_ko
> +_reload_module "btrfs"
>  _mount -o degraded $dev2 $SCRATCH_MNT >>$seqres.full 2>&1
>  _run_btrfs_util_prog filesystem show
>  checkpoint3=`md5sum $SCRATCH_MNT/tf2`
> diff --git a/tests/btrfs/125 b/tests/btrfs/125
> index 91aa8d8..dbb226c 100755
> --- a/tests/btrfs/125
> +++ b/tests/btrfs/125
> @@ -63,10 +63,7 @@ rm -f $seqres.full
>  _supported_fs btrfs
>  _supported_os Linux
>  _require_scratch_dev_pool 3
> -
> -# we need btrfs to unload, need test dir unmounted
> -_test_unmount
> -_require_btrfs_loadable
> +_require_loadable_module "btrfs"
>  
>  _scratch_dev_pool_get 3
>  
> @@ -118,7 +115,7 @@ echo "unmount" >> $seqres.full
>  _scratch_unmount
>  echo "clean btrfs ko" >> $seqres.full
>  # un-scan the btrfs devices
> -_reload_btrfs_ko
> +_reload_module "btrfs"
>  _mount -o degraded,device=$dev2 $dev1 $SCRATCH_MNT >>$seqres.full 2>&1
>  dd if=/dev/zero of="$SCRATCH_MNT"/tf2 bs=$bs count=$count \
>  					>>$seqres.full 2>&1
> @@ -154,7 +151,7 @@ echo "Mount degraded but with other dev"
>  
>  _scratch_unmount
>  # un-scan the btrfs devices
> -_reload_btrfs_ko
> +_reload_module "btrfs"
>  
>  _mount -o degraded,device=${dev2} $dev3 $SCRATCH_MNT >>$seqres.full 2>&1
>  
> 

  reply	other threads:[~2017-10-26  6:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  5:51 [PATCH 1/6] quota: clear speculative delalloc when checking quota usage Darrick J. Wong
2017-10-26  5:51 ` [PATCH 2/6] common/xfs: refactor xfs_scrub presence testing Darrick J. Wong
2017-10-27  4:37   ` Eryu Guan
2017-10-27 18:04     ` Darrick J. Wong
2017-10-27 20:21   ` [PATCH v2 " Darrick J. Wong
2017-10-26  5:51 ` [PATCH 3/6] common/xfs: standardize the xfs_scrub output that gets recorded to $seqres.full Darrick J. Wong
2017-10-26  5:51 ` [PATCH 4/6] generic/45[34]: force UTF-8 codeset to enable utf-8 namer checks in xfs_scrub Darrick J. Wong
2017-10-26  5:52 ` [PATCH 5/6] misc: add module reloading helpers Darrick J. Wong
2017-10-26  6:43   ` Eryu Guan [this message]
2017-10-27  0:35     ` Darrick J. Wong
2017-10-27  0:38   ` [PATCH v2 " Darrick J. Wong
2017-10-27  4:41     ` Eryu Guan
2017-10-27 18:18       ` Darrick J. Wong
2017-10-28  5:47         ` Eryu Guan
2017-10-27 20:23   ` [PATCH v3 " Darrick J. Wong
2017-10-26  5:52 ` [PATCH 6/6] xfs: test that we don't leak inodes and dquots during failed cow recovery Darrick J. Wong
2017-10-27  0:42   ` [PATCH v2 " Darrick J. Wong
2017-10-27  0:43 ` [PATCH 7/6] common/fuzzy: online re-scrub should not preen Darrick J. Wong
2017-10-27  0:44 ` [PATCH 8/6] xfs/333: fix errors with new inode pointer verifiers Darrick J. Wong
2017-10-27  6:04   ` Eryu Guan
2017-10-27 18:21     ` Darrick J. Wong
2017-10-27 20:24   ` [PATCH v2 " Darrick J. Wong
2017-11-01 21:13     ` Darrick J. Wong
2017-10-27  0:44 ` [PATCH 9/6] generic/459: fix test running errors Darrick J. Wong
2017-10-27  4:42   ` Eryu Guan
2017-10-27 18:22     ` Darrick J. Wong
2017-10-27 20:25   ` [PATCH v2 " Darrick J. Wong
2017-10-28 17:07     ` Darrick J. Wong
2017-10-28 17:08   ` [PATCH v3 " Darrick J. Wong
2017-10-30  5:01     ` Eryu Guan
2017-10-27 20:25 ` [PATCH 10/6] common/xfs: remove inode-paths cruft Darrick J. Wong
2017-10-30  5:00   ` Eryu Guan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171026064313.GJ3235@eguan.usersys.redhat.com \
    --to=eguan@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).