diff mbox series

[3/3] common/ext4: provide custom ext4 scratch fs options

Message ID 165950051745.198922.6487109955066878945.stgit@magnolia
State Superseded
Headers show
Series fstests: refactor ext4-specific code | expand

Commit Message

Darrick J. Wong Aug. 3, 2022, 4:21 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Create a _scratch_options backend for ext* so that we can inject
pathnames to external log devices into the scratch fs mount options.
This enables common/dm* to install block device filters, e.g. dm-error
for stress testing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/ext4 |   20 ++++++++++++++++++++
 common/rc   |    3 +++
 2 files changed, 23 insertions(+)

Comments

Zorro Lang Aug. 3, 2022, 6:28 p.m. UTC | #1
On Tue, Aug 02, 2022 at 09:21:57PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Create a _scratch_options backend for ext* so that we can inject
> pathnames to external log devices into the scratch fs mount options.
> This enables common/dm* to install block device filters, e.g. dm-error
> for stress testing.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  common/ext4 |   20 ++++++++++++++++++++
>  common/rc   |    3 +++
>  2 files changed, 23 insertions(+)
> 
> 
> diff --git a/common/ext4 b/common/ext4
> index 287705af..819f9786 100644
> --- a/common/ext4
> +++ b/common/ext4
> @@ -154,3 +154,23 @@ _require_scratch_richacl_ext4()
>  		|| _notrun "kernel doesn't support richacl feature on $FSTYP"
>  	_scratch_unmount
>  }
> +
> +_scratch_ext4_options()
> +{
> +    local type=$1
> +    local log_opt=""
> +
> +    case $type in
> +    mkfs)
> +        log_opt="-J device=$SCRATCH_LOGDEV"

In _scratch_mkfs_ext4, it deals with mkfs with SCRATCH_LOGDEV:

  [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
     $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \
     mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"

So is there a conflict or duplication?

> +	;;
> +    mount)
> +	# As of kernel 5.19, the kernel mount option path parser only accepts
> +	# direct paths to block devices--the final path component cannot be a
> +	# symlink.
> +        log_opt="-o journal_path=$(realpath $SCRATCH_LOGDEV)"
> +	;;
> +    esac
> +    [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> +	SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}"
> +}
> diff --git a/common/rc b/common/rc
> index dc1d65c3..b82bb36b 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -178,6 +178,9 @@ _scratch_options()
>      "xfs")
>  	_scratch_xfs_options "$@"
>  	;;
> +    ext2|ext3|ext4|ext4dev)
> +	_scratch_ext4_options "$@"
> +	;;
>      esac
>  }
>  
>
Darrick J. Wong Aug. 3, 2022, 6:52 p.m. UTC | #2
On Thu, Aug 04, 2022 at 02:28:43AM +0800, Zorro Lang wrote:
> On Tue, Aug 02, 2022 at 09:21:57PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> > 
> > Create a _scratch_options backend for ext* so that we can inject
> > pathnames to external log devices into the scratch fs mount options.
> > This enables common/dm* to install block device filters, e.g. dm-error
> > for stress testing.
> > 
> > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > ---
> >  common/ext4 |   20 ++++++++++++++++++++
> >  common/rc   |    3 +++
> >  2 files changed, 23 insertions(+)
> > 
> > 
> > diff --git a/common/ext4 b/common/ext4
> > index 287705af..819f9786 100644
> > --- a/common/ext4
> > +++ b/common/ext4
> > @@ -154,3 +154,23 @@ _require_scratch_richacl_ext4()
> >  		|| _notrun "kernel doesn't support richacl feature on $FSTYP"
> >  	_scratch_unmount
> >  }
> > +
> > +_scratch_ext4_options()
> > +{
> > +    local type=$1
> > +    local log_opt=""
> > +
> > +    case $type in
> > +    mkfs)
> > +        log_opt="-J device=$SCRATCH_LOGDEV"
> 
> In _scratch_mkfs_ext4, it deals with mkfs with SCRATCH_LOGDEV:
> 
>   [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
>      $mkfs_cmd -O journal_dev $MKFS_OPTIONS $SCRATCH_LOGDEV && \
>      mkfs_cmd="$mkfs_cmd -J device=$SCRATCH_LOGDEV"
> 
> So is there a conflict or duplication?

Nope, I simply missed that.  I'll respin the patch.

--D

> > +	;;
> > +    mount)
> > +	# As of kernel 5.19, the kernel mount option path parser only accepts
> > +	# direct paths to block devices--the final path component cannot be a
> > +	# symlink.
> > +        log_opt="-o journal_path=$(realpath $SCRATCH_LOGDEV)"
> > +	;;
> > +    esac
> > +    [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > +	SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}"
> > +}
> > diff --git a/common/rc b/common/rc
> > index dc1d65c3..b82bb36b 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -178,6 +178,9 @@ _scratch_options()
> >      "xfs")
> >  	_scratch_xfs_options "$@"
> >  	;;
> > +    ext2|ext3|ext4|ext4dev)
> > +	_scratch_ext4_options "$@"
> > +	;;
> >      esac
> >  }
> >  
> > 
>
diff mbox series

Patch

diff --git a/common/ext4 b/common/ext4
index 287705af..819f9786 100644
--- a/common/ext4
+++ b/common/ext4
@@ -154,3 +154,23 @@  _require_scratch_richacl_ext4()
 		|| _notrun "kernel doesn't support richacl feature on $FSTYP"
 	_scratch_unmount
 }
+
+_scratch_ext4_options()
+{
+    local type=$1
+    local log_opt=""
+
+    case $type in
+    mkfs)
+        log_opt="-J device=$SCRATCH_LOGDEV"
+	;;
+    mount)
+	# As of kernel 5.19, the kernel mount option path parser only accepts
+	# direct paths to block devices--the final path component cannot be a
+	# symlink.
+        log_opt="-o journal_path=$(realpath $SCRATCH_LOGDEV)"
+	;;
+    esac
+    [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+	SCRATCH_OPTIONS="$SCRATCH_OPTIONS ${log_opt}"
+}
diff --git a/common/rc b/common/rc
index dc1d65c3..b82bb36b 100644
--- a/common/rc
+++ b/common/rc
@@ -178,6 +178,9 @@  _scratch_options()
     "xfs")
 	_scratch_xfs_options "$@"
 	;;
+    ext2|ext3|ext4|ext4dev)
+	_scratch_ext4_options "$@"
+	;;
     esac
 }