Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1660795 > unrolled thread

[PATCH] Fix loop device flush before configure v3

Started byJames Wang <jnwang@suse.com>
First post2017-06-08 09:00 +0200
Last post2017-06-08 16:10 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] Fix loop device flush before configure v3 James Wang <jnwang@suse.com> - 2017-06-08 09:00 +0200
    Re: [PATCH] Fix loop device flush before configure v3 Johannes Thumshirn <jthumshirn@suse.de> - 2017-06-08 10:00 +0200
      Re: [PATCH] Fix loop device flush before configure v3 James Wang <jnwang@suse.com> - 2017-06-08 10:20 +0200
    Re: [PATCH] Fix loop device flush before configure v3 Jens Axboe <axboe@kernel.dk> - 2017-06-08 16:10 +0200

#1660795 — [PATCH] Fix loop device flush before configure v3

FromJames Wang <jnwang@suse.com>
Date2017-06-08 09:00 +0200
Subject[PATCH] Fix loop device flush before configure v3
Message-ID<tPZAd-Nh-1@gated-at.bofh.it>
While installing SLES-12 (based on v4.4), I found that the installer
will stall for 60+ seconds during LVM disk scan.  The root cause was
determined to be the removal of a bound device check in loop_flush()
by commit b5dd2f6047ca ("block: loop: improve performance via blk-mq").

Restoring this check, examining ->lo_state as set by loop_set_fd()
eliminates the bad behavior.

Test method:
modprobe loop max_loop=64
dd if=/dev/zero of=disk bs=512 count=200K
for((i=0;i<4;i++))do losetup -f disk; done
mkfs.ext4 -F /dev/loop0
for((i=0;i<4;i++))do mkdir t$i; mount /dev/loop$i t$i;done
for f in `ls /dev/loop[0-9]*|sort`; do \
	echo $f; dd if=$f of=/dev/null  bs=512 count=1; \
	done

Test output:  stock          patched
/dev/loop0    18.1217e-05    8.3842e-05
/dev/loop1     6.1114e-05    0.000147979
/dev/loop10    0.414701      0.000116564
/dev/loop11    0.7474        6.7942e-05
/dev/loop12    0.747986      8.9082e-05
/dev/loop13    0.746532      7.4799e-05
/dev/loop14    0.480041      9.3926e-05
/dev/loop15    1.26453       7.2522e-05

Note that from loop10 onward, the device is not mounted, yet the
stock kernel consumes several orders of magnitude more wall time
than it does for a mounted device.
(Thanks for Mike Galbraith <efault@gmx.de>, give a changelog review.)

Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: James Wang <jnwang@suse.com>
Fixes: b5dd2f6047ca ("block: loop: improve performance via blk-mq")
---
 drivers/block/loop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 48f6fa6f810e..2e5b8538760c 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -625,6 +625,9 @@ static int loop_switch(struct loop_device *lo, struct file *file)
  */
 static int loop_flush(struct loop_device *lo)
 {
+	/* loop not yet configured, no running thread, nothing to flush */
+	if (lo->lo_state != Lo_bound)
+		return 0;
 	return loop_switch(lo, NULL);
 }
 
-- 
2.12.3

[toc] | [next] | [standalone]


#1660889

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2017-06-08 10:00 +0200
Message-ID<tQ0wi-1oo-27@gated-at.bofh.it>
In reply to#1660795
On 06/08/2017 08:52 AM, James Wang wrote:
> Test method:
> modprobe loop max_loop=64
> dd if=/dev/zero of=disk bs=512 count=200K
> for((i=0;i<4;i++))do losetup -f disk; done
> mkfs.ext4 -F /dev/loop0
> for((i=0;i<4;i++))do mkdir t$i; mount /dev/loop$i t$i;done
> for f in `ls /dev/loop[0-9]*|sort`; do \
> 	echo $f; dd if=$f of=/dev/null  bs=512 count=1; \
> 	done
I think Christoph already asked this, but can you send a patch for
blktests [1] as well?

Thanks,
	Johannes

[1] https://github.com/osandov/blktests

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [next] | [standalone]


#1660918

FromJames Wang <jnwang@suse.com>
Date2017-06-08 10:20 +0200
Message-ID<tQ0PE-1Le-29@gated-at.bofh.it>
In reply to#1660889

On 06/08/2017 03:53 PM, Johannes Thumshirn wrote:
> On 06/08/2017 08:52 AM, James Wang wrote:
>> Test method:
>> modprobe loop max_loop=64
>> dd if=/dev/zero of=disk bs=512 count=200K
>> for((i=0;i<4;i++))do losetup -f disk; done
>> mkfs.ext4 -F /dev/loop0
>> for((i=0;i<4;i++))do mkdir t$i; mount /dev/loop$i t$i;done
>> for f in `ls /dev/loop[0-9]*|sort`; do \
>> 	echo $f; dd if=$f of=/dev/null  bs=512 count=1; \
>> 	done
> I think Christoph already asked this, but can you send a patch for
> blktests [1] as well?
I have forked this project and I'm working on it.
due to framework is limited, so I'm adjusting my code.
> Thanks,
> 	Johannes
>
> [1] https://github.com/osandov/blktests
>

-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1661301

FromJens Axboe <axboe@kernel.dk>
Date2017-06-08 16:10 +0200
Message-ID<tQ6in-5iV-47@gated-at.bofh.it>
In reply to#1660795
On 06/08/2017 12:52 AM, James Wang wrote:
> While installing SLES-12 (based on v4.4), I found that the installer
> will stall for 60+ seconds during LVM disk scan.  The root cause was
> determined to be the removal of a bound device check in loop_flush()
> by commit b5dd2f6047ca ("block: loop: improve performance via blk-mq").
> 
> Restoring this check, examining ->lo_state as set by loop_set_fd()
> eliminates the bad behavior.
> 
> Test method:
> modprobe loop max_loop=64
> dd if=/dev/zero of=disk bs=512 count=200K
> for((i=0;i<4;i++))do losetup -f disk; done
> mkfs.ext4 -F /dev/loop0
> for((i=0;i<4;i++))do mkdir t$i; mount /dev/loop$i t$i;done
> for f in `ls /dev/loop[0-9]*|sort`; do \
> 	echo $f; dd if=$f of=/dev/null  bs=512 count=1; \
> 	done
> 
> Test output:  stock          patched
> /dev/loop0    18.1217e-05    8.3842e-05
> /dev/loop1     6.1114e-05    0.000147979
> /dev/loop10    0.414701      0.000116564
> /dev/loop11    0.7474        6.7942e-05
> /dev/loop12    0.747986      8.9082e-05
> /dev/loop13    0.746532      7.4799e-05
> /dev/loop14    0.480041      9.3926e-05
> /dev/loop15    1.26453       7.2522e-05
> 
> Note that from loop10 onward, the device is not mounted, yet the
> stock kernel consumes several orders of magnitude more wall time
> than it does for a mounted device.
> (Thanks for Mike Galbraith <efault@gmx.de>, give a changelog review.)

Added for 4.12, thanks.

-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web