From patchwork Tue Aug 23 20:01:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 1089692 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7NK2d1l029310 for ; Tue, 23 Aug 2011 20:02:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756106Ab1HWUCh (ORCPT ); Tue, 23 Aug 2011 16:02:37 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:56659 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755878Ab1HWUCg (ORCPT ); Tue, 23 Aug 2011 16:02:36 -0400 Received: by mail-bw0-f46.google.com with SMTP id 11so372435bke.19 for ; Tue, 23 Aug 2011 13:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=veMMbROQeKSOv2pZ/AIBEbxKQFYO7d5hvQsEYIFYuO0=; b=fKOCCkaHz646mTNMaTE/gRmwjhfdxZvjKF/kYL9nhen5Hoeqp2F88U4rICrU7+dQNM ePo5q/95ULnSA80V8X3GKGLGkpqX3ewmToyadqbGolk+WA7GMhKk6lf1dOZBiYUxrnlw fvWaJvd1ptW6lUG6ofPr4aLT6cR9fMw91X/zg= Received: by 10.204.144.26 with SMTP id x26mr1696510bku.347.1314129755751; Tue, 23 Aug 2011 13:02:35 -0700 (PDT) Received: from localhost ([31.28.235.172]) by mx.google.com with ESMTPS id y3sm81144bkw.49.2011.08.23.13.02.34 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Aug 2011 13:02:35 -0700 (PDT) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Hugo Mills , idryomov@gmail.com Subject: [PATCH 13/21] Btrfs: virtual address space subset filter Date: Tue, 23 Aug 2011 23:01:54 +0300 Message-Id: <1314129722-31601-14-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1314129722-31601-1-git-send-email-idryomov@gmail.com> References: <1314129722-31601-1-git-send-email-idryomov@gmail.com> 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]); Tue, 23 Aug 2011 20:02:39 +0000 (UTC) Select chunks which have at least one byte located inside a given [vstart, vend) virtual address space range. Signed-off-by: Ilya Dryomov --- fs/btrfs/volumes.c | 20 ++++++++++++++++++++ fs/btrfs/volumes.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 4393f6d..eccd458 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2276,6 +2276,20 @@ static int chunk_drange_filter(struct extent_buffer *leaf, return 1; } +/* [vstart, vend) */ +static int chunk_vrange_filter(struct extent_buffer *leaf, + struct btrfs_chunk *chunk, + u64 chunk_offset, + struct btrfs_restripe_args *rargs) +{ + if (chunk_offset < rargs->vend && + chunk_offset + btrfs_chunk_length(leaf, chunk) > rargs->vstart) + /* at least part of the chunk is inside this vrange */ + return 0; + + return 1; +} + static int chunk_soft_convert_filter(u64 chunk_profile, struct btrfs_restripe_args *rargs) { @@ -2337,6 +2351,12 @@ static int should_restripe_chunk(struct btrfs_root *root, return 0; } + /* vrange filter */ + if ((rargs->flags & BTRFS_RESTRIPE_ARGS_VRANGE) && + chunk_vrange_filter(leaf, chunk, chunk_offset, rargs)) { + return 0; + } + /* soft profile changing mode */ if ((rargs->flags & BTRFS_RESTRIPE_ARGS_SOFT) && chunk_soft_convert_filter(chunk_type, rargs)) { diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 8d4bbcb..9726180 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -188,7 +188,8 @@ struct map_lookup { #define BTRFS_RESTRIPE_ARGS_PROFILES (1ULL << 0) #define BTRFS_RESTRIPE_ARGS_USAGE (1ULL << 1) #define BTRFS_RESTRIPE_ARGS_DEVID (1ULL << 2) -#define BTRFS_RESTRIPE_ARGS_DRANGE (1ULL << 3) +#define BTRFS_RESTRIPE_ARGS_DRANGE (1ULL << 3) +#define BTRFS_RESTRIPE_ARGS_VRANGE (1ULL << 4) /* * Profile changing flags. When SOFT is set we won't relocate chunk if