summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2011-09-16 16:09:32 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2011-09-16 16:09:32 +0200
commit28f8862fcc333da93cbaa13e27e12cd6568d3b3a (patch)
treed4a646825ef4da7524e234207b22bad00c798c84
parent552c6cc2d96d15c68badced19b9781f8a00646b5 (diff)
downloadstable-queue-28f8862fcc333da93cbaa13e27e12cd6568d3b3a.tar.gz
3.0 patches
-rw-r--r--queue-3.0/fs-9p-add-fid-before-dentry-instantiation.patch89
-rw-r--r--queue-3.0/fs-9p-always-ask-new-inode-in-lookup-for-cache-mode.patch73
-rw-r--r--queue-3.0/fs-9p-don-t-update-file-type-when-updating-file-attributes.patch342
-rw-r--r--queue-3.0/fs-9p-use-protocol-defined-value-for-lock-getlock-type-field.patch96
-rw-r--r--queue-3.0/net-9p-fix-kernel-crash-with-msize-512k.patch67
-rw-r--r--queue-3.0/series5
6 files changed, 672 insertions, 0 deletions
diff --git a/queue-3.0/fs-9p-add-fid-before-dentry-instantiation.patch b/queue-3.0/fs-9p-add-fid-before-dentry-instantiation.patch
new file mode 100644
index 0000000000..6886a9ebd0
--- /dev/null
+++ b/queue-3.0/fs-9p-add-fid-before-dentry-instantiation.patch
@@ -0,0 +1,89 @@
+From 5441ae5eb3614d3c28f77073370738a2820c88e4 Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Date: Mon, 25 Jul 2011 18:06:32 +0000
+Subject: fs/9p: Add fid before dentry instantiation
+
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+
+commit 5441ae5eb3614d3c28f77073370738a2820c88e4 upstream.
+
+d_instantiate marks the dentry positive. So a parallel lookup and mkdir of
+the directory can find dentry that doesn't have fid attached. This can result
+in both the code path doing v9fs_fid_add which results in v9fs_dentry leak.
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/9p/vfs_inode.c | 4 +---
+ fs/9p/vfs_inode_dotl.c | 8 ++++----
+ 2 files changed, 5 insertions(+), 7 deletions(-)
+
+--- a/fs/9p/vfs_inode.c
++++ b/fs/9p/vfs_inode.c
+@@ -633,13 +633,11 @@ v9fs_create(struct v9fs_session_info *v9
+ P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
+ goto error;
+ }
+- d_instantiate(dentry, inode);
+ err = v9fs_fid_add(dentry, fid);
+ if (err < 0)
+ goto error;
+-
++ d_instantiate(dentry, inode);
+ return ofid;
+-
+ error:
+ if (ofid)
+ p9_client_clunk(ofid);
+--- a/fs/9p/vfs_inode_dotl.c
++++ b/fs/9p/vfs_inode_dotl.c
+@@ -281,10 +281,10 @@ v9fs_vfs_create_dotl(struct inode *dir,
+ P9_DPRINTK(P9_DEBUG_VFS, "inode creation failed %d\n", err);
+ goto error;
+ }
+- d_instantiate(dentry, inode);
+ err = v9fs_fid_add(dentry, fid);
+ if (err < 0)
+ goto error;
++ d_instantiate(dentry, inode);
+
+ /* Now set the ACL based on the default value */
+ v9fs_set_create_acl(dentry, &dacl, &pacl);
+@@ -403,10 +403,10 @@ static int v9fs_vfs_mkdir_dotl(struct in
+ err);
+ goto error;
+ }
+- d_instantiate(dentry, inode);
+ err = v9fs_fid_add(dentry, fid);
+ if (err < 0)
+ goto error;
++ d_instantiate(dentry, inode);
+ fid = NULL;
+ } else {
+ /*
+@@ -657,10 +657,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir,
+ err);
+ goto error;
+ }
+- d_instantiate(dentry, inode);
+ err = v9fs_fid_add(dentry, fid);
+ if (err < 0)
+ goto error;
++ d_instantiate(dentry, inode);
+ fid = NULL;
+ } else {
+ /* Not in cached mode. No need to populate inode with stat */
+@@ -810,10 +810,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, s
+ err);
+ goto error;
+ }
+- d_instantiate(dentry, inode);
+ err = v9fs_fid_add(dentry, fid);
+ if (err < 0)
+ goto error;
++ d_instantiate(dentry, inode);
+ fid = NULL;
+ } else {
+ /*
diff --git a/queue-3.0/fs-9p-always-ask-new-inode-in-lookup-for-cache-mode.patch b/queue-3.0/fs-9p-always-ask-new-inode-in-lookup-for-cache-mode.patch
new file mode 100644
index 0000000000..365de0bca7
--- /dev/null
+++ b/queue-3.0/fs-9p-always-ask-new-inode-in-lookup-for-cache-mode.patch
@@ -0,0 +1,73 @@
+From 73f507171cfa407b19f254aef95cbb058c8180cf Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Date: Tue, 16 Aug 2011 22:19:28 +0530
+Subject: fs/9p: Always ask new inode in lookup for cache mode disabled
+
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+
+commit 73f507171cfa407b19f254aef95cbb058c8180cf upstream.
+
+This make sure we don't end up reusing the unlinked inode object.
+The ideal way is to use inode i_generation. But i_generation is
+not available in userspace always.
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/9p/vfs_inode.c | 28 +++++++++++++++++++++-------
+ 1 file changed, 21 insertions(+), 7 deletions(-)
+
+--- a/fs/9p/vfs_inode.c
++++ b/fs/9p/vfs_inode.c
+@@ -799,6 +799,7 @@ static int v9fs_vfs_mkdir(struct inode *
+ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
+ struct nameidata *nameidata)
+ {
++ struct dentry *res;
+ struct super_block *sb;
+ struct v9fs_session_info *v9ses;
+ struct p9_fid *dfid, *fid;
+@@ -830,22 +831,35 @@ struct dentry *v9fs_vfs_lookup(struct in
+
+ return ERR_PTR(result);
+ }
+-
+- inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
++ /*
++ * Make sure we don't use a wrong inode due to parallel
++ * unlink. For cached mode create calls request for new
++ * inode. But with cache disabled, lookup should do this.
++ */
++ if (v9ses->cache)
++ inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb);
++ else
++ inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
+ if (IS_ERR(inode)) {
+ result = PTR_ERR(inode);
+ inode = NULL;
+ goto error;
+ }
+-
+ result = v9fs_fid_add(dentry, fid);
+ if (result < 0)
+ goto error_iput;
+-
+ inst_out:
+- d_add(dentry, inode);
+- return NULL;
+-
++ /*
++ * If we had a rename on the server and a parallel lookup
++ * for the new name, then make sure we instantiate with
++ * the new name. ie look up for a/b, while on server somebody
++ * moved b under k and client parallely did a lookup for
++ * k/b.
++ */
++ res = d_materialise_unique(dentry, inode);
++ if (!IS_ERR(res))
++ return res;
++ result = PTR_ERR(res);
+ error_iput:
+ iput(inode);
+ error:
diff --git a/queue-3.0/fs-9p-don-t-update-file-type-when-updating-file-attributes.patch b/queue-3.0/fs-9p-don-t-update-file-type-when-updating-file-attributes.patch
new file mode 100644
index 0000000000..cfab5f3a71
--- /dev/null
+++ b/queue-3.0/fs-9p-don-t-update-file-type-when-updating-file-attributes.patch
@@ -0,0 +1,342 @@
+From 45089142b1497dab2327d60f6c71c40766fc3ea4 Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Date: Mon, 25 Jul 2011 18:06:33 +0000
+Subject: fs/9p: Don't update file type when updating file attributes
+
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+
+commit 45089142b1497dab2327d60f6c71c40766fc3ea4 upstream.
+
+We should only update attributes that we can change on stat2inode.
+Also do file type initialization in v9fs_init_inode.
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/9p/v9fs_vfs.h | 4 +-
+ fs/9p/vfs_inode.c | 91 ++++++++++++++++++++++++++-----------------------
+ fs/9p/vfs_inode_dotl.c | 23 ++++++++----
+ fs/9p/vfs_super.c | 2 -
+ 4 files changed, 68 insertions(+), 52 deletions(-)
+
+--- a/fs/9p/v9fs_vfs.h
++++ b/fs/9p/v9fs_vfs.h
+@@ -54,9 +54,9 @@ extern struct kmem_cache *v9fs_inode_cac
+
+ struct inode *v9fs_alloc_inode(struct super_block *sb);
+ void v9fs_destroy_inode(struct inode *inode);
+-struct inode *v9fs_get_inode(struct super_block *sb, int mode);
++struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t);
+ int v9fs_init_inode(struct v9fs_session_info *v9ses,
+- struct inode *inode, int mode);
++ struct inode *inode, int mode, dev_t);
+ void v9fs_evict_inode(struct inode *inode);
+ ino_t v9fs_qid2ino(struct p9_qid *qid);
+ void v9fs_stat2inode(struct p9_wstat *, struct inode *, struct super_block *);
+--- a/fs/9p/vfs_inode.c
++++ b/fs/9p/vfs_inode.c
+@@ -95,15 +95,18 @@ static int unixmode2p9mode(struct v9fs_s
+ /**
+ * p9mode2unixmode- convert plan9 mode bits to unix mode bits
+ * @v9ses: v9fs session information
+- * @mode: mode to convert
++ * @stat: p9_wstat from which mode need to be derived
++ * @rdev: major number, minor number in case of device files.
+ *
+ */
+-
+-static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
++static int p9mode2unixmode(struct v9fs_session_info *v9ses,
++ struct p9_wstat *stat, dev_t *rdev)
+ {
+ int res;
++ int mode = stat->mode;
+
+- res = mode & 0777;
++ res = mode & S_IALLUGO;
++ *rdev = 0;
+
+ if ((mode & P9_DMDIR) == P9_DMDIR)
+ res |= S_IFDIR;
+@@ -116,9 +119,26 @@ static int p9mode2unixmode(struct v9fs_s
+ && (v9ses->nodev == 0))
+ res |= S_IFIFO;
+ else if ((mode & P9_DMDEVICE) && (v9fs_proto_dotu(v9ses))
+- && (v9ses->nodev == 0))
+- res |= S_IFBLK;
+- else
++ && (v9ses->nodev == 0)) {
++ char type = 0, ext[32];
++ int major = -1, minor = -1;
++
++ strncpy(ext, stat->extension, sizeof(ext));
++ sscanf(ext, "%c %u %u", &type, &major, &minor);
++ switch (type) {
++ case 'c':
++ res |= S_IFCHR;
++ break;
++ case 'b':
++ res |= S_IFBLK;
++ break;
++ default:
++ P9_DPRINTK(P9_DEBUG_ERROR,
++ "Unknown special type %c %s\n", type,
++ stat->extension);
++ };
++ *rdev = MKDEV(major, minor);
++ } else
+ res |= S_IFREG;
+
+ if (v9fs_proto_dotu(v9ses)) {
+@@ -131,7 +151,6 @@ static int p9mode2unixmode(struct v9fs_s
+ if ((mode & P9_DMSETVTX) == P9_DMSETVTX)
+ res |= S_ISVTX;
+ }
+-
+ return res;
+ }
+
+@@ -242,13 +261,13 @@ void v9fs_destroy_inode(struct inode *in
+ }
+
+ int v9fs_init_inode(struct v9fs_session_info *v9ses,
+- struct inode *inode, int mode)
++ struct inode *inode, int mode, dev_t rdev)
+ {
+ int err = 0;
+
+ inode_init_owner(inode, NULL, mode);
+ inode->i_blocks = 0;
+- inode->i_rdev = 0;
++ inode->i_rdev = rdev;
+ inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ inode->i_mapping->a_ops = &v9fs_addr_operations;
+
+@@ -335,7 +354,7 @@ error:
+ *
+ */
+
+-struct inode *v9fs_get_inode(struct super_block *sb, int mode)
++struct inode *v9fs_get_inode(struct super_block *sb, int mode, dev_t rdev)
+ {
+ int err;
+ struct inode *inode;
+@@ -348,7 +367,7 @@ struct inode *v9fs_get_inode(struct supe
+ P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
+ return ERR_PTR(-ENOMEM);
+ }
+- err = v9fs_init_inode(v9ses, inode, mode);
++ err = v9fs_init_inode(v9ses, inode, mode, rdev);
+ if (err) {
+ iput(inode);
+ return ERR_PTR(err);
+@@ -435,11 +454,12 @@ void v9fs_evict_inode(struct inode *inod
+ static int v9fs_test_inode(struct inode *inode, void *data)
+ {
+ int umode;
++ dev_t rdev;
+ struct v9fs_inode *v9inode = V9FS_I(inode);
+ struct p9_wstat *st = (struct p9_wstat *)data;
+ struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode);
+
+- umode = p9mode2unixmode(v9ses, st->mode);
++ umode = p9mode2unixmode(v9ses, st, &rdev);
+ /* don't match inode of different type */
+ if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
+ return 0;
+@@ -473,6 +493,7 @@ static struct inode *v9fs_qid_iget(struc
+ struct p9_wstat *st,
+ int new)
+ {
++ dev_t rdev;
+ int retval, umode;
+ unsigned long i_ino;
+ struct inode *inode;
+@@ -496,8 +517,8 @@ static struct inode *v9fs_qid_iget(struc
+ * later.
+ */
+ inode->i_ino = i_ino;
+- umode = p9mode2unixmode(v9ses, st->mode);
+- retval = v9fs_init_inode(v9ses, inode, umode);
++ umode = p9mode2unixmode(v9ses, st, &rdev);
++ retval = v9fs_init_inode(v9ses, inode, umode, rdev);
+ if (retval)
+ goto error;
+
+@@ -990,7 +1011,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, s
+ return PTR_ERR(st);
+
+ v9fs_stat2inode(st, dentry->d_inode, dentry->d_inode->i_sb);
+- generic_fillattr(dentry->d_inode, stat);
++ generic_fillattr(dentry->d_inode, stat);
+
+ p9stat_free(st);
+ kfree(st);
+@@ -1074,6 +1095,7 @@ void
+ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode,
+ struct super_block *sb)
+ {
++ mode_t mode;
+ char ext[32];
+ char tag_name[14];
+ unsigned int i_nlink;
+@@ -1109,31 +1131,9 @@ v9fs_stat2inode(struct p9_wstat *stat, s
+ inode->i_nlink = i_nlink;
+ }
+ }
+- inode->i_mode = p9mode2unixmode(v9ses, stat->mode);
+- if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode))) {
+- char type = 0;
+- int major = -1;
+- int minor = -1;
+-
+- strncpy(ext, stat->extension, sizeof(ext));
+- sscanf(ext, "%c %u %u", &type, &major, &minor);
+- switch (type) {
+- case 'c':
+- inode->i_mode &= ~S_IFBLK;
+- inode->i_mode |= S_IFCHR;
+- break;
+- case 'b':
+- break;
+- default:
+- P9_DPRINTK(P9_DEBUG_ERROR,
+- "Unknown special type %c %s\n", type,
+- stat->extension);
+- };
+- inode->i_rdev = MKDEV(major, minor);
+- init_special_inode(inode, inode->i_mode, inode->i_rdev);
+- } else
+- inode->i_rdev = 0;
+-
++ mode = stat->mode & S_IALLUGO;
++ mode |= inode->i_mode & ~S_IALLUGO;
++ inode->i_mode = mode;
+ i_size_write(inode, stat->length);
+
+ /* not real number of blocks, but 512 byte ones ... */
+@@ -1399,6 +1399,8 @@ v9fs_vfs_mknod(struct inode *dir, struct
+
+ int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode)
+ {
++ int umode;
++ dev_t rdev;
+ loff_t i_size;
+ struct p9_wstat *st;
+ struct v9fs_session_info *v9ses;
+@@ -1407,6 +1409,12 @@ int v9fs_refresh_inode(struct p9_fid *fi
+ st = p9_client_stat(fid);
+ if (IS_ERR(st))
+ return PTR_ERR(st);
++ /*
++ * Don't update inode if the file type is different
++ */
++ umode = p9mode2unixmode(v9ses, st, &rdev);
++ if ((inode->i_mode & S_IFMT) != (umode & S_IFMT))
++ goto out;
+
+ spin_lock(&inode->i_lock);
+ /*
+@@ -1418,6 +1426,7 @@ int v9fs_refresh_inode(struct p9_fid *fi
+ if (v9ses->cache)
+ inode->i_size = i_size;
+ spin_unlock(&inode->i_lock);
++out:
+ p9stat_free(st);
+ kfree(st);
+ return 0;
+--- a/fs/9p/vfs_inode_dotl.c
++++ b/fs/9p/vfs_inode_dotl.c
+@@ -153,7 +153,8 @@ static struct inode *v9fs_qid_iget_dotl(
+ * later.
+ */
+ inode->i_ino = i_ino;
+- retval = v9fs_init_inode(v9ses, inode, st->st_mode);
++ retval = v9fs_init_inode(v9ses, inode,
++ st->st_mode, new_decode_dev(st->st_rdev));
+ if (retval)
+ goto error;
+
+@@ -414,7 +415,7 @@ static int v9fs_vfs_mkdir_dotl(struct in
+ * inode with stat. We need to get an inode
+ * so that we can set the acl with dentry
+ */
+- inode = v9fs_get_inode(dir->i_sb, mode);
++ inode = v9fs_get_inode(dir->i_sb, mode, 0);
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
+ goto error;
+@@ -540,6 +541,7 @@ int v9fs_vfs_setattr_dotl(struct dentry
+ void
+ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode)
+ {
++ mode_t mode;
+ struct v9fs_inode *v9inode = V9FS_I(inode);
+
+ if ((stat->st_result_mask & P9_STATS_BASIC) == P9_STATS_BASIC) {
+@@ -552,11 +554,10 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl
+ inode->i_uid = stat->st_uid;
+ inode->i_gid = stat->st_gid;
+ inode->i_nlink = stat->st_nlink;
+- inode->i_mode = stat->st_mode;
+- inode->i_rdev = new_decode_dev(stat->st_rdev);
+
+- if ((S_ISBLK(inode->i_mode)) || (S_ISCHR(inode->i_mode)))
+- init_special_inode(inode, inode->i_mode, inode->i_rdev);
++ mode = stat->st_mode & S_IALLUGO;
++ mode |= inode->i_mode & ~S_IALLUGO;
++ inode->i_mode = mode;
+
+ i_size_write(inode, stat->st_size);
+ inode->i_blocks = stat->st_blocks;
+@@ -664,7 +665,7 @@ v9fs_vfs_symlink_dotl(struct inode *dir,
+ fid = NULL;
+ } else {
+ /* Not in cached mode. No need to populate inode with stat */
+- inode = v9fs_get_inode(dir->i_sb, S_IFLNK);
++ inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0);
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
+ goto error;
+@@ -820,7 +821,7 @@ v9fs_vfs_mknod_dotl(struct inode *dir, s
+ * Not in cached mode. No need to populate inode with stat.
+ * socket syscall returns a fd, so we need instantiate
+ */
+- inode = v9fs_get_inode(dir->i_sb, mode);
++ inode = v9fs_get_inode(dir->i_sb, mode, rdev);
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
+ goto error;
+@@ -886,6 +887,11 @@ int v9fs_refresh_inode_dotl(struct p9_fi
+ st = p9_client_getattr_dotl(fid, P9_STATS_ALL);
+ if (IS_ERR(st))
+ return PTR_ERR(st);
++ /*
++ * Don't update inode if the file type is different
++ */
++ if ((inode->i_mode & S_IFMT) != (st->st_mode & S_IFMT))
++ goto out;
+
+ spin_lock(&inode->i_lock);
+ /*
+@@ -897,6 +903,7 @@ int v9fs_refresh_inode_dotl(struct p9_fi
+ if (v9ses->cache)
+ inode->i_size = i_size;
+ spin_unlock(&inode->i_lock);
++out:
+ kfree(st);
+ return 0;
+ }
+--- a/fs/9p/vfs_super.c
++++ b/fs/9p/vfs_super.c
+@@ -149,7 +149,7 @@ static struct dentry *v9fs_mount(struct
+ else
+ sb->s_d_op = &v9fs_dentry_operations;
+
+- inode = v9fs_get_inode(sb, S_IFDIR | mode);
++ inode = v9fs_get_inode(sb, S_IFDIR | mode, 0);
+ if (IS_ERR(inode)) {
+ retval = PTR_ERR(inode);
+ goto release_sb;
diff --git a/queue-3.0/fs-9p-use-protocol-defined-value-for-lock-getlock-type-field.patch b/queue-3.0/fs-9p-use-protocol-defined-value-for-lock-getlock-type-field.patch
new file mode 100644
index 0000000000..65f4ed10d6
--- /dev/null
+++ b/queue-3.0/fs-9p-use-protocol-defined-value-for-lock-getlock-type-field.patch
@@ -0,0 +1,96 @@
+From 51b8b4fb32271d39fbdd760397406177b2b0fd36 Mon Sep 17 00:00:00 2001
+From: Jim Garlick <garlick.jim@gmail.com>
+Date: Sun, 21 Aug 2011 00:21:18 +0530
+Subject: fs/9p: Use protocol-defined value for lock/getlock 'type' field.
+
+From: Jim Garlick <garlick.jim@gmail.com>
+
+commit 51b8b4fb32271d39fbdd760397406177b2b0fd36 upstream.
+
+Signed-off-by: Jim Garlick <garlick@llnl.gov>
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/9p/vfs_file.c | 34 +++++++++++++++++++++++++++-------
+ include/net/9p/9p.h | 5 +++++
+ 2 files changed, 32 insertions(+), 7 deletions(-)
+
+--- a/fs/9p/vfs_file.c
++++ b/fs/9p/vfs_file.c
+@@ -169,7 +169,18 @@ static int v9fs_file_do_lock(struct file
+
+ /* convert posix lock to p9 tlock args */
+ memset(&flock, 0, sizeof(flock));
+- flock.type = fl->fl_type;
++ /* map the lock type */
++ switch (fl->fl_type) {
++ case F_RDLCK:
++ flock.type = P9_LOCK_TYPE_RDLCK;
++ break;
++ case F_WRLCK:
++ flock.type = P9_LOCK_TYPE_WRLCK;
++ break;
++ case F_UNLCK:
++ flock.type = P9_LOCK_TYPE_UNLCK;
++ break;
++ }
+ flock.start = fl->fl_start;
+ if (fl->fl_end == OFFSET_MAX)
+ flock.length = 0;
+@@ -245,7 +256,7 @@ static int v9fs_file_getlock(struct file
+
+ /* convert posix lock to p9 tgetlock args */
+ memset(&glock, 0, sizeof(glock));
+- glock.type = fl->fl_type;
++ glock.type = P9_LOCK_TYPE_UNLCK;
+ glock.start = fl->fl_start;
+ if (fl->fl_end == OFFSET_MAX)
+ glock.length = 0;
+@@ -257,17 +268,26 @@ static int v9fs_file_getlock(struct file
+ res = p9_client_getlock_dotl(fid, &glock);
+ if (res < 0)
+ return res;
+- if (glock.type != F_UNLCK) {
+- fl->fl_type = glock.type;
++ /* map 9p lock type to os lock type */
++ switch (glock.type) {
++ case P9_LOCK_TYPE_RDLCK:
++ fl->fl_type = F_RDLCK;
++ break;
++ case P9_LOCK_TYPE_WRLCK:
++ fl->fl_type = F_WRLCK;
++ break;
++ case P9_LOCK_TYPE_UNLCK:
++ fl->fl_type = F_UNLCK;
++ break;
++ }
++ if (glock.type != P9_LOCK_TYPE_UNLCK) {
+ fl->fl_start = glock.start;
+ if (glock.length == 0)
+ fl->fl_end = OFFSET_MAX;
+ else
+ fl->fl_end = glock.start + glock.length - 1;
+ fl->fl_pid = glock.proc_id;
+- } else
+- fl->fl_type = F_UNLCK;
+-
++ }
+ return res;
+ }
+
+--- a/include/net/9p/9p.h
++++ b/include/net/9p/9p.h
+@@ -320,6 +320,11 @@ enum p9_qid_t {
+ /* Room for readdir header */
+ #define P9_READDIRHDRSZ 24
+
++/* 9p2000.L lock type */
++#define P9_LOCK_TYPE_RDLCK 0
++#define P9_LOCK_TYPE_WRLCK 1
++#define P9_LOCK_TYPE_UNLCK 2
++
+ /**
+ * struct p9_str - length prefixed string type
+ * @len: length of the string
diff --git a/queue-3.0/net-9p-fix-kernel-crash-with-msize-512k.patch b/queue-3.0/net-9p-fix-kernel-crash-with-msize-512k.patch
new file mode 100644
index 0000000000..c52a93cd7e
--- /dev/null
+++ b/queue-3.0/net-9p-fix-kernel-crash-with-msize-512k.patch
@@ -0,0 +1,67 @@
+From b49d8b5d7007a673796f3f99688b46931293873e Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Date: Wed, 17 Aug 2011 16:56:04 +0000
+Subject: net/9p: Fix kernel crash with msize 512K
+
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+
+commit b49d8b5d7007a673796f3f99688b46931293873e upstream.
+
+With msize equal to 512K (PAGE_SIZE * VIRTQUEUE_NUM), we hit multiple
+crashes. This patch fix those.
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ net/9p/trans_virtio.c | 17 ++++++++++++-----
+ 1 file changed, 12 insertions(+), 5 deletions(-)
+
+--- a/net/9p/trans_virtio.c
++++ b/net/9p/trans_virtio.c
+@@ -263,7 +263,6 @@ p9_virtio_request(struct p9_client *clie
+ {
+ int in, out, inp, outp;
+ struct virtio_chan *chan = client->trans;
+- char *rdata = (char *)req->rc+sizeof(struct p9_fcall);
+ unsigned long flags;
+ size_t pdata_off = 0;
+ struct trans_rpage_info *rpinfo = NULL;
+@@ -346,7 +345,8 @@ req_retry_pinned:
+ * Arrange in such a way that server places header in the
+ * alloced memory and payload onto the user buffer.
+ */
+- inp = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata, 11);
++ inp = pack_sg_list(chan->sg, out,
++ VIRTQUEUE_NUM, req->rc->sdata, 11);
+ /*
+ * Running executables in the filesystem may result in
+ * a read request with kernel buffer as opposed to user buffer.
+@@ -366,8 +366,8 @@ req_retry_pinned:
+ }
+ in += inp;
+ } else {
+- in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM, rdata,
+- req->rc->capacity);
++ in = pack_sg_list(chan->sg, out, VIRTQUEUE_NUM,
++ req->rc->sdata, req->rc->capacity);
+ }
+
+ err = virtqueue_add_buf(chan->vq, chan->sg, out, in, req->tc);
+@@ -592,7 +592,14 @@ static struct p9_trans_module p9_virtio_
+ .close = p9_virtio_close,
+ .request = p9_virtio_request,
+ .cancel = p9_virtio_cancel,
+- .maxsize = PAGE_SIZE*VIRTQUEUE_NUM,
++
++ /*
++ * We leave one entry for input and one entry for response
++ * headers. We also skip one more entry to accomodate, address
++ * that are not at page boundary, that can result in an extra
++ * page in zero copy.
++ */
++ .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3),
+ .pref = P9_TRANS_PREF_PAYLOAD_SEP,
+ .def = 0,
+ .owner = THIS_MODULE,
diff --git a/queue-3.0/series b/queue-3.0/series
index 8ca2f20c3c..25841d99f3 100644
--- a/queue-3.0/series
+++ b/queue-3.0/series
@@ -90,3 +90,8 @@ irda-fix-smsc-ircc2-section-mismatch-warning.patch
iommu-amd-don-t-take-domain-lock-recursivly.patch
iommu-amd-make-sure-iommu-need_sync-contains-correct-value.patch
acpica-do-not-repair-_tss-return-package-if-_pss-is-present.patch
+fs-9p-add-fid-before-dentry-instantiation.patch
+fs-9p-don-t-update-file-type-when-updating-file-attributes.patch
+net-9p-fix-kernel-crash-with-msize-512k.patch
+fs-9p-always-ask-new-inode-in-lookup-for-cache-mode.patch
+fs-9p-use-protocol-defined-value-for-lock-getlock-type-field.patch