Re: [patch 1/2] Balance progress monitoring (updated)
On 10/30/2010 09:39 PM, Hugo Mills wrote: This patch introduces a basic form of progress monitoring for balance operations, by counting the number of block groups remaining. The information is exposed to userspace by an ioctl. IMO, tracking the information of blocks which are balancing also makes sense. For example, the block information's blocknr. It can help us monitor better. Signed-off-by: Hugo Mills h...@carfax.org.uk --- This patch replaces the one previously posted, correcting a minor error. fs/btrfs/ctree.h |9 fs/btrfs/disk-io.c |2 + fs/btrfs/ioctl.c | 34 fs/btrfs/ioctl.h |7 ++ fs/btrfs/volumes.c | 55 +++-- 5 files changed, 105 insertions(+), 2 deletions(-) Index: linux-mainline/fs/btrfs/ctree.h === --- linux-mainline.orig/fs/btrfs/ctree.h 2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ctree.h 2010-10-30 14:35:25.306450922 +0100 @@ -803,6 +803,11 @@ struct list_head cluster_list; }; +struct btrfs_balance_info { + u64 expected; + u64 completed; +}; + struct reloc_control; struct btrfs_device; struct btrfs_fs_devices; @@ -1010,6 +1015,10 @@ unsigned metadata_ratio; void *bdev_holder; + + /* Keep track of any rebalance operations on this FS */ + spinlock_t balance_info_lock; + struct btrfs_balance_info *balance_info; }; /* Index: linux-mainline/fs/btrfs/ioctl.c === --- linux-mainline.orig/fs/btrfs/ioctl.c 2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ioctl.c 2010-10-30 14:35:25.396447198 +0100 @@ -1984,6 +1984,38 @@ return 0; } +/* + * Return the current status of any balance operation + */ +long btrfs_ioctl_balance_progress( + struct btrfs_fs_info *fs_info, + struct btrfs_ioctl_balance_progress __user *user_dest) +{ + int ret = 0; + struct btrfs_ioctl_balance_progress dest; + + spin_lock(fs_info-balance_info_lock); + if (!fs_info-balance_info) { + ret = -EINVAL; + goto error; + } + + dest.expected = fs_info-balance_info-expected; + dest.completed = fs_info-balance_info-completed; + + spin_unlock(fs_info-balance_info_lock); + + if (copy_to_user(user_dest, dest, + sizeof(struct btrfs_ioctl_balance_progress))) + return -EFAULT; + + return 0; + +error: + spin_unlock(fs_info-balance_info_lock); + return ret; +} + long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -2017,6 +2049,8 @@ return btrfs_ioctl_rm_dev(root, argp); case BTRFS_IOC_BALANCE: return btrfs_balance(root-fs_info-dev_root); + case BTRFS_IOC_BALANCE_PROGRESS: + return btrfs_ioctl_balance_progress(root-fs_info, argp); case BTRFS_IOC_CLONE: return btrfs_ioctl_clone(file, arg, 0, 0, 0); case BTRFS_IOC_CLONE_RANGE: Index: linux-mainline/fs/btrfs/ioctl.h === --- linux-mainline.orig/fs/btrfs/ioctl.h 2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ioctl.h 2010-10-30 14:35:25.316450509 +0100 @@ -138,6 +138,11 @@ struct btrfs_ioctl_space_info spaces[0]; }; +struct btrfs_ioctl_balance_progress { + __u64 expected; + __u64 completed; +}; + #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ struct btrfs_ioctl_vol_args) #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ @@ -178,4 +183,6 @@ #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64) #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ struct btrfs_ioctl_space_args) +#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 21, \ + struct btrfs_ioctl_balance_progress) #endif Index: linux-mainline/fs/btrfs/volumes.c === --- linux-mainline.orig/fs/btrfs/volumes.c2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/volumes.c 2010-10-30 14:35:25.326450096 +0100 @@ -1902,6 +1902,7 @@ struct btrfs_root *chunk_root = dev_root-fs_info-chunk_root; struct btrfs_trans_handle *trans; struct btrfs_key found_key; + struct btrfs_balance_info *bal_info; if (dev_root-fs_info-sb-s_flags MS_RDONLY) return -EROFS; @@ -1909,6 +1910,18 @@ mutex_lock(dev_root-fs_info-volume_mutex); dev_root = dev_root-fs_info-dev_root; + dev_root-fs_info-balance_info = kmalloc( + sizeof(struct btrfs_balance_info), +
Re: [patch 1/2] Balance progress monitoring (updated)
On Mon, Nov 01, 2010 at 04:06:53PM +0800, liubo wrote: On 10/30/2010 09:39 PM, Hugo Mills wrote: This patch introduces a basic form of progress monitoring for balance operations, by counting the number of block groups remaining. The information is exposed to userspace by an ioctl. IMO, tracking the information of blocks which are balancing also makes sense. For example, the block information's blocknr. It can help us monitor better. I don't see how that will help. The block group IDs (which is all that we get at this level) are effectively arbitrary 64-bit numbers, and are what appear in the kernel logs. How could that information be used to improve monitoring? I'm not ruling out the idea completely -- I just can't see at the moment how it would be used. Hugo. -- === Hugo Mills: h...@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- Is a diversity twice as good as a university? --- signature.asc Description: Digital signature
Re: [patch 1/2] Balance progress monitoring (updated)
On 11/01/2010 08:55 PM, Hugo Mills wrote: On Mon, Nov 01, 2010 at 04:06:53PM +0800, liubo wrote: On 10/30/2010 09:39 PM, Hugo Mills wrote: This patch introduces a basic form of progress monitoring for balance operations, by counting the number of block groups remaining. The information is exposed to userspace by an ioctl. IMO, tracking the information of blocks which are balancing also makes sense. For example, the block information's blocknr. It can help us monitor better. I don't see how that will help. The block group IDs (which is all that we get at this level) are effectively arbitrary 64-bit numbers, and are what appear in the kernel logs. How could that information be used to improve monitoring? 64-bit numbers are also shown in btrfs-debug-tree. With btrfs-debug-tree, it would be helpful to track balanced extent buffers. thanks, liubo I'm not ruling out the idea completely -- I just can't see at the moment how it would be used. Hugo. -- To unsubscribe from this list: send the line unsubscribe linux-btrfs in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 1/2] Balance progress monitoring.
On Sat, Oct 30, 2010 at 01:07:27AM +0100, Hugo Mills wrote: This patch introduces a basic form of progress monitoring for balance operations, by counting the number of block groups remaining. The information is exposed to userspace by an ioctl. Dammit. An unrefreshed quilt patch let an error get through (see below). Updated patch in a few moments. Hugo. Index: linux-mainline/fs/btrfs/volumes.c === --- linux-mainline.orig/fs/btrfs/volumes.c2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/volumes.c 2010-10-29 17:23:40.463279287 +0100 @@ -1902,6 +1902,7 @@ struct btrfs_root *chunk_root = dev_root-fs_info-chunk_root; struct btrfs_trans_handle *trans; struct btrfs_key found_key; + struct btrfs_balance_status *bal_info; + struct btrfs_balance_info *bal_info; -- === Hugo Mills: h...@... carfax.org.uk | darksatanic.net | lug.org.uk === PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- dragon A linked list is still a binary tree. Just a --- very unbalanced one. signature.asc Description: Digital signature
[patch 1/2] Balance progress monitoring.
This patch introduces a basic form of progress monitoring for balance operations, by counting the number of block groups remaining. The information is exposed to userspace by an ioctl. Signed-off-by: Hugo Mills h...@carfax.org.uk --- fs/btrfs/ctree.h |9 fs/btrfs/disk-io.c |2 + fs/btrfs/ioctl.c | 34 fs/btrfs/ioctl.h |7 ++ fs/btrfs/volumes.c | 55 +++-- 5 files changed, 105 insertions(+), 2 deletions(-) Index: linux-mainline/fs/btrfs/ctree.h === --- linux-mainline.orig/fs/btrfs/ctree.h2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ctree.h 2010-10-29 17:20:43.860460761 +0100 @@ -803,6 +803,11 @@ struct list_head cluster_list; }; +struct btrfs_balance_info { + u64 expected; + u64 completed; +}; + struct reloc_control; struct btrfs_device; struct btrfs_fs_devices; @@ -1010,6 +1015,10 @@ unsigned metadata_ratio; void *bdev_holder; + + /* Keep track of any rebalance operations on this FS */ + spinlock_t balance_info_lock; + struct btrfs_balance_info *balance_info; }; /* Index: linux-mainline/fs/btrfs/ioctl.c === --- linux-mainline.orig/fs/btrfs/ioctl.c2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ioctl.c 2010-10-29 17:21:26.128742389 +0100 @@ -1984,6 +1984,38 @@ return 0; } +/* + * Return the current status of any balance operation + */ +long btrfs_ioctl_balance_progress( + struct btrfs_fs_info *fs_info, + struct btrfs_ioctl_balance_progress __user *user_dest) +{ + int ret = 0; + struct btrfs_ioctl_balance_progress dest; + + spin_lock(fs_info-balance_info_lock); + if (!fs_info-balance_info) { + ret = -EINVAL; + goto error; + } + + dest.expected = fs_info-balance_info-expected; + dest.completed = fs_info-balance_info-completed; + + spin_unlock(fs_info-balance_info_lock); + + if (copy_to_user(user_dest, dest, +sizeof(struct btrfs_ioctl_balance_progress))) + return -EFAULT; + + return 0; + +error: + spin_unlock(fs_info-balance_info_lock); + return ret; +} + long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -2017,6 +2049,8 @@ return btrfs_ioctl_rm_dev(root, argp); case BTRFS_IOC_BALANCE: return btrfs_balance(root-fs_info-dev_root); + case BTRFS_IOC_BALANCE_PROGRESS: + return btrfs_ioctl_balance_progress(root-fs_info, argp); case BTRFS_IOC_CLONE: return btrfs_ioctl_clone(file, arg, 0, 0, 0); case BTRFS_IOC_CLONE_RANGE: Index: linux-mainline/fs/btrfs/ioctl.h === --- linux-mainline.orig/fs/btrfs/ioctl.h2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/ioctl.h 2010-10-29 17:05:44.447028825 +0100 @@ -138,6 +138,11 @@ struct btrfs_ioctl_space_info spaces[0]; }; +struct btrfs_ioctl_balance_progress { + __u64 expected; + __u64 completed; +}; + #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ struct btrfs_ioctl_vol_args) #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ @@ -178,4 +183,6 @@ #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64) #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ struct btrfs_ioctl_space_args) +#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 21, \ + struct btrfs_ioctl_balance_progress) #endif Index: linux-mainline/fs/btrfs/volumes.c === --- linux-mainline.orig/fs/btrfs/volumes.c 2010-10-26 18:03:38.0 +0100 +++ linux-mainline/fs/btrfs/volumes.c 2010-10-29 17:23:40.463279287 +0100 @@ -1902,6 +1902,7 @@ struct btrfs_root *chunk_root = dev_root-fs_info-chunk_root; struct btrfs_trans_handle *trans; struct btrfs_key found_key; + struct btrfs_balance_status *bal_info; if (dev_root-fs_info-sb-s_flags MS_RDONLY) return -EROFS; @@ -1909,6 +1910,18 @@ mutex_lock(dev_root-fs_info-volume_mutex); dev_root = dev_root-fs_info-dev_root; + dev_root-fs_info-balance_info = kmalloc( + sizeof(struct btrfs_balance_info), + GFP_NOFS); + if (!dev_root-fs_info-balance_info) { + ret = -ENOSPC; + goto error_no_status; + } + bal_info = dev_root-fs_info-balance_info; + bal_info-expected = -1; /* One less than actually counted, +