From patchwork Wed Mar 3 15:31:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 83352 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o23FVBio019221 for ; Wed, 3 Mar 2010 15:31:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446Ab0CCPbK (ORCPT ); Wed, 3 Mar 2010 10:31:10 -0500 Received: from mail-fx0-f219.google.com ([209.85.220.219]:41192 "EHLO mail-fx0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752454Ab0CCPbI (ORCPT ); Wed, 3 Mar 2010 10:31:08 -0500 Received: by fxm19 with SMTP id 19so1651123fxm.21 for ; Wed, 03 Mar 2010 07:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=0qLbWiNXfVkpFudECJ0zoZ4tCjMcUJx4m4zNIwz/78I=; b=jPBlk5iqZBSm5XGjUAE3b+VXITDmww7zWuhYASsdFV8wYMaj8kI6if5EkU17PJFkrm gOlsByoj6+uogNjiBgf/ybqmXjmSl1OnUWuXGvuHGtUmPVTkfwV4h4N/pH4nQLEGta12 LWFuU+8hqWYIowHpAm2iUi8NCQR6jw7G6F+4Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=CSRfPbA3x9bu8Pi81qtRy5g4n9jxAXNiZr9Yh9nXgkb2kS/tUqBash+LnbxfYooGtT hCddPC8Ddi6qkJ6A60qlBmGXU8E61To9aujjU7tdu0mbi1ygqlQfZyb39KPIE3yxjCmA bFoKS30RFTtv9KT8RPC0Tv+Q8vvntQNF20bB0= Received: by 10.86.236.26 with SMTP id j26mr603765fgh.77.1267630266944; Wed, 03 Mar 2010 07:31:06 -0800 (PST) Received: from [192.168.0.99] (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id d4sm1149173fga.3.2010.03.03.07.31.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Mar 2010 07:31:06 -0800 (PST) Message-ID: <4B8E80B7.3090404@gmail.com> Date: Wed, 03 Mar 2010 10:31:03 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH V2] 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 03 Mar 2010 15:31:11 +0000 (UTC) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5ca2c6d..4cd4754 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2579,10 +2579,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; @@ -2592,13 +2602,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