From patchwork Tue Mar 17 14:06:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 12625 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2HE6FYJ018789 for ; Tue, 17 Mar 2009 14:06:15 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 92A76619BF5; Tue, 17 Mar 2009 10:06:15 -0400 (EDT) Received: from int-mx2.corp.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n2HE6EiN023777 for ; Tue, 17 Mar 2009 10:06:14 -0400 Received: from hydrogen.msp.redhat.com (hydrogen.msp.redhat.com [10.15.80.1]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2HE6CV3012557 for ; Tue, 17 Mar 2009 10:06:12 -0400 Received: from hydrogen.msp.redhat.com (localhost.localdomain [127.0.0.1]) by hydrogen.msp.redhat.com (8.14.1/8.14.1) with ESMTP id n2HE6BwA017520 for ; Tue, 17 Mar 2009 09:06:11 -0500 Received: (from jbrassow@localhost) by hydrogen.msp.redhat.com (8.14.1/8.14.1/Submit) id n2HE6BV2017518 for dm-devel@redhat.com; Tue, 17 Mar 2009 09:06:11 -0500 Date: Tue, 17 Mar 2009 09:06:11 -0500 From: Jonathan Brassow Message-Id: <200903171406.n2HE6BV2017518@hydrogen.msp.redhat.com> To: dm-devel@redhat.com X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 24 of 29] dm-snap-get-rid-of-init_hash_tables-fn.patch X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux-2.6/drivers/md/dm-snap.c =================================================================== --- linux-2.6.orig/drivers/md/dm-snap.c +++ linux-2.6/drivers/md/dm-snap.c @@ -373,38 +373,6 @@ static int calc_max_buckets(void) } /* - * Allocate room for a suitable hash table. - */ -static int init_hash_tables(struct dm_snapshot *s) -{ - sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets; - - /* - * Calculate based on the size of the original volume or - * the COW volume... - */ - cow_dev_size = get_dev_size(s->store->cow->bdev); - origin_dev_size = get_dev_size(s->origin->bdev); - max_buckets = calc_max_buckets(); - - hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift; - hash_size = min(hash_size, max_buckets); - - hash_size = rounddown_pow_of_two(hash_size); - hash_size >>= 3; - if (hash_size < 64) - hash_size = 64; - - s->pending = dm_exception_table_create(hash_size, 0, - alloc_pending_exception, s, - free_pending_exception, NULL); - if (!s->pending) - return -ENOMEM; - - return 0; -} - -/* * create_exception_store * @ti * @argc @@ -477,6 +445,7 @@ static int create_exception_store(struct */ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) { + sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets; struct dm_snapshot *s; int i; int r = -EINVAL; @@ -520,11 +489,29 @@ static int snapshot_ctr(struct dm_target init_rwsem(&s->lock); spin_lock_init(&s->pe_lock); - /* Allocate hash table for COW data */ - if (init_hash_tables(s)) { + /* + * Calculate based on the size of the original volume or + * the COW volume... + */ + cow_dev_size = get_dev_size(store->cow->bdev); + origin_dev_size = get_dev_size(s->origin->bdev); + max_buckets = calc_max_buckets(); + + hash_size = min(origin_dev_size, cow_dev_size) >> store->chunk_shift; + hash_size = min(hash_size, max_buckets); + + hash_size = rounddown_pow_of_two(hash_size); + hash_size >>= 3; + if (hash_size < 64) + hash_size = 64; + + s->pending = dm_exception_table_create(hash_size, 0, + alloc_pending_exception, s, + free_pending_exception, NULL); + if (!s->pending) { ti->error = "Unable to allocate hash table space"; r = -ENOMEM; - goto bad_hash_tables; + goto bad_hash_table; } r = dm_kcopyd_client_create(SNAPSHOT_PAGES, &s->kcopyd_client); @@ -579,7 +566,7 @@ bad_pending_pool: bad_kcopyd: dm_exception_table_destroy(s->pending); -bad_hash_tables: +bad_hash_table: dm_put_device(ti, s->origin); bad_origin: