Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1448036imp; Fri, 22 Feb 2019 03:48:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ3XtcasGNmgbw0gJepGKMRuLajEUWJ/0w5oDvl2vgt2YO0pPuiDN/jYuHc9X5TshHZSUf5 X-Received: by 2002:a62:5444:: with SMTP id i65mr3901042pfb.193.1550836114365; Fri, 22 Feb 2019 03:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550836114; cv=none; d=google.com; s=arc-20160816; b=b9uM3/NfB1mVkUAkPsKvGVDjyh9mLz7OQlAediD2/p8DkWCw7qjpNEi2mgNZ7R1zCL 4j20Pglfi1bExOmlgV6P2S1ZmG8//kt91Omx17Ty9zLtjfTQg6FUA6nHRLT38vaeid8r jlRWtnDO4lL0UCfflOh3KiCH5qV7FSdFSC+XWoK9JnzPWsFoYmzoz7q5jwW70EE+uggr TK9QHxxopLruUnJ1DD1Lv8etuB+f7zNu8c9LMEAQGJS6mjlRlegIG60K9RUoe0SD/N3s 6u0+w5n2+xjF1dPHa93nVVvqiJlgnb8I4NHAgjbcBmjnH6v05JQZeyDAtsnRwIQkNeS3 lnbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=MuC3bFhnsqpbDLHkk5apZA0kBUFOxKG07Os+OdDs7/Y=; b=Lcvh//RmxB786EHrNfNP0eDZQ/Dy/D0FPUZyHEyyfaBEpAuhZkCmeL4ye7/CPsqqZJ 4s22DTskfzOrDDHU4QN1g8wvpkERcY3q52puvV6ULNrHFDD3IivTvrQf35rUvhBOMT3v ka0Dp/kJJBTSaj99KD4CiD1awnu6+EjbMrjS2ST5/MCay64uUhyJjRUJsGLH3k52KdPr xscyw+wbNgzjOkDVSkNZTPr0H5M2t3MgrQ2FlrI5EF/JDt3yEx2OsClJJEnH9y6yEst+ wCOKSUzRuEXN9kv21Z0oD0fXBgy559DDMMKC7LzW9Rc3YSkdOvlgQdeKUDArZGkkx7Nm naPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b27si1208248pgb.366.2019.02.22.03.48.18; Fri, 22 Feb 2019 03:48:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726673AbfBVLrW (ORCPT + 99 others); Fri, 22 Feb 2019 06:47:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:43176 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726131AbfBVLrV (ORCPT ); Fri, 22 Feb 2019 06:47:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7661CAFE2; Fri, 22 Feb 2019 11:47:20 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A234D1E0900; Fri, 22 Feb 2019 12:47:19 +0100 (CET) Date: Fri, 22 Feb 2019 12:47:19 +0100 From: Jan Kara To: Dongli Zhang Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@kernel.dk, jack@suse.cz Subject: Re: [PATCH v2 2/2] loop: set GENHD_FL_NO_PART_SCAN after blkdev_reread_part() Message-ID: <20190222114719.GI23071@quack2.suse.cz> References: <1550763223-21764-1-git-send-email-dongli.zhang@oracle.com> <1550763223-21764-3-git-send-email-dongli.zhang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550763223-21764-3-git-send-email-dongli.zhang@oracle.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 21-02-19 23:33:43, Dongli Zhang wrote: > Commit 0da03cab87e6 > ("loop: Fix deadlock when calling blkdev_reread_part()") moves > blkdev_reread_part() out of the loop_ctl_mutex. However, > GENHD_FL_NO_PART_SCAN is set before __blkdev_reread_part(). As a result, > __blkdev_reread_part() will fail the check of GENHD_FL_NO_PART_SCAN and > will not rescan the loop device to delete all partitions. > > Below are steps to reproduce the issue: > > step1 # dd if=/dev/zero of=tmp.raw bs=1M count=100 > step2 # losetup -P /dev/loop0 tmp.raw > step3 # parted /dev/loop0 mklabel gpt > step4 # parted -a none -s /dev/loop0 mkpart primary 64s 1 > step5 # losetup -d /dev/loop0 > > Step5 will not be able to delete /dev/loop0p1 (introduced by step4) and > there is below kernel warning message: > > [ 464.414043] __loop_clr_fd: partition scan of loop0 failed (rc=-22) > > This patch sets GENHD_FL_NO_PART_SCAN after blkdev_reread_part(). > > Fixes: 0da03cab87e6 ("loop: Fix deadlock when calling blkdev_reread_part()") > Signed-off-by: Dongli Zhang > --- > Changed since v1: > * move the setting of lo->lo_state to Lo_unbound after partscan has finished as well > (suggested by Jan Kara) > > drivers/block/loop.c | 26 ++++++++++++++++++++++---- > 1 file changed, 22 insertions(+), 4 deletions(-) Thanks the patch looks good! Just one nit below: > diff --git a/drivers/block/loop.c b/drivers/block/loop.c > index 7908673..a13f5dc 100644 > --- a/drivers/block/loop.c > +++ b/drivers/block/loop.c > @@ -1034,6 +1034,16 @@ loop_init_xfer(struct loop_device *lo, struct loop_func_table *xfer, > return err; > } > > +static void loop_disable_partscan(struct loop_device *lo) > +{ I don't think there's any benefit in having this small function with a single caller and furthermore with the subtle sideeffect that it changes lo_state. So I'd just put the code inline in __loop_clr_fd(). With that you can add: Reviewed-by: Jan Kara Honza -- Jan Kara SUSE Labs, CR