From patchwork Mon Jan 21 23:32:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alasdair G Kergon X-Patchwork-Id: 2014881 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by patchwork2.kernel.org (Postfix) with ESMTP id C04E4DF23A for ; Mon, 21 Jan 2013 23:35:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0LNWnDu013220; Mon, 21 Jan 2013 18:32:50 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0LNWknO001949 for ; Mon, 21 Jan 2013 18:32:46 -0500 Received: from agk-dp.fab.redhat.com (agk-dp.fab.redhat.com [10.33.0.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0LNWjxj022373 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 21 Jan 2013 18:32:46 -0500 Received: from agk by agk-dp.fab.redhat.com with local (Exim 4.69) (envelope-from ) id 1TxQr7-0007H2-BQ; Mon, 21 Jan 2013 23:32:45 +0000 Date: Mon, 21 Jan 2013 23:32:45 +0000 From: Alasdair G Kergon To: Joe Thornber Message-ID: <20130121233245.GF27093@agk-dp.fab.redhat.com> Mail-Followup-To: Joe Thornber , dm-devel@redhat.com References: <1355429956-22785-1-git-send-email-ejt@redhat.com> <1355429956-22785-5-git-send-email-ejt@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1355429956-22785-5-git-send-email-ejt@redhat.com> Organization: Red Hat UK Ltd. Registered in England and Wales, number 03798903. Registered Office: 64 Baker Street, 4th floor, London, W1U 7DF. User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: Re: [dm-devel] [PATCH 4/8] [dm-bio-prison] Change the bio-prison interface so the memory for the cells is passed in. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 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 On Thu, Dec 13, 2012 at 08:19:12PM +0000, Joe Thornber wrote: > @@ -87,6 +79,20 @@ void dm_bio_prison_destroy(struct dm_bio_prison *prison) > } > EXPORT_SYMBOL_GPL(dm_bio_prison_destroy); > > +struct dm_bio_prison_cell * > +dm_bio_prison_alloc_cell(struct dm_bio_prison *prison, gfp_t gfp) Let's keep that on one line. > +int dm_bio_detain(struct dm_bio_prison *prison, > + struct dm_cell_key *key, > + struct bio *inmate, > + struct dm_bio_prison_cell *memory, The caller has already allocated 'memory' specifically to hold that struct. Call it 'new_cell' perhaps? 'cell_prealloc' ? > + struct dm_bio_prison_cell **ref) cell_ref ? > @@ -226,6 +226,53 @@ struct thin_c { > > /*----------------------------------------------------------------*/ > > +static int bio_detain(struct pool *pool, struct dm_cell_key *key, struct bio *bio, > + struct dm_bio_prison_cell **result) > +{ > + int r; > + struct dm_bio_prison_cell *cell; > + > + cell = dm_bio_prison_alloc_cell(pool->prison, GFP_NOIO); > + if (!cell) > + return -ENOMEM; Redundant test? The mempool allocation always succeeds (or blocks). > + r = dm_bio_detain(pool->prison, key, bio, cell, result); > + > + if (r) > + /* > + * We reused an old cell, or errored; we can get rid of Can't have errored that I can see. > + * the new one. > + */ > + dm_bio_prison_free_cell(pool->prison, cell); > + > + return r; > +} Alasdair --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- a/dm-bio-prison.c 2013-01-14 19:32:36.000000000 +0000 +++ b/dm-bio-prison.c 2013-01-21 23:09:49.000000000 +0000 @@ -79,8 +79,7 @@ } EXPORT_SYMBOL_GPL(dm_bio_prison_destroy); -struct dm_bio_prison_cell * -dm_bio_prison_alloc_cell(struct dm_bio_prison *prison, gfp_t gfp) +struct dm_bio_prison_cell *dm_bio_prison_alloc_cell(struct dm_bio_prison *prison, gfp_t gfp) { return mempool_alloc(prison->cell_pool, gfp); } --- a/dm-thin.c 2013-01-18 15:00:00.000000000 +0000 +++ b/dm-thin.c 2013-01-21 23:09:48.000000000 +0000 @@ -250,16 +250,16 @@ int r; struct dm_bio_prison_cell *cell; + /* + * Allocate a cell from the prison's mempool. + * This might block but it can't fail. + */ cell = dm_bio_prison_alloc_cell(pool->prison, GFP_NOIO); - if (!cell) - return -ENOMEM; r = dm_bio_detain(pool->prison, key, bio, cell, result); - if (r) /* - * We reused an old cell, or errored; we can get rid of - * the new one. + * We reused an old cell: get rid of the new one. */ dm_bio_prison_free_cell(pool->prison, cell);