From patchwork Sun May 1 15:47:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Mills X-Patchwork-Id: 746082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p41FlYLg017568 for ; Sun, 1 May 2011 15:47:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760613Ab1EAPr2 (ORCPT ); Sun, 1 May 2011 11:47:28 -0400 Received: from frost.carfax.org.uk ([212.13.194.111]:2746 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757863Ab1EAPrV (ORCPT ); Sun, 1 May 2011 11:47:21 -0400 Received: from ruthven.carfax.org.uk ([10.0.0.10]) by frost.carfax.org.uk with esmtp (Exim 4.69) (envelope-from ) id 1QGYrd-0004Zl-Rm; Sun, 01 May 2011 15:47:18 +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 1QGYrd-0004hn-Ho; Sun, 01 May 2011 16:47:17 +0100 From: Hugo Mills To: Btrfs mailing list , Chris Mason Subject: [PATCH v6 6/8] Balance filter by device ID Date: Sun, 1 May 2011 16:47:14 +0100 Message-Id: <725a6071db510f6483100baced12834942438020.1304262467.git.hugo@carfax.org.uk> 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 "spamd3.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: Add the userspace implementation for filtering balances by device ID. Signed-off-by: Hugo Mills --- btrfs_cmds.c | 13 +++++++++++++ ioctl.h | 8 ++++++-- man/btrfs.8.in | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) [...] 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 (demeter2.kernel.org [140.211.167.43]); Sun, 01 May 2011 15:47:34 +0000 (UTC) Add the userspace implementation for filtering balances by device ID. Signed-off-by: Hugo Mills --- btrfs_cmds.c | 13 +++++++++++++ ioctl.h | 8 ++++++-- man/btrfs.8.in | 7 +++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/btrfs_cmds.c b/btrfs_cmds.c index 279d93a..0f1434f 100644 --- a/btrfs_cmds.c +++ b/btrfs_cmds.c @@ -775,6 +775,10 @@ const struct filter_class_desc filter_class[] = { "\t\tmeta, sys, data, raid0, raid1, raid10, dup\n" "\tPrefix a with ~ to negate the match.\n", BTRFS_BALANCE_FILTER_CHUNK_TYPE }, + { "devid", + "devid=\n" + "\tBalance only chunks which have a stripe on device .\n", + BTRFS_BALANCE_FILTER_DEVID }, { NULL, NULL, 0 } }; @@ -870,6 +874,15 @@ int parse_filter(struct btrfs_ioctl_balance_start *args, char *filters_string) part = strtok_r(NULL, "=,", &subsave); } break; + + case BTRFS_BALANCE_FILTER_DEVID: + errno = 0; + args->devid = strtoull(part, NULL, 10); + if (errno != 0) { + fprintf(stderr, "ERROR: '%s' is not a valid device ID\n", part); + return 15; + } + break; } this_filter_string = strtok_r(NULL, ":", &saveptr); diff --git a/ioctl.h b/ioctl.h index 230c314..e30687c 100644 --- a/ioctl.h +++ b/ioctl.h @@ -141,7 +141,8 @@ struct btrfs_ioctl_balance_progress { #define BTRFS_BALANCE_FILTER_COUNT_ONLY 0x1 #define BTRFS_BALANCE_FILTER_CHUNK_TYPE 0x2 -#define BTRFS_BALANCE_FILTER_MASK 0x3 +#define BTRFS_BALANCE_FILTER_DEVID 0x4 +#define BTRFS_BALANCE_FILTER_MASK 0x7 /* All the possible options for a filter */ struct btrfs_ioctl_balance_start { @@ -155,7 +156,10 @@ struct btrfs_ioctl_balance_start { __u64 chunk_type; /* Flag bits required */ __u64 chunk_type_mask; /* Mask of bits to examine */ - __u64 spare[507]; /* Make up the size of the structure to 4088 + /* For FILTER_DEVID */ + __u64 devid; + + __u64 spare[506]; /* 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 5ac0694..020260f 100644 --- a/man/btrfs.8.in +++ b/man/btrfs.8.in @@ -203,6 +203,13 @@ chunk types. \fBraid0\fR, \fBraid1\fR, \fBraid10\fR, \fBdup\fR for chunks of the given replication levels. +.TP +\fBdevid\fR=\fI\fR + +Select chunks which have data on device ID \fI\fR. This can be +used, for example, to reduplicate data in a mirrored configuration +where one drive has been lost due to hardware failure. + .SH EXIT STATUS \fBbtrfs\fR returns a zero exist status if it succeeds. Non zero is returned in case of failure.