--- /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
+@@ -2115,7 +2115,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_root_backup */
--- /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 96f6f98501196d46ce52c2697dd758d9300c63f5 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Thu, 12 Apr 2012 23:47:00 -0400
+Subject: nfsd: fix b0rken error value for setattr on read-only mount
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 96f6f98501196d46ce52c2697dd758d9300c63f5 upstream.
+
+..._want_write() returns -EROFS on failure, _not_ an NFS error value.
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfsd/nfs4proc.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/fs/nfsd/nfs4proc.c
++++ b/fs/nfsd/nfs4proc.c
+@@ -826,6 +826,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, st
+ struct nfsd4_setattr *setattr)
+ {
+ __be32 status = nfs_ok;
++ int err;
+
+ if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
+ nfs4_lock_state();
+@@ -837,9 +838,9 @@ nfsd4_setattr(struct svc_rqst *rqstp, st
+ return status;
+ }
+ }
+- status = fh_want_write(&cstate->current_fh);
+- if (status)
+- return status;
++ err = fh_want_write(&cstate->current_fh);
++ if (err)
++ return nfserrno(err);
+ status = nfs_ok;
+
+ status = check_attr_support(rqstp, cstate, setattr->sa_bmval,
--- /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 02f5fde5df0ea930e70f93763dd48beff182b208 Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 00:10:34 -0400
+Subject: nfsd: fix endianness breakage in TEST_STATEID handling
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 02f5fde5df0ea930e70f93763dd48beff182b208 upstream.
+
+->ts_id_status gets nfs errno, i.e. it's already big-endian; no need
+to apply htonl() to it. Broken by commit 174568 (NFSD: Added TEST_STATEID
+operation) last year...
+
+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/nfs4xdr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/nfsd/nfs4xdr.c
++++ b/fs/nfsd/nfs4xdr.c
+@@ -3410,7 +3410,7 @@ nfsd4_encode_test_stateid(struct nfsd4_c
+ nfsd4_decode_stateid(argp, &si);
+ valid = nfs4_validate_stateid(cl, &si);
+ RESERVE_SPACE(4);
+- *p++ = htonl(valid);
++ *p++ = valid;
+ resp->p = p;
+ }
+ nfs4_unlock_state();
--- /dev/null
+From 04da6e9d63427b2d0fd04766712200c250b3278f Mon Sep 17 00:00:00 2001
+From: Al Viro <viro@zeniv.linux.org.uk>
+Date: Fri, 13 Apr 2012 00:00:04 -0400
+Subject: nfsd: fix error values returned by nfsd4_lockt() when nfsd_open() fails
+
+From: Al Viro <viro@zeniv.linux.org.uk>
+
+commit 04da6e9d63427b2d0fd04766712200c250b3278f upstream.
+
+nfsd_open() already returns an NFS error value; only vfs_test_lock()
+result needs to be fed through nfserrno(). Broken by commit 55ef12
+(nfsd: Ensure nfsv4 calls the underlying filesystem on LOCKT)
+three years ago...
+
+Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/nfsd/nfs4state.c | 23 +++++++++--------------
+ 1 file changed, 9 insertions(+), 14 deletions(-)
+
+--- a/fs/nfsd/nfs4state.c
++++ b/fs/nfsd/nfs4state.c
+@@ -4109,16 +4109,14 @@ out:
+ * vfs_test_lock. (Arguably perhaps test_lock should be done with an
+ * inode operation.)
+ */
+-static int nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
++static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
+ {
+ struct file *file;
+- int err;
+-
+- err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
+- if (err)
+- return err;
+- err = vfs_test_lock(file, lock);
+- nfsd_close(file);
++ __be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
++ if (!err) {
++ err = nfserrno(vfs_test_lock(file, lock));
++ nfsd_close(file);
++ }
+ return err;
+ }
+
+@@ -4132,7 +4130,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, stru
+ struct inode *inode;
+ struct file_lock file_lock;
+ struct nfs4_lockowner *lo;
+- int error;
+ __be32 status;
+
+ if (locks_in_grace())
+@@ -4178,12 +4175,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, stru
+
+ nfs4_transform_lock_offset(&file_lock);
+
+- status = nfs_ok;
+- error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
+- if (error) {
+- status = nfserrno(error);
++ status = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
++ if (status)
+ goto out;
+- }
++
+ if (file_lock.fl_type != F_UNLCK) {
+ status = nfserr_denied;
+ nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);
--- /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.
dell-laptop-add-3-machines-that-has-touchpad-led.patch
dell-laptop-touchpad-led-should-persist-its-status-after-s3.patch
bluetooth-add-support-for-atheros.patch
+nfsd-fix-b0rken-error-value-for-setattr-on-read-only-mount.patch
+nfsd-fix-error-values-returned-by-nfsd4_lockt-when.patch
+nfsd-fix-endianness-breakage-in-test_stateid-handling.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