Skip to content

Commit afd8d65

Browse files
sderrericvh
authored andcommitted
9P: Add cancelled() to the transport functions.
And move transport-specific code out of net/9p/client.c Signed-off-by: Simon Derr <simon.derr@bull.net> Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
1 parent 05a782d commit afd8d65

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

include/net/9p/transport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
* @close: member function to discard a connection on this transport
4141
* @request: member function to issue a request to the transport
4242
* @cancel: member function to cancel a request (if it hasn't been sent)
43+
* @cancelled: member function to notify that a cancelled request will not
44+
* not receive a reply
4345
*
4446
* This is the basic API for a transport module which is registered by the
4547
* transport module with the 9P core network module and used by the client
@@ -58,6 +60,7 @@ struct p9_trans_module {
5860
void (*close) (struct p9_client *);
5961
int (*request) (struct p9_client *, struct p9_req_t *req);
6062
int (*cancel) (struct p9_client *, struct p9_req_t *req);
63+
int (*cancelled)(struct p9_client *, struct p9_req_t *req);
6164
int (*zc_request)(struct p9_client *, struct p9_req_t *,
6265
char *, char *, int , int, int, int);
6366
};

net/9p/client.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,16 +663,13 @@ static int p9_client_flush(struct p9_client *c, struct p9_req_t *oldreq)
663663
if (IS_ERR(req))
664664
return PTR_ERR(req);
665665

666-
667666
/*
668667
* if we haven't received a response for oldreq,
669668
* remove it from the list
670669
*/
671-
if (oldreq->status == REQ_STATUS_FLSH) {
672-
spin_lock(&c->lock);
673-
list_del(&oldreq->req_list);
674-
spin_unlock(&c->lock);
675-
}
670+
if (oldreq->status == REQ_STATUS_FLSH)
671+
if (c->trans_mod->cancelled)
672+
c->trans_mod->cancelled(c, oldreq);
676673

677674
p9_free_req(c, req);
678675
return 0;

net/9p/trans_fd.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,20 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req)
709709
return ret;
710710
}
711711

712+
static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)
713+
{
714+
p9_debug(P9_DEBUG_TRANS, "client %p req %p\n", client, req);
715+
716+
/* we haven't received a response for oldreq,
717+
* remove it from the list.
718+
*/
719+
spin_lock(&client->lock);
720+
list_del(&req->req_list);
721+
spin_unlock(&client->lock);
722+
723+
return 0;
724+
}
725+
712726
/**
713727
* parse_opts - parse mount options into p9_fd_opts structure
714728
* @params: options string passed from mount
@@ -1050,6 +1064,7 @@ static struct p9_trans_module p9_tcp_trans = {
10501064
.close = p9_fd_close,
10511065
.request = p9_fd_request,
10521066
.cancel = p9_fd_cancel,
1067+
.cancelled = p9_fd_cancelled,
10531068
.owner = THIS_MODULE,
10541069
};
10551070

@@ -1061,6 +1076,7 @@ static struct p9_trans_module p9_unix_trans = {
10611076
.close = p9_fd_close,
10621077
.request = p9_fd_request,
10631078
.cancel = p9_fd_cancel,
1079+
.cancelled = p9_fd_cancelled,
10641080
.owner = THIS_MODULE,
10651081
};
10661082

@@ -1072,6 +1088,7 @@ static struct p9_trans_module p9_fd_trans = {
10721088
.close = p9_fd_close,
10731089
.request = p9_fd_request,
10741090
.cancel = p9_fd_cancel,
1091+
.cancelled = p9_fd_cancelled,
10751092
.owner = THIS_MODULE,
10761093
};
10771094

0 commit comments

Comments
 (0)