aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/9p/v9fs.h1
-rw-r--r--fs/9p/vfs_addr.c2
-rw-r--r--fs/9p/vfs_file.c10
-rw-r--r--net/9p/protocol.c6
-rw-r--r--net/9p/trans_fd.c3
-rw-r--r--net/9p/trans_rdma.c52
-rw-r--r--net/9p/trans_virtio.c5
7 files changed, 58 insertions, 21 deletions
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 099c7712631c..fb9ffcb43277 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -78,7 +78,6 @@ enum p9_cache_modes {
78 * @cache: cache mode of type &p9_cache_modes 78 * @cache: cache mode of type &p9_cache_modes
79 * @cachetag: the tag of the cache associated with this session 79 * @cachetag: the tag of the cache associated with this session
80 * @fscache: session cookie associated with FS-Cache 80 * @fscache: session cookie associated with FS-Cache
81 * @options: copy of options string given by user
82 * @uname: string user name to mount hierarchy as 81 * @uname: string user name to mount hierarchy as
83 * @aname: mount specifier for remote hierarchy 82 * @aname: mount specifier for remote hierarchy
84 * @maxdata: maximum data to be sent/recvd per protocol message 83 * @maxdata: maximum data to be sent/recvd per protocol message
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index be35d05a4d0e..e9e04376c52c 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -231,9 +231,7 @@ static int v9fs_launder_page(struct page *page)
231/** 231/**
232 * v9fs_direct_IO - 9P address space operation for direct I/O 232 * v9fs_direct_IO - 9P address space operation for direct I/O
233 * @iocb: target I/O control block 233 * @iocb: target I/O control block
234 * @iov: array of vectors that define I/O buffer
235 * @pos: offset in file to begin the operation 234 * @pos: offset in file to begin the operation
236 * @nr_segs: size of iovec array
237 * 235 *
238 * The presence of v9fs_direct_IO() in the address space ops vector 236 * The presence of v9fs_direct_IO() in the address space ops vector
239 * allowes open() O_DIRECT flags which would have failed otherwise. 237 * allowes open() O_DIRECT flags which would have failed otherwise.
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 2a9dd37dc426..1ef16bd8280b 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -151,7 +151,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
151{ 151{
152 struct p9_flock flock; 152 struct p9_flock flock;
153 struct p9_fid *fid; 153 struct p9_fid *fid;
154 uint8_t status; 154 uint8_t status = P9_LOCK_ERROR;
155 int res = 0; 155 int res = 0;
156 unsigned char fl_type; 156 unsigned char fl_type;
157 157
@@ -196,7 +196,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
196 for (;;) { 196 for (;;) {
197 res = p9_client_lock_dotl(fid, &flock, &status); 197 res = p9_client_lock_dotl(fid, &flock, &status);
198 if (res < 0) 198 if (res < 0)
199 break; 199 goto out_unlock;
200 200
201 if (status != P9_LOCK_BLOCKED) 201 if (status != P9_LOCK_BLOCKED)
202 break; 202 break;
@@ -214,14 +214,16 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
214 case P9_LOCK_BLOCKED: 214 case P9_LOCK_BLOCKED:
215 res = -EAGAIN; 215 res = -EAGAIN;
216 break; 216 break;
217 default:
218 WARN_ONCE(1, "unknown lock status code: %d\n", status);
219 /* fallthough */
217 case P9_LOCK_ERROR: 220 case P9_LOCK_ERROR:
218 case P9_LOCK_GRACE: 221 case P9_LOCK_GRACE:
219 res = -ENOLCK; 222 res = -ENOLCK;
220 break; 223 break;
221 default:
222 BUG();
223 } 224 }
224 225
226out_unlock:
225 /* 227 /*
226 * incase server returned error for lock request, revert 228 * incase server returned error for lock request, revert
227 * it locally 229 * it locally
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index e9d0f0c1a048..16d287565987 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -275,7 +275,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
275 } 275 }
276 break; 276 break;
277 case 'R':{ 277 case 'R':{
278 int16_t *nwqid = va_arg(ap, int16_t *); 278 uint16_t *nwqid = va_arg(ap, uint16_t *);
279 struct p9_qid **wqids = 279 struct p9_qid **wqids =
280 va_arg(ap, struct p9_qid **); 280 va_arg(ap, struct p9_qid **);
281 281
@@ -440,7 +440,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
440 stbuf->n_gid, stbuf->n_muid); 440 stbuf->n_gid, stbuf->n_muid);
441 } break; 441 } break;
442 case 'V':{ 442 case 'V':{
443 int32_t count = va_arg(ap, int32_t); 443 uint32_t count = va_arg(ap, uint32_t);
444 struct iov_iter *from = 444 struct iov_iter *from =
445 va_arg(ap, struct iov_iter *); 445 va_arg(ap, struct iov_iter *);
446 errcode = p9pdu_writef(pdu, proto_version, "d", 446 errcode = p9pdu_writef(pdu, proto_version, "d",
@@ -471,7 +471,7 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
471 } 471 }
472 break; 472 break;
473 case 'R':{ 473 case 'R':{
474 int16_t nwqid = va_arg(ap, int); 474 uint16_t nwqid = va_arg(ap, int);
475 struct p9_qid *wqids = 475 struct p9_qid *wqids =
476 va_arg(ap, struct p9_qid *); 476 va_arg(ap, struct p9_qid *);
477 477
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 3e3d82d8ff70..bced8c074c12 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -734,6 +734,7 @@ static int parse_opts(char *params, struct p9_fd_opts *opts)
734 opts->port = P9_PORT; 734 opts->port = P9_PORT;
735 opts->rfd = ~0; 735 opts->rfd = ~0;
736 opts->wfd = ~0; 736 opts->wfd = ~0;
737 opts->privport = 0;
737 738
738 if (!params) 739 if (!params)
739 return 0; 740 return 0;
@@ -1013,7 +1014,6 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1013{ 1014{
1014 int err; 1015 int err;
1015 struct p9_fd_opts opts; 1016 struct p9_fd_opts opts;
1016 struct p9_trans_fd *p;
1017 1017
1018 parse_opts(args, &opts); 1018 parse_opts(args, &opts);
1019 1019
@@ -1026,7 +1026,6 @@ p9_fd_create(struct p9_client *client, const char *addr, char *args)
1026 if (err < 0) 1026 if (err < 0)
1027 return err; 1027 return err;
1028 1028
1029 p = (struct p9_trans_fd *) client->trans;
1030 p9_conn_create(client); 1029 p9_conn_create(client);
1031 1030
1032 return 0; 1031 return 0;
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 14ad43b5cf89..3533d2a53ab6 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -139,6 +139,7 @@ struct p9_rdma_opts {
139 int sq_depth; 139 int sq_depth;
140 int rq_depth; 140 int rq_depth;
141 long timeout; 141 long timeout;
142 int privport;
142}; 143};
143 144
144/* 145/*
@@ -146,7 +147,10 @@ struct p9_rdma_opts {
146 */ 147 */
147enum { 148enum {
148 /* Options that take integer arguments */ 149 /* Options that take integer arguments */
149 Opt_port, Opt_rq_depth, Opt_sq_depth, Opt_timeout, Opt_err, 150 Opt_port, Opt_rq_depth, Opt_sq_depth, Opt_timeout,
151 /* Options that take no argument */
152 Opt_privport,
153 Opt_err,
150}; 154};
151 155
152static match_table_t tokens = { 156static match_table_t tokens = {
@@ -154,6 +158,7 @@ static match_table_t tokens = {
154 {Opt_sq_depth, "sq=%u"}, 158 {Opt_sq_depth, "sq=%u"},
155 {Opt_rq_depth, "rq=%u"}, 159 {Opt_rq_depth, "rq=%u"},
156 {Opt_timeout, "timeout=%u"}, 160 {Opt_timeout, "timeout=%u"},
161 {Opt_privport, "privport"},
157 {Opt_err, NULL}, 162 {Opt_err, NULL},
158}; 163};
159 164
@@ -175,6 +180,7 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
175 opts->sq_depth = P9_RDMA_SQ_DEPTH; 180 opts->sq_depth = P9_RDMA_SQ_DEPTH;
176 opts->rq_depth = P9_RDMA_RQ_DEPTH; 181 opts->rq_depth = P9_RDMA_RQ_DEPTH;
177 opts->timeout = P9_RDMA_TIMEOUT; 182 opts->timeout = P9_RDMA_TIMEOUT;
183 opts->privport = 0;
178 184
179 if (!params) 185 if (!params)
180 return 0; 186 return 0;
@@ -193,13 +199,13 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
193 if (!*p) 199 if (!*p)
194 continue; 200 continue;
195 token = match_token(p, tokens, args); 201 token = match_token(p, tokens, args);
196 if (token == Opt_err) 202 if ((token != Opt_err) && (token != Opt_privport)) {
197 continue; 203 r = match_int(&args[0], &option);
198 r = match_int(&args[0], &option); 204 if (r < 0) {
199 if (r < 0) { 205 p9_debug(P9_DEBUG_ERROR,
200 p9_debug(P9_DEBUG_ERROR, 206 "integer field, but no integer?\n");
201 "integer field, but no integer?\n"); 207 continue;
202 continue; 208 }
203 } 209 }
204 switch (token) { 210 switch (token) {
205 case Opt_port: 211 case Opt_port:
@@ -214,6 +220,9 @@ static int parse_opts(char *params, struct p9_rdma_opts *opts)
214 case Opt_timeout: 220 case Opt_timeout:
215 opts->timeout = option; 221 opts->timeout = option;
216 break; 222 break;
223 case Opt_privport:
224 opts->privport = 1;
225 break;
217 default: 226 default:
218 continue; 227 continue;
219 } 228 }
@@ -607,6 +616,23 @@ static int rdma_cancelled(struct p9_client *client, struct p9_req_t *req)
607 return 0; 616 return 0;
608} 617}
609 618
619static int p9_rdma_bind_privport(struct p9_trans_rdma *rdma)
620{
621 struct sockaddr_in cl = {
622 .sin_family = AF_INET,
623 .sin_addr.s_addr = htonl(INADDR_ANY),
624 };
625 int port, err = -EINVAL;
626
627 for (port = P9_DEF_MAX_RESVPORT; port >= P9_DEF_MIN_RESVPORT; port--) {
628 cl.sin_port = htons((ushort)port);
629 err = rdma_bind_addr(rdma->cm_id, (struct sockaddr *)&cl);
630 if (err != -EADDRINUSE)
631 break;
632 }
633 return err;
634}
635
610/** 636/**
611 * trans_create_rdma - Transport method for creating atransport instance 637 * trans_create_rdma - Transport method for creating atransport instance
612 * @client: client instance 638 * @client: client instance
@@ -642,6 +668,16 @@ rdma_create_trans(struct p9_client *client, const char *addr, char *args)
642 /* Associate the client with the transport */ 668 /* Associate the client with the transport */
643 client->trans = rdma; 669 client->trans = rdma;
644 670
671 /* Bind to a privileged port if we need to */
672 if (opts.privport) {
673 err = p9_rdma_bind_privport(rdma);
674 if (err < 0) {
675 pr_err("%s (%d): problem binding to privport: %d\n",
676 __func__, task_pid_nr(current), -err);
677 goto error;
678 }
679 }
680
645 /* Resolve the server's address */ 681 /* Resolve the server's address */
646 rdma->addr.sin_family = AF_INET; 682 rdma->addr.sin_family = AF_INET;
647 rdma->addr.sin_addr.s_addr = in_aton(addr); 683 rdma->addr.sin_addr.s_addr = in_aton(addr);
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index e62bcbbabb5e..9dd49ca67dbc 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -525,7 +525,10 @@ static ssize_t p9_mount_tag_show(struct device *dev,
525 vdev = dev_to_virtio(dev); 525 vdev = dev_to_virtio(dev);
526 chan = vdev->priv; 526 chan = vdev->priv;
527 527
528 return snprintf(buf, chan->tag_len + 1, "%s", chan->tag); 528 memcpy(buf, chan->tag, chan->tag_len);
529 buf[chan->tag_len] = 0;
530
531 return chan->tag_len + 1;
529} 532}
530 533
531static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL); 534static DEVICE_ATTR(mount_tag, 0444, p9_mount_tag_show, NULL);