From patchwork Sat May 11 02:43:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2553101 Return-Path: X-Original-To: patchwork-linux-nfs@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 03CA7DF2A2 for ; Sat, 11 May 2013 02:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756621Ab3EKCnz (ORCPT ); Fri, 10 May 2013 22:43:55 -0400 Received: from mail-we0-f182.google.com ([74.125.82.182]:55247 "EHLO mail-we0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756416Ab3EKCny (ORCPT ); Fri, 10 May 2013 22:43:54 -0400 Received: by mail-we0-f182.google.com with SMTP id t60so4578971wes.41 for ; Fri, 10 May 2013 19:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=Mal6KZahAVR28WDWwwyWLtBOONozh1d2gnh6wRdQH6s=; b=0oQQ/rIJUuQR0CoSYPcpal8ctC/gnhuUFOqZVfmFlWbDhSwTJN1vjlGfBiR65y5vwn 4OrEFfDA69tJwZiYoD1zIh6mJ+jYWhFQaiU8KixIYDzPkrtK8xI7Y0V9wT3+Vfl598jY NPJiafjSun3wWSwSw4oZ+UVty962Gu4nsYl2nuH4RYaSLCaUXucAjxBcw2IyfhdEFwE9 jfPY/uVGO+P47aIEPs/DoqOrRAsecpINJMRcSuIuyw2rx83t3QFMmVk0nhy2H9n5KaXF aBMWEhyRdx+TAVQY+3m7mo3XYRXTPgx+uwYbudXgXJtCZmXFxoy622Qxv7WrfMBihyCj 02lw== X-Received: by 10.180.82.74 with SMTP id g10mr7226230wiy.10.1368240233738; Fri, 10 May 2013 19:43:53 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com (bzq-79-180-144-28.red.bezeqint.net. [79.180.144.28]) by mx.google.com with ESMTPSA id o3sm1408120wia.2.2013.05.10.19.43.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 10 May 2013 19:43:53 -0700 (PDT) From: Benny Halevy To: linux-nfs@vger.kernel.org Subject: [PATCH 21/38] SQUASHME: pnfsd: return bool from merge_layout and fix not found path Date: Sat, 11 May 2013 05:43:48 +0300 Message-Id: <1368240228-32538-1-git-send-email-bhalevy@tonian.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <518B6377.3000207@tonian.com> References: <518B6377.3000207@tonian.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This also fixes the false return when no layout is found (previously a non NULL pointer was returned) Signed-off-by: Benny Halevy --- fs/nfsd/nfs4pnfsd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c index 0bde7b7..ff688cb 100644 --- a/fs/nfsd/nfs4pnfsd.c +++ b/fs/nfsd/nfs4pnfsd.c @@ -578,7 +578,7 @@ struct super_block * /* * are two octet ranges overlapping or adjacent? */ -static int +static bool lo_seg_mergeable(struct nfsd4_layout_seg *l1, struct nfsd4_layout_seg *l2) { u64 start1 = l1->offset; @@ -615,25 +615,26 @@ struct super_block * lo_end : lo_end - lo_start; } -static struct nfs4_layout * +static bool merge_layout(struct nfs4_file *fp, struct nfs4_client *clp, struct nfsd4_layout_seg *seg) { - struct nfs4_layout *lp = NULL; + bool ret = false; + struct nfs4_layout *lp; spin_lock(&layout_lock); list_for_each_entry (lp, &fp->fi_layouts, lo_perfile) if (lp->lo_seg.layout_type == seg->layout_type && lp->lo_seg.clientid == seg->clientid && lp->lo_seg.iomode == seg->iomode && - lo_seg_mergeable(&lp->lo_seg, seg)) { + (ret = lo_seg_mergeable(&lp->lo_seg, seg))) { extend_layout(&lp->lo_seg, seg); break; } spin_unlock(&layout_lock); - return lp; + return ret; } __be32