From patchwork Sun May 15 01:06:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9095831 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D7803BF29F for ; Sun, 15 May 2016 01:07:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E2D2D2026C for ; Sun, 15 May 2016 01:07:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0479A20268 for ; Sun, 15 May 2016 01:07:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754026AbcEOBHJ (ORCPT ); Sat, 14 May 2016 21:07:09 -0400 Received: from mail-qg0-f47.google.com ([209.85.192.47]:35323 "EHLO mail-qg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754022AbcEOBHG (ORCPT ); Sat, 14 May 2016 21:07:06 -0400 Received: by mail-qg0-f47.google.com with SMTP id f74so75199119qge.2 for ; Sat, 14 May 2016 18:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poochiereds-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P4jqLzS6WgUxP9OXkUMsS0sc+O77Dr/1rlRR7uH/QV4=; b=KNs6x4Fl1A8yCGTCoCjLkCUaA0SsbipkxolOZj4s931xZ5FkT+kRiUeiTM5kQDQ/6P 4EANPSnG7Viiw9LSLb/s1PGTFfainGK1yz6K0EMP2ftLxRURLdYeipX6aC1aUffTfUzU RLcoA/E8Wj0yRvmQXvRHQW1VE9DYXqy/xD8VhJDPkhavsh44qkjGkjWmcbg2CtCy/6nn Tw7KNmLphdYPABM9RzfvXaZQdfnkCRurO1WeTaJUmX7XJmzoPTBD5tlgKXAsiJ01av8/ Wny/QAA0T9nJxBQQoomIjoB9UlDGia+Zm3KCrCq1BSyhV8eVEjBh+HnODEHlbid2yckA XMhA== 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=P4jqLzS6WgUxP9OXkUMsS0sc+O77Dr/1rlRR7uH/QV4=; b=NV3ASFgWtUL4+0PgxyXnARFJcwneYE4mKKc6TVpTWmzty00nL4FZAi5GKsTN+EGpMW O9zj6n8F/wasE4+9W9RF2IEaSyLqFkEnSQzUA+9cKbqU6xO1naPCMFIa40MQNNHJGQnQ azhusCWRv2d9x5WxIx5/jI1xLQCyEGGk5ivh/znLvoHf3GE6HLFXCc74eiCo1LHNScF5 hEhGdkqtej6JgK4fosp5SjBe+mxWMvdFmNT8sZ0na0p9a9Xs/TegJyWknDuO7BnTLWQ4 8GeFBC+3JtVHreK6stUS/nb8W7i+kksVGz/bUVOvHB1BVzNMCvz1gKItz/6uYFVNafYB SaMg== X-Gm-Message-State: AOPr4FXnUVBv+vEcmkFzsWkrqVUaUmEAekFp9F23frlfut0Z7a1+NmmMzc99pMQ9qm4DZQ== X-Received: by 10.140.96.100 with SMTP id j91mr22555188qge.10.1463274424934; Sat, 14 May 2016 18:07:04 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1125:4074:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id d12sm11520330qhd.13.2016.05.14.18.07.04 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 14 May 2016 18:07:04 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, hch@infradead.org Subject: [PATCH v3 13/13] pnfs: make pnfs_layout_process more robust Date: Sat, 14 May 2016 21:06:42 -0400 Message-Id: <1463274402-17746-14-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463274402-17746-1-git-send-email-jeff.layton@primarydata.com> References: <1463274402-17746-1-git-send-email-jeff.layton@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=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 It can return NULL if layoutgets are blocked currently. Fix it to return -EAGAIN in that case, so we can properly handle it in pnfs_update_layout. Also, clean up and simplify the error handling -- eliminate "status" and just use "lseg". Signed-off-by: Jeff Layton --- fs/nfs/pnfs.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d0760d30734d..4108e78ae3b6 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1706,21 +1706,19 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) struct pnfs_layout_segment *lseg; struct inode *ino = lo->plh_inode; LIST_HEAD(free_me); - int status = -EINVAL; if (!pnfs_sanity_check_layout_range(&res->range)) - goto out; + return ERR_PTR(-EINVAL); /* Inject layout blob into I/O device driver */ lseg = NFS_SERVER(ino)->pnfs_curr_ld->alloc_lseg(lo, res, lgp->gfp_flags); - if (!lseg || IS_ERR(lseg)) { + if (IS_ERR_OR_NULL(lseg)) { if (!lseg) - status = -ENOMEM; - else - status = PTR_ERR(lseg); - dprintk("%s: Could not allocate layout: error %d\n", - __func__, status); - goto out; + lseg = ERR_PTR(-ENOMEM); + + dprintk("%s: Could not allocate layout: error %ld\n", + __func__, PTR_ERR(lseg)); + return lseg; } init_lseg(lo, lseg); @@ -1730,15 +1728,14 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) spin_lock(&ino->i_lock); if (pnfs_layoutgets_blocked(lo)) { dprintk("%s forget reply due to state\n", __func__); - goto out_forget_reply; + goto out_forget; } if (nfs4_stateid_match_other(&lo->plh_stateid, &res->stateid)) { /* existing state ID, make sure the sequence number matches. */ if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { dprintk("%s forget reply due to sequence\n", __func__); - status = -EAGAIN; - goto out_forget_reply; + goto out_forget; } pnfs_set_layout_stateid(lo, &res->stateid, false); } else { @@ -1764,14 +1761,12 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) spin_unlock(&ino->i_lock); pnfs_free_lseg_list(&free_me); return lseg; -out: - return ERR_PTR(status); -out_forget_reply: +out_forget: spin_unlock(&ino->i_lock); lseg->pls_layout = lo; NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg); - goto out; + return ERR_PTR(-EAGAIN); } static void