Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7598987imm; Thu, 28 Jun 2018 06:29:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLB4ySRUwvAGOSuOuLEwpDzfiG3o60bBUKqC0wvXwkhniWQsaN7KZt6Iaq78ZmIVe1yc1xV X-Received: by 2002:a17:902:a518:: with SMTP id s24-v6mr10700888plq.144.1530192563032; Thu, 28 Jun 2018 06:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530192563; cv=none; d=google.com; s=arc-20160816; b=FziJAMKFWNZ6f/rM9kOse+OsmbsB1ywZwiPoDp/wy7y0r9cLKHRtuyy22UcfxBFBzx Ta3RbzucH6s1bidUef4gD+R/tiJIel8+Gxfv6xIbgk/yb0AHqy1h8cctcZ0ujOSNle2y y2c33bsOwGH6HJBU8JErelbowZan8QjNeskzUdLSBs/mvorrTPEX4n3nvJ/quMrzWMeR WEXUiovLpGcjatEWJhlJQgBEiVy6BGnR5JbZrwvobo+BqjCIymGlimsGI+9EN6sp6N1/ dfrSLEhz3HdUIlHxQYj3J0BFi2m8X7ZKT73cKlXXjxN6F9nwGrXjOzM8KkecPieP5keO cJuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=pKuPnBovgJ8+sywdr1QSI2Q8btKmadyyXncBiBb0Vtk=; b=AOxz/PTqRvqjOiyh1gFbcBMVjKmza3Di0tcOHAibWn1cNkhc/HmieEbfkBrUTSckz0 9E4WFoHNs+Wx0nNNr+OfWVQwskIEFIEwQQNEU/KkhkvP73FmCSpwelEGUx0e1e+HD7/E c90UpI07Vc825C4IVCVZCZSszfwlvf9vS3gF3WJ6jpWjeC5V2lyaphBLXVTYlwGpoSrR sJb2zeoiW5RxUdM6bQ+LVbfdMtHBHdOC9VZYU1Irs8Iky6zyA6EmiyMmjaLqtok+GUFS zVqCE5rE4leGLb2KnFmoUqOPKcLkBmHWd22epgquuQFzXnU/feZTdNLARZagOZZpq9NV NCVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rfws2Cln; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9-v6si5831699pgf.380.2018.06.28.06.29.08; Thu, 28 Jun 2018 06:29:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rfws2Cln; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966256AbeF1N2C (ORCPT + 99 others); Thu, 28 Jun 2018 09:28:02 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49820 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753784AbeF1N07 (ORCPT ); Thu, 28 Jun 2018 09:26:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pKuPnBovgJ8+sywdr1QSI2Q8btKmadyyXncBiBb0Vtk=; b=rfws2ClnSSiSUXHWpu9Il866+ dUtsxucdfVlowMEAvUPWjdH75w/uVdHFGagndPN9v4NPMC1mUtKcoV9+8HaCsf1ttAmzwru9NM+W/ yO4MMdJrR/mJsD56PWvy7E+Wwq0MWI9zD3gFz97JpTPFEA9mqw36WGEo6+FFwPQ9hcsWd0bz8dJ5y +5//0DCbRsJE8hP+EZYwkZcd5l3Tju9OUp9I/T4bExkh7XI67QGzVMzMHpMfzd6EFPqiBIf4aIg2M /9RPIGiipfLTGHJYJ/rp9zFmVnLaRCF/7NIb+Zs/VZ17+s3D29SM6ePVnhLbYIeC561hjKno7Jlmm 9Az7M6Rpg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYWws-0000rY-Aq; Thu, 28 Jun 2018 13:26:58 +0000 From: Matthew Wilcox To: v9fs-developer@lists.sourceforge.net Cc: linux-fsdevel@vger.kernel.org, Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , linux-kernel@vger.kernel.org, Matthew Wilcox Subject: [PATCH 1/6] 9p: Change p9_fid_create calling convention Date: Thu, 28 Jun 2018 06:26:24 -0700 Message-Id: <20180628132629.3148-2-willy@infradead.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180628132629.3148-1-willy@infradead.org> References: <20180628132629.3148-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return NULL instead of ERR_PTR when we can't allocate a FID. The ENOSPC return value was getting all the way back to userspace, and that's confusing for a userspace program which isn't expecting read() to tell it there's no space left on the filesystem. The best error we can return to indicate a temporary failure caused by lack of client resources is ENOMEM. Maybe it would be better to sleep until a FID is available, but that's not a change I'm comfortable making. Signed-off-by: Matthew Wilcox --- net/9p/client.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 18c5271910dc..f8d58b0852fe 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -913,13 +913,11 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt); fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL); if (!fid) - return ERR_PTR(-ENOMEM); + return NULL; ret = p9_idpool_get(clnt->fidpool); - if (ret < 0) { - ret = -ENOSPC; + if (ret < 0) goto error; - } fid->fid = ret; memset(&fid->qid, 0, sizeof(struct p9_qid)); @@ -935,7 +933,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) error: kfree(fid); - return ERR_PTR(ret); + return NULL; } static void p9_fid_destroy(struct p9_fid *fid) @@ -1137,9 +1135,8 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, p9_debug(P9_DEBUG_9P, ">>> TATTACH afid %d uname %s aname %s\n", afid ? afid->fid : -1, uname, aname); fid = p9_fid_create(clnt); - if (IS_ERR(fid)) { - err = PTR_ERR(fid); - fid = NULL; + if (!fid) { + err = -ENOMEM; goto error; } fid->uid = n_uname; @@ -1188,9 +1185,8 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname, clnt = oldfid->clnt; if (clone) { fid = p9_fid_create(clnt); - if (IS_ERR(fid)) { - err = PTR_ERR(fid); - fid = NULL; + if (!fid) { + err = -ENOMEM; goto error; } @@ -2018,9 +2014,8 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid, err = 0; clnt = file_fid->clnt; attr_fid = p9_fid_create(clnt); - if (IS_ERR(attr_fid)) { - err = PTR_ERR(attr_fid); - attr_fid = NULL; + if (!attr_fid) { + err = -ENOMEM; goto error; } p9_debug(P9_DEBUG_9P, -- 2.18.0