From patchwork Sun Apr 10 21:16:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Mills X-Patchwork-Id: 697211 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3ALGtjV024227 for ; Sun, 10 Apr 2011 21:16:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758024Ab1DJVQw (ORCPT ); Sun, 10 Apr 2011 17:16:52 -0400 Received: from frost.carfax.org.uk ([212.13.194.111]:1748 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755803Ab1DJVQg (ORCPT ); Sun, 10 Apr 2011 17:16:36 -0400 Received: from ruthven.carfax.org.uk ([10.0.0.10]) by frost.carfax.org.uk with esmtp (Exim 4.69) (envelope-from ) id 1Q91zn-0005B2-OZ; Sun, 10 Apr 2011 21:16:36 +0000 Received: from [10.0.0.10] (helo=ruthven.carfax.org.uk) by ruthven.carfax.org.uk with esmtp (Exim 4.72) (envelope-from ) id 1Q91zn-0003TJ-Gc; Sun, 10 Apr 2011 22:16:35 +0100 From: Hugo Mills To: chris.mason@oracle.com, linux-btrfs@vger.kernel.org Subject: [PATCH v5 8/8] Interface for device range balance filter Date: Sun, 10 Apr 2011 22:16:34 +0100 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: To: linux-btrfs@vger.kernel.org X-frost.carfax.org.uk-Spam-Score: -0.0 (/) X-frost.carfax.org.uk-Spam-Report: Spam detection software, running on the system "spamd2.lon.bitfolk.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Implement the userspace side of the balance filter for a range of bytes on any device. Note that this will match the same range on any device, so the use of the devid filter is recommended where this filter is used. [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Apr 2011 21:17:05 +0000 (UTC) Implement the userspace side of the balance filter for a range of bytes on any device. Note that this will match the same range on any device, so the use of the devid filter is recommended where this filter is used. Signed-off-by: Hugo Mills --- btrfs_cmds.c | 22 ++++++++++++++++++++++ ioctl.h | 9 +++++++-- man/btrfs.8.in | 8 ++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/btrfs_cmds.c b/btrfs_cmds.c index e5f2c39..e82c103 100644 --- a/btrfs_cmds.c +++ b/btrfs_cmds.c @@ -785,6 +785,12 @@ const struct filter_class_desc filter_class[] = { "\trange of the filesystem's virtual address space.\n" "\t is inclusive, is exclusive.\n", BTRFS_BALANCE_FILTER_VIRTUAL_ADDRESS_RANGE }, + { "drange", + "drange=,\n" + "\tBalances chunks which have any bytes within the given\n" + "\tbyte range on any of the filesystem's underlying devices.\n" + "\t is inclusive, is exclusive.\n", + BTRFS_BALANCE_FILTER_DEVICE_ADDRESS_RANGE }, { NULL, NULL, 0 } }; @@ -907,6 +913,22 @@ int parse_filter(struct btrfs_ioctl_balance_start *args, char *filters_string) return 15; } break; + + case BTRFS_BALANCE_FILTER_DEVICE_ADDRESS_RANGE: + errno = 0; + args->drange_start = strtoull(part, NULL, 10); + if (errno != 0) { + fprintf(stderr, "ERROR: '%s' is not a valid start address\n", part); + return 15; + } + part = strtok_r(NULL, "=,", &subsave); + errno = 0; + args->drange_end = strtoull(part, NULL, 10); + if (errno != 0) { + fprintf(stderr, "ERROR: '%s' is not a valid end address\n", part); + return 15; + } + break; } this_filter_string = strtok_r(NULL, ":", &saveptr); diff --git a/ioctl.h b/ioctl.h index 71fa90e..a99c225 100644 --- a/ioctl.h +++ b/ioctl.h @@ -143,7 +143,8 @@ struct btrfs_ioctl_balance_progress { #define BTRFS_BALANCE_FILTER_CHUNK_TYPE 0x2 #define BTRFS_BALANCE_FILTER_DEVID 0x4 #define BTRFS_BALANCE_FILTER_VIRTUAL_ADDRESS_RANGE 0x8 -#define BTRFS_BALANCE_FILTER_MASK 0xf +#define BTRFS_BALANCE_FILTER_DEVICE_ADDRESS_RANGE 0x10 +#define BTRFS_BALANCE_FILTER_MASK 0x1f /* All the possible options for a filter */ struct btrfs_ioctl_balance_start { @@ -164,7 +165,11 @@ struct btrfs_ioctl_balance_start { __u64 vrange_start; __u64 vrange_end; - __u64 spare[503]; /* Make up the size of the structure to 4088 + /* For FILTER_DEVICE_ADDRESS_RANGE */ + __u64 drange_start; + __u64 drange_end; + + __u64 spare[501]; /* Make up the size of the structure to 4088 * bytes for future expansion */ }; diff --git a/man/btrfs.8.in b/man/btrfs.8.in index 1031af6..6adf8bb 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -219,6 +219,14 @@ address of the last chunk moved, this filter can be used to restart a cancelled or interrupted balance operation, by supplying a range of \fB0,\fI\fR. +.TP +\fBdrange\fR=\fI\fB,\fI\fR + +Select chunks which contain data in the address range \fI\fR +(inclusive) to \fI\fR (exclusive) on \fIany\fR block device in +the filesystem. Can be mixed with the \fBdevid\fR filter to select +chunks in a given address range on a specific device. + .SH EXIT STATUS \fBbtrfs\fR returns a zero exist status if it succeeds. Non zero is returned in case of failure.