lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230628093500.68779-2-frank.li@vivo.com>
Date:   Wed, 28 Jun 2023 17:34:55 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     axboe@...nel.dk, song@...nel.org, viro@...iv.linux.org.uk,
        brauner@...nel.org, xiang@...nel.org, chao@...nel.org,
        huyue2@...lpad.com, jefflexu@...ux.alibaba.com, hch@...radead.org,
        djwong@...nel.org
Cc:     linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-raid@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-erofs@...ts.ozlabs.org, linux-xfs@...r.kernel.org,
        Yangtao Li <frank.li@...o.com>
Subject: [PATCH 2/7] block: Convert to bdev_logical_block_mask()

Use bdev_logical_block_mask() to simplify code.

Signed-off-by: Yangtao Li <frank.li@...o.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