diff mbox

[1/2] common/rc: introduce _overlay_mount_dirs helper

Message ID 1470741381-32610-1-git-send-email-eguan@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eryu Guan Aug. 9, 2016, 11:16 a.m. UTC
Introduce a new _overlay_mount_dirs() helper to do the actual
overlay mount operation and factor _overlay_scratch_mount and
_overlay_mount code to use a single implemention of
_overlay_mount_dirs(). Also convert all bare mount of overlay in
tests to use it.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
---
 common/rc         | 21 +++++++++++++++------
 tests/overlay/005 |  6 ++----
 tests/overlay/010 |  5 ++---
 3 files changed, 19 insertions(+), 13 deletions(-)

Comments

Eryu Guan Aug. 12, 2016, 3:33 a.m. UTC | #1
On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> Introduce a new _overlay_mount_dirs() helper to do the actual
> overlay mount operation and factor _overlay_scratch_mount and
> _overlay_mount code to use a single implemention of
> _overlay_mount_dirs(). Also convert all bare mount of overlay in
> tests to use it.
> 
> Suggested-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Eryu Guan <eguan@redhat.com>

Ping on this one, hope I can push this out this week.

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eryu Guan Aug. 19, 2016, 3:05 a.m. UTC | #2
On Fri, Aug 12, 2016 at 11:33:42AM +0800, Eryu Guan wrote:
> On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> > Introduce a new _overlay_mount_dirs() helper to do the actual
> > overlay mount operation and factor _overlay_scratch_mount and
> > _overlay_mount code to use a single implemention of
> > _overlay_mount_dirs(). Also convert all bare mount of overlay in
> > tests to use it.
> > 
> > Suggested-by: Dave Chinner <dchinner@redhat.com>
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
> 
> Ping on this one, hope I can push this out this week.

Ping again.

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eryu Guan Aug. 25, 2016, 4:11 a.m. UTC | #3
On Fri, Aug 19, 2016 at 11:05:17AM +0800, Eryu Guan wrote:
> On Fri, Aug 12, 2016 at 11:33:42AM +0800, Eryu Guan wrote:
> > On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> > > Introduce a new _overlay_mount_dirs() helper to do the actual
> > > overlay mount operation and factor _overlay_scratch_mount and
> > > _overlay_mount code to use a single implemention of
> > > _overlay_mount_dirs(). Also convert all bare mount of overlay in
> > > tests to use it.
> > > 
> > > Suggested-by: Dave Chinner <dchinner@redhat.com>
> > > Signed-off-by: Eryu Guan <eguan@redhat.com>
> > 
> > Ping on this one, hope I can push this out this week.
> 
> Ping again.

Ping for the third time :)

Thanks,
Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eryu Guan Aug. 31, 2016, 9:44 a.m. UTC | #4
Hi all,

On Thu, Aug 25, 2016 at 12:11:11PM +0800, Eryu Guan wrote:
> On Fri, Aug 19, 2016 at 11:05:17AM +0800, Eryu Guan wrote:
> > On Fri, Aug 12, 2016 at 11:33:42AM +0800, Eryu Guan wrote:
> > > On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> > > > Introduce a new _overlay_mount_dirs() helper to do the actual
> > > > overlay mount operation and factor _overlay_scratch_mount and
> > > > _overlay_mount code to use a single implemention of
> > > > _overlay_mount_dirs(). Also convert all bare mount of overlay in
> > > > tests to use it.
> > > > 
> > > > Suggested-by: Dave Chinner <dchinner@redhat.com>
> > > > Signed-off-by: Eryu Guan <eguan@redhat.com>
> > > 
> > > Ping on this one, hope I can push this out this week.
> > 
> > Ping again.
> 
> Ping for the third time :)

