aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2011-07-13 07:43:48 -0400
committerChristoph Hellwig <hch@lst.de>2011-07-13 07:43:48 -0400
commita00b7745c6e68ee89a123cd81e1dbc52fb55868e (patch)
tree9a58811ca53f674ca479ef088d1caa7f572ba43d /fs
parent5792664070c62479b088e4909000582de3686396 (diff)
xfs: cleanup struct xfs_dir2_free
Change the bests array to be a proper variable sized entry. This is done easily as no one relies on the size of the structure. Also change XFS_DIR2_MAX_FREE_BESTS to an inline function while we're at it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_dir2_format.h14
-rw-r--r--fs/xfs/xfs_dir2_node.c8
2 files changed, 12 insertions, 10 deletions
diff --git a/fs/xfs/xfs_dir2_format.h b/fs/xfs/xfs_dir2_format.h
index c3c4839eebd6..07270981f48f 100644
--- a/fs/xfs/xfs_dir2_format.h
+++ b/fs/xfs/xfs_dir2_format.h
@@ -516,13 +516,15 @@ typedef struct xfs_dir2_free_hdr {
516 516
517typedef struct xfs_dir2_free { 517typedef struct xfs_dir2_free {
518 xfs_dir2_free_hdr_t hdr; /* block header */ 518 xfs_dir2_free_hdr_t hdr; /* block header */
519 __be16 bests[1]; /* best free counts */ 519 __be16 bests[]; /* best free counts */
520 /* unused entries are -1 */ 520 /* unused entries are -1 */
521} xfs_dir2_free_t; 521} xfs_dir2_free_t;
522 522
523#define XFS_DIR2_MAX_FREE_BESTS(mp) \ 523static inline int xfs_dir2_free_max_bests(struct xfs_mount *mp)
524 (((mp)->m_dirblksize - (uint)sizeof(struct xfs_dir2_free_hdr)) / \ 524{
525 (uint)sizeof(xfs_dir2_data_off_t)) 525 return (mp->m_dirblksize - sizeof(struct xfs_dir2_free_hdr)) /
526 sizeof(xfs_dir2_data_off_t);
527}
526 528
527/* 529/*
528 * Convert data space db to the corresponding free db. 530 * Convert data space db to the corresponding free db.
@@ -530,7 +532,7 @@ typedef struct xfs_dir2_free {
530static inline xfs_dir2_db_t 532static inline xfs_dir2_db_t
531xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) 533xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
532{ 534{
533 return XFS_DIR2_FREE_FIRSTDB(mp) + db / XFS_DIR2_MAX_FREE_BESTS(mp); 535 return XFS_DIR2_FREE_FIRSTDB(mp) + db / xfs_dir2_free_max_bests(mp);
534} 536}
535 537
536/* 538/*
@@ -539,7 +541,7 @@ xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
539static inline int 541static inline int
540xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db) 542xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
541{ 543{
542 return db % XFS_DIR2_MAX_FREE_BESTS(mp); 544 return db % xfs_dir2_free_max_bests(mp);
543} 545}
544 546
545/* 547/*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index ec0a23e96705..084b3247d636 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -408,7 +408,7 @@ xfs_dir2_leafn_lookup_for_addname(
408 ASSERT(be32_to_cpu(free->hdr.magic) == 408 ASSERT(be32_to_cpu(free->hdr.magic) ==
409 XFS_DIR2_FREE_MAGIC); 409 XFS_DIR2_FREE_MAGIC);
410 ASSERT((be32_to_cpu(free->hdr.firstdb) % 410 ASSERT((be32_to_cpu(free->hdr.firstdb) %
411 XFS_DIR2_MAX_FREE_BESTS(mp)) == 0); 411 xfs_dir2_free_max_bests(mp)) == 0);
412 ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb); 412 ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb);
413 ASSERT(curdb < be32_to_cpu(free->hdr.firstdb) + 413 ASSERT(curdb < be32_to_cpu(free->hdr.firstdb) +
414 be32_to_cpu(free->hdr.nvalid)); 414 be32_to_cpu(free->hdr.nvalid));
@@ -924,7 +924,7 @@ xfs_dir2_leafn_remove(
924 free = fbp->data; 924 free = fbp->data;
925 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC)); 925 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
926 ASSERT(be32_to_cpu(free->hdr.firstdb) == 926 ASSERT(be32_to_cpu(free->hdr.firstdb) ==
927 XFS_DIR2_MAX_FREE_BESTS(mp) * 927 xfs_dir2_free_max_bests(mp) *
928 (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); 928 (fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
929 /* 929 /*
930 * Calculate which entry we need to fix. 930 * Calculate which entry we need to fix.
@@ -1603,7 +1603,7 @@ xfs_dir2_node_addname_int(
1603 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC); 1603 free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
1604 free->hdr.firstdb = cpu_to_be32( 1604 free->hdr.firstdb = cpu_to_be32(
1605 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1605 (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
1606 XFS_DIR2_MAX_FREE_BESTS(mp)); 1606 xfs_dir2_free_max_bests(mp));
1607 free->hdr.nvalid = 0; 1607 free->hdr.nvalid = 0;
1608 free->hdr.nused = 0; 1608 free->hdr.nused = 0;
1609 } else { 1609 } else {
@@ -1620,7 +1620,7 @@ xfs_dir2_node_addname_int(
1620 * freespace block, extend that table. 1620 * freespace block, extend that table.
1621 */ 1621 */
1622 if (findex >= be32_to_cpu(free->hdr.nvalid)) { 1622 if (findex >= be32_to_cpu(free->hdr.nvalid)) {
1623 ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp)); 1623 ASSERT(findex < xfs_dir2_free_max_bests(mp));
1624 free->hdr.nvalid = cpu_to_be32(findex + 1); 1624 free->hdr.nvalid = cpu_to_be32(findex + 1);
1625 /* 1625 /*
1626 * Tag new entry so nused will go up. 1626 * Tag new entry so nused will go up.