From patchwork Mon Jan 4 21:13:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jim owens X-Patchwork-Id: 70752 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 o04LOFPH026401 for ; Mon, 4 Jan 2010 21:24:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753157Ab0ADVYN (ORCPT ); Mon, 4 Jan 2010 16:24:13 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753145Ab0ADVYM (ORCPT ); Mon, 4 Jan 2010 16:24:12 -0500 Received: from g6t0185.atlanta.hp.com ([15.193.32.62]:22972 "EHLO g6t0185.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752751Ab0ADVYL (ORCPT ); Mon, 4 Jan 2010 16:24:11 -0500 Received: from g5t0030.atlanta.hp.com (g5t0030.atlanta.hp.com [16.228.8.142]) by g6t0185.atlanta.hp.com (Postfix) with ESMTP id B54B3241BD for ; Mon, 4 Jan 2010 21:13:16 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g5t0030.atlanta.hp.com (Postfix) with ESMTP id 983D114090 for ; Mon, 4 Jan 2010 21:13:16 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 5F4A3CF0011; Mon, 4 Jan 2010 14:13:16 -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 064Fj1EM0105; Mon, 4 Jan 2010 14:13:16 -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 A8EF4CF000E; Mon, 4 Jan 2010 14:13:15 -0700 (MST) Message-ID: <4B4259EA.4080001@hp.com> Date: Mon, 04 Jan 2010 16:13:14 -0500 From: jim owens User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: linux-btrfs Subject: [RFC 05/12 RESEND PATCH] Btrfs: remove dead code for unplugging pages. Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 009e3bd..72c08fa 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1289,10 +1289,10 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits) } /* - * this unplugs every device on the box, and it is only used when page - * is null + * this unplugs every device on the box, and yes that is ugly + * but there are currently no low cost alternatives */ -static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page) +static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) { struct btrfs_device *device; struct btrfs_fs_info *info; @@ -1308,62 +1308,6 @@ static void __unplug_io_fn(struct backing_dev_info *bdi, struct page *page) } } -static void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page) -{ - struct inode *inode; - struct extent_map_tree *em_tree; - struct extent_map *em; - struct address_space *mapping; - u64 offset; - - /* the generic O_DIRECT read code does this */ - if (1 || !page) { - __unplug_io_fn(bdi, page); - return; - } - - /* - * page->mapping may change at any time. Get a consistent copy - * and use that for everything below - */ - smp_mb(); - mapping = page->mapping; - if (!mapping) - return; - - inode = mapping->host; - - /* - * don't do the expensive searching for a small number of - * devices - */ - if (BTRFS_I(inode)->root->fs_info->fs_devices->open_devices <= 2) { - __unplug_io_fn(bdi, page); - return; - } - - offset = page_offset(page); - - em_tree = &BTRFS_I(inode)->extent_tree; - read_lock(&em_tree->lock); - em = lookup_extent_mapping(em_tree, offset, PAGE_CACHE_SIZE); - read_unlock(&em_tree->lock); - if (!em) { - __unplug_io_fn(bdi, page); - return; - } - - if (em->block_start >= EXTENT_MAP_LAST_BYTE) { - free_extent_map(em); - __unplug_io_fn(bdi, page); - return; - } - offset = offset - em->start; - btrfs_unplug_page(&BTRFS_I(inode)->root->fs_info->mapping_tree, - em->block_start + offset, page); - free_extent_map(em); -} - /* * If this fails, caller must call bdi_destroy() to get rid of the * bdi again. diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e6599ef..0e3146a 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2614,10 +2614,10 @@ static int find_live_mirror(struct map_lookup *map, int first, int num, return optimal; } -static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, +int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, u64 logical, u64 *length, struct btrfs_multi_bio **multi_ret, - int mirror_num, struct page *unplug_page) + int mirror_num) { struct extent_map *em; struct map_lookup *map; @@ -2629,15 +2629,12 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, int i; int num_stripes; int max_errors; - struct btrfs_multi_bio *multi = NULL; + struct btrfs_multi_bio *multi; read_lock(&em_tree->lock); em = lookup_extent_mapping(em_tree, logical, *length); read_unlock(&em_tree->lock); - if (!em && unplug_page) - return 0; - if (!em) { printk(KERN_CRIT "unable to find logical %llu len %llu\n", (unsigned long long)logical, @@ -2673,7 +2670,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, *length = min(*length, em->len - offset); } - if (!multi_ret && !unplug_page) + if (!multi_ret) goto out; if (mirror_num > map->num_stripes) @@ -2691,7 +2688,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, num_stripes = 1; stripe_index = 0; if (map->type & BTRFS_BLOCK_GROUP_RAID1) { - if (unplug_page || (rw & (1 << BIO_RW))) + if (rw & (1 << BIO_RW)) num_stripes = map->num_stripes; else if (mirror_num) stripe_index = mirror_num - 1; @@ -2713,7 +2710,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, stripe_index = do_div(stripe_nr, factor); stripe_index *= map->sub_stripes; - if (unplug_page || (rw & (1 << BIO_RW))) + if (rw & (1 << BIO_RW)) num_stripes = map->sub_stripes; else if (mirror_num) stripe_index += mirror_num - 1; @@ -2732,34 +2729,20 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, } BUG_ON(stripe_index >= map->num_stripes); - if (multi_ret) { - multi = kzalloc(btrfs_multi_bio_size(num_stripes), GFP_NOFS); - if (!multi) - return -ENOMEM; - *multi_ret = multi; + multi = kzalloc(btrfs_multi_bio_size(num_stripes), GFP_NOFS); + if (!multi) + return -ENOMEM; + *multi_ret = multi; - atomic_set(&multi->error, 0); - multi->num_stripes = num_stripes; - multi->max_errors = max_errors; - } + atomic_set(&multi->error, 0); + multi->num_stripes = num_stripes; + multi->max_errors = max_errors; for (i = 0; i < num_stripes; i++) { - if (unplug_page) { - struct btrfs_device *device; - struct backing_dev_info *bdi; - - device = map->stripes[stripe_index].dev; - if (device->bdev) { - bdi = blk_get_backing_dev_info(device->bdev); - if (bdi->unplug_io_fn) - bdi->unplug_io_fn(bdi, unplug_page); - } - } else { - multi->stripes[i].physical = - map->stripes[stripe_index].physical + - stripe_offset + stripe_nr * map->stripe_len; - multi->stripes[i].dev = map->stripes[stripe_index].dev; - } + multi->stripes[i].physical = + map->stripes[stripe_index].physical + + stripe_offset + stripe_nr * map->stripe_len; + multi->stripes[i].dev = map->stripes[stripe_index].dev; stripe_index++; } out: @@ -2767,14 +2750,6 @@ out: return 0; } -int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, - u64 logical, u64 *length, - struct btrfs_multi_bio **multi_ret, int mirror_num) -{ - return __btrfs_map_block(map_tree, rw, logical, length, multi_ret, - mirror_num, NULL); -} - int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree, u64 chunk_start, u64 physical, u64 devid, u64 **logical, int *naddrs, int *stripe_len) @@ -2840,14 +2815,6 @@ int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree, return 0; } -int btrfs_unplug_page(struct btrfs_mapping_tree *map_tree, - u64 logical, struct page *page) -{ - u64 length = PAGE_CACHE_SIZE; - return __btrfs_map_block(map_tree, READ, logical, &length, - NULL, 0, page); -} - static void end_bio_multi_stripe(struct bio *bio, int err) { struct btrfs_multi_bio *multi = bio->bi_private; diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 31b0fab..d5aab74 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -169,8 +169,6 @@ int btrfs_add_device(struct btrfs_trans_handle *trans, int btrfs_rm_device(struct btrfs_root *root, char *device_path); int btrfs_cleanup_fs_uuids(void); int btrfs_num_copies(struct btrfs_mapping_tree *map_tree, u64 logical, u64 len); -int btrfs_unplug_page(struct btrfs_mapping_tree *map_tree, - u64 logical, struct page *page); int btrfs_grow_device(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 new_size); struct btrfs_device *btrfs_find_device(struct btrfs_root *root, u64 devid,