--- /dev/null
+From f78233dd44a110c574fe760ad6f9c1e8741a0d00 Mon Sep 17 00:00:00 2001
+From: Sachin Prabhu <sprabhu@redhat.com>
+Date: Sat, 13 Mar 2010 09:03:55 -0600
+Subject: 9p: Skip check for mandatory locks when unlocking
+
+From: Sachin Prabhu <sprabhu@redhat.com>
+
+commit f78233dd44a110c574fe760ad6f9c1e8741a0d00 upstream.
+
+While investigating a bug, I came across a possible bug in v9fs. The
+problem is similar to the one reported for NFS by ASANO Masahiro in
+http://lkml.org/lkml/2005/12/21/334.
+
+v9fs_file_lock() will skip locks on file which has mode set to 02666.
+This is a problem in cases where the mode of the file is changed after
+a process has obtained a lock on the file. Such a lock will be skipped
+during unlock and the machine will end up with a BUG in
+locks_remove_flock().
+
+v9fs_file_lock() should skip the check for mandatory locks when
+unlocking a file.
+
+Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
+Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
+Cc: maximilian attems <max@stro.at>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/9p/vfs_file.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/9p/vfs_file.c
++++ b/fs/9p/vfs_file.c
+@@ -114,7 +114,7 @@ static int v9fs_file_lock(struct file *f
+ P9_DPRINTK(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
+
+ /* No mandatory locks */
+- if (__mandatory_lock(inode))
++ if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
+ return -ENOLCK;
+
+ if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
--- /dev/null
+From 78c37eb0d5e6a9727b12ea0f1821795ffaa66cfe Mon Sep 17 00:00:00 2001
+From: Tao Ma <tao.ma@oracle.com>
+Date: Wed, 3 Mar 2010 11:26:27 +0800
+Subject: ocfs2: Change bg_chain check for ocfs2_validate_gd_parent.
+
+From: Tao Ma <tao.ma@oracle.com>
+
+commit 78c37eb0d5e6a9727b12ea0f1821795ffaa66cfe upstream.
+
+In ocfs2_validate_gd_parent, we check bg_chain against the
+cl_next_free_rec of the dinode. Actually in resize, we have
+the chance of bg_chain == cl_next_free_rec. So add some
+additional condition check for it.
+
+I also rename paramter "clean_error" to "resize", since the
+old one is not clearly enough to indicate that we should only
+meet with this case in resize.
+
+btw, the correpsonding bug is
+http://oss.oracle.com/bugzilla/show_bug.cgi?id=1230.
+
+Signed-off-by: Tao Ma <tao.ma@oracle.com>
+Signed-off-by: Joel Becker <joel.becker@oracle.com>
+Cc: maximilian attems <max@stro.at>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/ocfs2/suballoc.c | 13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+--- a/fs/ocfs2/suballoc.c
++++ b/fs/ocfs2/suballoc.c
+@@ -152,7 +152,7 @@ static u32 ocfs2_bits_per_group(struct o
+
+ #define do_error(fmt, ...) \
+ do{ \
+- if (clean_error) \
++ if (resize) \
+ mlog(ML_ERROR, fmt "\n", ##__VA_ARGS__); \
+ else \
+ ocfs2_error(sb, fmt, ##__VA_ARGS__); \
+@@ -160,7 +160,7 @@ static u32 ocfs2_bits_per_group(struct o
+
+ static int ocfs2_validate_gd_self(struct super_block *sb,
+ struct buffer_head *bh,
+- int clean_error)
++ int resize)
+ {
+ struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
+
+@@ -211,7 +211,7 @@ static int ocfs2_validate_gd_self(struct
+ static int ocfs2_validate_gd_parent(struct super_block *sb,
+ struct ocfs2_dinode *di,
+ struct buffer_head *bh,
+- int clean_error)
++ int resize)
+ {
+ unsigned int max_bits;
+ struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *)bh->b_data;
+@@ -233,8 +233,11 @@ static int ocfs2_validate_gd_parent(stru
+ return -EINVAL;
+ }
+
+- if (le16_to_cpu(gd->bg_chain) >=
+- le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
++ /* In resize, we may meet the case bg_chain == cl_next_free_rec. */
++ if ((le16_to_cpu(gd->bg_chain) >
++ le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) ||
++ ((le16_to_cpu(gd->bg_chain) ==
++ le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) && !resize)) {
+ do_error("Group descriptor #%llu has bad chain %u",
+ (unsigned long long)bh->b_blocknr,
+ le16_to_cpu(gd->bg_chain));
--- /dev/null
+From fcefd25ac89239cb57fa198f125a79ff85468c75 Mon Sep 17 00:00:00 2001
+From: Mark Fasheh <mfasheh@suse.com>
+Date: Mon, 15 Mar 2010 15:39:00 -0700
+Subject: ocfs2: set i_mode on disk during acl operations
+
+From: Mark Fasheh <mfasheh@suse.com>
+
+commit fcefd25ac89239cb57fa198f125a79ff85468c75 upstream.
+
+ocfs2_set_acl() and ocfs2_init_acl() were setting i_mode on the in-memory
+inode, but never setting it on the disk copy. Thus, acls were some times not
+getting propagated between nodes. This patch fixes the issue by adding a
+helper function ocfs2_acl_set_mode() which does this the right way.
+ocfs2_set_acl() and ocfs2_init_acl() are then updated to call
+ocfs2_acl_set_mode().
+
+Signed-off-by: Mark Fasheh <mfasheh@suse.com>
+Signed-off-by: Joel Becker <joel.becker@oracle.com>
+Cc: maximilian attems <max@stro.at>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ fs/ocfs2/acl.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 72 insertions(+), 5 deletions(-)
+
+--- a/fs/ocfs2/acl.c
++++ b/fs/ocfs2/acl.c
+@@ -30,6 +30,8 @@
+ #include "alloc.h"
+ #include "dlmglue.h"
+ #include "file.h"
++#include "inode.h"
++#include "journal.h"
+ #include "ocfs2_fs.h"
+
+ #include "xattr.h"
+@@ -166,6 +168,60 @@ static struct posix_acl *ocfs2_get_acl(s
+ }
+
+ /*
++ * Helper function to set i_mode in memory and disk. Some call paths
++ * will not have di_bh or a journal handle to pass, in which case it
++ * will create it's own.
++ */
++static int ocfs2_acl_set_mode(struct inode *inode, struct buffer_head *di_bh,
++ handle_t *handle, umode_t new_mode)
++{
++ int ret, commit_handle = 0;
++ struct ocfs2_dinode *di;
++
++ if (di_bh == NULL) {
++ ret = ocfs2_read_inode_block(inode, &di_bh);
++ if (ret) {
++ mlog_errno(ret);
++ goto out;
++ }
++ } else
++ get_bh(di_bh);
++
++ if (handle == NULL) {
++ handle = ocfs2_start_trans(OCFS2_SB(inode->i_sb),
++ OCFS2_INODE_UPDATE_CREDITS);
++ if (IS_ERR(handle)) {
++ ret = PTR_ERR(handle);
++ mlog_errno(ret);
++ goto out_brelse;
++ }
++
++ commit_handle = 1;
++ }
++
++ di = (struct ocfs2_dinode *)di_bh->b_data;
++ ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
++ OCFS2_JOURNAL_ACCESS_WRITE);
++ if (ret) {
++ mlog_errno(ret);
++ goto out_commit;
++ }
++
++ inode->i_mode = new_mode;
++ di->i_mode = cpu_to_le16(inode->i_mode);
++
++ ocfs2_journal_dirty(handle, di_bh);
++
++out_commit:
++ if (commit_handle)
++ ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
++out_brelse:
++ brelse(di_bh);
++out:
++ return ret;
++}
++
++/*
+ * Set the access or default ACL of an inode.
+ */
+ static int ocfs2_set_acl(handle_t *handle,
+@@ -193,9 +249,14 @@ static int ocfs2_set_acl(handle_t *handl
+ if (ret < 0)
+ return ret;
+ else {
+- inode->i_mode = mode;
+ if (ret == 0)
+ acl = NULL;
++
++ ret = ocfs2_acl_set_mode(inode, di_bh,
++ handle, mode);
++ if (ret)
++ return ret;
++
+ }
+ }
+ break;
+@@ -283,6 +344,7 @@ int ocfs2_init_acl(handle_t *handle,
+ struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
+ struct posix_acl *acl = NULL;
+ int ret = 0;
++ mode_t mode;
+
+ if (!S_ISLNK(inode->i_mode)) {
+ if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) {
+@@ -291,12 +353,17 @@ int ocfs2_init_acl(handle_t *handle,
+ if (IS_ERR(acl))
+ return PTR_ERR(acl);
+ }
+- if (!acl)
+- inode->i_mode &= ~current_umask();
++ if (!acl) {
++ mode = inode->i_mode & ~current_umask();
++ ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
++ if (ret) {
++ mlog_errno(ret);
++ goto cleanup;
++ }
++ }
+ }
+ if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) {
+ struct posix_acl *clone;
+- mode_t mode;
+
+ if (S_ISDIR(inode->i_mode)) {
+ ret = ocfs2_set_acl(handle, inode, di_bh,
+@@ -313,7 +380,7 @@ int ocfs2_init_acl(handle_t *handle,
+ mode = inode->i_mode;
+ ret = posix_acl_create_masq(clone, &mode);
+ if (ret >= 0) {
+- inode->i_mode = mode;
++ ret = ocfs2_acl_set_mode(inode, di_bh, handle, mode);
+ if (ret > 0) {
+ ret = ocfs2_set_acl(handle, inode,
+ di_bh, ACL_TYPE_ACCESS,
x86-64-rwsem-avoid-store-forwarding-hazard-in-__downgrade_write.patch
fix-nfs4-handling-of-mountpoint-stat.patch
quota-fix-possible-dq_flags-corruption.patch
+ocfs2-set-i_mode-on-disk-during-acl-operations.patch
+ocfs2-change-bg_chain-check-for-ocfs2_validate_gd_parent.patch
+9p-skip-check-for-mandatory-locks-when-unlocking.patch