From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DBFAC388F9 for ; Sat, 21 Nov 2020 16:24:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 86B0522226 for ; Sat, 21 Nov 2020 16:24:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86B0522226 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7C53D6B0036; Sat, 21 Nov 2020 11:24:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7763F6B005D; Sat, 21 Nov 2020 11:24:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 63E3B6B0068; Sat, 21 Nov 2020 11:24:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 369916B0036 for ; Sat, 21 Nov 2020 11:24:16 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C9AA11EE6 for ; Sat, 21 Nov 2020 16:24:15 +0000 (UTC) X-FDA: 77508947670.23.join19_4b0f57727355 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id A62DF37604 for ; Sat, 21 Nov 2020 16:24:15 +0000 (UTC) X-HE-Tag: join19_4b0f57727355 X-Filterd-Recvd-Size: 2422 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Sat, 21 Nov 2020 16:24:14 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 951F467373; Sat, 21 Nov 2020 17:24:11 +0100 (CET) Date: Sat, 21 Nov 2020 17:24:11 +0100 From: Christoph Hellwig To: Jan Kara Cc: Matthew Wilcox , Christoph Hellwig , Jens Axboe , Tejun Heo , Josef Bacik , Konrad Rzeszutek Wilk , Coly Li , Mike Snitzer , dm-devel@redhat.com, Richard Weinberger , Jan Kara , linux-block@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 14/20] block: remove the nr_sects field in struct hd_struct Message-ID: <20201121162411.GA18475@lst.de> References: <20201118084800.2339180-1-hch@lst.de> <20201118084800.2339180-15-hch@lst.de> <20201119120525.GW1981@quack2.suse.cz> <20201120090820.GD21715@lst.de> <20201120112121.GB15537@quack2.suse.cz> <20201120153253.GA18990@lst.de> <20201120155956.GB4327@casper.infradead.org> <20201120200548.GA27360@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201120200548.GA27360@quack2.suse.cz> User-Agent: Mutt/1.5.17 (2007-11-01) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Nov 20, 2020 at 09:05:48PM +0100, Jan Kara wrote: > The code is already switched to it AFAICT (the lock is really only used in > the two places that write i_size). But the problem is that in theory two > i_size_write() calls can race in a way that the resulting stored i_size is a > mix of two stored sizes. Now I have hard time imagining how this could > happen for a block device and if two reconfigurations of a block device > could race like that we'd have a large problems anyway... Now that you mention it, yes - i_size_write needs to be under i_rwsem or an equivalent lock. We could look into using i_rwsem also for block device, but for now the spinlock seems to be doing fine. Note that in current mainline we only have such a lock protecting i_size of the block_device inode, but none for the size in hd_struct.