Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 124823
b: refs/heads/master
c: 136341b
h: refs/heads/master
i:
  124821: dde4a93
  124819: c4a9288
  124815: f873424
v: v3
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Oct 30, 2008
1 parent 7d7e3f3 commit dab78ef
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 98 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6c7699c047c50403149ad91331dd39de47dea070
refs/heads/master: 136341b41ad4883bd668120f727a52c42331fe8a
2 changes: 1 addition & 1 deletion trunk/fs/xfs/xfs_alloc_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ xfs_allocbt_update_lastrec(
if (numrecs) {
xfs_alloc_rec_t *rrp;

rrp = XFS_ALLOC_REC_ADDR(block, numrecs, cur);
rrp = XFS_ALLOC_REC_ADDR(cur->bc_mp, block, numrecs);
len = rrp->ar_blockcount;
} else {
len = 0;
Expand Down
25 changes: 18 additions & 7 deletions trunk/fs/xfs/xfs_alloc_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,27 @@ typedef struct xfs_btree_sblock xfs_alloc_block_t;

/*
* Record, key, and pointer address macros for btree blocks.
*
* (note that some of these may appear unused, but they are used in userspace)
*/
#define XFS_ALLOC_REC_ADDR(bb,i,cur) \
XFS_BTREE_REC_ADDR(xfs_alloc, bb, i)

#define XFS_ALLOC_KEY_ADDR(bb,i,cur) \
XFS_BTREE_KEY_ADDR(xfs_alloc, bb, i)
#define XFS_ALLOC_REC_ADDR(mp, block, index) \
((xfs_alloc_rec_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
(((index) - 1) * sizeof(xfs_alloc_rec_t))))

#define XFS_ALLOC_PTR_ADDR(bb,i,cur) \
XFS_BTREE_PTR_ADDR(xfs_alloc, bb, i, XFS_ALLOC_BLOCK_MAXRECS(1, cur))
#define XFS_ALLOC_KEY_ADDR(mp, block, index) \
((xfs_alloc_key_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
((index) - 1) * sizeof(xfs_alloc_key_t)))

#define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
((xfs_alloc_ptr_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
(maxrecs) * sizeof(xfs_alloc_key_t) + \
((index) - 1) * sizeof(xfs_alloc_ptr_t)))

extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
struct xfs_trans *, struct xfs_buf *,
Expand Down
54 changes: 24 additions & 30 deletions trunk/fs/xfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ xfs_bmap_count_leaves(

STATIC void
xfs_bmap_disk_count_leaves(
xfs_extnum_t idx,
struct xfs_mount *mp,
xfs_bmbt_block_t *block,
int numrecs,
int *count);
Expand Down Expand Up @@ -3539,7 +3539,7 @@ xfs_bmap_extents_to_btree(
ablock->bb_level = 0;
ablock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
arp = XFS_BMAP_REC_IADDR(ablock, 1, cur);
arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
for (cnt = i = 0; i < nextents; i++) {
ep = xfs_iext_get_ext(ifp, i);
Expand All @@ -3554,11 +3554,13 @@ xfs_bmap_extents_to_btree(
/*
* Fill in the root key and pointer.
*/
kp = XFS_BMAP_KEY_IADDR(block, 1, cur);
arp = XFS_BMAP_REC_IADDR(ablock, 1, cur);
kp = XFS_BMBT_KEY_ADDR(mp, block, 1);
arp = XFS_BMBT_REC_ADDR(mp, ablock, 1);
kp->br_startoff = cpu_to_be64(xfs_bmbt_disk_get_startoff(arp));
pp = XFS_BMAP_PTR_IADDR(block, 1, cur);
pp = XFS_BMBT_PTR_ADDR(mp, block, 1, xfs_bmbt_get_maxrecs(cur,
be16_to_cpu(block->bb_level)));
*pp = cpu_to_be64(args.fsbno);

/*
* Do all this logging at the end so that
* the root is at the right level.
Expand Down Expand Up @@ -4574,7 +4576,7 @@ xfs_bmap_read_extents(
error0);
if (level == 0)
break;
pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
bno = be64_to_cpu(*pp);
XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
xfs_trans_brelse(tp, bp);
Expand Down Expand Up @@ -4617,7 +4619,7 @@ xfs_bmap_read_extents(
/*
* Copy records into the extent records.
*/
frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
frp = XFS_BMBT_REC_ADDR(mp, block, 1);
start = i;
for (j = 0; j < num_recs; j++, i++, frp++) {
xfs_bmbt_rec_host_t *trp = xfs_iext_get_ext(ifp, i);
Expand Down Expand Up @@ -6187,12 +6189,7 @@ xfs_check_block(
prevp = NULL;
for( i = 1; i <= be16_to_cpu(block->bb_numrecs); i++) {
dmxr = mp->m_bmap_dmxr[0];

if (root) {
keyp = XFS_BMAP_BROOT_KEY_ADDR(block, i, sz);
} else {
keyp = XFS_BTREE_KEY_ADDR(xfs_bmbt, block, i);
}
keyp = XFS_BMBT_KEY_ADDR(mp, block, i);

if (prevp) {
ASSERT(be64_to_cpu(prevp->br_startoff) <
Expand All @@ -6203,19 +6200,16 @@ xfs_check_block(
/*
* Compare the block numbers to see if there are dups.
*/

if (root) {
if (root)
pp = XFS_BMAP_BROOT_PTR_ADDR(mp, block, i, sz);
} else {
pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, i, dmxr);
}
else
pp = XFS_BMBT_PTR_ADDR(mp, block, i, dmxr);

for (j = i+1; j <= be16_to_cpu(block->bb_numrecs); j++) {
if (root) {
if (root)
thispa = XFS_BMAP_BROOT_PTR_ADDR(mp, block, j, sz);
} else {
thispa = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, j,
dmxr);
}
else
thispa = XFS_BMBT_PTR_ADDR(mp, block, j, dmxr);
if (*thispa == *pp) {
cmn_err(CE_WARN, "%s: thispa(%d) == pp(%d) %Ld",
__func__, j, i,
Expand Down Expand Up @@ -6301,7 +6295,7 @@ xfs_bmap_check_leaf_extents(
*/

xfs_check_block(block, mp, 0, 0);
pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
bno = be64_to_cpu(*pp);
XFS_WANT_CORRUPTED_GOTO(XFS_FSB_SANITY_CHECK(mp, bno), error0);
if (bp_release) {
Expand Down Expand Up @@ -6337,14 +6331,14 @@ xfs_bmap_check_leaf_extents(
* conform with the first entry in this one.
*/

ep = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
ep = XFS_BMBT_REC_ADDR(mp, block, 1);
if (i) {
ASSERT(xfs_bmbt_disk_get_startoff(&last) +
xfs_bmbt_disk_get_blockcount(&last) <=
xfs_bmbt_disk_get_startoff(ep));
}
for (j = 1; j < num_recs; j++) {
nextp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, j + 1);
nextp = XFS_BMBT_REC_ADDR(mp, block, j + 1);
ASSERT(xfs_bmbt_disk_get_startoff(ep) +
xfs_bmbt_disk_get_blockcount(ep) <=
xfs_bmbt_disk_get_startoff(nextp));
Expand Down Expand Up @@ -6482,7 +6476,7 @@ xfs_bmap_count_tree(
}

/* Dive to the next level */
pp = XFS_BTREE_PTR_ADDR(xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[1]);
bno = be64_to_cpu(*pp);
if (unlikely((error =
xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) {
Expand All @@ -6497,7 +6491,7 @@ xfs_bmap_count_tree(
for (;;) {
nextbno = be64_to_cpu(block->bb_rightsib);
numrecs = be16_to_cpu(block->bb_numrecs);
xfs_bmap_disk_count_leaves(0, block, numrecs, count);
xfs_bmap_disk_count_leaves(mp, block, numrecs, count);
xfs_trans_brelse(tp, bp);
if (nextbno == NULLFSBLOCK)
break;
Expand Down Expand Up @@ -6536,7 +6530,7 @@ xfs_bmap_count_leaves(
*/
STATIC void
xfs_bmap_disk_count_leaves(
xfs_extnum_t idx,
struct xfs_mount *mp,
xfs_bmbt_block_t *block,
int numrecs,
int *count)
Expand All @@ -6545,7 +6539,7 @@ xfs_bmap_disk_count_leaves(
xfs_bmbt_rec_t *frp;

for (b = 1; b <= numrecs; b++) {
frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b);
frp = XFS_BMBT_REC_ADDR(mp, block, b);
*count += xfs_bmbt_disk_get_blockcount(frp);
}
}
13 changes: 6 additions & 7 deletions trunk/fs/xfs/xfs_bmap_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "xfs_error.h"
#include "xfs_quota.h"


/*
* Determine the extent state.
*/
Expand Down Expand Up @@ -85,9 +84,9 @@ xfs_bmdr_to_bmbt(
rblock->bb_leftsib = cpu_to_be64(NULLDFSBNO);
rblock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0);
fkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1);
tkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
fpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr);
fkp = XFS_BMDR_KEY_ADDR(dblock, 1);
tkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1);
fpp = XFS_BMDR_PTR_ADDR(dblock, 1, dmxr);
tpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen);
dmxr = be16_to_cpu(dblock->bb_numrecs);
memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
Expand Down Expand Up @@ -448,10 +447,10 @@ xfs_bmbt_to_bmdr(
dblock->bb_level = rblock->bb_level;
dblock->bb_numrecs = rblock->bb_numrecs;
dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0);
fkp = XFS_BMAP_BROOT_KEY_ADDR(rblock, 1, rblocklen);
tkp = XFS_BTREE_KEY_ADDR(xfs_bmdr, dblock, 1);
fkp = XFS_BMBT_KEY_ADDR(mp, rblock, 1);
tkp = XFS_BMDR_KEY_ADDR(dblock, 1);
fpp = XFS_BMAP_BROOT_PTR_ADDR(mp, rblock, 1, rblocklen);
tpp = XFS_BTREE_PTR_ADDR(xfs_bmdr, dblock, 1, dmxr);
tpp = XFS_BMDR_PTR_ADDR(dblock, 1, dmxr);
dmxr = be16_to_cpu(dblock->bb_numrecs);
memcpy(tkp, fkp, sizeof(*fkp) * dmxr);
memcpy(tpp, fpp, sizeof(*fpp) * dmxr);
Expand Down
62 changes: 40 additions & 22 deletions trunk/fs/xfs/xfs_bmap_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define XFS_BMAP_MAGIC 0x424d4150 /* 'BMAP' */

struct xfs_btree_cur;
struct xfs_btree_block;
struct xfs_btree_lblock;
struct xfs_mount;
struct xfs_inode;
Expand Down Expand Up @@ -151,33 +152,50 @@ typedef struct xfs_btree_lblock xfs_bmbt_block_t;

#define XFS_BUF_TO_BMBT_BLOCK(bp) ((xfs_bmbt_block_t *)XFS_BUF_PTR(bp))

#define XFS_BMAP_REC_DADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))

#define XFS_BMAP_REC_IADDR(bb,i,cur) (XFS_BTREE_REC_ADDR(xfs_bmbt, bb, i))

#define XFS_BMAP_KEY_DADDR(bb,i,cur) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))

#define XFS_BMAP_KEY_IADDR(bb,i,cur) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt, bb, i))

#define XFS_BMAP_PTR_DADDR(bb,i,cur) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, XFS_BMAP_BLOCK_DMAXRECS( \
be16_to_cpu((bb)->bb_level), cur)))
#define XFS_BMAP_PTR_IADDR(bb,i,cur) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt, bb, i, xfs_bmbt_get_maxrecs(cur, \
be16_to_cpu((bb)->bb_level))))
#define XFS_BMBT_REC_ADDR(mp, block, index) \
((xfs_bmbt_rec_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_lblock) + \
((index) - 1) * sizeof(xfs_bmbt_rec_t)))

#define XFS_BMBT_KEY_ADDR(mp, block, index) \
((xfs_bmbt_key_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_lblock) + \
((index) - 1) * sizeof(xfs_bmbt_key_t)))

#define XFS_BMBT_PTR_ADDR(mp, block, index, maxrecs) \
((xfs_bmbt_ptr_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_lblock) + \
(maxrecs) * sizeof(xfs_bmbt_key_t) + \
((index) - 1) * sizeof(xfs_bmbt_ptr_t)))

#define XFS_BMDR_REC_ADDR(block, index) \
((xfs_bmdr_rec_t *) \
((char *)(block) + \
sizeof(struct xfs_bmdr_block) + \
((index) - 1) * sizeof(xfs_bmdr_rec_t)))

#define XFS_BMDR_KEY_ADDR(block, index) \
((xfs_bmdr_key_t *) \
((char *)(block) + \
sizeof(struct xfs_bmdr_block) + \
((index) - 1) * sizeof(xfs_bmdr_key_t)))

#define XFS_BMDR_PTR_ADDR(block, index, maxrecs) \
((xfs_bmdr_ptr_t *) \
((char *)(block) + \
sizeof(struct xfs_bmdr_block) + \
(maxrecs) * sizeof(xfs_bmdr_key_t) + \
((index) - 1) * sizeof(xfs_bmdr_ptr_t)))

/*
* These are to be used when we know the size of the block and
* we don't have a cursor.
*/
#define XFS_BMAP_BROOT_REC_ADDR(bb,i,sz) \
(XFS_BTREE_REC_ADDR(xfs_bmbt,bb,i))
#define XFS_BMAP_BROOT_KEY_ADDR(bb,i,sz) \
(XFS_BTREE_KEY_ADDR(xfs_bmbt,bb,i))
#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb,i,sz) \
(XFS_BTREE_PTR_ADDR(xfs_bmbt,bb,i,xfs_bmbt_maxrecs(mp, sz, 0)))
#define XFS_BMAP_BROOT_PTR_ADDR(mp, bb, i, sz) \
XFS_BMBT_PTR_ADDR(mp, bb, i, xfs_bmbt_maxrecs(mp, sz, 0))

#define XFS_BMAP_BROOT_SPACE_CALC(nrecs) \
(int)(sizeof(xfs_bmbt_block_t) + \
Expand Down
15 changes: 0 additions & 15 deletions trunk/fs/xfs/xfs_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,6 @@ do { \
} \
} while (0)

/*
* Record, key, and pointer address calculation macros.
* Given block size, type prefix, block pointer, and index of requested entry
* (first entry numbered 1).
*/
#define XFS_BTREE_REC_ADDR(t,bb,i) \
((t ## _rec_t *)((char *)(bb) + sizeof(t ## _block_t) + \
((i) - 1) * sizeof(t ## _rec_t)))
#define XFS_BTREE_KEY_ADDR(t,bb,i) \
((t ## _key_t *)((char *)(bb) + sizeof(t ## _block_t) + \
((i) - 1) * sizeof(t ## _key_t)))
#define XFS_BTREE_PTR_ADDR(t,bb,i,mxr) \
((t ## _ptr_t *)((char *)(bb) + sizeof(t ## _block_t) + \
(mxr) * sizeof(t ## _key_t) + ((i) - 1) * sizeof(t ## _ptr_t)))

#define XFS_BTREE_MAXLEVELS 8 /* max of all btrees */

struct xfs_btree_ops {
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/xfs/xfs_fsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ xfs_growfs_data_private(
block->bb_numrecs = cpu_to_be16(1);
block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1);
arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));
Expand All @@ -279,7 +279,7 @@ xfs_growfs_data_private(
block->bb_numrecs = cpu_to_be16(1);
block->bb_leftsib = cpu_to_be32(NULLAGBLOCK);
block->bb_rightsib = cpu_to_be32(NULLAGBLOCK);
arec = XFS_BTREE_REC_ADDR(xfs_alloc, block, 1);
arec = XFS_ALLOC_REC_ADDR(mp, block, 1);
arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp));
arec->ar_blockcount = cpu_to_be32(
agsize - be32_to_cpu(arec->ar_startblock));
Expand Down
29 changes: 20 additions & 9 deletions trunk/fs/xfs/xfs_ialloc_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,27 @@ typedef struct xfs_btree_sblock xfs_inobt_block_t;

/*
* Record, key, and pointer address macros for btree blocks.
*
* (note that some of these may appear unused, but they are used in userspace)
*/
#define XFS_INOBT_REC_ADDR(bb,i,cur) \
(XFS_BTREE_REC_ADDR(xfs_inobt, bb, i))

#define XFS_INOBT_KEY_ADDR(bb,i,cur) \
(XFS_BTREE_KEY_ADDR(xfs_inobt, bb, i))

#define XFS_INOBT_PTR_ADDR(bb,i,cur) \
(XFS_BTREE_PTR_ADDR(xfs_inobt, bb, \
i, XFS_INOBT_BLOCK_MAXRECS(1, cur)))
#define XFS_INOBT_REC_ADDR(mp, block, index) \
((xfs_inobt_rec_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
(((index) - 1) * sizeof(xfs_inobt_rec_t))))

#define XFS_INOBT_KEY_ADDR(mp, block, index) \
((xfs_inobt_key_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
((index) - 1) * sizeof(xfs_inobt_key_t)))

#define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
((xfs_inobt_ptr_t *) \
((char *)(block) + \
sizeof(struct xfs_btree_sblock) + \
(maxrecs) * sizeof(xfs_inobt_key_t) + \
((index) - 1) * sizeof(xfs_inobt_ptr_t)))

extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *,
struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t);
Expand Down
Loading

0 comments on commit dab78ef

Please sign in to comment.