Commit d44c6d4f authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "A bunch of endianness fixes and a couple of nfsd error value fixes.

  Speaking of endianness stuff, I'm rather tempted to slap

	ccflags-y += -D__CHECK_ENDIAN__

  in fs/Makefile, if not making it default for the entire tree; nfsd
  regressions I've caught make one hell of a pile and we'd obviously
  benefit from having that kind of stuff caught earlier..."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  lockd: fix the endianness bug
  ocfs2: ->e_leaf_clusters endianness breakage
  ocfs2: ->rl_count endianness breakage
  ocfs: ->rl_used breakage on big-endian
  ocfs2: ->l_next_free_req breakage on big-endian
  btrfs: btrfs_root_readonly() broken on big-endian
  ext4: fix endianness breakage in ext4_split_extent_at()
  nfsd: fix compose_entry_fh() failure exits
  nfsd: fix error value on allocation failure in nfsd4_decode_test_stateid()
  nfsd: fix endianness breakage in TEST_STATEID handling
  nfsd: fix error values returned by nfsd4_lockt() when nfsd_open() fails
  nfsd: fix b0rken error value for setattr on read-only mount
parents bc0cf58e e847469b
...@@ -2166,7 +2166,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, ...@@ -2166,7 +2166,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
static inline bool btrfs_root_readonly(struct btrfs_root *root) 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 */ /* struct btrfs_root_backup */
......
...@@ -2882,7 +2882,7 @@ static int ext4_split_extent_at(handle_t *handle, ...@@ -2882,7 +2882,7 @@ static int ext4_split_extent_at(handle_t *handle,
if (err) if (err)
goto fix_extent_len; goto fix_extent_len;
/* update the extent length and mark as initialized */ /* update the extent length and mark as initialized */
ex->ee_len = cpu_to_le32(ee_len); ex->ee_len = cpu_to_le16(ee_len);
ext4_ext_try_to_merge(inode, path, ex); ext4_ext_try_to_merge(inode, path, ex);
err = ext4_ext_dirty(handle, inode, path + depth); err = ext4_ext_dirty(handle, inode, path + depth);
goto out; goto out;
......
...@@ -241,7 +241,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat) ...@@ -241,7 +241,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat)
p = xdr_inline_decode(xdr, 4); p = xdr_inline_decode(xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
goto out_overflow; goto out_overflow;
if (unlikely(*p > nlm4_failed)) if (unlikely(ntohl(*p) > ntohl(nlm4_failed)))
goto out_bad_xdr; goto out_bad_xdr;
*stat = *p; *stat = *p;
return 0; return 0;
......
...@@ -236,7 +236,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr, ...@@ -236,7 +236,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr,
p = xdr_inline_decode(xdr, 4); p = xdr_inline_decode(xdr, 4);
if (unlikely(p == NULL)) if (unlikely(p == NULL))
goto out_overflow; goto out_overflow;
if (unlikely(*p > nlm_lck_denied_grace_period)) if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period)))
goto out_enum; goto out_enum;
*stat = *p; *stat = *p;
return 0; return 0;
......
...@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, ...@@ -803,13 +803,13 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
return p; return p;
} }
static int static __be32
compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
const char *name, int namlen) const char *name, int namlen)
{ {
struct svc_export *exp; struct svc_export *exp;
struct dentry *dparent, *dchild; struct dentry *dparent, *dchild;
int rv = 0; __be32 rv = nfserr_noent;
dparent = cd->fh.fh_dentry; dparent = cd->fh.fh_dentry;
exp = cd->fh.fh_export; exp = cd->fh.fh_export;
...@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, ...@@ -817,26 +817,20 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
if (isdotent(name, namlen)) { if (isdotent(name, namlen)) {
if (namlen == 2) { if (namlen == 2) {
dchild = dget_parent(dparent); dchild = dget_parent(dparent);
if (dchild == dparent) {
/* filesystem root - cannot return filehandle for ".." */ /* filesystem root - cannot return filehandle for ".." */
dput(dchild); if (dchild == dparent)
return -ENOENT; goto out;
}
} else } else
dchild = dget(dparent); dchild = dget(dparent);
} else } else
dchild = lookup_one_len(name, dparent, namlen); dchild = lookup_one_len(name, dparent, namlen);
if (IS_ERR(dchild)) if (IS_ERR(dchild))
return -ENOENT; return rv;
rv = -ENOENT;
if (d_mountpoint(dchild)) if (d_mountpoint(dchild))
goto out; goto out;
rv = fh_compose(fhp, exp, dchild, &cd->fh);
if (rv)
goto out;
if (!dchild->d_inode) if (!dchild->d_inode)
goto out; goto out;
rv = 0; rv = fh_compose(fhp, exp, dchild, &cd->fh);
out: out:
dput(dchild); dput(dchild);
return rv; return rv;
...@@ -845,7 +839,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, ...@@ -845,7 +839,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen) static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
{ {
struct svc_fh fh; struct svc_fh fh;
int err; __be32 err;
fh_init(&fh, NFS3_FHSIZE); fh_init(&fh, NFS3_FHSIZE);
err = compose_entry_fh(cd, &fh, name, namlen); err = compose_entry_fh(cd, &fh, name, namlen);
......
...@@ -841,6 +841,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -841,6 +841,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_setattr *setattr) struct nfsd4_setattr *setattr)
{ {
__be32 status = nfs_ok; __be32 status = nfs_ok;
int err;
if (setattr->sa_iattr.ia_valid & ATTR_SIZE) { if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
nfs4_lock_state(); nfs4_lock_state();
...@@ -852,9 +853,9 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -852,9 +853,9 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
return status; return status;
} }
} }
status = fh_want_write(&cstate->current_fh); err = fh_want_write(&cstate->current_fh);
if (status) if (err)
return status; return nfserrno(err);
status = nfs_ok; status = nfs_ok;
status = check_attr_support(rqstp, cstate, setattr->sa_bmval, status = check_attr_support(rqstp, cstate, setattr->sa_bmval,
......
...@@ -4211,16 +4211,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4211,16 +4211,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
* vfs_test_lock. (Arguably perhaps test_lock should be done with an * vfs_test_lock. (Arguably perhaps test_lock should be done with an
* inode operation.) * 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; struct file *file;
int err; __be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
if (!err) {
err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file); err = nfserrno(vfs_test_lock(file, lock));
if (err)
return err;
err = vfs_test_lock(file, lock);
nfsd_close(file); nfsd_close(file);
}
return err; return err;
} }
...@@ -4234,7 +4232,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4234,7 +4232,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct inode *inode; struct inode *inode;
struct file_lock file_lock; struct file_lock file_lock;
struct nfs4_lockowner *lo; struct nfs4_lockowner *lo;
int error;
__be32 status; __be32 status;
if (locks_in_grace()) if (locks_in_grace())
...@@ -4280,12 +4277,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4280,12 +4277,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfs4_transform_lock_offset(&file_lock); nfs4_transform_lock_offset(&file_lock);
status = nfs_ok; status = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock); if (status)
if (error) {
status = nfserrno(error);
goto out; goto out;
}
if (file_lock.fl_type != F_UNLCK) { if (file_lock.fl_type != F_UNLCK) {
status = nfserr_denied; status = nfserr_denied;
nfs4_set_lock_denied(&file_lock, &lockt->lt_denied); nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);
......
...@@ -1392,7 +1392,7 @@ nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_sta ...@@ -1392,7 +1392,7 @@ nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_sta
for (i = 0; i < test_stateid->ts_num_ids; i++) { for (i = 0; i < test_stateid->ts_num_ids; i++) {
stateid = kmalloc(sizeof(struct nfsd4_test_stateid_id), GFP_KERNEL); stateid = kmalloc(sizeof(struct nfsd4_test_stateid_id), GFP_KERNEL);
if (!stateid) { if (!stateid) {
status = PTR_ERR(stateid); status = nfserrno(-ENOMEM);
goto out; goto out;
} }
...@@ -3410,7 +3410,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr, ...@@ -3410,7 +3410,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr,
*p++ = htonl(test_stateid->ts_num_ids); *p++ = htonl(test_stateid->ts_num_ids);
list_for_each_entry_safe(stateid, next, &test_stateid->ts_stateid_list, ts_id_list) { list_for_each_entry_safe(stateid, next, &test_stateid->ts_stateid_list, ts_id_list) {
*p++ = htonl(stateid->ts_id_status); *p++ = stateid->ts_id_status;
} }
ADJUST_ARGS(); ADJUST_ARGS();
......
...@@ -1134,7 +1134,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle, ...@@ -1134,7 +1134,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle,
} }
el = path_leaf_el(path); 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); ocfs2_adjust_rightmost_records(handle, et, path, rec);
......
...@@ -1036,14 +1036,14 @@ static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci, ...@@ -1036,14 +1036,14 @@ static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci,
tmp_el = left_path->p_node[subtree_root].el; tmp_el = left_path->p_node[subtree_root].el;
blkno = left_path->p_node[subtree_root+1].bh->b_blocknr; 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) { 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); *cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
break; 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: out:
ocfs2_free_path(left_path); ocfs2_free_path(left_path);
...@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh, ...@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh,
trace_ocfs2_divide_leaf_refcount_block( trace_ocfs2_divide_leaf_refcount_block(
(unsigned long long)ref_leaf_bh->b_blocknr, (unsigned long long)ref_leaf_bh->b_blocknr,
le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used)); le16_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
/* /*
* XXX: Improvement later. * XXX: Improvement later.
...@@ -2411,7 +2411,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, ...@@ -2411,7 +2411,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
rb = (struct ocfs2_refcount_block *) rb = (struct ocfs2_refcount_block *)
prev_bh->b_data; prev_bh->b_data;
if (le64_to_cpu(rb->rf_records.rl_used) + if (le16_to_cpu(rb->rf_records.rl_used) +
recs_add > recs_add >
le16_to_cpu(rb->rf_records.rl_count)) le16_to_cpu(rb->rf_records.rl_count))
ref_blocks++; ref_blocks++;
...@@ -2476,7 +2476,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, ...@@ -2476,7 +2476,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
if (prev_bh) { if (prev_bh) {
rb = (struct ocfs2_refcount_block *)prev_bh->b_data; 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)) le16_to_cpu(rb->rf_records.rl_count))
ref_blocks++; ref_blocks++;
...@@ -3629,7 +3629,7 @@ int ocfs2_refcounted_xattr_delete_need(struct inode *inode, ...@@ -3629,7 +3629,7 @@ int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
* one will split a refcount rec, so totally we need * one will split a refcount rec, so totally we need
* clusters * 2 new refcount rec. * 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)) le16_to_cpu(rb->rf_records.rl_count))
ref_blocks++; ref_blocks++;
......
...@@ -600,7 +600,7 @@ static void ocfs2_bg_alloc_cleanup(handle_t *handle, ...@@ -600,7 +600,7 @@ static void ocfs2_bg_alloc_cleanup(handle_t *handle,
ret = ocfs2_free_clusters(handle, cluster_ac->ac_inode, ret = ocfs2_free_clusters(handle, cluster_ac->ac_inode,
cluster_ac->ac_bh, cluster_ac->ac_bh,
le64_to_cpu(rec->e_blkno), le64_to_cpu(rec->e_blkno),
le32_to_cpu(rec->e_leaf_clusters)); le16_to_cpu(rec->e_leaf_clusters));
if (ret) if (ret)
mlog_errno(ret); mlog_errno(ret);
/* Try all the clusters to free */ /* Try all the clusters to free */
...@@ -1628,7 +1628,7 @@ static int ocfs2_bg_discontig_fix_by_rec(struct ocfs2_suballoc_result *res, ...@@ -1628,7 +1628,7 @@ static int ocfs2_bg_discontig_fix_by_rec(struct ocfs2_suballoc_result *res,
{ {
unsigned int bpc = le16_to_cpu(cl->cl_bpc); unsigned int bpc = le16_to_cpu(cl->cl_bpc);
unsigned int bitoff = le32_to_cpu(rec->e_cpos) * 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) if (res->sr_bit_offset < bitoff)
return 0; return 0;
......
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