I have trouble getting my patches reviewed. Could someone help review
this patchset? Thanks a lot!

Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dave Chinner Sept. 1, 2016, 12:16 a.m. UTC | #5
On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> Introduce a new _overlay_mount_dirs() helper to do the actual
> overlay mount operation and factor _overlay_scratch_mount and
> _overlay_mount code to use a single implemention of
> _overlay_mount_dirs(). Also convert all bare mount of overlay in
> tests to use it.
> 
> Suggested-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Eryu Guan <eguan@redhat.com>
> ---
>  common/rc         | 21 +++++++++++++++------
>  tests/overlay/005 |  6 ++----
>  tests/overlay/010 |  5 ++---
>  3 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/common/rc b/common/rc
> index b19b698..6c1c3ff 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -266,6 +266,18 @@ _scratch_mount_options()
>  					$SCRATCH_DEV $SCRATCH_MNT
>  }
>  
> +# helper function to do the actual overlayfs mount operation
> +_overlay_mount_dirs()
> +{
> +	local lowerdir=$1
> +	local upperdir=$2
> +	local workdir=$3
> +	shift 3
> +
> +	$MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \
> +		    -o workdir=$workdir $*
> +}
> +
>  # Given a dir, set up 3 subdirectories and mount on the given mnt.
>  # The dir is used as the mount device so it can be seen from df or mount
>  _overlay_mount()
> @@ -293,12 +305,9 @@ _overlay_mount()
>  	mkdir -p $dir/$OVERLAY_LOWER_DIR
>  	mkdir -p $dir/$OVERLAY_WORK_DIR
>  
> -	$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
> -		    -o lowerdir=$dir/$OVERLAY_LOWER_DIR \
> -		    -o upperdir=$dir/$OVERLAY_UPPER_DIR \
> -		    -o workdir=$dir/$OVERLAY_WORK_DIR   \
> -		    $OVERLAY_MOUNT_OPTIONS $* \
> -		    $dir $mnt
> +	_overlay_mount_dirs $dir/$OVERLAY_LOWER_DIR $dir/$OVERLAY_UPPER_DIR \
> +			    $dir/$OVERLAY_WORK_DIR $OVERLAY_MOUNT_OPTIONS $* \
> +			    $dir $mnt

This drops SELINUX_MOUNT_OPTIONS from the mount options. I'd suggest
this option should be moved inside _overlay_mount_dirs() so they are
always applied to overlayfs mounts if set.

Cheers,

Dave.
Eryu Guan Sept. 1, 2016, 3:33 a.m. UTC | #6
On Thu, Sep 01, 2016 at 10:16:29AM +1000, Dave Chinner wrote:
> On Tue, Aug 09, 2016 at 07:16:20PM +0800, Eryu Guan wrote:
> > Introduce a new _overlay_mount_dirs() helper to do the actual
> > overlay mount operation and factor _overlay_scratch_mount and
> > _overlay_mount code to use a single implemention of
> > _overlay_mount_dirs(). Also convert all bare mount of overlay in
> > tests to use it.
> > 
> > Suggested-by: Dave Chinner <dchinner@redhat.com>
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
> > ---
> >  common/rc         | 21 +++++++++++++++------
> >  tests/overlay/005 |  6 ++----
> >  tests/overlay/010 |  5 ++---
> >  3 files changed, 19 insertions(+), 13 deletions(-)
> > 
> > diff --git a/common/rc b/common/rc
> > index b19b698..6c1c3ff 100644
> > --- a/common/rc
> > +++ b/common/rc
> > @@ -266,6 +266,18 @@ _scratch_mount_options()
> >  					$SCRATCH_DEV $SCRATCH_MNT
> >  }
> >  
> > +# helper function to do the actual overlayfs mount operation
> > +_overlay_mount_dirs()
> > +{
> > +	local lowerdir=$1
> > +	local upperdir=$2
> > +	local workdir=$3
> > +	shift 3
> > +
> > +	$MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \
> > +		    -o workdir=$workdir $*
> > +}
> > +
> >  # Given a dir, set up 3 subdirectories and mount on the given mnt.
> >  # The dir is used as the mount device so it can be seen from df or mount
> >  _overlay_mount()
> > @@ -293,12 +305,9 @@ _overlay_mount()
> >  	mkdir -p $dir/$OVERLAY_LOWER_DIR
> >  	mkdir -p $dir/$OVERLAY_WORK_DIR
> >  
> > -	$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
> > -		    -o lowerdir=$dir/$OVERLAY_LOWER_DIR \
> > -		    -o upperdir=$dir/$OVERLAY_UPPER_DIR \
> > -		    -o workdir=$dir/$OVERLAY_WORK_DIR   \
> > -		    $OVERLAY_MOUNT_OPTIONS $* \
> > -		    $dir $mnt
> > +	_overlay_mount_dirs $dir/$OVERLAY_LOWER_DIR $dir/$OVERLAY_UPPER_DIR \
> > +			    $dir/$OVERLAY_WORK_DIR $OVERLAY_MOUNT_OPTIONS $* \
> > +			    $dir $mnt
> 
> This drops SELINUX_MOUNT_OPTIONS from the mount options. I'd suggest

