From patchwork Mon Mar 10 15:38:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Derr X-Patchwork-Id: 3804141 X-Patchwork-Delegate: ericvh@gmail.com Return-Path: X-Original-To: patchwork-v9fs-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 33BBE9F370 for ; Mon, 10 Mar 2014 16:11:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CD69202AE for ; Mon, 10 Mar 2014 16:11:43 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4967A2021E for ; Mon, 10 Mar 2014 16:11:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WN2nR-0000kv-0Q; Mon, 10 Mar 2014 16:11:21 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WN2nP-0000kZ-6g for v9fs-developer@lists.sourceforge.net; Mon, 10 Mar 2014 16:11:19 +0000 X-ACL-Warn: Received: from ecfrec.frec.bull.fr ([129.183.4.8]) by sog-mx-4.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1WN2nJ-00047r-GI for v9fs-developer@lists.sourceforge.net; Mon, 10 Mar 2014 16:11:19 +0000 Received: from atlas.frec.bull.fr (atlas.frec.bull.fr [129.183.91.13]) by ecfrec.frec.bull.fr (Postfix) with ESMTP id 920DA6F59B; Mon, 10 Mar 2014 16:39:11 +0100 (CET) Received: from atlas.frec.bull.fr (localhost [127.0.0.1]) by atlas.frec.bull.fr (Postfix) with ESMTP id DCE05A1850; Mon, 10 Mar 2014 16:39:09 +0100 (CET) Received: (from derr@localhost) by atlas.frec.bull.fr (8.14.4/8.14.4/Submit) id s2AFd9mW015153; Mon, 10 Mar 2014 16:39:09 +0100 From: Simon Derr To: v9fs-developer@lists.sourceforge.net Date: Mon, 10 Mar 2014 16:38:49 +0100 Message-Id: <1394465932-11520-2-git-send-email-simon.derr@bull.net> X-Mailer: git-send-email 1.7.10.1 In-Reply-To: <1394465932-11520-1-git-send-email-simon.derr@bull.net> References: <1394465932-11520-1-git-send-email-simon.derr@bull.net> X-Spam-Score: -0.0 (/) X-Headers-End: 1WN2nJ-00047r-GI Subject: [V9fs-developer] [PATCH 1/4] 9P: Add cancelled() to the transport functions. X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 And move transport-specific code out of net/9p/client.c Signed-off-by: Simon Derr --- include/net/9p/transport.h | 3 +++ net/9p/client.c | 9 +++------ net/9p/trans_fd.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h index 9a36d92..d9fa68f 100644 --- a/include/net/9p/transport.h +++ b/include/net/9p/transport.h @@ -40,6 +40,8 @@ * @close: member function to discard a connection on this transport * @request: member function to issue a request to the transport * @cancel: member function to cancel a request (if it hasn't been sent) + * @cancelled: member function to notify that a cancelled request will not + * not receive a reply * * This is the basic API for a transport module which is registered by the * transport module with the 9P core network module and used by the client @@ -58,6 +60,7 @@ struct p9_trans_module { void (*close) (struct p9_client *); int (*request) (struct p9_client *, struct p9_req_t *req); int (*cancel) (struct p9_client *, struct p9_req_t *req); + int (*cancelled)(struct p9_client *, struct p9_req_t *req); int (*zc_request)(struct p9_client *, struct p9_req_t *, char *, char *, int , int, int, int); }; diff --git a/net/9p/client.c b/net/9p/client.c index 95b1836..354bfb8 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -663,16 +663,13 @@ static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq) if (IS_ERR(req)) return PTR_ERR(req); - /* * if we haven't received a response for oldreq, * remove it from the list */ - if (oldreq->status == REQ_STATUS_FLSH) { - spin_lock(&c->lock); - list_del(&oldreq->req_list); - spin_unlock(&c->lock); - } + if (oldreq->status == REQ_STATUS_FLSH) + if (c->trans_mod->cancelled) + c->trans_mod->cancelled(c, oldreq); p9_free_req(c, req); return 0; diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c index 193efd5..fda4951 100644 --- a/net/9p/trans_fd.c +++ b/net/9p/trans_fd.c @@ -709,6 +709,20 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req) return ret; } +static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req) +{ + p9_debug(P9_DEBUG_TRANS, "client %p req %p\n", client, req); + + /* we haven't received a response for oldreq, + * remove it from the list. + */ + spin_lock(&client->lock); + list_del(&req->req_list); + spin_unlock(&client->lock); + + return 0; +} + /** * parse_opts - parse mount options into p9_fd_opts structure * @params: options string passed from mount @@ -1050,6 +1064,7 @@ static struct p9_trans_module p9_tcp_trans = { .close = p9_fd_close, .request = p9_fd_request, .cancel = p9_fd_cancel, + .cancelled = p9_fd_cancelled, .owner = THIS_MODULE, }; @@ -1061,6 +1076,7 @@ static struct p9_trans_module p9_unix_trans = { .close = p9_fd_close, .request = p9_fd_request, .cancel = p9_fd_cancel, + .cancelled = p9_fd_cancelled, .owner = THIS_MODULE, }; @@ -1072,6 +1088,7 @@ static struct p9_trans_module p9_fd_trans = { .close = p9_fd_close, .request = p9_fd_request, .cancel = p9_fd_cancel, + .cancelled = p9_fd_cancelled, .owner = THIS_MODULE, };