Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp603805imu; Tue, 11 Dec 2018 04:43:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/WOD1yjlk8v90/4yRG7pkaGgoEsGBv5E/9MP2wrzs4sfOfn9BOpKY1wEAwBvfH+73CWApY3 X-Received: by 2002:a62:ce0e:: with SMTP id y14mr16854644pfg.100.1544532215125; Tue, 11 Dec 2018 04:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544532215; cv=none; d=google.com; s=arc-20160816; b=h2crBob/2wxY6tXNiWes0W7lW5eRv3S0O9DlJH+neQCqLW/+woLQcCJGQtRBaJK+Yf 0RkPTLsqMAXZ8V18ao7Lj7l35iUpvGWHa3EICMWcDvhczEkaJBS8S7X+wgLzxXiNUs3U qCtRVZaACIqG+UAU/XrfvgO7PHqjEPnPTQcBrGafwvq609k4MAab4A/OU6rYWDKUuuvJ /Oex05hmaDGTqmSQIHoq7BHbmAYst3YuEyAYv77cNApw4WIrI/bHlJKCCgC08PjmfNQi hcj6UYcAno+tk2QCYyMUsBrkbzAXgq9If5ztbFkgU/9V4IXROW+69qtI2JV7NsjBXbq9 /9uw== 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; bh=qy3aY1xT4gfJjLwzo9TP2FgBwBnMP9EgylT5z0WtIwU=; b=m5piDytLgEMxvoy3v7zULgAGDY8z10ThU6gsuDHDiiMhI6hAzKZQDqpKMpaJBhkBFN eZuz+qMDYCNtZtf1fltygz3ONH9Tw1IhBzyfVvIombrZe+AsjHXMqjQrTAEqOVMClw17 uEQIpYq3Fg1X71ApFYptNN6D5Eydm3qTQAhtZJ856MP5cnqklXMK2P6Bs95uRQ+ztgRC G047mVa9XfbJ6g/mz9fyKa5inrV1iBWFQiKSbPIVW70K+/Dm1ZX9zUzMn9J/rJ0c4UzJ IrU/7gbQBybDws34u83RLtLoaH9v5Q8cMY2JmgK7hvGmQhJmoUFgQyXoki0qTiFXnkQ6 USsA== ARC-Authentication-Results: i=1; mx.google.com; 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 o124si13008475pfb.256.2018.12.11.04.43.20; Tue, 11 Dec 2018 04:43:35 -0800 (PST) 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; 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 S1726452AbeLKMmS (ORCPT + 99 others); Tue, 11 Dec 2018 07:42:18 -0500 Received: from nautica.notk.org ([91.121.71.147]:49675 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeLKMmQ (ORCPT ); Tue, 11 Dec 2018 07:42:16 -0500 Received: by nautica.notk.org (Postfix, from userid 1001) id 54B71C01E; Tue, 11 Dec 2018 13:42:13 +0100 (CET) From: Dominique Martinet To: v9fs-developer@lists.sourceforge.net Cc: Dominique Martinet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Van Hensbergen , Latchesar Ionkov , Tomas Bortoli , Dmitry Vyukov Subject: [PATCH 2/3] 9p/net: make clunk asynchronous Date: Tue, 11 Dec 2018 13:41:47 +0100 Message-Id: <1544532108-21689-2-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1544532108-21689-1-git-send-email-asmadeus@codewreck.org> References: <1544532108-21689-1-git-send-email-asmadeus@codewreck.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dominique Martinet clunk is defined as making the fid invalid whatever the server returns, and we should ignore errors so it is a good candidate for async call. The change should make 9p slightly faster (many vfs systeme calls won't need to wait for that clunk), but more importantly the flush rework means we won't clear pending signals and the current implementation of "retry twice then leak the fid" will stop working, so this needed improving. Signed-off-by: Dominique Martinet Cc: Eric Van Hensbergen Cc: Latchesar Ionkov Cc: Tomas Bortoli Cc: Dmitry Vyukov --- include/net/9p/client.h | 4 ++ net/9p/client.c | 124 +++++++++++++++++++--------------------- 2 files changed, 62 insertions(+), 66 deletions(-) diff --git a/include/net/9p/client.h b/include/net/9p/client.h index a4ded7666c73..75d7f83e5b94 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -91,6 +91,7 @@ enum p9_req_status_t { * @aux: transport specific data (provided for trans_fd migration) * @req_list: link used by trans_fd * @async_list: link used to check on async requests + * @clunked_fid: for clunk, points to fid */ struct p9_req_t { int status; @@ -102,6 +103,9 @@ struct p9_req_t { void *aux; struct list_head req_list; struct list_head async_list; + union { + struct p9_fid *clunked_fid; + }; }; /** diff --git a/net/9p/client.c b/net/9p/client.c index 0a67c3ccd4fd..a47b5a54573d 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -649,6 +649,51 @@ static int p9_check_zc_errors(struct p9_client *c, struct p9_req_t *req, return err; } +static struct p9_fid *p9_fid_create(struct p9_client *clnt) +{ + int ret; + struct p9_fid *fid; + + p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt); + fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL); + if (!fid) + return NULL; + + memset(&fid->qid, 0, sizeof(struct p9_qid)); + fid->mode = -1; + fid->uid = current_fsuid(); + fid->clnt = clnt; + fid->rdir = NULL; + fid->fid = 0; + + idr_preload(GFP_KERNEL); + spin_lock_irq(&clnt->lock); + ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1, + GFP_NOWAIT); + spin_unlock_irq(&clnt->lock); + idr_preload_end(); + + if (!ret) + return fid; + + kfree(fid); + return NULL; +} + +static void p9_fid_destroy(struct p9_fid *fid) +{ + struct p9_client *clnt; + unsigned long flags; + + p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); + clnt = fid->clnt; + spin_lock_irqsave(&clnt->lock, flags); + idr_remove(&clnt->fids, fid->fid); + spin_unlock_irqrestore(&clnt->lock, flags); + kfree(fid->rdir); + kfree(fid); +} + static struct p9_req_t * p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); @@ -778,6 +823,9 @@ static void p9_client_handle_async(struct p9_client *c, bool free_all) } if (free_all || req->status >= REQ_STATUS_RCVD) { /* Put old refs whatever reqs actually returned */ + if (req->tc.id == P9_TCLUNK) { + p9_fid_destroy(req->clunked_fid); + } list_del(&req->async_list); p9_tag_remove(c, req); } @@ -959,51 +1007,6 @@ static struct p9_req_t *p9_client_zc_rpc(struct p9_client *c, int8_t type, return ERR_PTR(safe_errno(err)); } -static struct p9_fid *p9_fid_create(struct p9_client *clnt) -{ - int ret; - struct p9_fid *fid; - - p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt); - fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL); - if (!fid) - return NULL; - - memset(&fid->qid, 0, sizeof(struct p9_qid)); - fid->mode = -1; - fid->uid = current_fsuid(); - fid->clnt = clnt; - fid->rdir = NULL; - fid->fid = 0; - - idr_preload(GFP_KERNEL); - spin_lock_irq(&clnt->lock); - ret = idr_alloc_u32(&clnt->fids, fid, &fid->fid, P9_NOFID - 1, - GFP_NOWAIT); - spin_unlock_irq(&clnt->lock); - idr_preload_end(); - - if (!ret) - return fid; - - kfree(fid); - return NULL; -} - -static void p9_fid_destroy(struct p9_fid *fid) -{ - struct p9_client *clnt; - unsigned long flags; - - p9_debug(P9_DEBUG_FID, "fid %d\n", fid->fid); - clnt = fid->clnt; - spin_lock_irqsave(&clnt->lock, flags); - idr_remove(&clnt->fids, fid->fid); - spin_unlock_irqrestore(&clnt->lock, flags); - kfree(fid->rdir); - kfree(fid); -} - static int p9_client_version(struct p9_client *c) { int err = 0; @@ -1534,7 +1537,6 @@ int p9_client_clunk(struct p9_fid *fid) int err; struct p9_client *clnt; struct p9_req_t *req; - int retries = 0; if (!fid) { pr_warn("%s (%d): Trying to clunk with NULL fid\n", @@ -1543,33 +1545,23 @@ int p9_client_clunk(struct p9_fid *fid) return 0; } -again: - p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d (try %d)\n", fid->fid, - retries); + p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d\n", fid->fid); err = 0; clnt = fid->clnt; - req = p9_client_rpc(clnt, P9_TCLUNK, "d", fid->fid); + req = p9_client_async_rpc(clnt, P9_TCLUNK, "d", fid->fid); if (IS_ERR(req)) { - err = PTR_ERR(req); - goto error; + return PTR_ERR(req); } - p9_debug(P9_DEBUG_9P, "<<< RCLUNK fid %d\n", fid->fid); + p9_debug(P9_DEBUG_MUX, "sent clunk for fid %d, tag %d\n", + fid->fid, req->tc.tag); + req->clunked_fid = fid; + spin_lock_irq(&clnt->lock); + list_add(&req->async_list, &clnt->async_req_list); + spin_unlock_irq(&clnt->lock); - p9_tag_remove(clnt, req); -error: - /* - * Fid is not valid even after a failed clunk - * If interrupted, retry once then give up and - * leak fid until umount. - */ - if (err == -ERESTARTSYS) { - if (retries++ == 0) - goto again; - } else - p9_fid_destroy(fid); - return err; + return 0; } EXPORT_SYMBOL(p9_client_clunk); -- 2.19.2