--- /dev/null
+From 6ed3cf2cdfce4c9f1d73171bd3f27d9cb77b734e Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 11:49:04 -0400
+Subject: btrfs: btrfs_root_readonly() broken on big-endian
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 6ed3cf2cdfce4c9f1d73171bd3f27d9cb77b734e upstream.
+
+->root_flags is __le64 and all accesses to it go through the helpers
+that do proper conversions. Except for btrfs_root_readonly(), which
+checks bit 0 as in host-endian...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Chris Mason <chris.mason@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/ctree.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/btrfs/ctree.h
++++ b/fs/btrfs/ctree.h
+@@ -1972,7 +1972,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snaps
+
+ static inline bool btrfs_root_readonly(struct btrfs_root *root)
+ {
+- return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY;
++ return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0;
+ }
+
+ /* struct btrfs_super_block */
--- /dev/null
+From e847469bf77a1d339274074ed068d461f0c872bc Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 13:49:47 -0400
+Subject: lockd: fix the endianness bug
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit e847469bf77a1d339274074ed068d461f0c872bc upstream.
+
+comparing be32 values for < is not doing the right thing...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: "J. Bruce Fields" <bfields@fieldses.org>
+Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/lockd/clnt4xdr.c | 2 +-
+ fs/lockd/clntxdr.c | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/lockd/clnt4xdr.c
++++ b/fs/lockd/clnt4xdr.c
+@@ -241,7 +241,7 @@ static int decode_nlm4_stat(struct xdr_s
+ p = xdr_inline_decode(xdr, 4);
+ if (unlikely(p == NULL))
+ goto out_overflow;
+- if (unlikely(*p > nlm4_failed))
++ if (unlikely(ntohl(*p) > ntohl(nlm4_failed)))
+ goto out_bad_xdr;
+ *stat = *p;
+ return 0;
+--- a/fs/lockd/clntxdr.c
++++ b/fs/lockd/clntxdr.c
+@@ -236,7 +236,7 @@ static int decode_nlm_stat(struct xdr_st
+ p = xdr_inline_decode(xdr, 4);
+ if (unlikely(p == NULL))
+ goto out_overflow;
+- if (unlikely(*p > nlm_lck_denied_grace_period))
++ if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period)))
+ goto out_enum;
+ *stat = *p;
+ return 0;
--- /dev/null
+From efe39651f08813180f37dc508d950fc7d92b29a8 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 00:32:14 -0400
+Subject: nfsd: fix compose_entry_fh() failure exits
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit efe39651f08813180f37dc508d950fc7d92b29a8 upstream.
+
+Restore the original logics ("fail on mountpoints, negatives and in
+case of fh_compose() failures"). Since commit 8177e (nfsd: clean up
+readdirplus encoding) that got broken -
+ rv = fh_compose(fhp, exp, dchild, &cd->fh);
+ if (rv)
+ goto out;
+ if (!dchild->d_inode)
+ goto out;
+ rv = 0;
+out:
+is equivalent to
+ rv = fh_compose(fhp, exp, dchild, &cd->fh);
+out:
+and the second check has no effect whatsoever...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: "J. Bruce Fields" <bfields@fieldses.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfsd/nfs3xdr.c | 22 ++++++++--------------
+ 1 file changed, 8 insertions(+), 14 deletions(-)
+
+--- a/fs/nfsd/nfs3xdr.c
++++ b/fs/nfsd/nfs3xdr.c
+@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdi
+ return p;
+ }
+
+-static int
++static __be32
+ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
+ const char *name, int namlen)
+ {
+ struct svc_export *exp;
+ struct dentry *dparent, *dchild;
+- int rv = 0;
++ __be32 rv = nfserr_noent;
+
+ dparent = cd->fh.fh_dentry;
+ exp = cd->fh.fh_export;
+@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres
+ if (isdotent(name, namlen)) {
+ if (namlen == 2) {
+ dchild = dget_parent(dparent);
+- if (dchild == dparent) {
+- /* filesystem root - cannot return filehandle for ".." */
+- dput(dchild);
+- return -ENOENT;
+- }
++ /* filesystem root - cannot return filehandle for ".." */
++ if (dchild == dparent)
++ goto out;
+ } else
+ dchild = dget(dparent);
+ } else
+ dchild = lookup_one_len(name, dparent, namlen);
+ if (IS_ERR(dchild))
+- return -ENOENT;
+- rv = -ENOENT;
++ return rv;
+ if (d_mountpoint(dchild))
+ goto out;
+- rv = fh_compose(fhp, exp, dchild, &cd->fh);
+- if (rv)
+- goto out;
+ if (!dchild->d_inode)
+ goto out;
+- rv = 0;
++ rv = fh_compose(fhp, exp, dchild, &cd->fh);
+ out:
+ dput(dchild);
+ return rv;
+@@ -845,7 +839,7 @@ out:
+ static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
+ {
+ struct svc_fh fh;
+- int err;
++ __be32 err;
+
+ fh_init(&fh, NFS3_FHSIZE);
+ err = compose_entry_fh(cd, &fh, name, namlen);
--- /dev/null
+From e1bf4cc620fd143766ddfcee3b004a1d1bb34fd0 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 12:27:11 -0400
+Subject: ocfs: ->rl_used breakage on big-endian
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit e1bf4cc620fd143766ddfcee3b004a1d1bb34fd0 upstream.
+
+it's le16, not le32 or le64...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Mark Fasheh <mfasheh@suse.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ocfs2/refcounttree.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/fs/ocfs2/refcounttree.c
++++ b/fs/ocfs2/refcounttree.c
+@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_bl
+
+ trace_ocfs2_divide_leaf_refcount_block(
+ (unsigned long long)ref_leaf_bh->b_blocknr,
+- le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used));
++ le32_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
+
+ /*
+ * XXX: Improvement later.
+@@ -2411,7 +2411,7 @@ static int ocfs2_calc_refcount_meta_cred
+ rb = (struct ocfs2_refcount_block *)
+ prev_bh->b_data;
+
+- if (le64_to_cpu(rb->rf_records.rl_used) +
++ if (le16_to_cpu(rb->rf_records.rl_used) +
+ recs_add >
+ le16_to_cpu(rb->rf_records.rl_count))
+ ref_blocks++;
+@@ -2476,7 +2476,7 @@ static int ocfs2_calc_refcount_meta_cred
+ if (prev_bh) {
+ rb = (struct ocfs2_refcount_block *)prev_bh->b_data;
+
+- if (le64_to_cpu(rb->rf_records.rl_used) + recs_add >
++ if (le16_to_cpu(rb->rf_records.rl_used) + recs_add >
+ le16_to_cpu(rb->rf_records.rl_count))
+ ref_blocks++;
+
+@@ -3629,7 +3629,7 @@ int ocfs2_refcounted_xattr_delete_need(s
+ * one will split a refcount rec, so totally we need
+ * clusters * 2 new refcount rec.
+ */
+- if (le64_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
++ if (le16_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
+ le16_to_cpu(rb->rf_records.rl_count))
+ ref_blocks++;
+
--- /dev/null
+From 72094e43e3af5020510f920321d71f1798fa896d Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 12:30:02 -0400
+Subject: ocfs2: ->e_leaf_clusters endianness breakage
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 72094e43e3af5020510f920321d71f1798fa896d upstream.
+
+le16, not le32...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Mark Fasheh <mfasheh@suse.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ocfs2/suballoc.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/fs/ocfs2/suballoc.c
++++ b/fs/ocfs2/suballoc.c
+@@ -600,7 +600,7 @@ static void ocfs2_bg_alloc_cleanup(handl
+ ret = ocfs2_free_clusters(handle, cluster_ac->ac_inode,
+ cluster_ac->ac_bh,
+ le64_to_cpu(rec->e_blkno),
+- le32_to_cpu(rec->e_leaf_clusters));
++ le16_to_cpu(rec->e_leaf_clusters));
+ if (ret)
+ mlog_errno(ret);
+ /* Try all the clusters to free */
+@@ -1628,7 +1628,7 @@ static int ocfs2_bg_discontig_fix_by_rec
+ {
+ unsigned int bpc = le16_to_cpu(cl->cl_bpc);
+ unsigned int bitoff = le32_to_cpu(rec->e_cpos) * bpc;
+- unsigned int bitcount = le32_to_cpu(rec->e_leaf_clusters) * bpc;
++ unsigned int bitcount = le16_to_cpu(rec->e_leaf_clusters) * bpc;
+
+ if (res->sr_bit_offset < bitoff)
+ return 0;
--- /dev/null
+From 3a251f04fe97c3d335b745c98e4b377e3c3899f2 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 12:22:00 -0400
+Subject: ocfs2: ->l_next_free_req breakage on big-endian
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 3a251f04fe97c3d335b745c98e4b377e3c3899f2 upstream.
+
+It's le16, not le32...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Mark Fasheh <mfasheh@suse.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ocfs2/alloc.c | 2 +-
+ fs/ocfs2/refcounttree.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/fs/ocfs2/alloc.c
++++ b/fs/ocfs2/alloc.c
+@@ -1134,7 +1134,7 @@ static int ocfs2_adjust_rightmost_branch
+ }
+
+ el = path_leaf_el(path);
+- rec = &el->l_recs[le32_to_cpu(el->l_next_free_rec) - 1];
++ rec = &el->l_recs[le16_to_cpu(el->l_next_free_rec) - 1];
+
+ ocfs2_adjust_rightmost_records(handle, et, path, rec);
+
+--- a/fs/ocfs2/refcounttree.c
++++ b/fs/ocfs2/refcounttree.c
+@@ -1036,14 +1036,14 @@ static int ocfs2_get_refcount_cpos_end(s
+
+ tmp_el = left_path->p_node[subtree_root].el;
+ blkno = left_path->p_node[subtree_root+1].bh->b_blocknr;
+- for (i = 0; i < le32_to_cpu(tmp_el->l_next_free_rec); i++) {
++ for (i = 0; i < le16_to_cpu(tmp_el->l_next_free_rec); i++) {
+ if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) {
+ *cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
+ break;
+ }
+ }
+
+- BUG_ON(i == le32_to_cpu(tmp_el->l_next_free_rec));
++ BUG_ON(i == le16_to_cpu(tmp_el->l_next_free_rec));
+
+ out:
+ ocfs2_free_path(left_path);
--- /dev/null
+From 28748b325dc2d730ccc312830a91c4ae0c0d9379 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 12:28:21 -0400
+Subject: ocfs2: ->rl_count endianness breakage
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 28748b325dc2d730ccc312830a91c4ae0c0d9379 upstream.
+
+le16, not le32...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Cc: Mark Fasheh <mfasheh@suse.com>
+Cc: Joel Becker <jlbec@evilplan.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/ocfs2/refcounttree.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/ocfs2/refcounttree.c
++++ b/fs/ocfs2/refcounttree.c
+@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_bl
+
+ trace_ocfs2_divide_leaf_refcount_block(
+ (unsigned long long)ref_leaf_bh->b_blocknr,
+- le32_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
++ le16_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
+
+ /*
+ * XXX: Improvement later.
rt2x00-add-usb-device-id-of-buffalo-wli-uc-gnhp.patch
rt2800-add-support-for-the-fujitsu-stylistic-q550.patch
rt2x00-identify-rt2800usb-chipsets.patch
+nfsd-fix-compose_entry_fh-failure-exits.patch
+btrfs-btrfs_root_readonly-broken-on-big-endian.patch
+ocfs2-l_next_free_req-breakage-on-big-endian.patch
+ocfs-rl_used-breakage-on-big-endian.patch
+ocfs2-rl_count-endianness-breakage.patch
+ocfs2-e_leaf_clusters-endianness-breakage.patch
+lockd-fix-the-endianness-bug.patch