This is unexpected, it's dropped by mistake..

> this option should be moved inside _overlay_mount_dirs() so they are
> always applied to overlayfs mounts if set.

Sure, will do.

Thanks a lot for the review!

Eryu
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/common/rc b/common/rc
index b19b698..6c1c3ff 100644
--- a/common/rc
+++ b/common/rc
@@ -266,6 +266,18 @@  _scratch_mount_options()
 					$SCRATCH_DEV $SCRATCH_MNT
 }
 
+# helper function to do the actual overlayfs mount operation
+_overlay_mount_dirs()
+{
+	local lowerdir=$1
+	local upperdir=$2
+	local workdir=$3
+	shift 3
+
+	$MOUNT_PROG -t overlay -o lowerdir=$lowerdir -o upperdir=$upperdir \
+		    -o workdir=$workdir $*
+}
+
 # Given a dir, set up 3 subdirectories and mount on the given mnt.
 # The dir is used as the mount device so it can be seen from df or mount
 _overlay_mount()
@@ -293,12 +305,9 @@  _overlay_mount()
 	mkdir -p $dir/$OVERLAY_LOWER_DIR
 	mkdir -p $dir/$OVERLAY_WORK_DIR
 
-	$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
-		    -o lowerdir=$dir/$OVERLAY_LOWER_DIR \
-		    -o upperdir=$dir/$OVERLAY_UPPER_DIR \
-		    -o workdir=$dir/$OVERLAY_WORK_DIR   \
-		    $OVERLAY_MOUNT_OPTIONS $* \
-		    $dir $mnt
+	_overlay_mount_dirs $dir/$OVERLAY_LOWER_DIR $dir/$OVERLAY_UPPER_DIR \
+			    $dir/$OVERLAY_WORK_DIR $OVERLAY_MOUNT_OPTIONS $* \
+			    $dir $mnt
 }
 
 _overlay_test_mount()
diff --git a/tests/overlay/005 b/tests/overlay/005
index 495e7b5..522c6f0 100755
--- a/tests/overlay/005
+++ b/tests/overlay/005
@@ -93,10 +93,8 @@  $XFS_IO_PROG -f -c "truncate 48m" ${lowerd}/test_file \
 	>>$seqres.full 2>&1
 
 # mount new overlayfs
-$MOUNT_PROG -t overlay $SELINUX_MOUNT_OPTIONS \
-	    -o lowerdir=$lowerd -o upperdir=$upperd \
-	    -o workdir=$workd \
-	    $SCRATCH_DEV $SCRATCH_MNT
+_overlay_mount_dirs $lowerd $upperd $workd $SELINUX_MOUNT_OPTIONS \
+		    $SCRATCH_DEV $SCRATCH_MNT
 
 # the open call triggers copy-up and it will fail ENOSPC
 $XFS_IO_PROG -f -c "o" ${SCRATCH_MNT}/test_file \
diff --git a/tests/overlay/010 b/tests/overlay/010
index 5d1c2bd..a302d74 100755
--- a/tests/overlay/010
+++ b/tests/overlay/010
@@ -67,9 +67,8 @@  touch $lowerdir1/testdir/a $lowerdir1/testdir/b
 mknod $lowerdir2/testdir/a c 0 0
 
 # Mount overlayfs and remove testdir, which led to kernel crash
-$MOUNT_PROG -t overlay -o lowerdir=$lowerdir2:$lowerdir1 \
-	    -o upperdir=$upperdir,workdir=$workdir \
-	    $SCRATCH_DEV $SCRATCH_MNT
+_overlay_mount_dirs "$lowerdir2:$lowerdir1" $upperdir $workdir \
+		    $SCRATCH_DEV $SCRATCH_MNT
 rm -rf $SCRATCH_MNT/testdir
 
 # success, all done