linux-nilfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
Cc: Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
	Coly Li <colyli-l3A5Bk7waGM@public.gmane.org>,
	Mike Snitzer <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Song Liu <song-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	David Sterba <dsterba-IBi9RG/b67k@public.gmane.org>,
	Josef Bacik <josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org>,
	Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>,
	OGAWA Hirofumi
	<hirofumi-UIVanBePwB70ZhReMnHkpc8NsWr+9BEh@public.gmane.org>,
	Dave Kleikamp <shaggy-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Ryusuke Konishi
	<konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Anton Altaparmakov
	<anton-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org>,
	Konstantin Komarov
	<almaz.alexandrovich-m5I1DM4ARimttCpgsWEBFlaTQe2KTcn/@public.gmane.org>,
	Phillip Lougher <phillip-Y7wUz+saRi+tmTQ+vhA3Yw@public.gmane.org>,
	Jan Kara <jack-IBi9RG/b67k@public.gmane.org>,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org,
	linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 24/29] block: add a sb_bdev_nr_blocks helper
Date: Tue, 12 Oct 2021 23:27:42 -0700	[thread overview]
Message-ID: <202110122319.3029AE5AA@keescook> (raw)
In-Reply-To: <20211013051042.1065752-25-hch-jcswGhMUV9g@public.gmane.org>

On Wed, Oct 13, 2021 at 07:10:37AM +0200, Christoph Hellwig wrote:
> Add a helper to return the size of sb->s_bdev in sb->s_blocksize_bits
> based unites.  Note that SECTOR_SHIFT has to be open coded due to
> include dependency issues for now, but I have a plan to sort that out
> eventually.

Wouldn't that just need a quick lift into a new header file to be
included by genhd.h, blkev.h, and:

drivers/mtd/ssfdc.c:#define SECTOR_SHIFT                9
fs/hfsplus/hfsplus_raw.h:#define HFSPLUS_SECTOR_SHIFT         9

I think that's worth doing at some point in this series since genhd.h
already has existing open-coded "9"s. And, really, a *lot* of other
places too:

$ git grep -E '(<<|>>) 9' | grep -E '\b(block|blk|sector|bdev)\b' | wc -l
240

> 
> Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
> ---
>  include/linux/genhd.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/linux/genhd.h b/include/linux/genhd.h
> index 082a3e5fd8fa1..6eaef8fa78bcd 100644
> --- a/include/linux/genhd.h
> +++ b/include/linux/genhd.h
> @@ -245,6 +245,12 @@ static inline sector_t get_capacity(struct gendisk *disk)
>  	return bdev_nr_sectors(disk->part0);
>  }
>  
> +static inline u64 sb_bdev_nr_blocks(struct super_block *sb)
> +{
> +	return bdev_nr_sectors(sb->s_bdev) >>
> +		(sb->s_blocksize_bits - 9 /* SECTOR_SHIFT */);
> +}
> +
>  int bdev_disk_changed(struct gendisk *disk, bool invalidate);
>  void blk_drop_partitions(struct gendisk *disk);
>  
> -- 
> 2.30.2
> 

