Skip to content

Commit 3808330

Browse files
committed
Merge tag '9p-6.3-for-linus-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs
Pull 9p updates from Eric Van Hensbergen: - some fixes and cleanup setting up for a larger set of performance patches I've been working on - a contributed fixes relating to 9p/rdma - some contributed fixes relating to 9p/xen * tag '9p-6.3-for-linus-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs: fs/9p: fix error reporting in v9fs_dir_release net/9p: fix bug in client create for .L 9p/rdma: unmap receive dma buffer in rdma_request()/post_recv() 9p/xen: fix connection sequence 9p/xen: fix version parsing fs/9p: Expand setup of writeback cache to all levels net/9p: Adjust maximum MSIZE to account for p9 header
2 parents 6e11058 + 89c58cb commit 3808330

File tree

9 files changed

+63
-36
lines changed

9 files changed

+63
-36
lines changed

fs/9p/v9fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
468468

469469
#ifdef CONFIG_9P_FSCACHE
470470
/* register the session for caching */
471-
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
471+
if (v9ses->cache == CACHE_FSCACHE) {
472472
rc = v9fs_cache_session_get_cookie(v9ses, dev_name);
473473
if (rc < 0)
474474
goto err_clnt;

fs/9p/vfs_addr.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
279279

280280
p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
281281

282-
BUG_ON(!v9inode->writeback_fid);
283-
284282
/* Prefetch area to be written into the cache if we're caching this
285283
* file. We need to do this before we get a lock on the page in case
286284
* there's more than one writer competing for the same cache block.

fs/9p/vfs_dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx)
197197

198198

199199
/**
200-
* v9fs_dir_release - close a directory
200+
* v9fs_dir_release - called on a close of a file or directory
201201
* @inode: inode of the directory
202202
* @filp: file pointer to a directory
203203
*
@@ -209,6 +209,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
209209
struct p9_fid *fid;
210210
__le32 version;
211211
loff_t i_size;
212+
int retval = 0;
212213

213214
fid = filp->private_data;
214215
p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n",
@@ -217,7 +218,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
217218
spin_lock(&inode->i_lock);
218219
hlist_del(&fid->ilist);
219220
spin_unlock(&inode->i_lock);
220-
p9_fid_put(fid);
221+
retval = p9_fid_put(fid);
221222
}
222223

223224
if ((filp->f_mode & FMODE_WRITE)) {
@@ -228,7 +229,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
228229
} else {
229230
fscache_unuse_cookie(v9fs_inode_cookie(v9inode), NULL, NULL);
230231
}
231-
return 0;
232+
return retval;
232233
}
233234

234235
const struct file_operations v9fs_dir_operations = {

fs/9p/vfs_file.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
7474
}
7575

7676
mutex_lock(&v9inode->v_mutex);
77-
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
78-
!v9inode->writeback_fid &&
77+
if ((v9ses->cache) && !v9inode->writeback_fid &&
7978
((file->f_flags & O_ACCMODE) != O_RDONLY)) {
8079
/*
8180
* clone a fid and add it to writeback_fid
@@ -93,9 +92,11 @@ int v9fs_file_open(struct inode *inode, struct file *file)
9392
v9inode->writeback_fid = (void *) writeback_fid;
9493
}
9594
mutex_unlock(&v9inode->v_mutex);
96-
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
95+
#ifdef CONFIG_9P_FSCACHE
96+
if (v9ses->cache == CACHE_FSCACHE)
9797
fscache_use_cookie(v9fs_inode_cookie(v9inode),
9898
file->f_mode & FMODE_WRITE);
99+
#endif
99100
v9fs_open_fid_add(inode, &fid);
100101
return 0;
101102
out_error:

fs/9p/vfs_inode.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
843843
inode = d_inode(dentry);
844844
v9inode = V9FS_I(inode);
845845
mutex_lock(&v9inode->v_mutex);
846-
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
847-
!v9inode->writeback_fid &&
846+
if ((v9ses->cache) && !v9inode->writeback_fid &&
848847
((flags & O_ACCMODE) != O_RDONLY)) {
849848
/*
850849
* clone a fid and add it to writeback_fid

fs/9p/vfs_inode_dotl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
316316

317317
v9inode = V9FS_I(inode);
318318
mutex_lock(&v9inode->v_mutex);
319-
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
320-
!v9inode->writeback_fid &&
319+
if ((v9ses->cache) && !v9inode->writeback_fid &&
321320
((flags & O_ACCMODE) != O_RDONLY)) {
322321
/*
323322
* clone a fid and add it to writeback_fid
@@ -340,9 +339,11 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
340339
if (err)
341340
goto out;
342341
file->private_data = ofid;
343-
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
342+
#ifdef CONFIG_9P_FSCACHE
343+
if (v9ses->cache == CACHE_FSCACHE)
344344
fscache_use_cookie(v9fs_inode_cookie(v9inode),
345345
file->f_mode & FMODE_WRITE);
346+
#endif
346347
v9fs_open_fid_add(inode, &ofid);
347348
file->f_mode |= FMODE_CREATED;
348349
out:

net/9p/client.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
#define CREATE_TRACE_POINTS
2929
#include <trace/events/9p.h>
3030

31-
#define DEFAULT_MSIZE (128 * 1024)
31+
/* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ +
32+
* room for write (16 extra) or read (11 extra) operands.
33+
*/
34+
35+
#define DEFAULT_MSIZE ((128 * 1024) + P9_IOHDRSZ)
3236

3337
/* Client Option Parsing (code inspired by NFS code)
3438
* - a little lazy - parse all client options
@@ -1289,7 +1293,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags,
12891293
qid->type, qid->path, qid->version, iounit);
12901294

12911295
memmove(&ofid->qid, qid, sizeof(struct p9_qid));
1292-
ofid->mode = mode;
1296+
ofid->mode = flags;
12931297
ofid->iounit = iounit;
12941298

12951299
free_and_error:

net/9p/trans_rdma.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
385385
struct p9_trans_rdma *rdma = client->trans;
386386
struct ib_recv_wr wr;
387387
struct ib_sge sge;
388+
int ret;
388389

389390
c->busa = ib_dma_map_single(rdma->cm_id->device,
390391
c->rc.sdata, client->msize,
@@ -402,7 +403,12 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
402403
wr.wr_cqe = &c->cqe;
403404
wr.sg_list = &sge;
404405
wr.num_sge = 1;
405-
return ib_post_recv(rdma->qp, &wr, NULL);
406+
407+
ret = ib_post_recv(rdma->qp, &wr, NULL);
408+
if (ret)
409+
ib_dma_unmap_single(rdma->cm_id->device, c->busa,
410+
client->msize, DMA_FROM_DEVICE);
411+
return ret;
406412

407413
error:
408414
p9_debug(P9_DEBUG_ERROR, "EIO\n");
@@ -499,7 +505,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
499505

500506
if (down_interruptible(&rdma->sq_sem)) {
501507
err = -EINTR;
502-
goto send_error;
508+
goto dma_unmap;
503509
}
504510

505511
/* Mark request as `sent' *before* we actually send it,
@@ -509,11 +515,14 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
509515
WRITE_ONCE(req->status, REQ_STATUS_SENT);
510516
err = ib_post_send(rdma->qp, &wr, NULL);
511517
if (err)
512-
goto send_error;
518+
goto dma_unmap;
513519

514520
/* Success */
515521
return 0;
516522

523+
dma_unmap:
524+
ib_dma_unmap_single(rdma->cm_id->device, c->busa,
525+
c->req->tc.size, DMA_TO_DEVICE);
517526
/* Handle errors that happened during or while preparing the send: */
518527
send_error:
519528
WRITE_ONCE(req->status, REQ_STATUS_ERROR);

net/9p/trans_xen.c

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,24 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
372372
return ret;
373373
}
374374

