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: <20230621083823.1724337-4-p.raghav@samsung.com>
Date:   Wed, 21 Jun 2023 10:38:22 +0200
From:   Pankaj Raghav <p.raghav@...sung.com>
To:     <hare@...e.de>, <willy@...radead.org>, <david@...morbit.com>
CC:     <gost.dev@...sung.com>, <mcgrof@...nel.org>, <hch@....de>,
        <jwong@...nel.org>, <linux-fsdevel@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>,
        Pankaj Raghav <p.raghav@...sung.com>
Subject: [RFC 3/4] block: set mapping order for the block cache in
 set_init_blocksize

From: Luis Chamberlain <mcgrof@...nel.org>

Automatically set the minimum mapping order for block devices in
set_init_blocksize(). The mapping order will be set only when the block
device uses iomap based aops.

Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
 block/bdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/block/bdev.c b/block/bdev.c
index 9bb54d9d02a6..db8cede8a320 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -126,6 +126,7 @@ static void set_init_blocksize(struct block_device *bdev)
 {
 	unsigned int bsize = bdev_logical_block_size(bdev);
 	loff_t size = i_size_read(bdev->bd_inode);
+	int order, folio_order;
 
 	while (bsize < PAGE_SIZE) {
 		if (size & bsize)
@@ -133,6 +134,14 @@ static void set_init_blocksize(struct block_device *bdev)
 		bsize <<= 1;
 	}
 	bdev->bd_inode->i_blkbits = blksize_bits(bsize);
+	order = bdev->bd_inode->i_blkbits - PAGE_SHIFT;
+	folio_order = mapping_min_folio_order(bdev->bd_inode->i_mapping);
+
+	if (!IS_ENABLED(CONFIG_BUFFER_HEAD)) {
+		/* Do not allow changing the folio order after it is set */
+		WARN_ON_ONCE(folio_order && (folio_order != order));
+		mapping_set_folio_orders(bdev->bd_inode->i_mapping, order, 31);
+	}
 }
 
 int set_blocksize(struct block_device *bdev, int size)
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