From patchwork Fri Aug 24 16:35:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1372181 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0EC34DF28C for ; Fri, 24 Aug 2012 16:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964841Ab2HXQfN (ORCPT ); Fri, 24 Aug 2012 12:35:13 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:45658 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964839Ab2HXQfL (ORCPT ); Fri, 24 Aug 2012 12:35:11 -0400 Received: by mail-iy0-f174.google.com with SMTP id o24so3735552ial.19 for ; Fri, 24 Aug 2012 09:35:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=GB2rh4TFDu+qSa04lTAjKt23KP0BSBjPds0qiQ6YmC0=; b=Nyfh8WeH5zM2jp2jRVs9sGZ3tUyy3wE/NKxSOak3PVWUc7lPBiPi3F7oHMSkrbSL2o qE7pZF6dMMO2EfizBQyYV+eC+Era4Sgt6a1yj4mRArrP2S1/FHagXoIZgGaecqlcHElZ wvKl+ThBoJmMVtaErSvvBGrJZqztFDGTerRgkGWdBKyDfFS/+It/gspxtUR2HMoghgvG N+R0Om43xGAy68xfUtUxfsU0Ouw/Y53cjbAQBOCu99B6J2+D7EXnfNAVAX6dKJLwVOZK QvzSrXE7QgPQC+4r1WQ/s0t2HIOtTtP8hFw99U8piaw400uSRfW6olBh0ZdtOG9WwRZr d07Q== Received: by 10.50.95.200 with SMTP id dm8mr2807486igb.60.1345826111356; Fri, 24 Aug 2012 09:35:11 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id z7sm250041igb.3.2012.08.24.09.35.04 (version=SSLv3 cipher=OTHER); Fri, 24 Aug 2012 09:35:07 -0700 (PDT) Message-ID: <5037AD38.9070701@inktank.com> Date: Fri, 24 Aug 2012 11:35:04 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 08/11] rbd: bio_chain_clone() cleanups References: <5037AB20.4000103@inktank.com> In-Reply-To: <5037AB20.4000103@inktank.com> X-Gm-Message-State: ALoCoQk7bdsgo+4oEXG+gF6kd2zSY2uNCOKd6Qj43QF7AkwehNDVBnb5Wm+sUlqfQXk8Bt3cU5g/ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org In bio_chain_clone(), at the end of the function the bi_next field of the tail of the new bio chain is nulled. This isn't necessary, because if "tail" is non-null, its value will be the last bio structure allocated at the top of the while loop in that function. And before that structure is added to the end of the new chain, its bi_next pointer is always made null. While touching that function, clean a few other things: - define each local variable on its own line - move the definition of "tmp" to an inner scope - move the modification of gfpmask closer to where it's used - rearrange the logic that sets the chain's tail pointer Signed-off-by: Alex Elder Reviewed-by: Yehuda Sadeh --- drivers/block/rbd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) if (*bp) { @@ -750,9 +752,12 @@ static struct bio *bio_chain_clone(struct bio **old, struct bio **next, } while (old_chain && (total < len)) { + struct bio *tmp; + tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs); if (!tmp) goto err_out; + gfpmask &= ~__GFP_WAIT; /* can't wait after the first */ if (total + old_chain->bi_size > len) { struct bio_pair *bp; @@ -780,15 +785,12 @@ static struct bio *bio_chain_clone(struct bio **old, struct bio **next, } tmp->bi_bdev = NULL; - gfpmask &= ~__GFP_WAIT; tmp->bi_next = NULL; - - if (!new_chain) { - new_chain = tail = tmp; - } else { + if (new_chain) tail->bi_next = tmp; - tail = tmp; - } + else + new_chain = tmp; + tail = tmp; old_chain = old_chain->bi_next; total += tmp->bi_size; @@ -796,9 +798,6 @@ static struct bio *bio_chain_clone(struct bio **old, struct bio **next, BUG_ON(total < len); - if (tail) - tail->bi_next = NULL; - *old = old_chain; return new_chain; diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index e94336d..bb8dad7 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -741,7 +741,9 @@ static struct bio *bio_chain_clone(struct bio **old, struct bio **next, struct bio_pair **bp, int len, gfp_t gfpmask) { - struct bio *tmp, *old_chain = *old, *new_chain = NULL, *tail = NULL; + struct bio *old_chain = *old; + struct bio *new_chain = NULL; + struct bio *tail; int total = 0;