mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yangtao Li <frank.li@vivo.com>
To: axboe@kernel.dk, song@kernel.org, viro@zeniv.linux.org.uk,
	brauner@kernel.org, xiang@kernel.org, chao@kernel.org,
	huyue2@coolpad.com, jefflexu@linux.alibaba.com,
	hch@infradead.org, djwong@kernel.org
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-erofs@lists.ozlabs.org, linux-xfs@vger.kernel.org,
	Yangtao Li <frank.li@vivo.com>
Subject: [PATCH 2/7] block: Convert to bdev_logical_block_mask()
Date: Wed, 28 Jun 2023 17:34:55 +0800	[thread overview]
Message-ID: <20230628093500.68779-2-frank.li@vivo.com> (raw)
In-Reply-To: <20230628093500.68779-1-frank.li@vivo.com>

Use bdev_logical_block_mask() to simplify code.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 block/bio.c   | 2 +-
 block/fops.c  | 4 ++--
 block/ioctl.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index 8672179213b9..42ccf5a21696 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1281,7 +1281,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
 
 	nr_pages = DIV_ROUND_UP(offset + size, PAGE_SIZE);
 
-	trim = size & (bdev_logical_block_size(bio->bi_bdev) - 1);
+	trim = size & bdev_logical_block_mask(bio->bi_bdev);
 	iov_iter_revert(iter, trim);
 
 	size -= trim;
diff --git a/block/fops.c b/block/fops.c
index a286bf3325c5..754f7014172a 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -45,7 +45,7 @@ static blk_opf_t dio_bio_write_op(struct kiocb *iocb)
 static bool blkdev_dio_unaligned(struct block_device *bdev, loff_t pos,
 			      struct iov_iter *iter)
 {
-	return pos & (bdev_logical_block_size(bdev) - 1) ||
+	return pos & bdev_logical_block_mask(bdev) ||
 		!bdev_iter_is_aligned(bdev, iter);
 }
 
@@ -653,7 +653,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
 	/*
 	 * Don't allow IO that isn't aligned to logical block size.
 	 */
-	if ((start | len) & (bdev_logical_block_size(bdev) - 1))
+	if ((start | len) & bdev_logical_block_mask(bdev))
 		return -EINVAL;
 
 	filemap_invalidate_lock(inode->i_mapping);
diff --git a/block/ioctl.c b/block/ioctl.c
index 3be11941fb2d..8544702d6263 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -39,7 +39,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,
 	switch (op) {
 	case BLKPG_ADD_PARTITION:
 		/* check if partition is aligned to blocksize */
-		if (p.start & (bdev_logical_block_size(bdev) - 1))
+		if (p.start & bdev_logical_block_mask(bdev))
 			return -EINVAL;
 		return bdev_add_partition(disk, p.pno, start, length);
 	case BLKPG_RESIZE_PARTITION:
-- 
2.39.0


  reply	other threads:[~2023-06-28  9:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28  9:34 [PATCH 1/7] block: add queue_logical_block_mask() and bdev_logical_block_mask() Yangtao Li
2023-06-28  9:34 ` Yangtao Li [this message]
2023-06-28  9:34 ` [PATCH 3/7] md: Convert to queue_logical_block_mask() Yangtao Li
2023-06-28  9:34 ` [PATCH 4/7] buffer: Convert to bdev_logical_block_mask() Yangtao Li
2023-06-28  9:34 ` [PATCH 5/7] iomap: " Yangtao Li
2023-06-28  9:34 ` [PATCH 6/7] xfs: " Yangtao Li
2023-06-28 16:41   ` Bill O'Donnell
2023-06-28  9:35 ` [PATCH 7/7] erofs: " Yangtao Li
2023-06-28 16:45 ` [PATCH 1/7] block: add queue_logical_block_mask() and bdev_logical_block_mask() Bill O'Donnell
2023-06-28 16:46 ` Matthew Wilcox
2023-06-29  3:44   ` Yangtao Li
2023-06-29  4:34     ` Darrick J. Wong
2023-06-29  5:44 ` Christoph Hellwig

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=20230628093500.68779-2-frank.li@vivo.com \
    --to=frank.li@vivo.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=chao@kernel.org \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiang@kernel.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

all inboxes | Powered by JetHome®