Skip to content

Commit 996d5b4

Browse files
Matthew WilcoxDominique Martinet
authored andcommitted
9p: Use a slab for allocating requests
Replace the custom batch allocation with a slab. Use an IDR to store pointers to the active requests instead of an array. We don't try to handle P9_NOTAG specially; the IDR will happily shrink all the way back once the TVERSION call has completed. Link: http://lkml.kernel.org/r/20180711210225.19730-6-willy@infradead.org Signed-off-by: Matthew Wilcox <willy@infradead.org> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr>
1 parent 62e3941 commit 996d5b4

3 files changed

Lines changed: 102 additions & 196 deletions

File tree

‎include/net/9p/client.h‎

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,15 @@ enum p9_trans_status {
6464

6565
/**
6666
* enum p9_req_status_t - status of a request
67-
* @REQ_STATUS_IDLE: request slot unused
6867
* @REQ_STATUS_ALLOC: request has been allocated but not sent
6968
* @REQ_STATUS_UNSENT: request waiting to be sent
7069
* @REQ_STATUS_SENT: request sent to server
7170
* @REQ_STATUS_RCVD: response received from server
7271
* @REQ_STATUS_FLSHD: request has been flushed
7372
* @REQ_STATUS_ERROR: request encountered an error on the client side
74-
*
75-
* The @REQ_STATUS_IDLE state is used to mark a request slot as unused
76-
* but use is actually tracked by the idpool structure which handles tag
77-
* id allocation.
78-
*
7973
*/
8074

8175
enum p9_req_status_t {
82-
REQ_STATUS_IDLE,
8376
REQ_STATUS_ALLOC,
8477
REQ_STATUS_UNSENT,
8578
REQ_STATUS_SENT,
@@ -92,65 +85,39 @@ enum p9_req_status_t {
9285
* struct p9_req_t - request slots
9386
* @status: status of this request slot
9487
* @t_err: transport error
95-
* @flush_tag: tag of request being flushed (for flush requests)
9688
* @wq: wait_queue for the client to block on for this request
9789
* @tc: the request fcall structure
9890
* @rc: the response fcall structure
9991
* @aux: transport specific data (provided for trans_fd migration)
10092
* @req_list: link for higher level objects to chain requests
101-
*
102-
* Transport use an array to track outstanding requests
103-
* instead of a list. While this may incurr overhead during initial
104-
* allocation or expansion, it makes request lookup much easier as the
105-
* tag id is a index into an array. (We use tag+1 so that we can accommodate
106-
* the -1 tag for the T_VERSION request).
107-
* This also has the nice effect of only having to allocate wait_queues
108-
* once, instead of constantly allocating and freeing them. Its possible
109-
* other resources could benefit from this scheme as well.
110-
*
11193
*/
112-
11394
struct p9_req_t {
11495
int status;
11596
int t_err;
11697
wait_queue_head_t wq;
11798
struct p9_fcall *tc;
11899
struct p9_fcall *rc;
119100
void *aux;
120-
121101
struct list_head req_list;
122102
};
123103

124104
/**
125105
* struct p9_client - per client instance state
126-
* @lock: protect @fidlist
106+
* @lock: protect @fids and @reqs
127107
* @msize: maximum data size negotiated by protocol
128-
* @dotu: extension flags negotiated by protocol
129108
* @proto_version: 9P protocol version to use
130109
* @trans_mod: module API instantiated with this client
110+
* @status: connection state
131111
* @trans: tranport instance state and API
132112
* @fids: All active FID handles
133-
* @tagpool - transaction id accounting for session
134-
* @reqs - 2D array of requests
135-
* @max_tag - current maximum tag id allocated
136-
* @name - node name used as client id
113+
* @reqs: All active requests.
114+
* @name: node name used as client id
137115
*
138116
* The client structure is used to keep track of various per-client
139117
* state that has been instantiated.
140-
* In order to minimize per-transaction overhead we use a
141-
* simple array to lookup requests instead of a hash table
142-
* or linked list. In order to support larger number of
143-
* transactions, we make this a 2D array, allocating new rows
144-
* when we need to grow the total number of the transactions.
145-
*
146-
* Each row is 256 requests and we'll support up to 256 rows for
147-
* a total of 64k concurrent requests per session.
148-
*
149-
* Bugs: duplicated data and potentially unnecessary elements.
150118
*/
151-
152119
struct p9_client {
153-
spinlock_t lock; /* protect client structure */
120+
spinlock_t lock;
154121
unsigned int msize;
155122
unsigned char proto_version;
156123
struct p9_trans_module *trans_mod;
@@ -170,10 +137,7 @@ struct p9_client {
170137
} trans_opts;
171138

172139
struct idr fids;
173-
174-
struct p9_idpool *tagpool;
175-
struct p9_req_t *reqs[P9_ROW_MAXTAG];
176-
int max_tag;
140+
struct idr reqs;
177141

178142
char name[__NEW_UTS_LEN + 1];
179143
};
@@ -279,4 +243,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *);
279243
int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int);
280244
int p9_client_readlink(struct p9_fid *fid, char **target);
281245

246+
int p9_client_init(void);
247+
void p9_client_exit(void);
248+
282249
#endif /* NET_9P_CLIENT_H */

0 commit comments

Comments
 (0)