From patchwork Mon Jan 4 21:14:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 70747 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o04LEWRl025107 for ; Mon, 4 Jan 2010 21:14:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753367Ab0ADVOb (ORCPT ); Mon, 4 Jan 2010 16:14:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753365Ab0ADVOb (ORCPT ); Mon, 4 Jan 2010 16:14:31 -0500 Received: from g1t0029.austin.hp.com ([15.216.28.36]:25730 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753286Ab0ADVOa (ORCPT ); Mon, 4 Jan 2010 16:14:30 -0500 Received: from g1t0038.austin.hp.com (g1t0038.austin.hp.com [16.236.32.44]) by g1t0029.austin.hp.com (Postfix) with ESMTP id 2583B383EB for ; Mon, 4 Jan 2010 21:14:30 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g1t0038.austin.hp.com (Postfix) with ESMTP id 1B2D93006C for ; Mon, 4 Jan 2010 21:14:30 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id DFD5BCF0011; Mon, 4 Jan 2010 14:14:29 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hOkeCdvzrLjB; Mon, 4 Jan 2010 14:14:29 -0700 (MST) Received: from [192.168.0.99] (squirrel.fc.hp.com [15.11.146.57]) (Authenticated sender: owens@fc.hp.com) by ldl (Postfix) with ESMTPA id 657F0CF000E; Mon, 4 Jan 2010 14:14:29 -0700 (MST) Message-ID: <4B425A34.6000801@hp.com> Date: Mon, 04 Jan 2010 16:14:28 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [RFC 12/12 PATCH] Btrfs: add direct I/O helper to return mirror count from extent_map. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6aa04e4..3dda2ce 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2574,10 +2574,20 @@ void btrfs_mapping_tree_free(struct btrfs_mapping_tree *tree) } } +int btrfs_map_num_copies(struct extent_map *em) +{ + struct map_lookup *map = (struct map_lookup *)em->bdev; + + if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) + return map->num_stripes; + if (map->type & BTRFS_BLOCK_GROUP_RAID10) + return map->sub_stripes; + return 1; +} + int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len) { struct extent_map *em; - struct map_lookup *map; struct extent_map_tree *em_tree = &map_tree->map_tree; int ret; @@ -2587,13 +2597,9 @@ int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len) BUG_ON(!em); BUG_ON(em->start > logical || em->start + em->len < logical); - map = (struct map_lookup *)em->bdev; - if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) - ret = map->num_stripes; - else if (map->type & BTRFS_BLOCK_GROUP_RAID10) - ret = map->sub_stripes; - else - ret = 1; + + ret = btrfs_map_num_copies(em); + free_extent_map(em); return ret; } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 226200d..732c8c5 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -195,4 +195,5 @@ int find_free_dev_extent(struct btrfs_trans_handle *trans, int btrfs_map_stripe_count(struct extent_map *em); struct block_device *btrfs_map_stripe_bdev(struct extent_map *em, int stripe); u64 btrfs_map_stripe_physical(struct extent_map *em, int stripe); +int btrfs_map_num_copies(struct extent_map *em); #endif