Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3878285pxb; Tue, 17 Nov 2020 06:03:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwi4fWzp/TA181g7UVGDQ4Jahz6MRyoG9q0Iyi/HcsMOJgMqF0JjKtIoJ/tQ8SRVHwV9PQQ X-Received: by 2002:a50:b224:: with SMTP id o33mr20258791edd.21.1605621815670; Tue, 17 Nov 2020 06:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621815; cv=none; d=google.com; s=arc-20160816; b=FrueTEos8nWYmdGhp1YTolx/7YDOWj5r8b9oNrICwCr9GQRitUOi5VFl7kCaCg0JhK VUXpp7xf/GcDI37EAqrdk+znlDIudjbbxZBojDgpvcdqqKWqD1dnd22tO5p1haFQHcaD m6BYhk7FfGeHkEkZ+o6yMXMSx+lnrHwyTIaAt8O+zaLSOWdctpHxrh+MbccMrhKUJexN gHQExPp/VUwx5OT+O/alqrg5YDyvQPpdqH/e6FO6Y3MgC+OqRuYAHf2AXrK+AQYeN9AM nxH8s+4Cqjq0Ya7MDlWpgbGnmx6Ppo62xVsaWbCbaRQ4Ze/Ng/Gp9NVExwJpLyttzI/6 ZfLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=03NNqm6eWyYefqHAIAL/fJQzSyS+OZYBRikbJbwGO7o=; b=qanK7cO9f0NfcYZA3vPTbIUz9kMt+ZYurlFJ98J1veprz/JD/KtwjEC6HYVuI2+43/ wjaCY191r42JefZIQsuqvyk3x8VN7Zpl3RfSpoj2I76XKaxKTAdiA3OjtSZ71Vq2JPfJ nWJsrCprjo29+xDljZ2G23WDR6odbiEiqLCYr+Rox4ZevSRUmNiPKnwpJk+vH1U2sdNn FhJfTKC53My/aRXPsV9FIRNBLOqjau5y8qmahWUyDDPYqMfjiCR5LErJcnlZusCyMFV/ GO3UaZ+FEprf51N2f+qtn9CJ1shmnq4nr4UaUn49CsPrxJZ36ncB3GIEGOcuH753Yg+Q xo5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k0r+6UNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd28si13407963edb.329.2020.11.17.06.03.11; Tue, 17 Nov 2020 06:03:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k0r+6UNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387548AbgKQOA5 (ORCPT + 99 others); Tue, 17 Nov 2020 09:00:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:45322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729057AbgKQNO2 (ORCPT ); Tue, 17 Nov 2020 08:14:28 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACB2C241A5; Tue, 17 Nov 2020 13:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605618867; bh=J4zeeKNy8JRtCJcZKOQEo10fGGyKWqDlH2ii/KXrWx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k0r+6UNgStFWuz7Sv4S7C/pF9lDflw6plv6CgFkPh7uAa4L2Et1M6IP7Jjb2iGD/y dz8gqZa31nfq4jrA8SCU0awS8CEirSW0aMVjv0R/2vSV8HHz3KATLt+BJw6U61d5Fy 78nMPe8BXq9E4jW/k2VxJoftln2gNd22z/wVND7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, lining , Ming Lei , Josef Bacik , Jan Kara , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 05/85] nbd: dont update block size after device is started Date: Tue, 17 Nov 2020 14:04:34 +0100 Message-Id: <20201117122111.281487055@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei [ Upstream commit b40813ddcd6bf9f01d020804e4cb8febc480b9e4 ] Mounted NBD device can be resized, one use case is rbd-nbd. Fix the issue by setting up default block size, then not touch it in nbd_size_update() any more. This kind of usage is aligned with loop which has same use case too. Cc: stable@vger.kernel.org Fixes: c8a83a6b54d0 ("nbd: Use set_blocksize() to set device blocksize") Reported-by: lining Signed-off-by: Ming Lei Cc: Josef Bacik Cc: Jan Kara Tested-by: lining Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/nbd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index cdf62fb94fb15..9a0fb2d52a76c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -268,7 +268,7 @@ static void nbd_size_clear(struct nbd_device *nbd) } } -static void nbd_size_update(struct nbd_device *nbd) +static void nbd_size_update(struct nbd_device *nbd, bool start) { struct nbd_config *config = nbd->config; struct block_device *bdev = bdget_disk(nbd->disk, 0); @@ -279,7 +279,8 @@ static void nbd_size_update(struct nbd_device *nbd) if (bdev) { if (bdev->bd_disk) { bd_set_size(bdev, config->bytesize); - set_blocksize(bdev, config->blksize); + if (start) + set_blocksize(bdev, config->blksize); } else bdev->bd_invalidated = 1; bdput(bdev); @@ -294,7 +295,7 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize, config->blksize = blocksize; config->bytesize = blocksize * nr_blocks; if (nbd->task_recv != NULL) - nbd_size_update(nbd); + nbd_size_update(nbd, false); } static void nbd_complete_rq(struct request *req) @@ -1231,7 +1232,7 @@ static int nbd_start_device(struct nbd_device *nbd) args->index = i; queue_work(nbd->recv_workq, &args->work); } - nbd_size_update(nbd); + nbd_size_update(nbd, true); return error; } -- 2.27.0