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=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 10DADC5519F for ; Fri, 20 Nov 2020 11:21:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7493822244 for ; Fri, 20 Nov 2020 11:21:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7493822244 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 837D06B0068; Fri, 20 Nov 2020 06:21:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E6D36B006E; Fri, 20 Nov 2020 06:21:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FCD16B0070; Fri, 20 Nov 2020 06:21:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id 36B9C6B0068 for ; Fri, 20 Nov 2020 06:21:26 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B65CE1EF2 for ; Fri, 20 Nov 2020 11:21:25 +0000 (UTC) X-FDA: 77504555730.02.skirt27_40013922734b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 8EA5D10097AA1 for ; Fri, 20 Nov 2020 11:21:25 +0000 (UTC) X-HE-Tag: skirt27_40013922734b X-Filterd-Recvd-Size: 4813 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Nov 2020 11:21:24 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C4C79AED9; Fri, 20 Nov 2020 11:21:21 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 2825E1E130B; Fri, 20 Nov 2020 12:21:21 +0100 (CET) Date: Fri, 20 Nov 2020 12:21:21 +0100 From: Jan Kara To: Christoph Hellwig Cc: Jan Kara , 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: <20201120112121.GB15537@quack2.suse.cz> References: <20201118084800.2339180-1-hch@lst.de> <20201118084800.2339180-15-hch@lst.de> <20201119120525.GW1981@quack2.suse.cz> <20201120090820.GD21715@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201120090820.GD21715@lst.de> User-Agent: Mutt/1.10.1 (2018-07-13) 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 20-11-20 10:08:20, Christoph Hellwig wrote: > On Thu, Nov 19, 2020 at 01:05:25PM +0100, Jan Kara wrote: > > > @@ -613,7 +613,7 @@ void guard_bio_eod(struct bio *bio) > > > rcu_read_lock(); > > > part = __disk_get_part(bio->bi_disk, bio->bi_partno); > > > if (part) > > > - maxsector = part_nr_sects_read(part); > > > + maxsector = bdev_nr_sectors(part->bdev); > > > else > > > maxsector = get_capacity(bio->bi_disk); > > > > I have to say that after these changes I find it a bit confusing that we > > have get/set_capacity() and bdev_nr_sectors() / bdev_set_nr_sectors() and > > they are all the same thing (i_size of the bdev). Is there a reason for the > > distinction? > > get_capacity/set_capacity are the existing unchanged interfaces that > work on struct gendisk, and unchanged from what we had before. They also > have lots of users which makes them kinda awkward to touch. > > bdev_nr_sectors is the public interface to query the size for any > kind of struct block device, to be used by consumers of the block > device interface. > > bdev_set_nr_sectors is a private helper for the partitions core that > avoids duplicating a bit of code, and works on partitions. OK, I guess I'll get used to this... > > > @@ -38,6 +38,16 @@ static void disk_add_events(struct gendisk *disk); > > > static void disk_del_events(struct gendisk *disk); > > > static void disk_release_events(struct gendisk *disk); > > > > > > +void set_capacity(struct gendisk *disk, sector_t sectors) > > > +{ > > > + struct block_device *bdev = disk->part0.bdev; > > > + > > > + spin_lock(&bdev->bd_size_lock); > > > + i_size_write(bdev->bd_inode, (loff_t)sectors << SECTOR_SHIFT); > > > + spin_unlock(&bdev->bd_size_lock); > > > > AFAICT bd_size_lock is pointless after these changes so we can just remove > > it? > > I don't think it is, as reuqiring bd_mutex for size updates leads to > rather awkward lock ordering problems. OK, let me ask differently: What is bd_size_lock protecting now? Ah, I see, on 32-bit it is needed to prevent torn writes to i_size, right? > > > if (capacity != size && capacity != 0 && size != 0) { > > > char *envp[] = { "RESIZE=1", NULL }; > > > > > > + pr_info("%s: detected capacity change from %lld to %lld\n", > > > + disk->disk_name, size, capacity); > > > > So we are now missing above message for transitions from / to 0 capacity? > > Is there any other notification in the kernel log when e.g. media is > > inserted into a CD-ROM drive? I remember using these messages for detecting > > that... > > True, I guess we should keep the messages for that case at least under > some circumstances. Let me take a closer look at what could make sense. > > > Also what about GENHD_FL_HIDDEN devices? Are we sure we never set capacity > > for them? > > We absolutely set the capacity for them, as we have to. And even use > this interface. But yes, I think we should skip sending the uevent for > them. Also previously we were not printing any messages for hidden devices and now we do. I'm not sure whether that's intended or not. Honza -- Jan Kara SUSE Labs, CR