diff mbox series

[v2] minix: convert minix to use the new mount api

Message ID 20240307163325.998723-1-bodonnel@redhat.com (mailing list archive)
State New, archived
Headers show
Series [v2] minix: convert minix to use the new mount api | expand

Commit Message

Bill O'Donnell March 7, 2024, 4:29 p.m. UTC
Convert the minix filesystem to use the new mount API.

Tested using mount and remount on minix device.

Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
---

v2: Remove unneeded minix_context struct and its allocation/freeing.

---
 fs/minix/inode.c | 48 ++++++++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 18 deletions(-)

Comments

Eric Sandeen March 7, 2024, 6:26 p.m. UTC | #1
On 3/7/24 10:29 AM, Bill O'Donnell wrote:
> Convert the minix filesystem to use the new mount API.
> 
> Tested using mount and remount on minix device.
> 
> Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>

Looks good to me now, thanks

Acked-by: Eric Sandeen <sandeen@redhat.com>

> ---
> 
> v2: Remove unneeded minix_context struct and its allocation/freeing.
> 
> ---
>  fs/minix/inode.c | 48 ++++++++++++++++++++++++++++++------------------
>  1 file changed, 30 insertions(+), 18 deletions(-)
> 
> diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> index 73f37f298087..7b2b394a0799 100644
> --- a/fs/minix/inode.c
> +++ b/fs/minix/inode.c
> @@ -20,11 +20,11 @@
>  #include <linux/mpage.h>
>  #include <linux/vfs.h>
>  #include <linux/writeback.h>
> +#include <linux/fs_context.h>
>  
>  static int minix_write_inode(struct inode *inode,
>  		struct writeback_control *wbc);
>  static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
> -static int minix_remount (struct super_block * sb, int * flags, char * data);
>  
>  static void minix_evict_inode(struct inode *inode)
>  {
> @@ -111,19 +111,19 @@ static const struct super_operations minix_sops = {
>  	.evict_inode	= minix_evict_inode,
>  	.put_super	= minix_put_super,
>  	.statfs		= minix_statfs,
> -	.remount_fs	= minix_remount,
>  };
>  
> -static int minix_remount (struct super_block * sb, int * flags, char * data)
> +static int minix_reconfigure(struct fs_context *fc)
>  {
> -	struct minix_sb_info * sbi = minix_sb(sb);
>  	struct minix_super_block * ms;
> +	struct super_block *sb = fc->root->d_sb;
> +	struct minix_sb_info * sbi = sb->s_fs_info;
>  
>  	sync_filesystem(sb);
>  	ms = sbi->s_ms;
> -	if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
> +	if ((bool)(fc->sb_flags & SB_RDONLY) == sb_rdonly(sb))
>  		return 0;
> -	if (*flags & SB_RDONLY) {
> +	if (fc->sb_flags & SB_RDONLY) {
>  		if (ms->s_state & MINIX_VALID_FS ||
>  		    !(sbi->s_mount_state & MINIX_VALID_FS))
>  			return 0;
> @@ -170,7 +170,7 @@ static bool minix_check_superblock(struct super_block *sb)
>  	return true;
>  }
>  
> -static int minix_fill_super(struct super_block *s, void *data, int silent)
> +static int minix_fill_super(struct super_block *s, struct fs_context *fc)
>  {
>  	struct buffer_head *bh;
>  	struct buffer_head **map;
> @@ -180,6 +180,7 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
>  	struct inode *root_inode;
>  	struct minix_sb_info *sbi;
>  	int ret = -EINVAL;
> +	int silent = fc->sb_flags & SB_SILENT;
>  
>  	sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
>  	if (!sbi)
> @@ -371,6 +372,23 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
>  	return ret;
>  }
>  
> +static int minix_get_tree(struct fs_context *fc)
> +{
> +	 return get_tree_bdev(fc, minix_fill_super);
> +}
> +
> +static const struct fs_context_operations minix_context_ops = {
> +	.get_tree	= minix_get_tree,
> +	.reconfigure	= minix_reconfigure,
> +};
> +
> +static int minix_init_fs_context(struct fs_context *fc)
> +{
> +	fc->ops = &minix_context_ops;
> +
> +	return 0;
> +}
> +
>  static int minix_statfs(struct dentry *dentry, struct kstatfs *buf)
>  {
>  	struct super_block *sb = dentry->d_sb;
> @@ -680,18 +698,12 @@ void minix_truncate(struct inode * inode)
>  		V2_minix_truncate(inode);
>  }
>  
> -static struct dentry *minix_mount(struct file_system_type *fs_type,
> -	int flags, const char *dev_name, void *data)
> -{
> -	return mount_bdev(fs_type, flags, dev_name, data, minix_fill_super);
> -}
> -
>  static struct file_system_type minix_fs_type = {
> -	.owner		= THIS_MODULE,
> -	.name		= "minix",
> -	.mount		= minix_mount,
> -	.kill_sb	= kill_block_super,
> -	.fs_flags	= FS_REQUIRES_DEV,
> +	.owner			= THIS_MODULE,
> +	.name			= "minix",
> +	.kill_sb		= kill_block_super,
> +	.fs_flags		= FS_REQUIRES_DEV,
> +	.init_fs_context	= minix_init_fs_context,
>  };
>  MODULE_ALIAS_FS("minix");
>
Christian Brauner March 11, 2024, 1:28 p.m. UTC | #2
On Thu, 07 Mar 2024 10:29:18 -0600, Bill O'Donnell wrote:
> Convert the minix filesystem to use the new mount API.
> 
> Tested using mount and remount on minix device.
> 
> 

Applied to the vfs.mount.api branch of the vfs/vfs.git tree.
Patches in the vfs.mount.api branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.mount.api

[1/1] minix: convert minix to use the new mount api
      https://git.kernel.org/vfs/vfs/c/f1e4cac59dc6
diff mbox series

Patch

diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 73f37f298087..7b2b394a0799 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -20,11 +20,11 @@ 
 #include <linux/mpage.h>
 #include <linux/vfs.h>
 #include <linux/writeback.h>
+#include <linux/fs_context.h>
 
 static int minix_write_inode(struct inode *inode,
 		struct writeback_control *wbc);
 static int minix_statfs(struct dentry *dentry, struct kstatfs *buf);
-static int minix_remount (struct super_block * sb, int * flags, char * data);
 
 static void minix_evict_inode(struct inode *inode)
 {
@@ -111,19 +111,19 @@  static const struct super_operations minix_sops = {
 	.evict_inode	= minix_evict_inode,
 	.put_super	= minix_put_super,
 	.statfs		= minix_statfs,
-	.remount_fs	= minix_remount,
 };
 
-static int minix_remount (struct super_block * sb, int * flags, char * data)
+static int minix_reconfigure(struct fs_context *fc)
 {
-	struct minix_sb_info * sbi = minix_sb(sb);
 	struct minix_super_block * ms;
+	struct super_block *sb = fc->root->d_sb;
+	struct minix_sb_info * sbi = sb->s_fs_info;
 
 	sync_filesystem(sb);
 	ms = sbi->s_ms;
-	if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
+	if ((bool)(fc->sb_flags & SB_RDONLY) == sb_rdonly(sb))
 		return 0;
-	if (*flags & SB_RDONLY) {
+	if (fc->sb_flags & SB_RDONLY) {
 		if (ms->s_state & MINIX_VALID_FS ||
 		    !(sbi->s_mount_state & MINIX_VALID_FS))
 			return 0;
@@ -170,7 +170,7 @@  static bool minix_check_superblock(struct super_block *sb)
 	return true;
 }
 
-static int minix_fill_super(struct super_block *s, void *data, int silent)
+static int minix_fill_super(struct super_block *s, struct fs_context *fc)
 {
 	struct buffer_head *bh;
 	struct buffer_head **map;
@@ -180,6 +180,7 @@  static int minix_fill_super(struct super_block *s, void *data, int silent)
 	struct inode *root_inode;
 	struct minix_sb_info *sbi;
 	int ret = -EINVAL;
+	int silent = fc->sb_flags & SB_SILENT;
 
 	sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
 	if (!sbi)
@@ -371,6 +372,23 @@  static int minix_fill_super(struct super_block *s, void *data, int silent)
 	return ret;
 }
 
+static int minix_get_tree(struct fs_context *fc)
+{
+	 return get_tree_bdev(fc, minix_fill_super);
+}
+
+static const struct fs_context_operations minix_context_ops = {
+	.get_tree	= minix_get_tree,
+	.reconfigure	= minix_reconfigure,
+};
+
+static int minix_init_fs_context(struct fs_context *fc)
+{
+	fc->ops = &minix_context_ops;
+
+	return 0;
+}
+
 static int minix_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
 	struct super_block *sb = dentry->d_sb;
@@ -680,18 +698,12 @@  void minix_truncate(struct inode * inode)
 		V2_minix_truncate(inode);
 }
 
-static struct dentry *minix_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
-{
-	return mount_bdev(fs_type, flags, dev_name, data, minix_fill_super);
-}
-
 static struct file_system_type minix_fs_type = {
-	.owner		= THIS_MODULE,
-	.name		= "minix",
-	.mount		= minix_mount,
-	.kill_sb	= kill_block_super,
-	.fs_flags	= FS_REQUIRES_DEV,
+	.owner			= THIS_MODULE,
+	.name			= "minix",
+	.kill_sb		= kill_block_super,
+	.fs_flags		= FS_REQUIRES_DEV,
+	.init_fs_context	= minix_init_fs_context,
 };
 MODULE_ALIAS_FS("minix");