Skip to content

Commit c44393d

Browse files
Eric Sandeenmartinetd
authored andcommitted
net/9p: move structures and macros to header files
With the new mount API all option parsing will need to happen in fs/v9fs.c, so move some existing data structures and macros to header files to facilitate this. Rename some to reflect the transport they are used for (rdma, fd, etc), for clarity. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Message-ID: <20251010214222.1347785-3-sandeen@redhat.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
1 parent 695f2ca commit c44393d

5 files changed

Lines changed: 49 additions & 47 deletions

File tree

include/net/9p/client.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
/* Number of requests per row */
1717
#define P9_ROW_MAXTAG 255
1818

19+
/* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ +
20+
* room for write (16 extra) or read (11 extra) operands.
21+
*/
22+
23+
#define DEFAULT_MSIZE ((128 * 1024) + P9_IOHDRSZ)
24+
1925
/** enum p9_proto_versions - 9P protocol versions
2026
* @p9_proto_legacy: 9P Legacy mode, pre-9P2000.u
2127
* @p9_proto_2000u: 9P2000.u extension

include/net/9p/transport.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,45 @@
1414
#define P9_DEF_MIN_RESVPORT (665U)
1515
#define P9_DEF_MAX_RESVPORT (1023U)
1616

17+
#define P9_FD_PORT 564
18+
19+
#define P9_RDMA_PORT 5640
20+
#define P9_RDMA_SQ_DEPTH 32
21+
#define P9_RDMA_RQ_DEPTH 32
22+
#define P9_RDMA_TIMEOUT 30000 /* 30 seconds */
23+
24+
/**
25+
* struct p9_fd_opts - per-transport options for fd transport
26+
* @rfd: file descriptor for reading (trans=fd)
27+
* @wfd: file descriptor for writing (trans=fd)
28+
* @port: port to connect to (trans=tcp)
29+
* @privport: port is privileged
30+
*/
31+
32+
struct p9_fd_opts {
33+
int rfd;
34+
int wfd;
35+
u16 port;
36+
bool privport;
37+
};
38+
39+
/**
40+
* struct p9_rdma_opts - Collection of mount options for rdma transport
41+
* @port: port of connection
42+
* @privport: Whether a privileged port may be used
43+
* @sq_depth: The requested depth of the SQ. This really doesn't need
44+
* to be any deeper than the number of threads used in the client
45+
* @rq_depth: The depth of the RQ. Should be greater than or equal to SQ depth
46+
* @timeout: Time to wait in msecs for CM events
47+
*/
48+
struct p9_rdma_opts {
49+
short port;
50+
bool privport;
51+
int sq_depth;
52+
int rq_depth;
53+
long timeout;
54+
};
55+
1756
/**
1857
* struct p9_trans_module - transport module interface
1958
* @list: used to maintain a list of currently available transports

net/9p/client.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
#define CREATE_TRACE_POINTS
3030
#include <trace/events/9p.h>
3131

32-
/* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ +
33-
* room for write (16 extra) or read (11 extra) operands.
34-
*/
35-
36-
#define DEFAULT_MSIZE ((128 * 1024) + P9_IOHDRSZ)
37-
3832
/* Client Option Parsing (code inspired by NFS code)
3933
* - a little lazy - parse all client options
4034
*/

net/9p/trans_fd.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,12 @@
3131

3232
#include <linux/syscalls.h> /* killme */
3333

34-
#define P9_PORT 564
3534
#define MAX_SOCK_BUF (1024*1024)
3635
#define MAXPOLLWADDR 2
3736

3837
static struct p9_trans_module p9_tcp_trans;
3938
static struct p9_trans_module p9_fd_trans;
4039

