Commit 3808330b authored by Linus Torvalds's avatar Linus Torvalds

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
parents 6e110580 89c58cb3
...@@ -468,7 +468,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses, ...@@ -468,7 +468,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
#ifdef CONFIG_9P_FSCACHE #ifdef CONFIG_9P_FSCACHE
/* register the session for caching */ /* register the session for caching */
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) { if (v9ses->cache == CACHE_FSCACHE) {
rc = v9fs_cache_session_get_cookie(v9ses, dev_name); rc = v9fs_cache_session_get_cookie(v9ses, dev_name);
if (rc < 0) if (rc < 0)
goto err_clnt; goto err_clnt;
......
...@@ -279,8 +279,6 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping, ...@@ -279,8 +279,6 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping); p9_debug(P9_DEBUG_VFS, "filp %p, mapping %p\n", filp, mapping);
BUG_ON(!v9inode->writeback_fid);
/* Prefetch area to be written into the cache if we're caching this /* Prefetch area to be written into the cache if we're caching this
* file. We need to do this before we get a lock on the page in case * file. We need to do this before we get a lock on the page in case
* there's more than one writer competing for the same cache block. * there's more than one writer competing for the same cache block.
......
...@@ -197,7 +197,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx) ...@@ -197,7 +197,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx)
/** /**
* v9fs_dir_release - close a directory * v9fs_dir_release - called on a close of a file or directory
* @inode: inode of the directory * @inode: inode of the directory
* @filp: file pointer to a directory * @filp: file pointer to a directory
* *
...@@ -209,6 +209,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) ...@@ -209,6 +209,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
struct p9_fid *fid; struct p9_fid *fid;
__le32 version; __le32 version;
loff_t i_size; loff_t i_size;
int retval = 0;
fid = filp->private_data; fid = filp->private_data;
p9_debug(P9_DEBUG_VFS, "inode: %p filp: %p fid: %d\n", 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) ...@@ -217,7 +218,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
hlist_del(&fid->ilist); hlist_del(&fid->ilist);
spin_unlock(&inode->i_lock); spin_unlock(&inode->i_lock);
p9_fid_put(fid); retval = p9_fid_put(fid);
} }
if ((filp->f_mode & FMODE_WRITE)) { if ((filp->f_mode & FMODE_WRITE)) {
...@@ -228,7 +229,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) ...@@ -228,7 +229,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
} else { } else {
fscache_unuse_cookie(v9fs_inode_cookie(v9inode), NULL, NULL); fscache_unuse_cookie(v9fs_inode_cookie(v9inode), NULL, NULL);
} }
return 0; return retval;
} }
const struct file_operations v9fs_dir_operations = { const struct file_operations v9fs_dir_operations = {
......
...@@ -74,8 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file) ...@@ -74,8 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file)
} }
mutex_lock(&v9inode->v_mutex); mutex_lock(&v9inode->v_mutex);
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && if ((v9ses->cache) && !v9inode->writeback_fid &&
!v9inode->writeback_fid &&
((file->f_flags & O_ACCMODE) != O_RDONLY)) { ((file->f_flags & O_ACCMODE) != O_RDONLY)) {
/* /*
* clone a fid and add it to writeback_fid * clone a fid and add it to writeback_fid
...@@ -93,9 +92,11 @@ int v9fs_file_open(struct inode *inode, struct file *file) ...@@ -93,9 +92,11 @@ int v9fs_file_open(struct inode *inode, struct file *file)
v9inode->writeback_fid = (void *) writeback_fid; v9inode->writeback_fid = (void *) writeback_fid;
} }
mutex_unlock(&v9inode->v_mutex); mutex_unlock(&v9inode->v_mutex);
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) #ifdef CONFIG_9P_FSCACHE
if (v9ses->cache == CACHE_FSCACHE)
fscache_use_cookie(v9fs_inode_cookie(v9inode), fscache_use_cookie(v9fs_inode_cookie(v9inode),
file->f_mode & FMODE_WRITE); file->f_mode & FMODE_WRITE);
#endif
v9fs_open_fid_add(inode, &fid); v9fs_open_fid_add(inode, &fid);
return 0; return 0;
out_error: out_error:
......
...@@ -843,8 +843,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -843,8 +843,7 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
inode = d_inode(dentry); inode = d_inode(dentry);
v9inode = V9FS_I(inode); v9inode = V9FS_I(inode);
mutex_lock(&v9inode->v_mutex); mutex_lock(&v9inode->v_mutex);
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && if ((v9ses->cache) && !v9inode->writeback_fid &&
!v9inode->writeback_fid &&
((flags & O_ACCMODE) != O_RDONLY)) { ((flags & O_ACCMODE) != O_RDONLY)) {
/* /*
* clone a fid and add it to writeback_fid * clone a fid and add it to writeback_fid
......
...@@ -316,8 +316,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -316,8 +316,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
v9inode = V9FS_I(inode); v9inode = V9FS_I(inode);
mutex_lock(&v9inode->v_mutex); mutex_lock(&v9inode->v_mutex);
if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) && if ((v9ses->cache) && !v9inode->writeback_fid &&
!v9inode->writeback_fid &&
((flags & O_ACCMODE) != O_RDONLY)) { ((flags & O_ACCMODE) != O_RDONLY)) {
/* /*
* clone a fid and add it to writeback_fid * clone a fid and add it to writeback_fid
...@@ -340,9 +339,11 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -340,9 +339,11 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
if (err) if (err)
goto out; goto out;
file->private_data = ofid; file->private_data = ofid;
if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) #ifdef CONFIG_9P_FSCACHE
if (v9ses->cache == CACHE_FSCACHE)
fscache_use_cookie(v9fs_inode_cookie(v9inode), fscache_use_cookie(v9fs_inode_cookie(v9inode),
file->f_mode & FMODE_WRITE); file->f_mode & FMODE_WRITE);
#endif
v9fs_open_fid_add(inode, &ofid); v9fs_open_fid_add(inode, &ofid);
file->f_mode |= FMODE_CREATED; file->f_mode |= FMODE_CREATED;
out: out:
......
...@@ -28,7 +28,11 @@ ...@@ -28,7 +28,11 @@
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include <trace/events/9p.h> #include <trace/events/9p.h>
#define DEFAULT_MSIZE (128 * 1024) /* DEFAULT MSIZE = 32 pages worth of payload + P9_HDRSZ +
* room for write (16 extra) or read (11 extra) operands.
*/
#define DEFAULT_MSIZE ((128 * 1024) + P9_IOHDRSZ)
/* Client Option Parsing (code inspired by NFS code) /* Client Option Parsing (code inspired by NFS code)
* - a little lazy - parse all client options * - 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, ...@@ -1289,7 +1293,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags,
qid->type, qid->path, qid->version, iounit); qid->type, qid->path, qid->version, iounit);
memmove(&ofid->qid, qid, sizeof(struct p9_qid)); memmove(&ofid->qid, qid, sizeof(struct p9_qid));
ofid->mode = mode; ofid->mode = flags;
ofid->iounit = iounit; ofid->iounit = iounit;
free_and_error: free_and_error:
......
...@@ -385,6 +385,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) ...@@ -385,6 +385,7 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
struct p9_trans_rdma *rdma = client->trans; struct p9_trans_rdma *rdma = client->trans;
struct ib_recv_wr wr; struct ib_recv_wr wr;
struct ib_sge sge; struct ib_sge sge;
int ret;
c->busa = ib_dma_map_single(rdma->cm_id->device, c->busa = ib_dma_map_single(rdma->cm_id->device,
c->rc.sdata, client->msize, c->rc.sdata, client->msize,
...@@ -402,7 +403,12 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c) ...@@ -402,7 +403,12 @@ post_recv(struct p9_client *client, struct p9_rdma_context *c)
wr.wr_cqe = &c->cqe; wr.wr_cqe = &c->cqe;
wr.sg_list = &sge; wr.sg_list = &sge;
wr.num_sge = 1; wr.num_sge = 1;
return ib_post_recv(rdma->qp, &wr, NULL);
ret = ib_post_recv(rdma->qp, &wr, NULL);
if (ret)
ib_dma_unmap_single(rdma->cm_id->device, c->busa,
client->msize, DMA_FROM_DEVICE);
return ret;
error: error:
p9_debug(P9_DEBUG_ERROR, "EIO\n"); p9_debug(P9_DEBUG_ERROR, "EIO\n");
...@@ -499,7 +505,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) ...@@ -499,7 +505,7 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
if (down_interruptible(&rdma->sq_sem)) { if (down_interruptible(&rdma->sq_sem)) {
err = -EINTR; err = -EINTR;
goto send_error; goto dma_unmap;
} }
/* Mark request as `sent' *before* we actually send it, /* 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) ...@@ -509,11 +515,14 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
WRITE_ONCE(req->status, REQ_STATUS_SENT); WRITE_ONCE(req->status, REQ_STATUS_SENT);
err = ib_post_send(rdma->qp, &wr, NULL); err = ib_post_send(rdma->qp, &wr, NULL);
if (err) if (err)
goto send_error; goto dma_unmap;
/* Success */ /* Success */
return 0; return 0;
dma_unmap:
ib_dma_unmap_single(rdma->cm_id->device, c->busa,
c->req->tc.size, DMA_TO_DEVICE);
/* Handle errors that happened during or while preparing the send: */ /* Handle errors that happened during or while preparing the send: */
send_error: send_error:
WRITE_ONCE(req->status, REQ_STATUS_ERROR); WRITE_ONCE(req->status, REQ_STATUS_ERROR);
......
...@@ -372,19 +372,24 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev, ...@@ -372,19 +372,24 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
return ret; return ret;
} }
static int xen_9pfs_front_probe(struct xenbus_device *dev, static int xen_9pfs_front_init(struct xenbus_device *dev)
const struct xenbus_device_id *id)
{ {
int ret, i; int ret, i;
struct xenbus_transaction xbt; struct xenbus_transaction xbt;
struct xen_9pfs_front_priv *priv = NULL; struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
char *versions; char *versions, *v;
unsigned int max_rings, max_ring_order, len = 0; unsigned int max_rings, max_ring_order, len = 0;
versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len); versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
if (IS_ERR(versions)) if (IS_ERR(versions))
return PTR_ERR(versions); return PTR_ERR(versions);
if (strcmp(versions, "1")) { for (v = versions; *v; v++) {
if (simple_strtoul(v, &v, 10) == 1) {
v = NULL;
break;
}
}
if (v) {
kfree(versions); kfree(versions);
return -EINVAL; return -EINVAL;
} }
...@@ -399,11 +404,6 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, ...@@ -399,11 +404,6 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order)) if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2; p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->dev = dev;
priv->num_rings = XEN_9PFS_NUM_RINGS; priv->num_rings = XEN_9PFS_NUM_RINGS;
priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings), priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings),
GFP_KERNEL); GFP_KERNEL);
...@@ -462,23 +462,35 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev, ...@@ -462,23 +462,35 @@ static int xen_9pfs_front_probe(struct xenbus_device *dev,
goto error; goto error;
} }
write_lock(&xen_9pfs_lock);
list_add_tail(&priv->list, &xen_9pfs_devs);
write_unlock(&xen_9pfs_lock);
dev_set_drvdata(&dev->dev, priv);
xenbus_switch_state(dev, XenbusStateInitialised);
return 0; return 0;
error_xenbus: error_xenbus:
xenbus_transaction_end(xbt, 1); xenbus_transaction_end(xbt, 1);
xenbus_dev_fatal(dev, ret, "writing xenstore"); xenbus_dev_fatal(dev, ret, "writing xenstore");
error: error:
dev_set_drvdata(&dev->dev, NULL);
xen_9pfs_front_free(priv); xen_9pfs_front_free(priv);
return ret; return ret;
} }
static int xen_9pfs_front_probe(struct xenbus_device *dev,
const struct xenbus_device_id *id)
{
struct xen_9pfs_front_priv *priv = NULL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->dev = dev;
dev_set_drvdata(&dev->dev, priv);
write_lock(&xen_9pfs_lock);
list_add_tail(&priv->list, &xen_9pfs_devs);
write_unlock(&xen_9pfs_lock);
return 0;
}
static int xen_9pfs_front_resume(struct xenbus_device *dev) static int xen_9pfs_front_resume(struct xenbus_device *dev)
{ {
dev_warn(&dev->dev, "suspend/resume unsupported\n"); dev_warn(&dev->dev, "suspend/resume unsupported\n");
...@@ -497,6 +509,8 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev, ...@@ -497,6 +509,8 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev,
break; break;
case XenbusStateInitWait: case XenbusStateInitWait:
if (!xen_9pfs_front_init(dev))
xenbus_switch_state(dev, XenbusStateInitialised);
break; break;
case XenbusStateConnected: case XenbusStateConnected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment