From patchwork Thu Apr 24 18:15:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 4053251 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B4155BFF02 for ; Thu, 24 Apr 2014 18:15:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE34120340 for ; Thu, 24 Apr 2014 18:15:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D51A420279 for ; Thu, 24 Apr 2014 18:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932272AbaDXSPx (ORCPT ); Thu, 24 Apr 2014 14:15:53 -0400 Received: from mail-ig0-f170.google.com ([209.85.213.170]:44669 "EHLO mail-ig0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084AbaDXSPw (ORCPT ); Thu, 24 Apr 2014 14:15:52 -0400 Received: by mail-ig0-f170.google.com with SMTP id uq10so1356687igb.3 for ; Thu, 24 Apr 2014 11:15:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UHTGN/rC77YssrhDNUaZUsEk3/EQRqVNnnNAW8EZ6to=; b=Qr9JrEUjt4FsoJRvrOawnpcLhhcBevEHlgiLpFqalb+wWzsb1hANhGBHrUxypBhGYm cjhZi7uAZ+a2NQmUcoJENcuDaoqI4Hz7OES7Y40sVfwhOOZXtoEwKhAYyDAyABF3FLCx uIaZ3VKFa6CmsIz6xNb9DJN2G1o99uL9625EHNpmdhiXPxsltY6SPNlzgpY4SWIPmDXd M3H+jzG4skQUqD5kIlyDW4SNwQC0NAeH0zte86hF6o2nQ+P0Bcejf6p73rWwo6IHSpRe DfU45Pa/I7W9pRnvtZ79Q+1RlQWqcP4S+TFWCdCQbPO6lkHR1zC/MtRCFjAXhD/AblLh QSNQ== X-Gm-Message-State: ALoCoQkZLe+hds76eo7FxDdpvsBootoLsgugk2CEgms2XrxU0IyNBpwSHkWZwWyVgB8lvBoCS++3 X-Received: by 10.50.27.2 with SMTP id p2mr301138igg.32.1398363351738; Thu, 24 Apr 2014 11:15:51 -0700 (PDT) Received: from gavrio-wifi.robotsandstuff.fake (c-98-209-19-144.hsd1.mi.comcast.net. [98.209.19.144]) by mx.google.com with ESMTPSA id lp4sm789824igb.12.2014.04.24.11.15.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 24 Apr 2014 11:15:50 -0700 (PDT) From: Weston Andros Adamson To: trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH 10/18 v2] pnfs: clean up filelayout_alloc_commit_info Date: Thu, 24 Apr 2014 14:15:20 -0400 Message-Id: <1398363328-7100-11-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1398363328-7100-1-git-send-email-dros@primarydata.com> References: <1398363328-7100-1-git-send-email-dros@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove unneeded else statement and clean up how commit info dataserver buckets are replaced. Suggested-by: Trond Myklebust Signed-off-by: Weston Andros Adamson --- fs/nfs/nfs4filelayout.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c index 9319427..9cea935 100644 --- a/fs/nfs/nfs4filelayout.c +++ b/fs/nfs/nfs4filelayout.c @@ -850,11 +850,15 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, { struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); struct pnfs_commit_bucket *buckets; - int size; + int size, i; if (fl->commit_through_mds) return 0; - if (cinfo->ds->nbuckets != 0) { + + size = (fl->stripe_type == STRIPE_SPARSE) ? + fl->dsaddr->ds_num : fl->dsaddr->stripe_count; + + if (cinfo->ds->nbuckets >= size) { /* This assumes there is only one IOMODE_RW lseg. What * we really want to do is have a layout_hdr level * dictionary of keys, each @@ -864,30 +868,32 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, return 0; } - size = (fl->stripe_type == STRIPE_SPARSE) ? - fl->dsaddr->ds_num : fl->dsaddr->stripe_count; - buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket), gfp_flags); if (!buckets) return -ENOMEM; - else { - int i; + for (i = 0; i < size; i++) { + INIT_LIST_HEAD(&buckets[i].written); + INIT_LIST_HEAD(&buckets[i].committing); + } - spin_lock(cinfo->lock); - if (cinfo->ds->nbuckets != 0) - kfree(buckets); - else { - cinfo->ds->buckets = buckets; - cinfo->ds->nbuckets = size; - for (i = 0; i < size; i++) { - INIT_LIST_HEAD(&buckets[i].written); - INIT_LIST_HEAD(&buckets[i].committing); - } - } - spin_unlock(cinfo->lock); - return 0; + spin_lock(cinfo->lock); + if (cinfo->ds->nbuckets >= size) + goto out; + for (i = 0; i < cinfo->ds->nbuckets; i++) { + list_splice(&cinfo->ds->buckets[i].written, + &buckets[i].written); + list_splice(&cinfo->ds->buckets[i].committing, + &buckets[i].committing); + buckets[i].wlseg = cinfo->ds->buckets[i].wlseg; + buckets[i].clseg = cinfo->ds->buckets[i].clseg; } + swap(cinfo->ds->buckets, buckets); + cinfo->ds->nbuckets = size; +out: + spin_unlock(cinfo->lock); + kfree(buckets); + return 0; } static struct pnfs_layout_segment *