Skip to content

Commit d44c6d4

Browse files
committed
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
2 parents bc0cf58 + e847469 commit d44c6d4

File tree

11 files changed

+36
-46
lines changed

11 files changed

+36
-46
lines changed

fs/btrfs/ctree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2166,7 +2166,7 @@ BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item,
21662166

21672167
static inline bool btrfs_root_readonly(struct btrfs_root *root)
21682168
{
2169-
return root->root_item.flags & BTRFS_ROOT_SUBVOL_RDONLY;
2169+
return (root->root_item.flags & cpu_to_le64(BTRFS_ROOT_SUBVOL_RDONLY)) != 0;
21702170
}
21712171

21722172
/* struct btrfs_root_backup */

fs/ext4/extents.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ static int ext4_split_extent_at(handle_t *handle,
28822882
if (err)
28832883
goto fix_extent_len;
28842884
/* update the extent length and mark as initialized */
2885-
ex->ee_len = cpu_to_le32(ee_len);
2885+
ex->ee_len = cpu_to_le16(ee_len);
28862886
ext4_ext_try_to_merge(inode, path, ex);
28872887
err = ext4_ext_dirty(handle, inode, path + depth);
28882888
goto out;

fs/lockd/clnt4xdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static int decode_nlm4_stat(struct xdr_stream *xdr, __be32 *stat)
241241
p = xdr_inline_decode(xdr, 4);
242242
if (unlikely(p == NULL))
243243
goto out_overflow;
244-
if (unlikely(*p > nlm4_failed))
244+
if (unlikely(ntohl(*p) > ntohl(nlm4_failed)))
245245
goto out_bad_xdr;
246246
*stat = *p;
247247
return 0;

fs/lockd/clntxdr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static int decode_nlm_stat(struct xdr_stream *xdr,
236236
p = xdr_inline_decode(xdr, 4);
237237
if (unlikely(p == NULL))
238238
goto out_overflow;
239-
if (unlikely(*p > nlm_lck_denied_grace_period))
239+
if (unlikely(ntohl(*p) > ntohl(nlm_lck_denied_grace_period)))
240240
goto out_enum;
241241
*stat = *p;
242242
return 0;

fs/nfsd/nfs3xdr.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -803,40 +803,34 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
803803
return p;
804804
}
805805

806-
static int
806+
static __be32
807807
compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
808808
const char *name, int namlen)
809809
{
810810
struct svc_export *exp;
811811
struct dentry *dparent, *dchild;
812-
int rv = 0;
812+
__be32 rv = nfserr_noent;
813813

814814
dparent = cd->fh.fh_dentry;
815815
exp = cd->fh.fh_export;
816816

817817
if (isdotent(name, namlen)) {
818818
if (namlen == 2) {
819819
dchild = dget_parent(dparent);
820-
if (dchild == dparent) {
821-
/* filesystem root - cannot return filehandle for ".." */
822-
dput(dchild);
823-
return -ENOENT;
824-
}
820+
/* filesystem root - cannot return filehandle for ".." */
821+
if (dchild == dparent)
822+
goto out;
825823
} else
826824
dchild = dget(dparent);
827825
} else
828826
dchild = lookup_one_len(name, dparent, namlen);
829827
if (IS_ERR(dchild))
830-
return -ENOENT;
831-
rv = -ENOENT;
828+
return rv;
832829
if (d_mountpoint(dchild))
833830
goto out;
834-
rv = fh_compose(fhp, exp, dchild, &cd->fh);
835-
if (rv)
836-
goto out;
837831
if (!dchild->d_inode)
838832
goto out;
839-
rv = 0;
833+
rv = fh_compose(fhp, exp, dchild, &cd->fh);
840834
out:
841835
dput(dchild);
842836
return rv;
@@ -845,7 +839,7 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
845839
static __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen)
846840
{
847841
struct svc_fh fh;
848-
int err;
842+
__be32 err;
849843

850844
fh_init(&fh, NFS3_FHSIZE);
851845
err = compose_entry_fh(cd, &fh, name, namlen);

fs/nfsd/nfs4proc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
841841
struct nfsd4_setattr *setattr)
842842
{
843843
__be32 status = nfs_ok;
844+
int err;
844845

845846
if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
846847
nfs4_lock_state();
@@ -852,9 +853,9 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
852853
return status;
853854
}
854855
}
855-
status = fh_want_write(&cstate->current_fh);
856-
if (status)
857-
return status;
856+
err = fh_want_write(&cstate->current_fh);
857+
if (err)
858+
return nfserrno(err);
858859
status = nfs_ok;
859860

