Received: by 10.213.65.68 with SMTP id h4csp2119182imn; Sun, 8 Apr 2018 20:10:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+iacFVwEC/gs/MzLKtfO/Nl9DgDiglpKQ4ctbsF8J2zsi7MGy/jTZcERrlgVd88lIqabNL X-Received: by 2002:a17:902:bc4b:: with SMTP id t11-v6mr7042614plz.343.1523243444890; Sun, 08 Apr 2018 20:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243444; cv=none; d=google.com; s=arc-20160816; b=EUIWS8dDGSk8J5RHfwzxI+toxloyNaRZaukxZ2jAmDDix3hAbSNHn6CBMtFk36tZTn nOXKcr07TenNLuO6P7/aLJwWhvWhBI8l/ye5wb6YrRFNjMg3fYa93U98wEQEy4a8uyz3 7MjSmkl/Depmp3ua1BloqWflfYRE1oN71tUJHcuE00M+0V1FgUK+bY2SbFw7ty6AV0cZ +GJ8+ILDfATFkRH7odHW0ZBZpPOkpDkoTmAfIzeK7Mbw1MYSLcXRzBHl13V4K5gEeAC0 n5Jkc3BdhX7G+8qkr9x1OYFC3MvBajVdAVYOBRYOBecJC1VW6NEmmkENUMVMCl8WZuDo OfZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Il2UN7LdpdVf/fSytyAluCmonMnpmPQPl91QoGD2nXg=; b=IZ5/6nWl74z4KI3qvjUfxnUR6WHlY0iWAnEYMQ9dfQ40HT5J8t1I/xyEam/rW45JFC vTRmWFnTqritxc51BNKdUB4/TbMc0i2l3SLSMBGYByvY1ve5WEvrUbwscNTq7G96u3dD BQ9EfER5lMOlmCFfg54NlbO/9xLWtjmSt5QUYY4QRW2dxmt0HFnmj+mgv35VEe1snviB Dv7hwp4Z5BAadIuOWfZvng0vBy2Lp3GSACqGzmWEf3XpEk2sdsFDBe8Hwmk0XGb+RzhK l1eRUffjZrvnayh6s7Nwf0pwoR47zK8PHHKHT57x06OFiJJCWDsNm+LSPdLvK/WSJqjA wNNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eJzTtcq2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v45si10655232pgn.379.2018.04.08.20.10.08; Sun, 08 Apr 2018 20:10:44 -0700 (PDT) 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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=eJzTtcq2; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756369AbeDICqF (ORCPT + 99 others); Sun, 8 Apr 2018 22:46:05 -0400 Received: from mail-cys01nam02on0098.outbound.protection.outlook.com ([104.47.37.98]:9607 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755411AbeDIA0m (ORCPT ); Sun, 8 Apr 2018 20:26:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Il2UN7LdpdVf/fSytyAluCmonMnpmPQPl91QoGD2nXg=; b=eJzTtcq2ZSeOBsW8F1KiKo4DdnAwr3uBffoEqzGmL6+l92LIJEVN1QyZEPVJTuNw356DeStPd7xz3umFJHiaMwgSYBm7/jXwp3pQeWxpiHtcIandjlZTvuVU3yzWd+LjJhc89xfKfXaiYuGv0ghZts7upP6HcWbZ3zYRX/sHRjg= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:26:36 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:26:36 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: James Wang , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 011/293] Fix loop device flush before configure v3 Thread-Topic: [PATCH AUTOSEL for 4.9 011/293] Fix loop device flush before configure v3 Thread-Index: AQHTz5joHY7lHbXYlk+OWISM+bLcIg== Date: Mon, 9 Apr 2018 00:22:56 +0000 Message-ID: <20180409002239.163177-11-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1015;7:Vn4QDmO0euWbGkh+9TVQ+4vB1I7X3AVUVhN/GTiaPbB5tsZ1SyHcdAabI45hM7voe2uREjEqHuatvNHR4H0RRuPDvo3Of4w4qAdq1SZ5KZZZuQPP6D7SwvXa+CUy9sbxo2/yU2ccTymKdy4KD2jJdkm8rxbFDDci6v6sBmx0OMlXNL9RbdGHh8mA7KN0ZmnEI+xZgdUqm5kd7kAD7EWakejqMnzKKMq9Hx7/lO2K0bcI4lQaNeBG3NrTu9N39P/E;20:72PS5fElzSu/tuq5wO3xFR9TPIUps8JCPJzccidtqP/WRF5ByLDBzq9fmNNJuFmEdwLdUZLN/ypvswBu8hzWc4yJzejKRWN1jhN4AIojrrIvihSCcXMNxHRAV6PrtQnj9amAiYmtIXPKNHPhn9EPkv/lJC2Lg55unKxvl4w8Kog= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 9123ff0d-baaa-4d4d-cdd3-08d59db08ddf x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(26323138287068)(89211679590171)(67672495146484); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(39380400002)(376002)(346002)(366004)(189003)(199004)(54534003)(53936002)(4326008)(478600001)(72206003)(3280700002)(2616005)(14454004)(305945005)(5250100002)(3660700001)(2501003)(2900100001)(54906003)(110136005)(86362001)(1076002)(107886003)(6506007)(36756003)(446003)(68736007)(6512007)(7736002)(486006)(2906002)(5660300001)(6436002)(3846002)(86612001)(6486002)(66066001)(11346002)(476003)(6666003)(26005)(10090500001)(316002)(22452003)(8676002)(81156014)(81166006)(6116002)(105586002)(99286004)(186003)(106356001)(76176011)(25786009)(97736004)(10290500003)(102836004)(8936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 38xNPMGOpJpvAkDq3izW/7ADs0VNkjmHnDM0CKKUhO04h3VIV2/8gZtixbNA7x/RjNE+uCoh85YdGzKRi7wL2Cef79FkLxccNuKqogiY8CmI8j1fJOtFGNQpLm9vKvaR1R/dhkQySkLjxX5gv0tOzs5sYM3yCiarV6D7iRnCkD26/AIttZTFBBvK0XxaI+OlYIfF0SAqKTDS9Ug2PmGPZT9jkjF08Cob5X4whX6SIoeliTRTMp/nvNx4cQIFYFBbHWy3nF2VT0ItX6j90s58/9T2a/dWTmCsOD3JH5RW9YCBljAPkrRlmC6G8E+I32CDaukmHK6kCZjsklFc8BUot2Rq2LT4ax4Ivu3KOm6b4nnwXNbz4cy1H1W20KHuW9z//bWAmyOwTgY+NQ3Gu3ujDoHNO/rOO4o9MY9TOY2yoCI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9123ff0d-baaa-4d4d-cdd3-08d59db08ddf X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:22:56.4873 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Wang [ Upstream commit 6460495709aeb651896bc8e5c134b2e4ca7d34a8 ] 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=3D64 dd if=3D/dev/zero of=3Ddisk bs=3D512 count=3D200K for((i=3D0;i<4;i++))do losetup -f disk; done mkfs.ext4 -F /dev/loop0 for((i=3D0;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=3D$f of=3D/dev/null bs=3D512 count=3D1; \ 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 , give a changelog review.) Reviewed-by: Hannes Reinecke Reviewed-by: Ming Lei Signed-off-by: James Wang Fixes: b5dd2f6047ca ("block: loop: improve performance via blk-mq") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/loop.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 68bfcef24701..dc318b9100c2 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -612,6 +612,9 @@ static int loop_switch(struct loop_device *lo, struct f= ile *file) */ static int loop_flush(struct loop_device *lo) { + /* loop not yet configured, no running thread, nothing to flush */ + if (lo->lo_state !=3D Lo_bound) + return 0; return loop_switch(lo, NULL); } =20 --=20 2.15.1