Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3875553pxb; Tue, 17 Nov 2020 06:00:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwBYbdmQIEDynBAL1OtKU70cmvGWamLamq2Yy92CzRKW4zH+Ml4vZxc0m41jnm0qdbgFfq X-Received: by 2002:a50:fc89:: with SMTP id f9mr22246745edq.89.1605621635750; Tue, 17 Nov 2020 06:00:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605621635; cv=none; d=google.com; s=arc-20160816; b=gTPrAn4+x5damITqyacKJ0hq8AkhA2ItBKs/MM0DmfR0DoL99nA+o1RyWcpZBhVLQW 8ZUIZTtT+bZgpCqkq2nNbZODwicdHL3sswy3qxQzpJ7xXzG3oaMKbWKA7uvalWzT2Sos N4n+gHMDAvECcvVrWm0qbVM9qcflJdwOPJKhL8x8zoIJVgmSkYeh5RAO1uliRykUjLWk WILNOp1pHktuNiN2c13XnT91SaYXgVtYX4bpXIaIG+G0d+6l+40+Ilb2Q/eI+vwLHhRJ APhLF5v10GAGHXIoZAOYrrhPlZAbljgup8She9hOsQrFvMAHp27rkz/m3ZwhRJj45B+7 Y4PQ== 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=TnHobFH2OXGS0lYppwOlPFhrOlrwuYepk5QlaG7nOr0=; b=bgVSt6ZrYXl8Ib6bXZeJT3JZ+Xfo5Dg7u4GMsY8eWgWuCeh3gHJw+RNFTecWNSYrzr E6qvp8C4VfRwJjLf+Hjcx2wRl2JRcyD4DeG5ZU7qeZu+HkjR/4FnSVrooGtogz671GAX iY9xWGZV64kSBZskwcwJxIeetb5f1UgzAnuxSTlse4QxVzGNF5+SHtIJum0N/owU0A/H r06uU1EEMTBXWLU5nQIE6ZXF9hmnsIVItl3ZESCSyXzJf7bcWOtH9X7SBLYeJvKoH+Ea GfW1lTlsCi056JWwcn8NsViTsQMFe4rfIeSJ1NxVywYp1nQrGDRkiNyLgWnED8HviUKo dh5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=deroA62m; 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 d18si13337717ejr.174.2020.11.17.06.00.12; Tue, 17 Nov 2020 06:00: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=deroA62m; 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 S1731841AbgKQN41 (ORCPT + 99 others); Tue, 17 Nov 2020 08:56:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:56880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730684AbgKQNWh (ORCPT ); Tue, 17 Nov 2020 08:22:37 -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 3818E24654; Tue, 17 Nov 2020 13:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619355; bh=OE6TXPUCQ1k1btAVrSTPMn085/IQmXSbfPHDe+Htxa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=deroA62modJvnORXnLR4YdDYHGM6PaC2t+jovFNYmI4y+BOb6l1LO4MrG3bTym3fC 4HRf9Yna1ueEplDg3vZAyzuRJW1aoZ2tQHrvjFUaZKxmYsoh++eekZ+9VQiM1NjckG dQl1C6MBIIFxg5kstvvJdkJmwo9nfgUXT/zu719Q= 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 5.4 003/151] nbd: dont update block size after device is started Date: Tue, 17 Nov 2020 14:03:53 +0100 Message-Id: <20201117122121.556211131@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122121.381905960@linuxfoundation.org> References: <20201117122121.381905960@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 742f8160b6e28..62a873718b5bb 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -296,7 +296,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); @@ -312,7 +312,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); @@ -327,7 +328,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) @@ -1293,7 +1294,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