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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83347C433F5 for ; Fri, 15 Apr 2022 04:54:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2738C6B0087; Fri, 15 Apr 2022 00:54:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 184DC6B0085; Fri, 15 Apr 2022 00:54:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF08C6B0087; Fri, 15 Apr 2022 00:54:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id D439F6B0083 for ; Fri, 15 Apr 2022 00:54:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 83B058249980 for ; Fri, 15 Apr 2022 04:54:03 +0000 (UTC) X-FDA: 79357896366.26.5B3F597 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id E828540005 for ; Fri, 15 Apr 2022 04:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=HrgNfnZXHjI7+oEfFDB5J5Uuocj6xy8pedsh1Yy5WG4=; b=R0lBPRibOGoSZmsdT2BBTTPD3x NwCzRpJB/bxli2xONupKhhJNx7Tq1nA6hg5urvI8CevCDma1aSHOvltCxPQVBkCYYIAazdu94JhOg jUc9C0uB0ZcqdXuo3tqllo7RFWblcuoKttRRtshPAOTk9xPWXo9L51Jx+MBLxWuevzEN6ePJqPM9o O/Kgk+1vrPJJ/tXWxgEWAoGzr7Z1pW3yunSGYLN41shEprbTPauLr7ZDX+uOWX/sBmVGFEWkzS8iP pSkYNyZUK+8w0sI6r2DBAifGctVRL3GCvrebz8RO5GOBvOX0W6zq/yOSLOkXbitIIxFW4u3HYF7ZU 82QTqcrQ==; Received: from [2a02:1205:504b:4280:f5dd:42a4:896c:d877] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfDxl-008P65-E3; Fri, 15 Apr 2022 04:53:41 +0000 From: Christoph Hellwig To: Jens Axboe Cc: dm-devel@redhat.com, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-um@lists.infradead.org, linux-block@vger.kernel.org, drbd-dev@lists.linbit.com, nbd@other.debian.org, ceph-devel@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, jfs-discussion@lists.sourceforge.net, linux-nilfs@vger.kernel.org, ntfs3@lists.linux.dev, ocfs2-devel@oss.oracle.com, linux-mm@kvack.org, "Martin K . Petersen" , David Sterba Subject: [PATCH 11/27] block: add a bdev_nonrot helper Date: Fri, 15 Apr 2022 06:52:42 +0200 Message-Id: <20220415045258.199825-12-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220415045258.199825-1-hch@lst.de> References: <20220415045258.199825-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E828540005 X-Stat-Signature: hj9i94tmoofe8c98i5b1iabwuks4ka6i Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=R0lBPRib; spf=none (imf01.hostedemail.com: domain of BATV+2d633663de0085320ac7+6809+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+2d633663de0085320ac7+6809+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none X-HE-Tag: 1649998442-856479 Content-Transfer-Encoding: quoted-printable 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: Add a helper to check the nonrot flag based on the block_device instead of having to poke into the block layer internal request_queue. Signed-off-by: Christoph Hellwig Reviewed-by: Martin K. Petersen Acked-by: David Sterba [btrfs] --- block/ioctl.c | 2 +- drivers/block/loop.c | 2 +- drivers/md/dm-table.c | 4 +--- drivers/md/md.c | 3 +-- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- drivers/target/target_core_file.c | 3 +-- drivers/target/target_core_iblock.c | 2 +- fs/btrfs/volumes.c | 4 ++-- fs/ext4/mballoc.c | 2 +- include/linux/blkdev.h | 5 +++++ mm/swapfile.c | 4 ++-- 13 files changed, 19 insertions(+), 18 deletions(-) diff --git a/block/ioctl.c b/block/ioctl.c index 4a86340133e46..ad3771b268b81 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -489,7 +489,7 @@ static int blkdev_common_ioctl(struct block_device *b= dev, fmode_t mode, queue_max_sectors(bdev_get_queue(bdev))); return put_ushort(argp, max_sectors); case BLKROTATIONAL: - return put_ushort(argp, !blk_queue_nonrot(bdev_get_queue(bdev))); + return put_ushort(argp, !bdev_nonrot(bdev)); case BLKRASET: case BLKFRASET: if(!capable(CAP_SYS_ADMIN)) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index a58595f5ee2c8..8d800d46e4985 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -903,7 +903,7 @@ static void loop_update_rotational(struct loop_device= *lo) =20 /* not all filesystems (e.g. tmpfs) have a sb->s_bdev */ if (file_bdev) - nonrot =3D blk_queue_nonrot(bdev_get_queue(file_bdev)); + nonrot =3D bdev_nonrot(file_bdev); =20 if (nonrot) blk_queue_flag_set(QUEUE_FLAG_NONROT, q); diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 03541cfc2317c..5e38d0dd009d5 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1820,9 +1820,7 @@ static int device_dax_write_cache_enabled(struct dm= _target *ti, static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev= , sector_t start, sector_t len, void *data) { - struct request_queue *q =3D bdev_get_queue(dev->bdev); - - return !blk_queue_nonrot(q); + return !bdev_nonrot(dev->bdev); } =20 static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev= , diff --git a/drivers/md/md.c b/drivers/md/md.c index 309b3af906ad3..19636c2f2cda4 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -5991,8 +5991,7 @@ int md_run(struct mddev *mddev) bool nonrot =3D true; =20 rdev_for_each(rdev, mddev) { - if (rdev->raid_disk >=3D 0 && - !blk_queue_nonrot(bdev_get_queue(rdev->bdev))) { + if (rdev->raid_disk >=3D 0 && !bdev_nonrot(rdev->bdev)) { nonrot =3D false; break; } diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 99d5464a51f81..d81b896855f9f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -704,7 +704,7 @@ static int read_balance(struct r1conf *conf, struct r= 1bio *r1_bio, int *max_sect /* At least two disks to choose from so failfast is OK */ set_bit(R1BIO_FailFast, &r1_bio->state); =20 - nonrot =3D blk_queue_nonrot(bdev_get_queue(rdev->bdev)); + nonrot =3D bdev_nonrot(rdev->bdev); has_nonrot_disk |=3D nonrot; pending =3D atomic_read(&rdev->nr_pending); dist =3D abs(this_sector - conf->mirrors[disk].head_position); diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index dfe7d62d3fbdd..7816c8b2e8087 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -796,7 +796,7 @@ static struct md_rdev *read_balance(struct r10conf *c= onf, if (!do_balance) break; =20 - nonrot =3D blk_queue_nonrot(bdev_get_queue(rdev->bdev)); + nonrot =3D bdev_nonrot(rdev->bdev); has_nonrot_disk |=3D nonrot; pending =3D atomic_read(&rdev->nr_pending); if (min_pending > pending && nonrot) { diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 351d341a1ffa4..0bbae0e638666 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7242,7 +7242,7 @@ static struct r5conf *setup_conf(struct mddev *mdde= v) rdev_for_each(rdev, mddev) { if (test_bit(Journal, &rdev->flags)) continue; - if (blk_queue_nonrot(bdev_get_queue(rdev->bdev))) { + if (bdev_nonrot(rdev->bdev)) { conf->batch_bio_dispatch =3D false; break; } diff --git a/drivers/target/target_core_file.c b/drivers/target/target_co= re_file.c index 8d191fdc33217..b6ba582b06775 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -135,7 +135,6 @@ static int fd_configure_device(struct se_device *dev) inode =3D file->f_mapping->host; if (S_ISBLK(inode->i_mode)) { struct block_device *bdev =3D I_BDEV(inode); - struct request_queue *q =3D bdev_get_queue(bdev); unsigned long long dev_size; =20 fd_dev->fd_block_size =3D bdev_logical_block_size(bdev); @@ -160,7 +159,7 @@ static int fd_configure_device(struct se_device *dev) */ dev->dev_attrib.max_write_same_len =3D 0xFFFF; =20 - if (blk_queue_nonrot(q)) + if (bdev_nonrot(bdev)) dev->dev_attrib.is_nonrot =3D 1; } else { if (!(fd_dev->fbd_flags & FBDF_HAS_SIZE)) { diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_= core_iblock.c index b886ce1770bfd..b41ee5c3b5b82 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -133,7 +133,7 @@ static int iblock_configure_device(struct se_device *= dev) else dev->dev_attrib.max_write_same_len =3D 0xFFFF; =20 - if (blk_queue_nonrot(q)) + if (bdev_nonrot(bd)) dev->dev_attrib.is_nonrot =3D 1; =20 bi =3D bdev_get_integrity(bd); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 2cfbc74a3b4ee..77f1a5696842b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -643,7 +643,7 @@ static int btrfs_open_one_device(struct btrfs_fs_devi= ces *fs_devices, set_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state); } =20 - if (!blk_queue_nonrot(bdev_get_queue(bdev))) + if (!bdev_nonrot(bdev)) fs_devices->rotating =3D true; =20 device->bdev =3D bdev; @@ -2706,7 +2706,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_= info, const char *device_path =20 atomic64_add(device->total_bytes, &fs_info->free_chunk_space); =20 - if (!blk_queue_nonrot(bdev_get_queue(bdev))) + if (!bdev_nonrot(bdev)) fs_devices->rotating =3D true; =20 orig_super_total_bytes =3D btrfs_super_total_bytes(fs_info->super_copy)= ; diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 252c168454c7f..c3668c977cd99 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -3498,7 +3498,7 @@ int ext4_mb_init(struct super_block *sb) spin_lock_init(&lg->lg_prealloc_lock); } =20 - if (blk_queue_nonrot(bdev_get_queue(sb->s_bdev))) + if (bdev_nonrot(sb->s_bdev)) sbi->s_mb_max_linear_groups =3D 0; else sbi->s_mb_max_linear_groups =3D MB_DEFAULT_LINEAR_LIMIT; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 60d0161389971..3a9578e14a6b0 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1326,6 +1326,11 @@ static inline unsigned int bdev_write_zeroes_secto= rs(struct block_device *bdev) return 0; } =20 +static inline bool bdev_nonrot(struct block_device *bdev) +{ + return blk_queue_nonrot(bdev_get_queue(bdev)); +} + static inline enum blk_zoned_model bdev_zoned_model(struct block_device = *bdev) { struct request_queue *q =3D bdev_get_queue(bdev); diff --git a/mm/swapfile.c b/mm/swapfile.c index 4c7537162af5e..d5ab7ec4d92ca 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2466,7 +2466,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, speci= alfile) if (p->flags & SWP_CONTINUED) free_swap_count_continuations(p); =20 - if (!p->bdev || !blk_queue_nonrot(bdev_get_queue(p->bdev))) + if (!p->bdev || !bdev_nonrot(p->bdev)) atomic_dec(&nr_rotate_swap); =20 mutex_lock(&swapon_mutex); @@ -3071,7 +3071,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specia= lfile, int, swap_flags) if (p->bdev && p->bdev->bd_disk->fops->rw_page) p->flags |=3D SWP_SYNCHRONOUS_IO; =20 - if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) { + if (p->bdev && bdev_nonrot(p->bdev)) { int cpu; unsigned long ci, nr_cluster; =20 --=20 2.30.2