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: <20240924192351.74728-2-kernel@pankajraghav.com>
Date: Tue, 24 Sep 2024 21:23:50 +0200
From: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
To: linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: willy@...radead.org,
	mcgrof@...nel.org,
	gost.dev@...sung.com,
	akpm@...ux-foundation.org,
	kernel@...kajraghav.com,
	Christian Brauner <brauner@...nel.org>,
	Pankaj Raghav <p.raghav@...sung.com>
Subject: [PATCH 1/2] ramfs: add blocksize mount option

From: Pankaj Raghav <p.raghav@...sung.com>

ramfs has only supported blocksize == PAGE_SIZE as page cache's minimum
allocation unit was a PAGE_SIZE.

As the page cache now has minimum folio order support, ramfs can support
different blocksizes.

This is a preparation patch which adds blocksize mount option but still
supporting only blocksize == PAGE_SIZE.

Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
---
 fs/ramfs/inode.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 8006faaaf0ec7..d846345a0f4b1 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -43,6 +43,7 @@
 
 struct ramfs_mount_opts {
 	umode_t mode;
+	u32 blocksize;
 };
 
 struct ramfs_fs_info {
@@ -221,10 +222,12 @@ static const struct super_operations ramfs_ops = {
 
 enum ramfs_param {
 	Opt_mode,
+	Opt_blocksize,
 };
 
 const struct fs_parameter_spec ramfs_fs_parameters[] = {
 	fsparam_u32oct("mode",	Opt_mode),
+	fsparam_u32("blocksize", Opt_blocksize),
 	{}
 };
 
@@ -254,6 +257,19 @@ static int ramfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 	case Opt_mode:
 		fsi->mount_opts.mode = result.uint_32 & S_IALLUGO;
 		break;
+	case Opt_blocksize:
+		if (!fsi->mount_opts.blocksize)
+			return -EINVAL;
+
+		fsi->mount_opts.blocksize = rounddown_pow_of_two(result.uint_32);
+
+		if (fsi->mount_opts.blocksize > PAGE_SIZE)
+			fsi->mount_opts.blocksize = PAGE_SIZE;
+
+		if (fsi->mount_opts.blocksize < PAGE_SIZE)
+			fsi->mount_opts.blocksize = PAGE_SIZE;
+
+		break;
 	}
 
 	return 0;
@@ -265,8 +281,8 @@ static int ramfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	struct inode *inode;
 
 	sb->s_maxbytes		= MAX_LFS_FILESIZE;
-	sb->s_blocksize		= PAGE_SIZE;
-	sb->s_blocksize_bits	= PAGE_SHIFT;
+	sb->s_blocksize		= fsi->mount_opts.blocksize;
+	sb->s_blocksize_bits	= ilog2(fsi->mount_opts.blocksize);
 	sb->s_magic		= RAMFS_MAGIC;
 	sb->s_op		= &ramfs_ops;
 	sb->s_time_gran		= 1;
@@ -304,6 +320,7 @@ int ramfs_init_fs_context(struct fs_context *fc)
 		return -ENOMEM;
 
 	fsi->mount_opts.mode = RAMFS_DEFAULT_MODE;
+	fsi->mount_opts.blocksize = PAGE_SIZE;
 	fc->s_fs_info = fsi;
 	fc->ops = &ramfs_context_ops;
 	return 0;
-- 
2.44.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