Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file
@ 2019-10-11  0:23 Marcos Paulo de Souza
  2019-10-11  2:02 ` Anand Jain
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marcos Paulo de Souza @ 2019-10-11  0:23 UTC (permalink / raw)
  To: dsterba, clm
  Cc: Marcos Paulo de Souza, Marcos Paulo de Souza, Josef Bacik,
	linux-btrfs, linux-kernel

Some functions are doing some bikeshedding to reach the btrfs_fs_info
struct. Change these functions to receive a btrfs_fs_info struct instead
of a *file.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 The kernel survived btrfs-progs tests with this patch applied.

 fs/btrfs/ioctl.c | 36 +++++++++++++++---------------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index de730e56d3f5..870e5c48b362 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -479,10 +479,9 @@ static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
 	return put_user(inode->i_generation, arg);
 }
 
-static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
+static noinline int btrfs_ioctl_fitrim(struct btrfs_fs_info *fs_info,
+					void __user *arg)
 {
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_device *device;
 	struct request_queue *q;
 	struct fstrim_range range;
@@ -4960,10 +4959,9 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
 	return ret;
 }
 
-static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
+static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info,
+						void __user *arg)
 {
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_ioctl_quota_rescan_args *qsa;
 	int ret = 0;
 
@@ -4986,11 +4984,9 @@ static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
 	return ret;
 }
 
-static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg)
+static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info,
+						void __user *arg)
 {
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
-
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
@@ -5162,10 +5158,9 @@ static long btrfs_ioctl_set_received_subvol(struct file *file,
 	return ret;
 }
 
-static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
+static int btrfs_ioctl_get_fslabel(struct btrfs_fs_info *fs_info,
+					void __user *arg)
 {
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	size_t len;
 	int ret;
 	char label[BTRFS_LABEL_SIZE];
@@ -5249,10 +5244,9 @@ int btrfs_ioctl_get_supported_features(void __user *arg)
 	return 0;
 }
 
-static int btrfs_ioctl_get_features(struct file *file, void __user *arg)
+static int btrfs_ioctl_get_features(struct btrfs_fs_info *fs_info,
+					void __user *arg)
 {
-	struct inode *inode = file_inode(file);
-	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct btrfs_super_block *super_block = fs_info->super_copy;
 	struct btrfs_ioctl_feature_flags features;
 
@@ -5453,11 +5447,11 @@ long btrfs_ioctl(struct file *file, unsigned int
 	case FS_IOC_GETVERSION:
 		return btrfs_ioctl_getversion(file, argp);
 	case FS_IOC_GETFSLABEL:
-		return btrfs_ioctl_get_fslabel(file, argp);
+		return btrfs_ioctl_get_fslabel(fs_info, argp);
 	case FS_IOC_SETFSLABEL:
 		return btrfs_ioctl_set_fslabel(file, argp);
 	case FITRIM:
-		return btrfs_ioctl_fitrim(file, argp);
+		return btrfs_ioctl_fitrim(fs_info, argp);
 	case BTRFS_IOC_SNAP_CREATE:
 		return btrfs_ioctl_snap_create(file, argp, 0);
 	case BTRFS_IOC_SNAP_CREATE_V2:
@@ -5562,15 +5556,15 @@ long btrfs_ioctl(struct file *file, unsigned int
 	case BTRFS_IOC_QUOTA_RESCAN:
 		return btrfs_ioctl_quota_rescan(file, argp);
 	case BTRFS_IOC_QUOTA_RESCAN_STATUS:
-		return btrfs_ioctl_quota_rescan_status(file, argp);
+		return btrfs_ioctl_quota_rescan_status(fs_info, argp);
 	case BTRFS_IOC_QUOTA_RESCAN_WAIT:
-		return btrfs_ioctl_quota_rescan_wait(file, argp);
+		return btrfs_ioctl_quota_rescan_wait(fs_info, argp);
 	case BTRFS_IOC_DEV_REPLACE:
 		return btrfs_ioctl_dev_replace(fs_info, argp);
 	case BTRFS_IOC_GET_SUPPORTED_FEATURES:
 		return btrfs_ioctl_get_supported_features(argp);
 	case BTRFS_IOC_GET_FEATURES:
-		return btrfs_ioctl_get_features(file, argp);
+		return btrfs_ioctl_get_features(fs_info, argp);
 	case BTRFS_IOC_SET_FEATURES:
 		return btrfs_ioctl_set_features(file, argp);
 	case FS_IOC_FSGETXATTR:
-- 
2.23.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file
  2019-10-11  0:23 [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file Marcos Paulo de Souza
@ 2019-10-11  2:02 ` Anand Jain
  2019-10-11  6:38 ` Nikolay Borisov
  2019-10-11 17:41 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Anand Jain @ 2019-10-11  2:02 UTC (permalink / raw)
  To: Marcos Paulo de Souza; +Cc: Marcos Paulo de Souza, linux-btrfs

(cleaned up cc list - I didn't want to clutter others inboxes with my 
review).

On 10/11/19 8:23 AM, Marcos Paulo de Souza wrote:
> Some functions are doing some bikeshedding to reach the btrfs_fs_info
> struct. Change these functions to receive a btrfs_fs_info struct instead
> of a *file.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Thanks for the fix.
Reviewed-by: Anand Jain <anand.jain@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file
  2019-10-11  0:23 [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file Marcos Paulo de Souza
  2019-10-11  2:02 ` Anand Jain
