linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dongli Zhang <dongli.zhang@oracle.com>
To: Omar Sandoval <osandov@osandov.com>
Cc: linux-block@vger.kernel.org, osandov@fb.com, jack@suse.cz
Subject: Re: [PATCH blktests 2/2] loop/001: verify all partitions are removed
Date: Fri, 15 Mar 2019 10:00:27 +0800	[thread overview]
Message-ID: <c55aa1f3-6b5f-3dab-6c74-247ba65b5bd0@oracle.com> (raw)
In-Reply-To: <20190314175533.GC11825@vader>



On 3/15/19 1:55 AM, Omar Sandoval wrote:
> On Thu, Mar 14, 2019 at 07:45:17PM +0800, Dongli Zhang wrote:
>> loop/001 does not test whether all partitions are removed successfully
>> during loop device partition scanning. As a result, the regression
>> introduced by 0da03cab87e6 ("loop: Fix deadlock when calling
>> blkdev_reread_part()") can not be detected.
>>
>> The regression will generate below message in dmesg:
>>
>> [  464.414043] __loop_clr_fd: partition scan of loop0 failed (rc=-22)
>>
>> and leave orphan partitions like below:
>>
>> - /dev/loop0p1
>> - /sys/block/loop0/loop0p1
>>
>> This patch verifies all partitions are removed by checking if there is
>> /sys/block/loopX/loopXpY left. The expected number of partitions left is 0.
> 
> Thanks for the test! A couple of comments below.
> 
>> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
>> ---
>>  tests/loop/001     | 5 +++++
>>  tests/loop/001.out | 1 +
>>  2 files changed, 6 insertions(+)
>>
>> diff --git a/tests/loop/001 b/tests/loop/001
>> index 47f760a..a0326b7 100755
>> --- a/tests/loop/001
>> +++ b/tests/loop/001
>> @@ -4,6 +4,9 @@
>>  #
>>  # Test loop device partition scanning. Regression test for commit e02898b42380
>>  # ("loop: fix LO_FLAGS_PARTSCAN hang").
>> +#
>> +# Test loop device paritition scanning. Regression test for commit 758a58d0bc67
>> +# ("loop: set GENHD_FL_NO_PART_SCAN after blkdev_reread_part()").
> 
> These can just be combined to
> 
> # Test loop device partition scanning. Regression test for commits e02898b42380
> # ("loop: fix LO_FLAGS_PARTSCAN hang") and 758a58d0bc67 ("loop: set
> # GENHD_FL_NO_PART_SCAN after blkdev_reread_part()").
> 
>>  . tests/loop/rc
>>  
>> @@ -24,9 +27,11 @@ test() {
>>  		mkpart primary 50% 100%
>>  
>>  	loop_device="$(losetup -P -f --show "$TMPDIR/img")"
>> +	loop_name=${loop_device:5}
>>  	lsblk -ln "$loop_device" | wc -l
>>  
>>  	losetup -d "$loop_device"
>> +	ls /sys/block/$loop_name | grep loop | wc -l
> 
> We can just repeat the same `lsblk -ln "$loop_device" | wc -l` from
> earlier, right? That's a bit cleaner than the hardcoded string slicing
> and ls.

Seems 'lsblk' does not work here.

step1: truncate -s 100M /tmp/tmp.raw
step2: parted /tmp/tmp.raw --script mklabel msdos \
       mkpart primary 0% 50% mkpart primary 50% 100%
step3: losetup -P -f --show /tmp/tmp.raw

Now we are able to see two loop partitions from 'lsblk'

# lsblk -ln /dev/loop0
loop0     7:0    0  100M  0 loop
loop0p1 259:0    0   50M  0 loop
loop0p2 259:1    0   50M  0 loop


step4: # losetup -d /dev/loop0

There is below syslog as  partscan is failed.

[  261.181049] __loop_clr_fd: partition scan of loop0 failed (rc=-22)


There are 2 partitions left:

# ls /dev | grep loop0
loop0
loop0p1
loop0p2

# ls /sys/block/loop0 | grep loop
loop0p1
loop0p2


However, 'lsblk -ln' does not report the orphan paritions:

# lsblk -ln
sr0   11:0    1 1024M  0 rom
sda    8:0    0   20G  0 disk
sda2   8:2    0    1K  0 part
sda5   8:5    0  4.1G  0 part [SWAP]
sda1   8:1    0 15.9G  0 part /


Therefore, we would not be able to use 'lsblk' here.

Dongli Zhang

  reply	other threads:[~2019-03-15  1:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 11:45 [PATCH blktests 1/2] loop/001: fix typo 'paritition' to 'partition' Dongli Zhang
2019-03-14 11:45 ` [PATCH blktests 2/2] loop/001: verify all partitions are removed Dongli Zhang
2019-03-14 17:55   ` Omar Sandoval
2019-03-15  2:00     ` Dongli Zhang [this message]
2019-03-21 23:26       ` Omar Sandoval
2019-03-22  2:23         ` Dongli Zhang
2019-03-25 17:32           ` Omar Sandoval

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=c55aa1f3-6b5f-3dab-6c74-247ba65b5bd0@oracle.com \
    --to=dongli.zhang@oracle.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    --cc=osandov@osandov.com \
    /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).