41-
/**
42-
* struct p9_fd_opts - per-transport options
43-
* @rfd: file descriptor for reading (trans=fd)
44-
* @wfd: file descriptor for writing (trans=fd)
45-
* @port: port to connect to (trans=tcp)
46-
* @privport: port is privileged
47-
*/
48-
49-
struct p9_fd_opts {
50-
int rfd;
51-
int wfd;
52-
u16 port;
53-
bool privport;
54-
};
55-
5640
/*
5741
* Option Parsing (code inspired by NFS code)
5842
* - a little lazy - parse all fd-transport options
@@ -742,7 +726,7 @@ static int p9_fd_cancelled(struct p9_client *client, struct p9_req_t *req)
742726
static int p9_fd_show_options(struct seq_file *m, struct p9_client *clnt)
743727
{
744728
if (clnt->trans_mod == &p9_tcp_trans) {
745-
if (clnt->trans_opts.tcp.port != P9_PORT)
729+
if (clnt->trans_opts.tcp.port != P9_FD_PORT)
746730
seq_printf(m, ",port=%u", clnt->trans_opts.tcp.port);
747731
} else if (clnt->trans_mod == &p9_fd_trans) {
748732
if (clnt->trans_opts.fd.rfd != ~0)
@@ -768,7 +752,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
768752
int option;
769753
char *options, *tmp_options;
770754

771-
opts->port = P9_PORT;
755+
opts->port = P9_FD_PORT;
772756
opts->rfd = ~0;
773757
opts->wfd = ~0;
774758
opts->privport = false;

net/9p/trans_rdma.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@
3232
#include <rdma/ib_verbs.h>
3333
#include <rdma/rdma_cm.h>
3434

35-
#define P9_PORT 5640
36-
#define P9_RDMA_SQ_DEPTH 32
37-
#define P9_RDMA_RQ_DEPTH 32
3835
#define P9_RDMA_SEND_SGE 4
3936
#define P9_RDMA_RECV_SGE 4
4037
#define P9_RDMA_IRD 0
4138
#define P9_RDMA_ORD 0
42-
#define P9_RDMA_TIMEOUT 30000 /* 30 seconds */
4339
#define P9_RDMA_MAXSIZE (1024*1024) /* 1MB */
4440

4541
/**
@@ -110,23 +106,6 @@ struct p9_rdma_context {
110106
};
111107
};
112108

113-
/**
114-
* struct p9_rdma_opts - Collection of mount options
115-
* @port: port of connection
116-
* @privport: Whether a privileged port may be used
117-
* @sq_depth: The requested depth of the SQ. This really doesn't need
118-
* to be any deeper than the number of threads used in the client
119-
* @rq_depth: The depth of the RQ. Should be greater than or equal to SQ depth
120-
* @timeout: Time to wait in msecs for CM events
121-
*/
122-
struct p9_rdma_opts {
123-
short port;
124-
bool privport;
125-
int sq_depth;
126-
int rq_depth;
127-
long timeout;
128-
};
129-
130109
/*
131110
* Option Parsing (code inspired by NFS code)
132111
*/
@@ -151,7 +130,7 @@ static int p9_rdma_show_options(struct seq_file *m, struct p9_client *clnt)
151130
{
152131
struct p9_trans_rdma *rdma = clnt->trans;
153132

154-
if (rdma->port != P9_PORT)
133+
if (rdma->port != P9_RDMA_PORT)
155134
seq_printf(m, ",port=%u", rdma->port);
156135
if (rdma->sq_depth != P9_RDMA_SQ_DEPTH)
157136
seq_printf(m, ",sq=%u", rdma->sq_depth);
@@ -178,7 +157,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
178157
int option;
179158
char *options, *tmp_options;
180159

181-
opts->port = P9_PORT;
160+
opts->port = P9_RDMA_PORT;
182161
opts->sq_depth = P9_RDMA_SQ_DEPTH;
183162
opts->rq_depth = P9_RDMA_RQ_DEPTH;
184163
opts->timeout = P9_RDMA_TIMEOUT;

0 commit comments

Comments
 (0)