375-
static int xen_9pfs_front_probe(struct xenbus_device *dev,
376-
const struct xenbus_device_id *id)
375+
static int xen_9pfs_front_init(struct xenbus_device *dev)
377376
{
378377
int ret, i;
379378
struct xenbus_transaction xbt;
380-
struct xen_9pfs_front_priv *priv = NULL;
381-
char *versions;
379+
struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
380+
char *versions, *v;
382381
unsigned int max_rings, max_ring_order, len = 0;
383382

384383
versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
385384
if (IS_ERR(versions))
386385
return PTR_ERR(versions);
387-
if (strcmp(versions, "1")) {
386+
for (v = versions; *v; v++) {
387+
if (simple_strtoul(v, &v, 10) == 1) {
388+
v = NULL;
389+
break;
390+
}
391+
}
392+
if (v) {
388393
kfree(versions);
389394
return -EINVAL;
390395
}
@@ -399,11 +404,6 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
399404
if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
400405
p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
401406

402-
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
403-
if (!priv)
404-
return -ENOMEM;
405-
406-
priv->dev = dev;
407407
priv->num_rings = XEN_9PFS_NUM_RINGS;
408408
priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings),
409409
GFP_KERNEL);
@@ -462,23 +462,35 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
462462
goto error;
463463
}
464464

465-
write_lock(&xen_9pfs_lock);
466-
list_add_tail(&priv->list, &xen_9pfs_devs);
467-
write_unlock(&xen_9pfs_lock);
468-
dev_set_drvdata(&dev->dev, priv);
469-
xenbus_switch_state(dev, XenbusStateInitialised);
470-
471465
return 0;
472466

473467
error_xenbus:
474468
xenbus_transaction_end(xbt, 1);
475469
xenbus_dev_fatal(dev, ret, "writing xenstore");
476470
error:
477-
dev_set_drvdata(&dev->dev, NULL);
478471
xen_9pfs_front_free(priv);
479472
return ret;
480473
}
481474

475+
static int xen_9pfs_front_probe(struct xenbus_device *dev,
476+
const struct xenbus_device_id *id)
477+
{
478+
struct xen_9pfs_front_priv *priv = NULL;
479+
480+
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
481+
if (!priv)
482+
return -ENOMEM;
483+
484+
priv->dev = dev;
485+
dev_set_drvdata(&dev->dev, priv);
486+
487+
write_lock(&xen_9pfs_lock);
488+
list_add_tail(&priv->list, &xen_9pfs_devs);
489+
write_unlock(&xen_9pfs_lock);
490+
491+
return 0;
492+
}
493+
482494
static int xen_9pfs_front_resume(struct xenbus_device *dev)
483495
{
484496
dev_warn(&dev->dev, "suspend/resume unsupported\n");
@@ -497,6 +509,8 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev,
497509
break;
498510

499511
case XenbusStateInitWait:
512+
if (!xen_9pfs_front_init(dev))
513+
xenbus_switch_state(dev, XenbusStateInitialised);
500514
break;
501515

502516
case XenbusStateConnected:

0 commit comments

Comments
 (0)