860861
status = check_attr_support(rqstp, cstate, setattr->sa_bmval,

fs/nfsd/nfs4state.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,16 +4211,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
42114211
* vfs_test_lock. (Arguably perhaps test_lock should be done with an
42124212
* inode operation.)
42134213
*/
4214-
static int nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
4214+
static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
42154215
{
42164216
struct file *file;
4217-
int err;
4218-
4219-
err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
4220-
if (err)
4221-
return err;
4222-
err = vfs_test_lock(file, lock);
4223-
nfsd_close(file);
4217+
__be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
4218+
if (!err) {
4219+
err = nfserrno(vfs_test_lock(file, lock));
4220+
nfsd_close(file);
4221+
}
42244222
return err;
42254223
}
42264224

@@ -4234,7 +4232,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
42344232
struct inode *inode;
42354233
struct file_lock file_lock;
42364234
struct nfs4_lockowner *lo;
4237-
int error;
42384235
__be32 status;
42394236

42404237
if (locks_in_grace())
@@ -4280,12 +4277,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
42804277

42814278
nfs4_transform_lock_offset(&file_lock);
42824279

4283-
status = nfs_ok;
4284-
error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
4285-
if (error) {
4286-
status = nfserrno(error);
4280+
status = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
4281+
if (status)
42874282
goto out;
4288-
}
4283+
42894284
if (file_lock.fl_type != F_UNLCK) {
42904285
status = nfserr_denied;
42914286
nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);

fs/nfsd/nfs4xdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_sta
13921392
for (i = 0; i < test_stateid->ts_num_ids; i++) {
13931393
stateid = kmalloc(sizeof(struct nfsd4_test_stateid_id), GFP_KERNEL);
13941394
if (!stateid) {
1395-
status = PTR_ERR(stateid);
1395+
status = nfserrno(-ENOMEM);
13961396
goto out;
13971397
}
13981398

@@ -3410,7 +3410,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr,
34103410
*p++ = htonl(test_stateid->ts_num_ids);
34113411

34123412
list_for_each_entry_safe(stateid, next, &test_stateid->ts_stateid_list, ts_id_list) {
3413-
*p++ = htonl(stateid->ts_id_status);
3413+
*p++ = stateid->ts_id_status;
34143414
}
34153415

34163416
ADJUST_ARGS();

fs/ocfs2/alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle,
11341134
}
11351135

11361136
el = path_leaf_el(path);
1137-
rec = &el->l_recs[le32_to_cpu(el->l_next_free_rec) - 1];
1137+
rec = &el->l_recs[le16_to_cpu(el->l_next_free_rec) - 1];
11381138

11391139
ocfs2_adjust_rightmost_records(handle, et, path, rec);
11401140

fs/ocfs2/refcounttree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,14 +1036,14 @@ static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci,
10361036

10371037
tmp_el = left_path->p_node[subtree_root].el;
10381038
blkno = left_path->p_node[subtree_root+1].bh->b_blocknr;
1039-
for (i = 0; i < le32_to_cpu(tmp_el->l_next_free_rec); i++) {
1039+
for (i = 0; i < le16_to_cpu(tmp_el->l_next_free_rec); i++) {
10401040
if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) {
10411041
*cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
10421042
break;
10431043
}
10441044
}
10451045

1046-
BUG_ON(i == le32_to_cpu(tmp_el->l_next_free_rec));
1046+
BUG_ON(i == le16_to_cpu(tmp_el->l_next_free_rec));
10471047

10481048
out:
10491049
ocfs2_free_path(left_path);
@@ -1468,7 +1468,7 @@ static int ocfs2_divide_leaf_refcount_block(struct buffer_head *ref_leaf_bh,
14681468

14691469
trace_ocfs2_divide_leaf_refcount_block(
14701470
(unsigned long long)ref_leaf_bh->b_blocknr,
1471-
le32_to_cpu(rl->rl_count), le32_to_cpu(rl->rl_used));
1471+
le16_to_cpu(rl->rl_count), le16_to_cpu(rl->rl_used));
14721472

14731473
/*
14741474
* XXX: Improvement later.
@@ -2411,7 +2411,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
24112411
rb = (struct ocfs2_refcount_block *)
24122412
prev_bh->b_data;
24132413

2414-
if (le64_to_cpu(rb->rf_records.rl_used) +
2414+
if (le16_to_cpu(rb->rf_records.rl_used) +
24152415
recs_add >
24162416
le16_to_cpu(rb->rf_records.rl_count))
24172417
ref_blocks++;
@@ -2476,7 +2476,7 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb,
24762476
if (prev_bh) {
24772477
rb = (struct ocfs2_refcount_block *)prev_bh->b_data;
24782478

2479-
if (le64_to_cpu(rb->rf_records.rl_used) + recs_add >
2479+
if (le16_to_cpu(rb->rf_records.rl_used) + recs_add >
24802480
le16_to_cpu(rb->rf_records.rl_count))
24812481
ref_blocks++;
24822482

@@ -3629,7 +3629,7 @@ int ocfs2_refcounted_xattr_delete_need(struct inode *inode,
36293629
* one will split a refcount rec, so totally we need
36303630
* clusters * 2 new refcount rec.
36313631
*/
3632-
if (le64_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
3632+
if (le16_to_cpu(rb->rf_records.rl_used) + clusters * 2 >
36333633
le16_to_cpu(rb->rf_records.rl_count))
36343634
ref_blocks++;
36353635

fs/ocfs2/suballoc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static void ocfs2_bg_alloc_cleanup(handle_t *handle,
600600
ret = ocfs2_free_clusters(handle, cluster_ac->ac_inode,
601601
cluster_ac->ac_bh,
602602
le64_to_cpu(rec->e_blkno),
603-
le32_to_cpu(rec->e_leaf_clusters));
603+
le16_to_cpu(rec->e_leaf_clusters));
604604
if (ret)
605605
mlog_errno(ret);
606606
/* Try all the clusters to free */
@@ -1628,7 +1628,7 @@ static int ocfs2_bg_discontig_fix_by_rec(struct ocfs2_suballoc_result *res,
16281628
{
16291629
unsigned int bpc = le16_to_cpu(cl->cl_bpc);
16301630
unsigned int bitoff = le32_to_cpu(rec->e_cpos) * bpc;
1631-
unsigned int bitcount = le32_to_cpu(rec->e_leaf_clusters) * bpc;
1631+
unsigned int bitcount = le16_to_cpu(rec->e_leaf_clusters) * bpc;
16321632

16331633
if (res->sr_bit_offset < bitoff)
16341634
return 0;

0 commit comments

Comments
 (0)