Skip to content

Commit 7eeabbd

Browse files
committed
Merge branch 'xfs-misc-fixes-for-4.5' into for-next
2 parents 609adfc + a841b64 commit 7eeabbd

28 files changed

+126
-83
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ xfs_agfl_write_verify(
535535
}
536536

537537
const struct xfs_buf_ops xfs_agfl_buf_ops = {
538+
.name = "xfs_agfl",
538539
.verify_read = xfs_agfl_read_verify,
539540
.verify_write = xfs_agfl_write_verify,
540541
};
@@ -1926,7 +1927,7 @@ xfs_alloc_space_available(
19261927
* Decide whether to use this allocation group for this allocation.
19271928
* If so, fix up the btree freelist's size.
19281929
*/
1929-
STATIC int /* error */
1930+
int /* error */
19301931
xfs_alloc_fix_freelist(
19311932
struct xfs_alloc_arg *args, /* allocation argument structure */
19321933
int flags) /* XFS_ALLOC_FLAG_... */
@@ -2339,6 +2340,7 @@ xfs_agf_write_verify(
23392340
}
23402341

23412342
const struct xfs_buf_ops xfs_agf_buf_ops = {
2343+
.name = "xfs_agf",
23422344
.verify_read = xfs_agf_read_verify,
23432345
.verify_write = xfs_agf_write_verify,
23442346
};

fs/xfs/libxfs/xfs_alloc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,6 @@ xfs_alloc_get_rec(
235235

236236
int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
237237
xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);
238+
int xfs_alloc_fix_freelist(struct xfs_alloc_arg *args, int flags);
238239

239240
#endif /* __XFS_ALLOC_H__ */

fs/xfs/libxfs/xfs_alloc_btree.c

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,7 @@ xfs_allocbt_verify(
293293
level = be16_to_cpu(block->bb_level);
294294
switch (block->bb_magic) {
295295
case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
296-
if (!xfs_sb_version_hascrc(&mp->m_sb))
297-
return false;
298-
if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
299-
return false;
300-
if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
301-
return false;
302-
if (pag &&
303-
be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
296+
if (!xfs_btree_sblock_v5hdr_verify(bp))
304297
return false;
305298
/* fall through */
306299
case cpu_to_be32(XFS_ABTB_MAGIC):
@@ -311,14 +304,7 @@ xfs_allocbt_verify(
311304
return false;
312305
break;
313306
case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
314-
if (!xfs_sb_version_hascrc(&mp->m_sb))
315-
return false;
316-
if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
317-
return false;
318-
if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
319-
return false;
320-
if (pag &&
321-
be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
307+
if (!xfs_btree_sblock_v5hdr_verify(bp))
322308
return false;
323309
/* fall through */
324310
case cpu_to_be32(XFS_ABTC_MAGIC):
@@ -332,21 +318,7 @@ xfs_allocbt_verify(
332318
return false;
333319
}
334320

335-
/* numrecs verification */
336-
if (be16_to_cpu(block->bb_numrecs) > mp->m_alloc_mxr[level != 0])
337-
return false;
338-
339-
/* sibling pointer verification */
340-
if (!block->bb_u.s.bb_leftsib ||
341-
(be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks &&
342-
block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK)))
343-
return false;
344-
if (!block->bb_u.s.bb_rightsib ||
345-
(be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks &&
346-
block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
347-
return false;
348-
349-
return true;
321+
return xfs_btree_sblock_verify(bp, mp->m_alloc_mxr[level != 0]);
350322
}
351323

352324
static void
@@ -379,6 +351,7 @@ xfs_allocbt_write_verify(
379351
}
380352

381353
const struct xfs_buf_ops xfs_allocbt_buf_ops = {
354+
.name = "xfs_allocbt",
382355
.verify_read = xfs_allocbt_read_verify,
383356
.verify_write = xfs_allocbt_write_verify,
384357
};

fs/xfs/libxfs/xfs_attr_leaf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ xfs_attr3_leaf_read_verify(
328328
}
329329

330330
const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
331+
.name = "xfs_attr3_leaf",
331332
.verify_read = xfs_attr3_leaf_read_verify,
332333
.verify_write = xfs_attr3_leaf_write_verify,
333334
};

fs/xfs/libxfs/xfs_attr_remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ xfs_attr3_rmt_write_verify(
201201
}
202202

203203
const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
204+
.name = "xfs_attr3_rmt",
204205
.verify_read = xfs_attr3_rmt_read_verify,
205206
.verify_write = xfs_attr3_rmt_write_verify,
206207
};

fs/xfs/libxfs/xfs_bit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ int
3232
xfs_bitmap_empty(uint *map, uint size)
3333
{
3434
uint i;
35-
uint ret = 0;
3635

3736
for (i = 0; i < size; i++) {
38-
ret |= map[i];
37+
if (map[i] != 0)
38+
return 0;
3939
}
4040

41-
return (ret == 0);
41+
return 1;
4242
}
4343

4444
/*

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,10 +1723,11 @@ xfs_bmap_add_extent_delay_real(
17231723
xfs_filblks_t temp=0; /* value for da_new calculations */
17241724
xfs_filblks_t temp2=0;/* value for da_new calculations */
17251725
int tmp_rval; /* partial logging flags */
1726+
int whichfork = XFS_DATA_FORK;
17261727
struct xfs_mount *mp;
17271728

1728-
mp = bma->tp ? bma->tp->t_mountp : NULL;
1729-
ifp = XFS_IFORK_PTR(bma->ip, XFS_DATA_FORK);
1729+
mp = bma->ip->i_mount;
1730+
ifp = XFS_IFORK_PTR(bma->ip, whichfork);
17301731

17311732
ASSERT(bma->idx >= 0);
17321733
ASSERT(bma->idx <= ifp->if_bytes / sizeof(struct xfs_bmbt_rec));
@@ -1785,7 +1786,7 @@ xfs_bmap_add_extent_delay_real(
17851786
* Don't set contiguous if the combined extent would be too large.
17861787
* Also check for all-three-contiguous being too large.
17871788
*/
1788-
if (bma->idx < bma->ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
1789+
if (bma->idx < ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1) {
17891790
state |= BMAP_RIGHT_VALID;
17901791
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, bma->idx + 1), &RIGHT);
17911792

@@ -2016,10 +2017,10 @@ xfs_bmap_add_extent_delay_real(
20162017
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
20172018
}
20182019

2019-
if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
2020+
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
20202021
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
20212022
bma->firstblock, bma->flist,
2022-
&bma->cur, 1, &tmp_rval, XFS_DATA_FORK);
2023+
&bma->cur, 1, &tmp_rval, whichfork);
20232024
rval |= tmp_rval;
20242025
if (error)
20252026
goto done;
@@ -2100,10 +2101,10 @@ xfs_bmap_add_extent_delay_real(
21002101
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
21012102
}
21022103

2103-
if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
2104+
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
21042105
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
21052106
bma->firstblock, bma->flist, &bma->cur, 1,
2106-
&tmp_rval, XFS_DATA_FORK);
2107+
&tmp_rval, whichfork);
21072108
rval |= tmp_rval;
21082109
if (error)
21092110
goto done;
@@ -2169,10 +2170,10 @@ xfs_bmap_add_extent_delay_real(
21692170
XFS_WANT_CORRUPTED_GOTO(mp, i == 1, done);
21702171
}
21712172

2172-
if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
2173+
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
21732174
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
21742175
bma->firstblock, bma->flist, &bma->cur,
2175-
1, &tmp_rval, XFS_DATA_FORK);
2176+
1, &tmp_rval, whichfork);
21762177
rval |= tmp_rval;
21772178
if (error)
21782179
goto done;
@@ -2215,13 +2216,13 @@ xfs_bmap_add_extent_delay_real(
22152216
}
22162217