-- 
Kees Cook

  parent reply	other threads:[~2021-10-13  6:27 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  5:10 don't use ->bd_inode to access the block device size Christoph Hellwig
2021-10-13  5:10 ` [PATCH 01/29] bcache: remove bdev_sectors Christoph Hellwig
2021-10-13  5:21   ` Coly Li
2021-10-13  6:09   ` Kees Cook
2021-10-13  5:10 ` [PATCH 02/29] drbd: use bdev_nr_sectors instead of open coding it Christoph Hellwig
2021-10-13  6:09   ` Kees Cook
2021-10-13 22:33   ` Chaitanya Kulkarni
2021-10-13  5:10 ` [PATCH 03/29] dm: " Christoph Hellwig
2021-10-13  6:10   ` Kees Cook
2021-10-13 16:43   ` Mike Snitzer
2021-10-13  5:10 ` [PATCH 04/29] md: " Christoph Hellwig
2021-10-13  6:12   ` Kees Cook
2021-10-13 21:14     ` Song Liu
2021-10-13  5:10 ` [PATCH 05/29] mtd/block2mtd: " Christoph Hellwig
2021-10-13  5:10 ` [PATCH 06/29] nvmet: " Christoph Hellwig
2021-10-13 22:33   ` Chaitanya Kulkarni
2021-10-13  5:10 ` [PATCH 07/29] target/iblock: " Christoph Hellwig
2021-10-13  9:31   ` Bodo Stroesser
2021-10-13 22:37   ` Chaitanya Kulkarni
2021-10-13  5:10 ` [PATCH 08/29] fs: use bdev_nr_sectors instead of open coding it in blkdev_max_block Christoph Hellwig
     [not found]   ` <20211013051042.1065752-9-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13 10:42     ` Jan Kara
2021-10-13 22:35   ` Chaitanya Kulkarni
2021-10-13  5:10 ` [PATCH 09/29] fs: simplify init_page_buffers Christoph Hellwig
     [not found]   ` <20211013051042.1065752-10-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:14     ` Kees Cook
2021-10-13 10:42   ` Jan Kara
2021-10-13  5:10 ` [PATCH 10/29] affs: use bdev_nr_sectors instead of open coding it Christoph Hellwig
     [not found]   ` <20211013051042.1065752-11-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:14     ` Kees Cook
2021-10-13  5:10 ` [PATCH 11/29] btrfs: " Christoph Hellwig
2021-10-13  7:08   ` Anand Jain
2021-10-13 22:36   ` Chaitanya Kulkarni
     [not found]   ` <20211013051042.1065752-12-hch-jcswGhMUV9g@public.gmane.org>
2021-10-14  2:44     ` Keith Busch
2021-10-13  5:10 ` [PATCH 12/29] cramfs: " Christoph Hellwig
     [not found]   ` <20211013051042.1065752-13-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:16     ` Kees Cook
2021-10-13  5:10 ` [PATCH 13/29] fat: " Christoph Hellwig
     [not found]   ` <20211013051042.1065752-14-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:16     ` Kees Cook
2021-10-13  5:10 ` [PATCH 14/29] hfs: " Christoph Hellwig
2021-10-13  6:16   ` Kees Cook
2021-10-13  5:10 ` [PATCH 15/29] hfsplus: " Christoph Hellwig
2021-10-13  6:16   ` Kees Cook
2021-10-13  5:10 ` [PATCH 16/29] jfs: " Christoph Hellwig
2021-10-13 14:13   ` Dave Kleikamp
2021-10-13  5:10 ` [PATCH 17/29] nfs/blocklayout: " Christoph Hellwig
2021-10-13  5:10 ` [PATCH 18/29] nilfs2: " Christoph Hellwig
2021-10-13  5:10 ` [PATCH 19/29] ntfs3: " Christoph Hellwig
2021-10-13  5:10 ` [PATCH 20/29] pstore/blk: " Christoph Hellwig
2021-10-13  5:10 ` [PATCH 21/29] reiserfs: " Christoph Hellwig
2021-10-13 10:43   ` Jan Kara
2021-10-13  5:10 ` [PATCH 22/29] squashfs: " Christoph Hellwig
2021-10-13 19:37   ` Phillip Lougher
2021-10-13  5:10 ` [PATCH 23/29] block: use bdev_nr_sectors instead of open coding it in blkdev_fallocate Christoph Hellwig
2021-10-13 10:44   ` Jan Kara
     [not found]   ` <20211013051042.1065752-24-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13 22:34     ` Chaitanya Kulkarni
2021-10-13  5:10 ` [PATCH 24/29] block: add a sb_bdev_nr_blocks helper Christoph Hellwig
     [not found]   ` <20211013051042.1065752-25-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:27     ` Kees Cook [this message]
2021-10-13  5:10 ` [PATCH 25/29] ext4: use sb_bdev_nr_blocks Christoph Hellwig
2021-10-13  6:29   ` Kees Cook
     [not found]   ` <20211013051042.1065752-26-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:30     ` Kees Cook
2021-10-13 10:46   ` Jan Kara
2021-10-13 15:51   ` Theodore Ts'o
2021-10-13  5:10 ` [PATCH 26/29] jfs: " Christoph Hellwig
2021-10-13  6:31   ` Kees Cook
2021-10-13  5:10 ` [PATCH 27/29] ntfs: " Christoph Hellwig
     [not found]   ` <20211013051042.1065752-28-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13  6:33     ` Kees Cook
2021-10-13  5:10 ` [PATCH 28/29] reiserfs: " Christoph Hellwig
2021-10-13  6:33   ` Kees Cook
2021-10-13 10:46   ` Jan Kara
2021-10-13  5:10 ` [PATCH 29/29] udf: " Christoph Hellwig
2021-10-13  6:34   ` Kees Cook
     [not found]   ` <20211013051042.1065752-30-hch-jcswGhMUV9g@public.gmane.org>
2021-10-13 10:47     ` Jan Kara
2021-10-13  6:39 ` don't use ->bd_inode to access the block device size Kees Cook
2021-10-13  7:14 ` Anand Jain
2021-10-14  6:28 ` Christoph Hellwig
2021-10-14  9:32   ` Anton Altaparmakov
2021-10-14 13:13     ` Dave Kleikamp
2021-10-14 15:14       ` Kees Cook
2021-10-14 15:35         ` Wol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202110122319.3029AE5AA@keescook \
    --to=keescook-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
    --cc=almaz.alexandrovich-m5I1DM4ARimttCpgsWEBFlaTQe2KTcn/@public.gmane.org \
    --cc=anton-yrGDUoBaLx3QT0dZR+AlfA@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=colyli-l3A5Bk7waGM@public.gmane.org \
    --cc=dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org \
    --cc=dsterba-IBi9RG/b67k@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=hirofumi-UIVanBePwB70ZhReMnHkpc8NsWr+9BEh@public.gmane.org \
    --cc=jack-IBi9RG/b67k@public.gmane.org \
    --cc=josef-DigfWCa+lFGyeJad7bwFQA@public.gmane.org \
    --cc=konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=phillip-Y7wUz+saRi+tmTQ+vhA3Yw@public.gmane.org \
    --cc=shaggy-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=song-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=target-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).