Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1198639imm; Wed, 11 Jul 2018 19:56:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWEPGPp+0iTngjqnLEqIkhZhZWARzqKmZA/N6w4C5ismkwr4GqKAhxVtKv6gDHcA5HDLef X-Received: by 2002:a62:fd06:: with SMTP id p6-v6mr443619pfh.167.1531364186261; Wed, 11 Jul 2018 19:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531364186; cv=none; d=google.com; s=arc-20160816; b=Rta7MniTMPW8U1jC4e9/nzxJ7NRRtlhb2LesjAqbnG3L0w+3td5BUO+dOaW8OIfxmX +urULJ+SnC9JmymgsKne6w2iZvikq2srTmJSrEHINM1aLoW+nOrTX+ch7viMFUuh978K AkSXEicpG2k84VRUBiwd3rmmjzaLQwsqoFqCLMybY7QkL4mTytmvofDTPEggnffAJ1l2 2wpoiTJKlr28RGvaNZz4sL5dtq24WOzGnr/NHn5EfAp21E/+H8UjLJNqyhwGh7qqpo9g 9lXi5/LgsorpeLWe6KcHy9lWsrAjMT6+oDcozTdqVoW7UGGBtJ0m8v17GM+wzdRdhjMt Zftg== 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=KQwMWMrlfhptUGUgG/1qH/mpQGgKQiKOF01kGmprnow=; b=NaIcJ07Gjlll4EjS6+pZb+H9NpBjUIIpCUfWwqb8Urs2mNMQXMCGpO9gflisTWEzta SH6b1mH8zNNiK5489xy5PeUOkururkOxzbKNiaD5FYVx4LJ5QqNWhI03SHspe+JGlAY9 JoFAi/M7taMG0mpWQs14L6Jg18Epj7rgPThs2vKA/wRuwopqiq8a3b2Oes8f2T4RFZHk DRSpsmCsoUaFT3HUVT2ut49915DKeUlGWNrdKe/F5DrHBFXFV5IYwwkK568pljCO3P1x ljVBRVcOvWdPkFezoycp5Rd0e6ZsKGdRCYlkTh1khJ8OpMOOIzgWbQGC8xnO5yiz2CEk X3dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=RbcNPTfd; 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 1-v6si21145750plt.342.2018.07.11.19.56.11; Wed, 11 Jul 2018 19:56:26 -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=RbcNPTfd; 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 S2390456AbeGKVIz (ORCPT + 99 others); Wed, 11 Jul 2018 17:08:55 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:47018 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733024AbeGKVIx (ORCPT ); Wed, 11 Jul 2018 17:08:53 -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=KQwMWMrlfhptUGUgG/1qH/mpQGgKQiKOF01kGmprnow=; b=RbcNPTfdCsiVDP9Jggb2HBgbi /XB+I6TUMW361TaJgCthxZnQm8CZNLY7x9iwAEAtoFyXO5CBFciv92nCWtQgqqsbRlQGiEd4mU8PU U4XNdVyLNF7EVNFI27Ud1WbIwyXCLDp3a2fG19TgjU7mT3foZnTDqSOApei3gCn3I290Cv+LpCH41 X1uA9f74kVMBBnYIDRiOwNCW+BDPeqmJyT2cFK40uKkSZPDnefyIX/KOFzc9gOF5942J9GLSmugTk 6dMy9+EMgaoIOqUhm/PaNH9bii1xYS3VZDoEGQwK6UJXr3Vvb7JxoVDvAeFDdH62kW0AFoHOuM+cm SxYhfvm3Q==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdMFq-0005AB-01; Wed, 11 Jul 2018 21:02:30 +0000 From: Matthew Wilcox To: Dominique Martinet Cc: Matthew Wilcox , v9fs-developer@lists.sourceforge.net, Latchesar Ionkov , Eric Van Hensbergen , Ron Minnich , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 2/6] 9p: Change p9_fid_create calling convention Date: Wed, 11 Jul 2018 14:02:21 -0700 Message-Id: <20180711210225.19730-3-willy@infradead.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180711210225.19730-1-willy@infradead.org> References: <20180711210225.19730-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 999eceb8af98..389a2904b7b3 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