22172218
/* convert to a btree if necessary */
2218-
if (xfs_bmap_needs_btree(bma->ip, XFS_DATA_FORK)) {
2219+
if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
22192220
int tmp_logflags; /* partial log flag return val */
22202221

22212222
ASSERT(bma->cur == NULL);
22222223
error = xfs_bmap_extents_to_btree(bma->tp, bma->ip,
22232224
bma->firstblock, bma->flist, &bma->cur,
2224-
da_old > 0, &tmp_logflags, XFS_DATA_FORK);
2225+
da_old > 0, &tmp_logflags, whichfork);
22252226
bma->logflags |= tmp_logflags;
22262227
if (error)
22272228
goto done;
@@ -2242,7 +2243,7 @@ xfs_bmap_add_extent_delay_real(
22422243
if (bma->cur)
22432244
bma->cur->bc_private.b.allocated = 0;
22442245

2245-
xfs_bmap_check_leaf_extents(bma->cur, bma->ip, XFS_DATA_FORK);
2246+
xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork);
22462247
done:
22472248
bma->logflags |= rval;
22482249
return error;
@@ -2939,7 +2940,7 @@ xfs_bmap_add_extent_hole_real(
29392940
int state; /* state bits, accessed thru macros */
29402941
struct xfs_mount *mp;
29412942

2942-
mp = bma->tp ? bma->tp->t_mountp : NULL;
2943+
mp = bma->ip->i_mount;
29432944
ifp = XFS_IFORK_PTR(bma->ip, whichfork);
29442945

29452946
ASSERT(bma->idx >= 0);

fs/xfs/libxfs/xfs_bmap_btree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ xfs_bmbt_write_verify(
720720
}
721721

722722
const struct xfs_buf_ops xfs_bmbt_buf_ops = {
723+
.name = "xfs_bmbt",
723724
.verify_read = xfs_bmbt_read_verify,
724725
.verify_write = xfs_bmbt_write_verify,
725726
};

fs/xfs/libxfs/xfs_btree.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,3 +4080,61 @@ xfs_btree_change_owner(
40804080

40814081
return 0;
40824082
}
4083+
4084+
/**
4085+
* xfs_btree_sblock_v5hdr_verify() -- verify the v5 fields of a short-format
4086+
* btree block
4087+
*
4088+
* @bp: buffer containing the btree block
4089+
* @max_recs: pointer to the m_*_mxr max records field in the xfs mount
4090+
* @pag_max_level: pointer to the per-ag max level field
4091+
*/
4092+
bool
4093+
xfs_btree_sblock_v5hdr_verify(
4094+
struct xfs_buf *bp)
4095+
{
4096+
struct xfs_mount *mp = bp->b_target->bt_mount;
4097+
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
4098+
struct xfs_perag *pag = bp->b_pag;
4099+
4100+
if (!xfs_sb_version_hascrc(&mp->m_sb))
4101+
return false;
4102+
if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
4103+
return false;
4104+
if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
4105+
return false;
4106+
if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
4107+
return false;
4108+
return true;
4109+
}
4110+
4111+
/**
4112+
* xfs_btree_sblock_verify() -- verify a short-format btree block
4113+
*
4114+
* @bp: buffer containing the btree block
4115+
* @max_recs: maximum records allowed in this btree node
4116+
*/
4117+
bool
4118+
xfs_btree_sblock_verify(
4119+
struct xfs_buf *bp,
4120+
unsigned int max_recs)
4121+
{
4122+
struct xfs_mount *mp = bp->b_target->bt_mount;
4123+
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
4124+
4125+
/* numrecs verification */
4126+
if (be16_to_cpu(block->bb_numrecs) > max_recs)
4127+
return false;
4128+
4129+
/* sibling pointer verification */
4130+
if (!block->bb_u.s.bb_leftsib ||
4131+
(be32_to_cpu(block->bb_u.s.bb_leftsib) >= mp->m_sb.sb_agblocks &&
4132+
block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK)))
4133+
return false;
4134+
if (!block->bb_u.s.bb_rightsib ||
4135+
(be32_to_cpu(block->bb_u.s.bb_rightsib) >= mp->m_sb.sb_agblocks &&
4136+
block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK)))
4137+
return false;
4138+
4139+
return true;
4140+
}

fs/xfs/libxfs/xfs_btree.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,7 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
472472
#define XFS_BTREE_TRACE_ARGR(c, r)
473473
#define XFS_BTREE_TRACE_CURSOR(c, t)
474474

475+
bool xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
476+
bool xfs_btree_sblock_verify(struct xfs_buf *bp, unsigned int max_recs);
477+
475478
#endif /* __XFS_BTREE_H__ */

0 commit comments

Comments
 (0)