All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: Goffredo Baroncelli <kreijack@libero.it>
Cc: linux-btrfs@vger.kernel.org,
	Zygo Blaxell <ce3g8jdj@umail.furryterror.org>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.cz>,
	Sinnamohideen Shafeeq <shafeeqs@panasas.com>,
	Paul Jones <paul@pauljones.id.au>,
	Goffredo Baroncelli <kreijack@inwind.it>
Subject: Re: [PATCH 5/6] btrfs: rename dev_item->type to dev_item->flags
Date: Wed, 5 Jan 2022 15:50:57 -0800	[thread overview]
Message-ID: <YdYu4Sy4tgZnvIqF@zen> (raw)
In-Reply-To: <c03fe9a171e6e377a345dfebc56c6c49dfa494c3.1639766364.git.kreijack@inwind.it>

On Fri, Dec 17, 2021 at 07:47:21PM +0100, Goffredo Baroncelli wrote:
> From: Goffredo Baroncelli <kreijack@inwind.it>
> 
> Rename the field type of dev_item from 'type' to 'flags' changing the
> struct btrfs_device and btrfs_dev_item.
> 
> Signed-off-by: Goffredo Baroncelli <krejack@inwind.it>
> ---
>  fs/btrfs/ctree.h                |  4 ++--
>  fs/btrfs/disk-io.c              |  2 +-
>  fs/btrfs/sysfs.c                | 17 +++++++++--------
>  fs/btrfs/volumes.c              | 10 +++++-----
>  fs/btrfs/volumes.h              |  4 ++--
>  include/uapi/linux/btrfs_tree.h |  4 ++--
>  6 files changed, 21 insertions(+), 20 deletions(-)

Can you also change the comment in include/uapi/linux/btrfs_tree.h to
reflect changing from dev_item.type to dev_item.flags?

LGTM otherwise.

> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 459d00211181..778c7c807289 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1669,7 +1669,7 @@ static inline void btrfs_set_device_total_bytes(const struct extent_buffer *eb,
>  }
>  
>  
> -BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64);
> +BTRFS_SETGET_FUNCS(device_flags, struct btrfs_dev_item, flags, 64);
>  BTRFS_SETGET_FUNCS(device_bytes_used, struct btrfs_dev_item, bytes_used, 64);
>  BTRFS_SETGET_FUNCS(device_io_align, struct btrfs_dev_item, io_align, 32);
>  BTRFS_SETGET_FUNCS(device_io_width, struct btrfs_dev_item, io_width, 32);
> @@ -1682,7 +1682,7 @@ BTRFS_SETGET_FUNCS(device_seek_speed, struct btrfs_dev_item, seek_speed, 8);
>  BTRFS_SETGET_FUNCS(device_bandwidth, struct btrfs_dev_item, bandwidth, 8);
>  BTRFS_SETGET_FUNCS(device_generation, struct btrfs_dev_item, generation, 64);
>  
> -BTRFS_SETGET_STACK_FUNCS(stack_device_type, struct btrfs_dev_item, type, 64);
> +BTRFS_SETGET_STACK_FUNCS(stack_device_flags, struct btrfs_dev_item, flags, 64);
>  BTRFS_SETGET_STACK_FUNCS(stack_device_total_bytes, struct btrfs_dev_item,
>  			 total_bytes, 64);
>  BTRFS_SETGET_STACK_FUNCS(stack_device_bytes_used, struct btrfs_dev_item,
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index fc7dd5109806..02ffb8bc7d6b 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -4342,7 +4342,7 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors)
>  			continue;
>  
>  		btrfs_set_stack_device_generation(dev_item, 0);
> -		btrfs_set_stack_device_type(dev_item, dev->type);
> +		btrfs_set_stack_device_flags(dev_item, dev->flags);
>  		btrfs_set_stack_device_id(dev_item, dev->devid);
>  		btrfs_set_stack_device_total_bytes(dev_item,
>  						   dev->commit_total_bytes);
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index 53acc66065dd..be4196a1645c 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -1582,7 +1582,7 @@ static ssize_t btrfs_devinfo_allocation_hint_show(struct kobject *kobj,
>  						   devid_kobj);
>  
>  	return scnprintf(buf, PAGE_SIZE, "0x%08llx\n",
> -		device->type & BTRFS_DEV_ALLOCATION_HINT_MASK );
> +		device->flags & BTRFS_DEV_ALLOCATION_HINT_MASK );
>  }
>  
>  static ssize_t btrfs_devinfo_allocation_hint_store(struct kobject *kobj,
> @@ -1595,7 +1595,7 @@ static ssize_t btrfs_devinfo_allocation_hint_store(struct kobject *kobj,
>  	int ret;
>  	struct btrfs_trans_handle *trans;
>  
> -	u64 type, prev_type;
> +	u64 flags, prev_flags;
>  
>  	device = container_of(kobj, struct btrfs_device, devid_kobj);
>  	fs_info = device->fs_info;
> @@ -1606,24 +1606,25 @@ static ssize_t btrfs_devinfo_allocation_hint_store(struct kobject *kobj,
>  	if (sb_rdonly(fs_info->sb))
>  		return -EROFS;
>  
> -	ret = kstrtou64(buf, 0, &type);
> +	ret = kstrtou64(buf, 0, &flags);
>  	if (ret < 0)
>  		return -EINVAL;
>  
>  	/* for now, allow to touch only the 'allocation hint' bits */
> -	if (type & ~BTRFS_DEV_ALLOCATION_HINT_MASK)
> +	if (flags & ~BTRFS_DEV_ALLOCATION_HINT_MASK)
>  		return -EINVAL;
>  
>  	/* check if a change is really needed */
> -	if ((device->type & BTRFS_DEV_ALLOCATION_HINT_MASK) == type)
> +	if ((device->flags & BTRFS_DEV_ALLOCATION_HINT_MASK) == flags)
>  		return len;
>  
>  	trans = btrfs_start_transaction(root, 1);
>  	if (IS_ERR(trans))
>  		return PTR_ERR(trans);
>  
> -	prev_type = device->type;
> -	device->type = (device->type & ~BTRFS_DEV_ALLOCATION_HINT_MASK) | type;
> +	prev_flags = device->flags;
> +	device->flags = (device->flags & ~BTRFS_DEV_ALLOCATION_HINT_MASK) |
> +			flags;
>  
>  	ret = btrfs_update_device(trans, device);
>  
> @@ -1639,7 +1640,7 @@ static ssize_t btrfs_devinfo_allocation_hint_store(struct kobject *kobj,
>  
>  	return len;
>  abort:
> -	device->type = prev_type;
> +	device->flags = prev_flags;
>  	return  ret;
>  }
>  BTRFS_ATTR_RW(devid, allocation_hint, btrfs_devinfo_allocation_hint_show,
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index beee7d1ae79d..9184570c51b0 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1876,7 +1876,7 @@ static int btrfs_add_dev_item(struct btrfs_trans_handle *trans,
>  
>  	btrfs_set_device_id(leaf, dev_item, device->devid);
>  	btrfs_set_device_generation(leaf, dev_item, 0);
> -	btrfs_set_device_type(leaf, dev_item, device->type);
> +	btrfs_set_device_flags(leaf, dev_item, device->flags);
>  	btrfs_set_device_io_align(leaf, dev_item, device->io_align);
>  	btrfs_set_device_io_width(leaf, dev_item, device->io_width);
>  	btrfs_set_device_sector_size(leaf, dev_item, device->sector_size);
> @@ -2900,7 +2900,7 @@ noinline int btrfs_update_device(struct btrfs_trans_handle *trans,
>  	dev_item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_item);
>  
>  	btrfs_set_device_id(leaf, dev_item, device->devid);
> -	btrfs_set_device_type(leaf, dev_item, device->type);
> +	btrfs_set_device_flags(leaf, dev_item, device->flags);
>  	btrfs_set_device_io_align(leaf, dev_item, device->io_align);
>  	btrfs_set_device_io_width(leaf, dev_item, device->io_width);
>  	btrfs_set_device_sector_size(leaf, dev_item, device->sector_size);
> @@ -5285,7 +5285,7 @@ static int gather_device_info(struct btrfs_fs_devices *fs_devices,
>  			 */
>  			devices_info[ndevs].alloc_hint = 0;
>  		} else if (ctl->type & BTRFS_BLOCK_GROUP_DATA) {
> -			hint = device->type & BTRFS_DEV_ALLOCATION_HINT_MASK;
> +			hint = device->flags & BTRFS_DEV_ALLOCATION_HINT_MASK;
>  
>  			/*
>  			 * skip BTRFS_DEV_METADATA_ONLY disks
> @@ -5299,7 +5299,7 @@ static int gather_device_info(struct btrfs_fs_devices *fs_devices,
>  			 */
>  			devices_info[ndevs].alloc_hint = -alloc_hint_map[hint];
>  		} else { /* BTRFS_BLOCK_GROUP_METADATA */
> -			hint = device->type & BTRFS_DEV_ALLOCATION_HINT_MASK;
> +			hint = device->flags & BTRFS_DEV_ALLOCATION_HINT_MASK;
>  
>  			/*
>  			 * skip BTRFS_DEV_DATA_ONLY disks
> @@ -7293,7 +7293,7 @@ static void fill_device_from_item(struct extent_buffer *leaf,
>  	device->commit_total_bytes = device->disk_total_bytes;
>  	device->bytes_used = btrfs_device_bytes_used(leaf, dev_item);
>  	device->commit_bytes_used = device->bytes_used;
> -	device->type = btrfs_device_type(leaf, dev_item);
> +	device->flags = btrfs_device_flags(leaf, dev_item);
>  	device->io_align = btrfs_device_io_align(leaf, dev_item);
>  	device->io_width = btrfs_device_io_width(leaf, dev_item);
>  	device->sector_size = btrfs_device_sector_size(leaf, dev_item);
> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
> index 61c0cba045e9..27ecf062d50c 100644
> --- a/fs/btrfs/volumes.h
> +++ b/fs/btrfs/volumes.h
> @@ -96,8 +96,8 @@ struct btrfs_device {
>  
>  	/* optimal io width for this device */
>  	u32 io_width;
> -	/* type and info about this device */
> -	u64 type;
> +	/* device flags (e.g. allocation hint) */
> +	u64 flags;
>  
>  	/* minimal io size for this device */
>  	u32 sector_size;
> diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
> index 55da906c2eac..f9891c94a75e 100644
> --- a/include/uapi/linux/btrfs_tree.h
> +++ b/include/uapi/linux/btrfs_tree.h
> @@ -421,8 +421,8 @@ struct btrfs_dev_item {
>  	/* minimal io size for this device */
>  	__le32 sector_size;
>  
> -	/* type and info about this device */
> -	__le64 type;
> +	/* device flags (e.g. allocation hint) */
> +	__le64 flags;
>  
>  	/* expected generation for this device */
>  	__le64 generation;
> -- 
> 2.34.1
> 

  reply	other threads:[~2022-01-05 23:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 18:47 [RFC][V9][PATCH 0/6] btrfs: allocation_hint mode Goffredo Baroncelli
2021-12-17 18:47 ` [PATCH 1/6] btrfs: add flags to give an hint to the chunk allocator Goffredo Baroncelli
2022-01-05 22:10   ` Boris Burkov
2022-01-06  8:53     ` Goffredo Baroncelli
2021-12-17 18:47 ` [PATCH 2/6] btrfs: export the device allocation_hint property in sysfs Goffredo Baroncelli
2022-01-05 21:57   ` Boris Burkov
2021-12-17 18:47 ` [PATCH 3/6] btrfs: change the device allocation_hint property via sysfs Goffredo Baroncelli
2021-12-17 18:47 ` [PATCH 4/6] btrfs: add allocation_hint mode Goffredo Baroncelli
2022-01-05 23:48   ` Boris Burkov
2022-01-06 10:09     ` Goffredo Baroncelli
2021-12-17 18:47 ` [PATCH 5/6] btrfs: rename dev_item->type to dev_item->flags Goffredo Baroncelli
2022-01-05 23:50   ` Boris Burkov [this message]
2021-12-17 18:47 ` [PATCH 6/6] btrfs: add allocation_hint option Goffredo Baroncelli
2022-01-05  2:44 ` [RFC][V9][PATCH 0/6] btrfs: allocation_hint mode Boris Burkov
2022-01-05  9:16   ` Goffredo Baroncelli
2022-01-05 17:55     ` Boris Burkov
2022-01-05 18:07     ` Zygo Blaxell
2022-01-05 18:16       ` Goffredo Baroncelli
2022-01-05 18:29         ` Boris Burkov
2022-01-05 22:21 ` Boris Burkov
  -- strict thread matches above, loose matches on Subject: below --
2022-01-06 17:49 [PATCH 0/6][V10] btrfs: " Goffredo Baroncelli
2022-01-06 17:49 ` [PATCH 5/6] btrfs: rename dev_item->type to dev_item->flags Goffredo Baroncelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YdYu4Sy4tgZnvIqF@zen \
    --to=boris@bur.io \
    --cc=ce3g8jdj@umail.furryterror.org \
    --cc=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kreijack@inwind.it \
    --cc=kreijack@libero.it \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=paul@pauljones.id.au \
    --cc=shafeeqs@panasas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.