@ 2019-10-11  6:38 ` Nikolay Borisov
  2019-10-11 17:41 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2019-10-11  6:38 UTC (permalink / raw)
  To: Marcos Paulo de Souza, clm, David Sterba
  Cc: Marcos Paulo de Souza, Josef Bacik, open list:BTRFS FILE SYSTEM,
	open list



On 11.10.19 г. 3:23 ч., Marcos Paulo de Souza wrote:
> Some functions are doing some bikeshedding to reach the btrfs_fs_info
> struct. Change these functions to receive a btrfs_fs_info struct instead
> of a *file.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Changes seems pretty self-explanatory so :

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  The kernel survived btrfs-progs tests with this patch applied.
> 
>  fs/btrfs/ioctl.c | 36 +++++++++++++++---------------------
>  1 file changed, 15 insertions(+), 21 deletions(-)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index de730e56d3f5..870e5c48b362 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -479,10 +479,9 @@ static int btrfs_ioctl_getversion(struct file *file, int __user *arg)
>  	return put_user(inode->i_generation, arg);
>  }
>  
> -static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
> +static noinline int btrfs_ioctl_fitrim(struct btrfs_fs_info *fs_info,
> +					void __user *arg)
>  {
> -	struct inode *inode = file_inode(file);
> -	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>  	struct btrfs_device *device;
>  	struct request_queue *q;
>  	struct fstrim_range range;
> @@ -4960,10 +4959,9 @@ static long btrfs_ioctl_quota_rescan(struct file *file, void __user *arg)
>  	return ret;
>  }
>  
> -static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
> +static long btrfs_ioctl_quota_rescan_status(struct btrfs_fs_info *fs_info,
> +						void __user *arg)
>  {
> -	struct inode *inode = file_inode(file);
> -	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>  	struct btrfs_ioctl_quota_rescan_args *qsa;
>  	int ret = 0;
>  
> @@ -4986,11 +4984,9 @@ static long btrfs_ioctl_quota_rescan_status(struct file *file, void __user *arg)
>  	return ret;
>  }
>  
> -static long btrfs_ioctl_quota_rescan_wait(struct file *file, void __user *arg)
> +static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info,
> +						void __user *arg)
>  {
> -	struct inode *inode = file_inode(file);
> -	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
> -
>  	if (!capable(CAP_SYS_ADMIN))
>  		return -EPERM;
>  
> @@ -5162,10 +5158,9 @@ static long btrfs_ioctl_set_received_subvol(struct file *file,
>  	return ret;
>  }
>  
> -static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
> +static int btrfs_ioctl_get_fslabel(struct btrfs_fs_info *fs_info,
> +					void __user *arg)
>  {
> -	struct inode *inode = file_inode(file);
> -	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>  	size_t len;
>  	int ret;
>  	char label[BTRFS_LABEL_SIZE];
> @@ -5249,10 +5244,9 @@ int btrfs_ioctl_get_supported_features(void __user *arg)
>  	return 0;
>  }
>  
> -static int btrfs_ioctl_get_features(struct file *file, void __user *arg)
> +static int btrfs_ioctl_get_features(struct btrfs_fs_info *fs_info,
> +					void __user *arg)
>  {
> -	struct inode *inode = file_inode(file);
> -	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>  	struct btrfs_super_block *super_block = fs_info->super_copy;
>  	struct btrfs_ioctl_feature_flags features;
>  
> @@ -5453,11 +5447,11 @@ long btrfs_ioctl(struct file *file, unsigned int
>  	case FS_IOC_GETVERSION:
>  		return btrfs_ioctl_getversion(file, argp);
>  	case FS_IOC_GETFSLABEL:
> -		return btrfs_ioctl_get_fslabel(file, argp);
> +		return btrfs_ioctl_get_fslabel(fs_info, argp);
>  	case FS_IOC_SETFSLABEL:
>  		return btrfs_ioctl_set_fslabel(file, argp);
>  	case FITRIM:
> -		return btrfs_ioctl_fitrim(file, argp);
> +		return btrfs_ioctl_fitrim(fs_info, argp);
>  	case BTRFS_IOC_SNAP_CREATE:
>  		return btrfs_ioctl_snap_create(file, argp, 0);
>  	case BTRFS_IOC_SNAP_CREATE_V2:
> @@ -5562,15 +5556,15 @@ long btrfs_ioctl(struct file *file, unsigned int
>  	case BTRFS_IOC_QUOTA_RESCAN:
>  		return btrfs_ioctl_quota_rescan(file, argp);
>  	case BTRFS_IOC_QUOTA_RESCAN_STATUS:
> -		return btrfs_ioctl_quota_rescan_status(file, argp);
> +		return btrfs_ioctl_quota_rescan_status(fs_info, argp);
>  	case BTRFS_IOC_QUOTA_RESCAN_WAIT:
> -		return btrfs_ioctl_quota_rescan_wait(file, argp);
> +		return btrfs_ioctl_quota_rescan_wait(fs_info, argp);
>  	case BTRFS_IOC_DEV_REPLACE:
>  		return btrfs_ioctl_dev_replace(fs_info, argp);
>  	case BTRFS_IOC_GET_SUPPORTED_FEATURES:
>  		return btrfs_ioctl_get_supported_features(argp);
>  	case BTRFS_IOC_GET_FEATURES:
> -		return btrfs_ioctl_get_features(file, argp);
> +		return btrfs_ioctl_get_features(fs_info, argp);
>  	case BTRFS_IOC_SET_FEATURES:
>  		return btrfs_ioctl_set_features(file, argp);
>  	case FS_IOC_FSGETXATTR:
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file
  2019-10-11  0:23 [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file Marcos Paulo de Souza
  2019-10-11  2:02 ` Anand Jain
  2019-10-11  6:38 ` Nikolay Borisov
@ 2019-10-11 17:41 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2019-10-11 17:41 UTC (permalink / raw)
  To: Marcos Paulo de Souza
  Cc: dsterba, clm, Marcos Paulo de Souza, Josef Bacik,
	open list:BTRFS FILE SYSTEM, open list

On Thu, Oct 10, 2019 at 09:23:11PM -0300, Marcos Paulo de Souza wrote:
> Some functions are doing some bikeshedding to reach the btrfs_fs_info
> struct. Change these functions to receive a btrfs_fs_info struct instead
> of a *file.

Makes sense, thanks. Added to msic-next.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11  0:23 [PATCH] btrfs: ioctl: Try to use btrfs_fs_info instead of *file Marcos Paulo de Souza
2019-10-11  2:02 ` Anand Jain
2019-10-11  6:38 ` Nikolay Borisov
2019-10-11 17:41 ` David Sterba

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox