Skip to content

Commit bdcb864

Browse files
committed
Merge tag '9p-for-7.1-rc1' of https://github.com/martinetd/linux
Pull 9p updates from Dominique Martinet: - 9p access flag fix (cannot change access flag since new mount API implem) - some minor cleanup * tag '9p-for-7.1-rc1' of https://github.com/martinetd/linux: 9p/trans_xen: replace simple_strto* with kstrtouint 9p/trans_xen: make cleanup idempotent after dataring alloc errors 9p: document missing enum values in kernel-doc comments 9p: fix access mode flags being ORed instead of replaced 9p: fix memory leak in v9fs_init_fs_context error path
2 parents f9569c6 + 8fc518e commit bdcb864

4 files changed

Lines changed: 95 additions & 30 deletions

File tree

fs/9p/v9fs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,11 @@ static void v9fs_apply_options(struct v9fs_session_info *v9ses,
413413
/*
414414
* Note that we must |= flags here as session_init already
415415
* set basic flags. This adds in flags from parsed options.
416+
* Default access flags must be cleared if session options
417+
* changes them to avoid mangling the setting.
416418
*/
419+
if (ctx->session_opts.flags & V9FS_ACCESS_MASK)
420+
v9ses->flags &= ~V9FS_ACCESS_MASK;
417421
v9ses->flags |= ctx->session_opts.flags;
418422
#ifdef CONFIG_9P_FSCACHE
419423
v9ses->cachetag = ctx->session_opts.cachetag;

fs/9p/vfs_super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ static int v9fs_init_fs_context(struct fs_context *fc)
312312
if (!ctx)
313313
return -ENOMEM;
314314

315+
fc->ops = &v9fs_context_ops;
316+
fc->fs_private = ctx;
317+
315318
/* initialize core options */
316319
ctx->session_opts.afid = ~0;
317320
ctx->session_opts.cache = CACHE_NONE;
@@ -345,9 +348,6 @@ static int v9fs_init_fs_context(struct fs_context *fc)
345348
ctx->rdma_opts.timeout = P9_RDMA_TIMEOUT;
346349
ctx->rdma_opts.privport = false;
347350

348-
fc->ops = &v9fs_context_ops;
349-
fc->fs_private = ctx;
350-
351351
return 0;
352352
error:
353353
fc->need_free = 1;

include/net/9p/9p.h

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* @P9_DEBUG_PKT: packet marshalling/unmarshalling
2525
* @P9_DEBUG_FSC: FS-cache tracing
2626
* @P9_DEBUG_VPKT: Verbose packet debugging (full packet dump)
27+
* @P9_DEBUG_CACHE: cache operations tracing
28+
* @P9_DEBUG_MMAP: memory-mapped I/O tracing
2729
*
2830
* These flags are passed at mount time to turn on various levels of
2931
* verbosity and tracing which will be output to the system logs.
@@ -68,13 +70,39 @@ void _p9_debug(enum p9_debug_flags level, const char *func,
6870
* @P9_RSYMLINK: make symlink response
6971
* @P9_TMKNOD: create a special file object request
7072
* @P9_RMKNOD: create a special file object response
73+
* @P9_TLOPEN: open a file for I/O (9P2000.L)
74+
* @P9_RLOPEN: response with qid and iounit (9P2000.L)
7175
* @P9_TLCREATE: prepare a handle for I/O on an new file for 9P2000.L
7276
* @P9_RLCREATE: response with file access information for 9P2000.L
7377
* @P9_TRENAME: rename request
7478
* @P9_RRENAME: rename response
75-
* @P9_TMKDIR: create a directory request
76-
* @P9_RMKDIR: create a directory response
77-
* @P9_TVERSION: version handshake request
79+
* @P9_TREADLINK: read symbolic link target (9P2000.L)
80+
* @P9_RREADLINK: response with symbolic link target (9P2000.L)
81+
* @P9_TGETATTR: get file attributes request (9P2000.L)
82+
* @P9_RGETATTR: get file attributes response (9P2000.L)
83+
* @P9_TSETATTR: set file attributes request (9P2000.L)
84+
* @P9_RSETATTR: set file attributes response (9P2000.L)
85+
* @P9_TXATTRWALK: prepare to read/list extended attributes (9P2000.L)
86+
* @P9_RXATTRWALK: response with extended attribute size (9P2000.L)
87+
* @P9_TXATTRCREATE: prepare to set extended attribute (9P2000.L)
88+
* @P9_RXATTRCREATE: set extended attribute response (9P2000.L)
89+
* @P9_TREADDIR: read directory entries request (9P2000.L)
90+
* @P9_RREADDIR: read directory entries response (9P2000.L)
91+
* @P9_TFSYNC: flush cached file data to storage request (9P2000.L)
92+
* @P9_RFSYNC: flush cached file data to storage response (9P2000.L)
93+
* @P9_TLOCK: acquire or release a POSIX record lock (9P2000.L)
94+
* @P9_RLOCK: POSIX record lock response (9P2000.L)
95+
* @P9_TGETLOCK: test for existence of POSIX record lock (9P2000.L)
96+
* @P9_RGETLOCK: POSIX record lock test response (9P2000.L)
97+
* @P9_TLINK: create a hard link (9P2000.L)
98+
* @P9_RLINK: hard link response (9P2000.L)
99+
* @P9_TRENAMEAT: safely rename across directories (9P2000.L)
100+
* @P9_RRENAMEAT: rename response (9P2000.L)
101+
* @P9_TUNLINKAT: unlink a file or directory (9P2000.L)
102+
* @P9_RUNLINKAT: unlink response (9P2000.L)
103+
* @P9_TMKDIR: create a directory request (9P2000.L)
104+
* @P9_RMKDIR: create a directory response (9P2000.L)
105+
* @P9_TVERSION: negotiate protocol version and message size
78106
* @P9_RVERSION: version handshake response
79107
* @P9_TAUTH: request to establish authentication channel
80108
* @P9_RAUTH: response with authentication information
@@ -194,6 +222,10 @@ enum p9_msg_t {
194222
* @P9_ORCLOSE: remove the file when the file is closed
195223
* @P9_OAPPEND: open the file and seek to the end
196224
* @P9_OEXCL: only create a file, do not open it
225+
* @P9L_MODE_MASK: mask for protocol mode bits (client-side only)
226+
* @P9L_DIRECT: disable client-side caching for this file
227+
* @P9L_NOWRITECACHE: disable write caching for this file
228+
* @P9L_LOOSE: enable loose cache consistency
197229
*
198230
* 9P open modes differ slightly from Posix standard modes.
199231
* In particular, there are extra modes which specify different

net/9p/trans_xen.c

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -283,25 +283,33 @@ static void xen_9pfs_front_free(struct xen_9pfs_front_priv *priv)
283283

284284
cancel_work_sync(&ring->work);
285285

286-
if (!priv->rings[i].intf)
286+
if (!ring->intf)
287287
break;
288-
if (priv->rings[i].irq > 0)
289-
unbind_from_irqhandler(priv->rings[i].irq, ring);
290-
if (priv->rings[i].data.in) {
291-
for (j = 0;
292-
j < (1 << priv->rings[i].intf->ring_order);
288+
if (ring->irq >= 0) {
289+
unbind_from_irqhandler(ring->irq, ring);
290+
ring->irq = -1;
291+
}
292+
if (ring->data.in) {
293+
for (j = 0; j < (1 << ring->intf->ring_order);
293294
j++) {
294295
grant_ref_t ref;
295296

296-
ref = priv->rings[i].intf->ref[j];
297+
ref = ring->intf->ref[j];
297298
gnttab_end_foreign_access(ref, NULL);
299+
ring->intf->ref[j] = INVALID_GRANT_REF;
298300
}
299-
free_pages_exact(priv->rings[i].data.in,
300-
1UL << (priv->rings[i].intf->ring_order +
301-
XEN_PAGE_SHIFT));
301+
free_pages_exact(ring->data.in,
302+
1UL << (ring->intf->ring_order +
303+
XEN_PAGE_SHIFT));
304+
ring->data.in = NULL;
305+
ring->data.out = NULL;
306+
}
307+
if (ring->ref != INVALID_GRANT_REF) {
308+
gnttab_end_foreign_access(ring->ref, NULL);
309+
ring->ref = INVALID_GRANT_REF;
302310
}
303-
gnttab_end_foreign_access(priv->rings[i].ref, NULL);
304-
free_page((unsigned long)priv->rings[i].intf);
311+
free_page((unsigned long)ring->intf);
312+
ring->intf = NULL;
305313
}
306314
kfree(priv->rings);
307315
}
@@ -334,6 +342,12 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
334342
int ret = -ENOMEM;
335343
void *bytes = NULL;
336344

345+
ring->intf = NULL;
346+
ring->data.in = NULL;
347+
ring->data.out = NULL;
348+
ring->ref = INVALID_GRANT_REF;
349+
ring->irq = -1;
350+
337351
init_waitqueue_head(&ring->wq);
338352
spin_lock_init(&ring->lock);
339353
INIT_WORK(&ring->work, p9_xen_response);
@@ -379,9 +393,18 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
379393
for (i--; i >= 0; i--)
380394
gnttab_end_foreign_access(ring->intf->ref[i], NULL);
381395
free_pages_exact(bytes, 1UL << (order + XEN_PAGE_SHIFT));
396+
ring->data.in = NULL;
397+
ring->data.out = NULL;
382398
}
383-
gnttab_end_foreign_access(ring->ref, NULL);
384-
free_page((unsigned long)ring->intf);
399+
if (ring->ref != INVALID_GRANT_REF) {
400+
gnttab_end_foreign_access(ring->ref, NULL);
401+
ring->ref = INVALID_GRANT_REF;
402+
}
403+
if (ring->intf) {
404+
free_page((unsigned long)ring->intf);
405+
ring->intf = NULL;
406+
}
407+
ring->irq = -1;
385408
return ret;
386409
}
387410

@@ -390,23 +413,29 @@ static int xen_9pfs_front_init(struct xenbus_device *dev)
390413
int ret, i;
391414
struct xenbus_transaction xbt;
392415
struct xen_9pfs_front_priv *priv;
393-
char *versions, *v;
394-
unsigned int max_rings, max_ring_order, len = 0;
416+
char *versions, *v, *token;
417+
bool version_1 = false;
418+
unsigned int max_rings, max_ring_order, len = 0, version;
395419

396420
versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
397421
if (IS_ERR(versions))
398422
return PTR_ERR(versions);
399-
for (v = versions; *v; v++) {
400-
if (simple_strtoul(v, &v, 10) == 1) {
401-
v = NULL;
402-
break;
423+
for (v = versions; (token = strsep(&v, ",")); ) {
424+
if (!*token)
425+
continue;
426+
427+
ret = kstrtouint(token, 10, &version);
428+
if (ret) {
429+
kfree(versions);
430+
return ret;
403431
}
404-
}
405-
if (v) {
406-
kfree(versions);
407-
return -EINVAL;
432+
if (version == 1)
433+
version_1 = true;
408434
}
409435
kfree(versions);
436+
if (!version_1)
437+
return -EINVAL;
438+
410439
max_rings = xenbus_read_unsigned(dev->otherend, "max-rings", 0);
411440
if (max_rings < XEN_9PFS_NUM_RINGS)
412441
return -EINVAL;

0 commit comments

Comments
 (0)