From patchwork Mon Mar 22 03:29:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 87344 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 o2M3ToDt019269 for ; Mon, 22 Mar 2010 03:29:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753866Ab0CVD3t (ORCPT ); Sun, 21 Mar 2010 23:29:49 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:60218 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753711Ab0CVD3s (ORCPT ); Sun, 21 Mar 2010 23:29:48 -0400 Received: by vws6 with SMTP id 6so233695vws.19 for ; Sun, 21 Mar 2010 20:29:47 -0700 (PDT) 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=Rtvi+3sM7qIsPPqHJ8C3i1J+8a/NOlADtjQ4iiYR6Tg=; b=VXQJs5REu2FUzrABhkNf9vA9pss18VLDXXao+p6OL4Z3JicUN3tnhSpHcZfAdvOvXs 6S4OwnIUjHS4hWYOdss9kHO7G+fEVNblB4B9iFfBAPPoDjzFqQw4/dOEeG22i8x6Rx4S r5Oi6HrldihNrBh1m63c5jKzXZUS+171ftmAQ= 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=axWszvj/oCxXzYLhVfVjBK+H6glUI130ayzH19jRqn8tc3d8cs1O8wjJwEkdzrH+Ih wYMd8fjBxfoAkGu/7rWhFqcwr14aigzBpvwt400+uTq0QYCcr2NqioCnoQUV6ubYXB5Y DS0Xg2xSze11L2surY/eE7mb0uOy/YHJ1Bml8= Received: by 10.220.4.20 with SMTP id 20mr490307vcp.142.1269228587811; Sun, 21 Mar 2010 20:29:47 -0700 (PDT) Received: from [192.168.0.97] (c-24-147-40-65.hsd1.nh.comcast.net [24.147.40.65]) by mx.google.com with ESMTPS id 28sm31588537vws.6.2010.03.21.20.29.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 21 Mar 2010 20:29:47 -0700 (PDT) Message-ID: <4BA6E42A.7000608@gmail.com> Date: Sun, 21 Mar 2010 23:29:46 -0400 From: jim owens User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: linux-btrfs Subject: [PATCH V3 12/18] 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]); Mon, 22 Mar 2010 03:30:08 +0000 (UTC) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5a44c5c..aedef39 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2586,10 +2586,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; @@ -2599,13 +2609,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