Message ID | 20190205065312.19743-1-wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] btrfs-progs: Port kernel fs_devices::total_rw_bytes to btrfs-progs | expand |
On Tue, Feb 05, 2019 at 02:53:11PM +0800, Qu Wenruo wrote: > Unlike kernel, btrfs-progs doesn't (yet) support devices grow/shrink, > the port only needs to handle open_ctree() time initialization (at > read_one_dev()), and btrfs_add_device() used for mkfs. > > This provide the basis for incoming unification of chunk allocator > behavior. > > Signed-off-by: Qu Wenruo <wqu@suse.com> 1 and 2 applied, thanks.
diff --git a/volumes.c b/volumes.c index 2c6aaf42c5fb..2611a932c01c 100644 --- a/volumes.c +++ b/volumes.c @@ -744,6 +744,7 @@ int btrfs_add_device(struct btrfs_trans_handle *trans, write_extent_buffer(leaf, fs_info->fs_devices->metadata_uuid, ptr, BTRFS_UUID_SIZE); btrfs_mark_buffer_dirty(leaf); + fs_info->fs_devices->total_rw_bytes += device->total_bytes; ret = 0; out: @@ -2060,6 +2061,8 @@ static int read_one_dev(struct btrfs_fs_info *fs_info, fill_device_from_item(leaf, dev_item, device); device->dev_root = fs_info->dev_root; + fs_info->fs_devices->total_rw_bytes += + btrfs_device_total_bytes(leaf, dev_item); return ret; } diff --git a/volumes.h b/volumes.h index e30bcef7dba5..dbe9d3dea647 100644 --- a/volumes.h +++ b/volumes.h @@ -77,6 +77,9 @@ struct btrfs_fs_devices { u64 latest_devid; u64 latest_trans; u64 lowest_devid; + + u64 total_rw_bytes; + int latest_bdev; int lowest_bdev; struct list_head devices;
Unlike kernel, btrfs-progs doesn't (yet) support devices grow/shrink, the port only needs to handle open_ctree() time initialization (at read_one_dev()), and btrfs_add_device() used for mkfs. This provide the basis for incoming unification of chunk allocator behavior. Signed-off-by: Qu Wenruo <wqu@suse.com> --- volumes.c | 3 +++ volumes.h | 3 +++ 2 files changed, 6 insertions(+)