Commit 7dee2451 authored by Nathan Scott's avatar Nathan Scott

[XFS] Sector size updates - macros for calculating address/size of sector-sized

data structures (sb,agf,agi,agfl) are now sector size aware.  Cleaned up
the early mount code dealing with log devices and logsectsize.

SGI Modid: 2.5.x-xfs:slinx:134065a
parent b95040ee
......@@ -640,12 +640,13 @@ linvfs_fill_super(
vfsp->vfs_flag |= VFS_RDONLY;
vfsp->vfs_super = sb;
set_blocksize(sb->s_bdev, BBSIZE);
set_max_bytes(sb);
set_quota_ops(sb);
sb->s_op = &linvfs_sops;
sb->s_export_op = &linvfs_export_ops;
sb_min_blocksize(sb, BBSIZE);
LINVFS_SET_VFS(sb, vfsp);
VFSOPS_MOUNT(vfsops, vfsp, args, NULL, error);
......@@ -767,8 +768,8 @@ STATIC void
linvfs_put_super(
struct super_block *sb)
{
int error;
vfs_t *vfsp = LINVFS_GET_VFS(sb);
int error;
VFS_DOUNMOUNT(vfsp, 0, NULL, NULL, error);
if (error) {
......
......@@ -109,12 +109,12 @@ typedef struct xfs_agf
#define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1)
/* disk block (xfs_daddr_t) in the AG */
#define XFS_AGF_DADDR ((xfs_daddr_t)1)
#define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGF_BLOCK)
xfs_agblock_t xfs_agf_block(struct xfs_mount *mp);
#define XFS_AGF_BLOCK(mp) xfs_agf_block(mp)
#else
#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR)
#define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp))
#endif
/*
......@@ -164,29 +164,30 @@ typedef struct xfs_agi
#define XFS_AGI_ALL_BITS ((1 << XFS_AGI_NUM_BITS) - 1)
/* disk block (xfs_daddr_t) in the AG */
#define XFS_AGI_DADDR ((xfs_daddr_t)2)
#define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGI_BLOCK)
xfs_agblock_t xfs_agi_block(struct xfs_mount *mp);
#define XFS_AGI_BLOCK(mp) xfs_agi_block(mp)
#else
#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR)
#define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp))
#endif
/*
* The third a.g. block contains the a.g. freelist, an array
* of block pointers to blocks owned by the allocation btree code.
*/
#define XFS_AGFL_DADDR ((xfs_daddr_t)3)
#define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log))
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AGFL_BLOCK)
xfs_agblock_t xfs_agfl_block(struct xfs_mount *mp);
#define XFS_AGFL_BLOCK(mp) xfs_agfl_block(mp)
#else
#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR)
#define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp))
#endif
#define XFS_AGFL_SIZE (BBSIZE / sizeof(xfs_agblock_t))
typedef struct xfs_agfl
{
xfs_agblock_t agfl_bno[XFS_AGFL_SIZE];
#define XFS_AGFL_SIZE(mp) ((mp)->m_sb.sb_sectsize / sizeof(xfs_agblock_t))
/* -- nathans TODO ... use of BBSIZE here - should be sector size -- */
typedef struct xfs_agfl {
xfs_agblock_t agfl_bno[BBSIZE/sizeof(xfs_agblock_t)];
} xfs_agfl_t;
/*
......@@ -249,8 +250,8 @@ xfs_extlen_t xfs_ag_best_blocks(int bl, xfs_drfsbno_t blks);
* Best is XFS_AG_BEST_BLOCKS at and below 64 Gigabyte filesystems, and
* XFS_AG_MAX_BLOCKS above 64 Gigabytes.
*/
#define XFS_AG_BEST_BLOCKS(bl,blks) ((xfs_extlen_t)((1LL << (36 - bl)) >= \
blks) ? \
#define XFS_AG_BEST_BLOCKS(bl,blks) \
((xfs_extlen_t)((1LL << (36 - bl)) >= blks) ? \
((xfs_extlen_t)(XFS_AG_BEST_BYTES >> bl)) : \
XFS_AG_MAX_BLOCKS(bl))
#endif
......@@ -333,7 +334,8 @@ xfs_daddr_t xfs_agb_to_daddr(struct xfs_mount *mp, xfs_agnumber_t agno,
*/
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_AG_DADDR)
xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno, xfs_daddr_t d);
xfs_daddr_t xfs_ag_daddr(struct xfs_mount *mp, xfs_agnumber_t agno,
xfs_daddr_t d);
#define XFS_AG_DADDR(mp,agno,d) xfs_ag_daddr(mp,agno,d)
#else
#define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d))
......
......@@ -399,12 +399,14 @@ xfs_alloc_read_agfl(
xfs_buf_t **bpp) /* buffer for the ag free block array */
{
xfs_buf_t *bp; /* return value */
xfs_daddr_t d; /* disk block address */
int error;
ASSERT(agno != NULLAGNUMBER);
d = XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR);
if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 1, 0, &bp)))
error = xfs_trans_read_buf(
mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, &bp);
if (error)
return error;
ASSERT(bp);
ASSERT(!XFS_BUF_GETERROR(bp));
......@@ -1821,9 +1823,8 @@ xfs_alloc_compute_maxlevels(
/*
* Decide whether to use this allocation group for this allocation.
* If so, fix up the btree freelist's size.
* This is external so mkfs can call it, too.
*/
int /* error */
STATIC int /* error */
xfs_alloc_fix_freelist(
xfs_alloc_arg_t *args, /* allocation argument structure */
int flags) /* XFS_ALLOC_FLAG_... */
......@@ -2020,7 +2021,7 @@ xfs_alloc_get_freelist(
bno = INT_GET(agfl->agfl_bno[INT_GET(agf->agf_flfirst, ARCH_CONVERT)], ARCH_CONVERT);
INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1);
xfs_trans_brelse(tp, agflbp);
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE)
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp))
INT_ZERO(agf->agf_flfirst, ARCH_CONVERT);
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1);
......@@ -2120,13 +2121,13 @@ xfs_alloc_put_freelist(
return error;
agfl = XFS_BUF_TO_AGFL(agflbp);
INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1);
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE)
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp))
INT_ZERO(agf->agf_fllast, ARCH_CONVERT);
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1);
xfs_trans_agflist_delta(tp, 1);
pag->pagf_flcount++;
ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE);
ASSERT(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp));
blockp = &agfl->agfl_bno[INT_GET(agf->agf_fllast, ARCH_CONVERT)];
INT_SET(*blockp, ARCH_CONVERT, bno);
TRACE_MODAGF(NULL, agf, XFS_AGF_FLLAST | XFS_AGF_FLCOUNT);
......@@ -2152,15 +2153,17 @@ xfs_alloc_read_agf(
xfs_agf_t *agf; /* ag freelist header */
int agf_ok; /* set if agf is consistent */
xfs_buf_t *bp; /* return value */
xfs_daddr_t d; /* disk block address */
int error;
xfs_perag_t *pag; /* per allocation group data */
int error;
ASSERT(agno != NULLAGNUMBER);
d = XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR);
if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 1,
error = xfs_trans_read_buf(
mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1),
(flags & XFS_ALLOC_FLAG_TRYLOCK) ? XFS_BUF_TRYLOCK : 0U,
&bp)))
&bp);
if (error)
return error;
ASSERT(!bp || !XFS_BUF_GETERROR(bp));
if (!bp) {
......@@ -2173,12 +2176,13 @@ xfs_alloc_read_agf(
agf = XFS_BUF_TO_AGF(bp);
agf_ok =
INT_GET(agf->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC &&
XFS_AGF_GOOD_VERSION(INT_GET(agf->agf_versionnum, ARCH_CONVERT)) &&
XFS_AGF_GOOD_VERSION(
INT_GET(agf->agf_versionnum, ARCH_CONVERT)) &&
INT_GET(agf->agf_freeblks, ARCH_CONVERT) <=
INT_GET(agf->agf_length, ARCH_CONVERT) &&
INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE &&
INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE &&
INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE;
INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) &&
INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp) &&
INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp);
if (XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF,
XFS_RANDOM_ALLOC_READ_AGF)) {
xfs_trans_brelse(tp, bp);
......@@ -2197,13 +2201,13 @@ xfs_alloc_read_agf(
cmn_err(CE_NOTE, "Bad freeblks %d %d",
INT_GET(agf->agf_freeblks, ARCH_CONVERT),
INT_GET(agf->agf_length, ARCH_CONVERT));
if (!(INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE))
if (!(INT_GET(agf->agf_flfirst, ARCH_CONVERT) < XFS_AGFL_SIZE(mp)))
cmn_err(CE_NOTE, "Bad flfirst %d",
INT_GET(agf->agf_flfirst, ARCH_CONVERT));
if (!(INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE))
if (!(INT_GET(agf->agf_fllast, ARCH_CONVERT) < XFS_AGFL_SIZE(mp)))
cmn_err(CE_NOTE, "Bad fllast %d",
INT_GET(agf->agf_fllast, ARCH_CONVERT));
if (!(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE))
if (!(INT_GET(agf->agf_flcount, ARCH_CONVERT) <= XFS_AGFL_SIZE(mp)))
cmn_err(CE_NOTE, "Bad flcount %d",
INT_GET(agf->agf_flcount, ARCH_CONVERT));
#endif
......
......@@ -130,16 +130,6 @@ void
xfs_alloc_compute_maxlevels(
struct xfs_mount *mp); /* file system mount structure */
/*
* Decide whether to use this allocation group for this allocation.
* If so, fix up the btree freelist's size.
* This is external so mkfs can call it, too.
*/
int /* error */
xfs_alloc_fix_freelist(
xfs_alloc_arg_t *args, /* allocation argument structure */
int flags); /* XFS_ALLOC_FLAG_... */
/*
* Get a block from the freelist.
* Returns with the buffer for the block gotten.
......
......@@ -225,15 +225,16 @@ typedef struct xfs_fsop_resblks {
#define XFS_FSOP_GEOM_VERSION 0
#define XFS_FSOP_GEOM_FLAGS_ATTR 0x01 /* attributes in use */
#define XFS_FSOP_GEOM_FLAGS_NLINK 0x02 /* 32-bit nlink values */
#define XFS_FSOP_GEOM_FLAGS_QUOTA 0x04 /* quotas enabled */
#define XFS_FSOP_GEOM_FLAGS_IALIGN 0x08 /* inode alignment */
#define XFS_FSOP_GEOM_FLAGS_DALIGN 0x10 /* large data alignment */
#define XFS_FSOP_GEOM_FLAGS_SHARED 0x20 /* read-only shared */
#define XFS_FSOP_GEOM_FLAGS_EXTFLG 0x40 /* special extent flag */
#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x80 /* directory version 2 */
#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x100 /* log format version 2 */
#define XFS_FSOP_GEOM_FLAGS_ATTR 0x0001 /* attributes in use */
#define XFS_FSOP_GEOM_FLAGS_NLINK 0x0002 /* 32-bit nlink values */
#define XFS_FSOP_GEOM_FLAGS_QUOTA 0x0004 /* quotas enabled */
#define XFS_FSOP_GEOM_FLAGS_IALIGN 0x0008 /* inode alignment */
#define XFS_FSOP_GEOM_FLAGS_DALIGN 0x0010 /* large data alignment */
#define XFS_FSOP_GEOM_FLAGS_SHARED 0x0020 /* read-only shared */
#define XFS_FSOP_GEOM_FLAGS_EXTFLG 0x0040 /* special extent flag */
#define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */
#define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */
#define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */
/*
......
......@@ -78,9 +78,12 @@ xfs_fs_geometry(
(XFS_SB_VERSION_HASEXTFLGBIT(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_EXTFLG : 0) |
(XFS_SB_VERSION_HASDIRV2(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_DIRV2 : 0);
geo->logsectsize = mp->m_sb.sb_sectsize; /* XXX */
geo->rtsectsize = mp->m_sb.sb_sectsize; /* XXX */
XFS_FSOP_GEOM_FLAGS_DIRV2 : 0) |
(XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
XFS_FSOP_GEOM_FLAGS_SECTOR : 0);
geo->logsectsize = XFS_SB_VERSION_HASSECTOR(&mp->m_sb) ?
mp->m_sb.sb_logsectsize : BBSIZE;
geo->rtsectsize = mp->m_sb.sb_blocksize;
geo->dirblocksize = mp->m_dirblksize;
}
if (new_version >= 4) {
......@@ -105,9 +108,7 @@ xfs_growfs_data_private(
xfs_alloc_rec_t *arec;
xfs_btree_sblock_t *block;
xfs_buf_t *bp;
int bsize;
int bucket;
xfs_daddr_t disk_addr;
int dpct;
int error;
xfs_agnumber_t nagcount;
......@@ -117,7 +118,6 @@ xfs_growfs_data_private(
xfs_agnumber_t oagcount;
int pct;
xfs_sb_t *sbp;
int sectbb;
xfs_trans_t *tp;
nb = in->newblocks;
......@@ -125,8 +125,9 @@ xfs_growfs_data_private(
if (nb < mp->m_sb.sb_dblocks || pct < 0 || pct > 100)
return XFS_ERROR(EINVAL);
dpct = pct - mp->m_sb.sb_imax_pct;
error = xfs_read_buf(mp, mp->m_ddev_targp, XFS_FSB_TO_BB(mp, nb) - 1, 1,
0, &bp);
error = xfs_read_buf(mp, mp->m_ddev_targp,
XFS_FSB_TO_BB(mp, nb) - XFS_FSS_TO_BB(mp, 1),
XFS_FSS_TO_BB(mp, 1), 0, &bp);
if (error)
return error;
ASSERT(bp);
......@@ -161,19 +162,15 @@ xfs_growfs_data_private(
xfs_trans_cancel(tp, 0);
return error;
}
/* new ag's */
sectbb = BTOBB(mp->m_sb.sb_sectsize);
bsize = mp->m_sb.sb_blocksize;
nfree = 0;
for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) {
/*
* AG freelist header block
*/
disk_addr = XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR);
bp = xfs_buf_get(mp->m_ddev_targp,
disk_addr,
sectbb, 0);
XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0);
agf = XFS_BUF_TO_AGF(bp);
memset(agf, 0, mp->m_sb.sb_sectsize);
INT_SET(agf->agf_magicnum, ARCH_CONVERT, XFS_AGF_MAGIC);
......@@ -186,12 +183,14 @@ xfs_growfs_data_private(
else
agsize = mp->m_sb.sb_agblocks;
INT_SET(agf->agf_length, ARCH_CONVERT, agsize);
INT_SET(agf->agf_roots[XFS_BTNUM_BNOi], ARCH_CONVERT, XFS_BNO_BLOCK(mp));
INT_SET(agf->agf_roots[XFS_BTNUM_CNTi], ARCH_CONVERT, XFS_CNT_BLOCK(mp));
INT_SET(agf->agf_roots[XFS_BTNUM_BNOi], ARCH_CONVERT,
XFS_BNO_BLOCK(mp));
INT_SET(agf->agf_roots[XFS_BTNUM_CNTi], ARCH_CONVERT,
XFS_CNT_BLOCK(mp));
INT_SET(agf->agf_levels[XFS_BTNUM_BNOi], ARCH_CONVERT, 1);
INT_SET(agf->agf_levels[XFS_BTNUM_CNTi], ARCH_CONVERT, 1);
INT_ZERO(agf->agf_flfirst, ARCH_CONVERT);
INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE - 1);
INT_SET(agf->agf_fllast, ARCH_CONVERT, XFS_AGFL_SIZE(mp) - 1);
INT_ZERO(agf->agf_flcount, ARCH_CONVERT);
tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp);
INT_SET(agf->agf_freeblks, ARCH_CONVERT, tmpsize);
......@@ -203,10 +202,9 @@ xfs_growfs_data_private(
/*
* AG inode header block
*/
disk_addr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
bp = xfs_buf_get(mp->m_ddev_targp,
disk_addr,
sectbb, 0);
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0);
agi = XFS_BUF_TO_AGI(bp);
memset(agi, 0, mp->m_sb.sb_sectsize);
INT_SET(agi->agi_magicnum, ARCH_CONVERT, XFS_AGI_MAGIC);
......@@ -220,7 +218,8 @@ xfs_growfs_data_private(
INT_SET(agi->agi_newino, ARCH_CONVERT, NULLAGINO);
INT_SET(agi->agi_dirino, ARCH_CONVERT, NULLAGINO);
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++)
INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT, NULLAGINO);
INT_SET(agi->agi_unlinked[bucket], ARCH_CONVERT,
NULLAGINO);
error = xfs_bwrite(mp, bp);
if (error) {
goto error0;
......@@ -228,21 +227,22 @@ xfs_growfs_data_private(
/*
* BNO btree root block
*/
disk_addr = XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp));
bp = xfs_buf_get(mp->m_ddev_targp,
disk_addr,
BTOBB(bsize), 0);
XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0);
block = XFS_BUF_TO_SBLOCK(bp);
memset(block, 0, bsize);
memset(block, 0, mp->m_sb.sb_blocksize);
INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTB_MAGIC);
INT_ZERO(block->bb_level, ARCH_CONVERT);
INT_SET(block->bb_numrecs, ARCH_CONVERT, 1);
INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK);
INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK);
arec = XFS_BTREE_REC_ADDR(bsize, xfs_alloc, block, 1,
mp->m_alloc_mxr[0]);
INT_SET(arec->ar_startblock, ARCH_CONVERT, XFS_PREALLOC_BLOCKS(mp));
INT_SET(arec->ar_blockcount, ARCH_CONVERT, agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
block, 1, mp->m_alloc_mxr[0]);
INT_SET(arec->ar_startblock, ARCH_CONVERT,
XFS_PREALLOC_BLOCKS(mp));
INT_SET(arec->ar_blockcount, ARCH_CONVERT,
agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
error = xfs_bwrite(mp, bp);
if (error) {
goto error0;
......@@ -250,21 +250,22 @@ xfs_growfs_data_private(
/*
* CNT btree root block
*/
disk_addr = XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp));
bp = xfs_buf_get(mp->m_ddev_targp,
disk_addr,
BTOBB(bsize), 0);
XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0);
block = XFS_BUF_TO_SBLOCK(bp);
memset(block, 0, bsize);
memset(block, 0, mp->m_sb.sb_blocksize);
INT_SET(block->bb_magic, ARCH_CONVERT, XFS_ABTC_MAGIC);
INT_ZERO(block->bb_level, ARCH_CONVERT);
INT_SET(block->bb_numrecs, ARCH_CONVERT, 1);
INT_SET(block->bb_leftsib, ARCH_CONVERT, NULLAGBLOCK);
INT_SET(block->bb_rightsib, ARCH_CONVERT, NULLAGBLOCK);
arec = XFS_BTREE_REC_ADDR(bsize, xfs_alloc, block, 1,
mp->m_alloc_mxr[0]);
INT_SET(arec->ar_startblock, ARCH_CONVERT, XFS_PREALLOC_BLOCKS(mp));
INT_SET(arec->ar_blockcount, ARCH_CONVERT, agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
arec = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_alloc,
block, 1, mp->m_alloc_mxr[0]);
INT_SET(arec->ar_startblock, ARCH_CONVERT,
XFS_PREALLOC_BLOCKS(mp));
INT_SET(arec->ar_blockcount, ARCH_CONVERT,
agsize - INT_GET(arec->ar_startblock, ARCH_CONVERT));
nfree += INT_GET(arec->ar_blockcount, ARCH_CONVERT);
error = xfs_bwrite(mp, bp);
if (error) {
......@@ -273,12 +274,11 @@ xfs_growfs_data_private(
/*
* INO btree root block
*/
disk_addr = XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp));
bp = xfs_buf_get(mp->m_ddev_targp,
disk_addr,
BTOBB(bsize), 0);
XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0);
block = XFS_BUF_TO_SBLOCK(bp);
memset(block, 0, bsize);
memset(block, 0, mp->m_sb.sb_blocksize);
INT_SET(block->bb_magic, ARCH_CONVERT, XFS_IBT_MAGIC);
INT_ZERO(block->bb_level, ARCH_CONVERT);
INT_ZERO(block->bb_numrecs, ARCH_CONVERT);
......@@ -304,8 +304,9 @@ xfs_growfs_data_private(
ASSERT(bp);
agi = XFS_BUF_TO_AGI(bp);
INT_MOD(agi->agi_length, ARCH_CONVERT, new);
ASSERT(nagcount == oagcount
|| INT_GET(agi->agi_length, ARCH_CONVERT) == mp->m_sb.sb_agblocks);
ASSERT(nagcount == oagcount ||
INT_GET(agi->agi_length, ARCH_CONVERT) ==
mp->m_sb.sb_agblocks);
xfs_ialloc_log_agi(tp, bp, XFS_AGI_LENGTH);
/*
* Change agf length.
......@@ -350,7 +351,7 @@ xfs_growfs_data_private(
for (agno = 1; agno < nagcount; agno++) {
error = xfs_read_buf(mp, mp->m_ddev_targp,
XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
sectbb, 0, &bp);
XFS_FSS_TO_BB(mp, 1), 0, &bp);
if (error) {
xfs_fs_cmn_err(CE_WARN, mp,
"error %d reading secondary superblock for ag %d",
......@@ -585,7 +586,6 @@ xfs_fs_freeze(
return 0;
}
int
xfs_fs_thaw(
xfs_mount_t *mp)
......
......@@ -1258,8 +1258,7 @@ xfs_ialloc_log_agi(
xfs_agi_t *agi; /* allocation group header */
agi = XFS_BUF_TO_AGI(bp);
ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) ==
XFS_AGI_MAGIC);
ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
#endif
/*
* Compute byte offsets for the first and last fields.
......@@ -1284,26 +1283,26 @@ xfs_ialloc_read_agi(
xfs_agi_t *agi; /* allocation group header */
int agi_ok; /* agi is consistent */
xfs_buf_t *bp; /* allocation group hdr buf */
xfs_daddr_t d; /* disk block address */
int error;
#ifdef DEBUG
int i;
#endif
xfs_perag_t *pag; /* per allocation group data */
int error;
ASSERT(agno != NULLAGNUMBER);
d = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 1, 0, &bp)))
error = xfs_trans_read_buf(
mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, &bp);
if (error)
return error;
ASSERT(bp && !XFS_BUF_GETERROR(bp));
/*
* Validate the magic number of the agi block.
*/
agi = XFS_BUF_TO_AGI(bp);
agi_ok =
INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC &&
XFS_AGI_GOOD_VERSION(INT_GET(agi->agi_versionnum, ARCH_CONVERT));
XFS_AGI_GOOD_VERSION(
INT_GET(agi->agi_versionnum, ARCH_CONVERT));
if (XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
XFS_RANDOM_IALLOC_READ_AGI)) {
xfs_trans_brelse(tp, bp);
......@@ -1323,13 +1322,20 @@ xfs_ialloc_read_agi(
* It's possible for these to be out of sync if
* we are in the middle of a forced shutdown.
*/
ASSERT(pag->pagi_freecount == INT_GET(agi->agi_freecount, ARCH_CONVERT)
ASSERT(pag->pagi_freecount ==
INT_GET(agi->agi_freecount, ARCH_CONVERT)
|| XFS_FORCED_SHUTDOWN(mp));
}
#ifdef DEBUG
{
int i;
for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++)
ASSERT(!INT_ISZERO(agi->agi_unlinked[i], ARCH_CONVERT));
}
#endif
XFS_BUF_SET_VTYPE_REF(bp, B_FS_AGI, XFS_AGI_REF);
*bpp = bp;
return 0;
......
......@@ -213,10 +213,10 @@ xfs_inobt_delrec(
*/
agfbno = XFS_AG_DADDR(cur->bc_mp,
cur->bc_private.i.agno,
XFS_AGF_DADDR);
XFS_AGF_DADDR(mp));
if (error = xfs_trans_read_buf(cur->bc_mp, cur->bc_tp,
cur->bc_mp->m_ddev_targp, agfbno, 1, 0,
&agfbp))
cur->bc_mp->m_ddev_targp, agfbno,
XFS_FSS_TO_BB(mp, 1), 0, &agfbp))
return error;
ASSERT(!XFS_BUF_GETERROR(agfbp));
xfs_trans_bhold_until_committed(cur->bc_tp, agfbp);
......@@ -506,9 +506,10 @@ xfs_inobt_delrec(
* transaction record makes it to the on-disk log.
*/
agfbno = XFS_AG_DADDR(cur->bc_mp, cur->bc_private.i.agno,
XFS_AGF_DADDR);
XFS_AGF_DADDR(mp));
if (error = xfs_trans_read_buf(cur->bc_mp, cur->bc_tp,
cur->bc_mp->m_ddev_targp, agfbno, 1, 0, &agfbp))
cur->bc_mp->m_ddev_targp, agfbno,
XFS_FSS_TO_BB(mp, 1), 0, &agfbp))
return error;
ASSERT(!XFS_BUF_GETERROR(agfbp));
xfs_trans_bhold_until_committed(cur->bc_tp, agfbp);
......
......@@ -1799,14 +1799,14 @@ xfs_iunlink(
mp = tp->t_mountp;
agno = XFS_INO_TO_AGNO(mp, ip->i_ino);
agdaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
agdaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp));
/*
* Get the agi buffer first. It ensures lock ordering
* on the list.
*/
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, agdaddr,
1, 0, &agibp);
XFS_FSS_TO_BB(mp, 1), 0, &agibp);
if (error) {
return error;
}
......@@ -1898,15 +1898,15 @@ xfs_iunlink_remove(
mp = tp->t_mountp;
agno = XFS_INO_TO_AGNO(mp, ip->i_ino);
agdaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
agdaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp));
/*
* Get the agi buffer first. It ensures lock ordering
* on the list.
*/
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, agdaddr,
1, 0, &agibp);
if (error != 0) {
XFS_FSS_TO_BB(mp, 1), 0, &agibp);
if (error) {
cmn_err(CE_WARN,
"xfs_iunlink_remove: xfs_trans_read_buf() returned an error %d on %s. Returning error.",
error, mp->m_fsname);
......
......@@ -50,7 +50,7 @@ STATIC void xlog_recover_check_ail(xfs_mount_t *mp, xfs_log_item_t *lip,
xfs_buf_t *
xlog_get_bp(int num_bblks,xfs_mount_t *mp)
xlog_get_bp(int num_bblks, xfs_mount_t *mp)
{
xfs_buf_t *bp;
......@@ -307,9 +307,10 @@ xlog_find_verify_cycle( xlog_t *log,
return ENOMEM;
}
for (i = start_blk; i < start_blk + nbblks; i += bufblks) {
int bcount = min(bufblks, (start_blk + nbblks - i));
int bcount;
bcount = min(bufblks, (start_blk + nbblks - i));
if ((error = xlog_bread(log, i, bcount, bp)))
goto out;
......@@ -373,11 +374,10 @@ xlog_find_verify_log_record(xlog_t *log,
} else {
if ((error = xlog_bread(log, start_blk, num_blks, bp)))
goto out;
buf = XFS_BUF_PTR(bp) + (num_blks - 1) * BBSIZE;
buf = XFS_BUF_PTR(bp) + ((num_blks - 1) << BBSHIFT);
}
for (i=(*last_blk)-1; i>=0; i--) {
for (i = (*last_blk) - 1; i >= 0; i--) {
if (i < start_blk) {
/* legal log record not found */
xlog_warn("XFS: Log inconsistent (didn't find previous header)");
......@@ -422,7 +422,8 @@ xlog_find_verify_log_record(xlog_t *log,
* record do we update last_blk.
*/
if (XFS_SB_VERSION_HASLOGV2(&log->l_mp->m_sb)) {
int h_size = INT_GET(head->h_size, ARCH_CONVERT);
uint h_size = INT_GET(head->h_size, ARCH_CONVERT);
xhdrs = h_size / XLOG_HEADER_CYCLE_SIZE;
if (h_size % XLOG_HEADER_CYCLE_SIZE)
xhdrs++;
......@@ -925,7 +926,6 @@ xlog_find_zeroed(struct log *log,
xfs_daddr_t num_scan_bblks;
int error, log_bbnum = log->l_logBBsize;
error = 0;
/* check totally zeroed log */
bp = xlog_get_bp(1,log->l_mp);
if (!bp)
......@@ -1088,12 +1088,9 @@ xlog_clear_stale_blocks(
xlog_t *log,
xfs_lsn_t tail_lsn)
{
int tail_cycle;
int head_cycle;
int tail_block;
int head_block;
int tail_distance;
int max_distance;
int tail_cycle, head_cycle;
int tail_block, head_block;
int tail_distance, max_distance;
int distance;
int error;
......@@ -1118,8 +1115,7 @@ xlog_clear_stale_blocks(
*/
if (head_block < tail_block || head_block >= log->l_logBBsize)
return XFS_ERROR(EFSCORRUPTED);
tail_distance = tail_block +
(log->l_logBBsize - head_block);
tail_distance = tail_block + (log->l_logBBsize - head_block);
} else {
/*
* The head is behind the tail in the physical log,
......@@ -1980,9 +1976,8 @@ xlog_recover_do_buffer_trans(xlog_t *log,
* the buffer out of the buffer cache so that the buffer won't
* overlap with future reads of those inodes.
*/
error = 0;
if ((INT_GET(*((__uint16_t *)(xfs_buf_offset(bp, 0))), ARCH_CONVERT) == XFS_DINODE_MAGIC) &&
if (XFS_DINODE_MAGIC ==
INT_GET(*((__uint16_t *)(xfs_buf_offset(bp, 0))), ARCH_CONVERT) &&
(XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize,
(__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) {
XFS_BUF_STALE(bp);
......@@ -2042,6 +2037,7 @@ xlog_recover_do_inode_trans(xlog_t *log,
imap.im_blkno = 0;
xfs_imap(log->l_mp, 0, ino, &imap, 0);
}
bp = xfs_buf_read_flags(mp->m_ddev_targp, imap.im_blkno, imap.im_len,
XFS_BUF_LOCK);
if (XFS_BUF_ISERROR(bp)) {
......@@ -2170,8 +2166,6 @@ xlog_recover_do_inode_trans(xlog_t *log,
break;
}
/*
* If we logged any attribute data, recover it. There may or
* may not have been any other non-core data logged in this
......@@ -2844,7 +2838,6 @@ xlog_recover_clear_agi_bucket(
{
xfs_trans_t *tp;
xfs_agi_t *agi;
xfs_daddr_t agidaddr;
xfs_buf_t *agibp;
int offset;
int error;
......@@ -2852,9 +2845,9 @@ xlog_recover_clear_agi_bucket(
tp = xfs_trans_alloc(mp, XFS_TRANS_CLEAR_AGI_BUCKET);
xfs_trans_reserve(tp, 0, XFS_CLEAR_AGI_BUCKET_LOG_RES(mp), 0, 0, 0);
agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, agidaddr,
1, 0, &agibp);
error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0, &agibp);
if (error) {
xfs_trans_cancel(tp, XFS_TRANS_ABORT);
return;
......@@ -2895,7 +2888,6 @@ xlog_recover_process_iunlinks(xlog_t *log)
xfs_mount_t *mp;
xfs_agnumber_t agno;
xfs_agi_t *agi;
xfs_daddr_t agidaddr;
xfs_buf_t *agibp;
xfs_buf_t *ibp;
xfs_dinode_t *dip;
......@@ -2920,14 +2912,17 @@ xlog_recover_process_iunlinks(xlog_t *log)
/*
* Find the agi for this ag.
*/
agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
agibp = xfs_buf_read(mp->m_ddev_targp, agidaddr, 1, 0);
agibp = xfs_buf_read(mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0);
if (XFS_BUF_ISERROR(agibp)) {
xfs_ioerror_alert("xlog_recover_process_iunlinks(agi#1)",
log->l_mp, agibp, agidaddr);
xfs_ioerror_alert("xlog_recover_process_iunlinks(#1)",
log->l_mp, agibp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)));
}
agi = XFS_BUF_TO_AGI(agibp);
ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
ASSERT(XFS_AGI_MAGIC ==
INT_GET(agi->agi_magicnum, ARCH_CONVERT));
for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) {
......@@ -3006,15 +3001,20 @@ xlog_recover_process_iunlinks(xlog_t *log)
* Reacquire the agibuffer and continue around
* the loop.
*/
agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
agibp = xfs_buf_read(mp->m_ddev_targp,
agidaddr, 1, 0);
XFS_AG_DADDR(mp, agno,
XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0);
if (XFS_BUF_ISERROR(agibp)) {
xfs_ioerror_alert("xlog_recover_process_iunlinks(agi#2)",
log->l_mp, agibp, agidaddr);
xfs_ioerror_alert(
"xlog_recover_process_iunlinks(#2)",
log->l_mp, agibp,
XFS_AG_DADDR(mp, agno,
XFS_AGI_DADDR(mp)));
}
agi = XFS_BUF_TO_AGI(agibp);
ASSERT(INT_GET(agi->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
ASSERT(XFS_AGI_MAGIC == INT_GET(
agi->agi_magicnum, ARCH_CONVERT));
}
}
......@@ -3485,9 +3485,8 @@ xlog_do_recover(xlog_t *log,
return error;
}
/* convert superblock from on-disk format */
sbp=&log->l_mp->m_sb;
/* Convert superblock from on-disk format */
sbp = &log->l_mp->m_sb;
xfs_xlatesb(XFS_BUF_TO_SBP(bp), sbp, 1, ARCH_CONVERT, XFS_SB_ALL_BITS);
ASSERT(sbp->sb_magicnum == XFS_SB_MAGIC);
ASSERT(XFS_SB_GOOD_VERSION(sbp));
......@@ -3653,30 +3652,36 @@ xlog_recover_check_summary(xlog_t *log)
itotal = 0LL;
ifree = 0LL;
for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
agfdaddr = XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR);
agfbp = xfs_buf_read(mp->m_ddev_targp, agfdaddr, 1, 0);
agfdaddr = XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp));
agfbp = xfs_buf_read(mp->m_ddev_targp, agfdaddr,
XFS_FSS_TO_BB(mp, 1), 0);
if (XFS_BUF_ISERROR(agfbp)) {
xfs_ioerror_alert("xlog_recover_check_summary(agf)",
log->l_mp, agfbp, agfdaddr);
mp, agfbp, agfdaddr);
}
agfp = XFS_BUF_TO_AGF(agfbp);
ASSERT(INT_GET(agfp->agf_magicnum, ARCH_CONVERT) == XFS_AGF_MAGIC);
ASSERT(XFS_AGF_GOOD_VERSION(INT_GET(agfp->agf_versionnum, ARCH_CONVERT)));
ASSERT(XFS_AGF_MAGIC ==
INT_GET(agfp->agf_magicnum, ARCH_CONVERT));
ASSERT(XFS_AGF_GOOD_VERSION(
INT_GET(agfp->agf_versionnum, ARCH_CONVERT)));
ASSERT(INT_GET(agfp->agf_seqno, ARCH_CONVERT) == agno);
freeblks += INT_GET(agfp->agf_freeblks, ARCH_CONVERT) +
INT_GET(agfp->agf_flcount, ARCH_CONVERT);
xfs_buf_relse(agfbp);
agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR);
agibp = xfs_buf_read(mp->m_ddev_targp, agidaddr, 1, 0);
agidaddr = XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp));
agibp = xfs_buf_read(mp->m_ddev_targp, agidaddr,
XFS_FSS_TO_BB(mp, 1), 0);
if (XFS_BUF_ISERROR(agibp)) {
xfs_ioerror_alert("xlog_recover_check_summary(agi)",
log->l_mp, agibp, agidaddr);
}
agip = XFS_BUF_TO_AGI(agibp);
ASSERT(INT_GET(agip->agi_magicnum, ARCH_CONVERT) == XFS_AGI_MAGIC);
ASSERT(XFS_AGI_GOOD_VERSION(INT_GET(agip->agi_versionnum, ARCH_CONVERT)));
ASSERT(XFS_AGI_MAGIC ==
INT_GET(agip->agi_magicnum, ARCH_CONVERT));
ASSERT(XFS_AGI_GOOD_VERSION(
INT_GET(agip->agi_versionnum, ARCH_CONVERT)));
ASSERT(INT_GET(agip->agi_seqno, ARCH_CONVERT) == agno);
itotal += INT_GET(agip->agi_count, ARCH_CONVERT);
......
......@@ -2179,6 +2179,14 @@ xfs_sb_version_haslogv2(xfs_sb_t *sbp)
}
#endif
#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_HASSECTOR)
int
xfs_sb_version_hassector(xfs_sb_t *sbp)
{
return XFS_SB_VERSION_HASSECTOR(sbp);
}
#endif
#if XFS_WANT_FUNCS_C || (XFS_WANT_SPACE_C && XFSSO_XFS_SB_VERSION_TONEW)
unsigned
xfs_sb_version_tonew(unsigned v)
......
......@@ -215,11 +215,6 @@ xfs_mount_validate_sb(
return XFS_ERROR(EFSCORRUPTED);
}
if (!sbp->sb_logsectlog)
sbp->sb_logsectlog = sbp->sb_sectlog;
if (!sbp->sb_logsectsize)
sbp->sb_logsectsize = sbp->sb_sectsize;
/*
* More sanity checking. These were stolen directly from
* xfs_repair.
......@@ -229,10 +224,6 @@ xfs_mount_validate_sb(
sbp->sb_sectsize > XFS_MAX_SECTORSIZE ||
sbp->sb_sectlog < XFS_MIN_SECTORSIZE_LOG ||
sbp->sb_sectlog > XFS_MAX_SECTORSIZE_LOG ||
sbp->sb_logsectsize < XFS_MIN_SECTORSIZE ||
sbp->sb_logsectsize > XFS_MAX_SECTORSIZE ||
sbp->sb_logsectlog < XFS_MIN_SECTORSIZE_LOG ||
sbp->sb_logsectlog > XFS_MAX_SECTORSIZE_LOG ||
sbp->sb_blocksize < XFS_MIN_BLOCKSIZE ||
sbp->sb_blocksize > XFS_MAX_BLOCKSIZE ||
sbp->sb_blocklog < XFS_MIN_BLOCKSIZE_LOG ||
......@@ -276,10 +267,10 @@ xfs_mount_validate_sb(
*/
if (sbp->sb_blocksize > PAGE_SIZE) {
cmn_err(CE_WARN,
"XFS: Trying to mount file system with blocksize %d bytes",
"XFS: Attempted to mount file system with blocksize %d bytes",
sbp->sb_blocksize);
cmn_err(CE_WARN,
"XFS: Only page-sized (%d bytes) or less blocksizes currently work.",
"XFS: Only page-sized (%d) or less blocksizes currently work.",
PAGE_SIZE);
return XFS_ERROR(EWRONGFS);
}
......@@ -795,8 +786,8 @@ xfs_mountfs(
goto error1;
}
error = xfs_read_buf(mp, mp->m_logdev_targp,
d - XFS_LOGS_TO_BB(mp, 1),
XFS_LOGS_TO_BB(mp, 1), 0, &bp);
d - XFS_FSB_TO_BB(mp, 1),
XFS_FSB_TO_BB(mp, 1), 0, &bp);
if (!error) {
xfs_buf_relse(bp);
} else {
......
......@@ -1925,7 +1925,8 @@ xfs_growfs_rt(
* Read in the last block of the device, make sure it exists.
*/
error = xfs_read_buf(mp, mp->m_rtdev_targp,
XFS_FSB_TO_BB(mp, in->newblocks) - 1, 1, 0, &bp);
XFS_FSB_TO_BB(mp, in->newblocks - 1),
XFS_FSB_TO_BB(mp, 1), 0, &bp);
if (error)
return error;
ASSERT(bp);
......@@ -2285,7 +2286,9 @@ xfs_rtmount_init(
(unsigned long long) mp->m_sb.sb_rblocks);
return XFS_ERROR(E2BIG);
}
error = xfs_read_buf(mp, mp->m_rtdev_targp, d - 1, 1, 0, &bp);
error = xfs_read_buf(mp, mp->m_rtdev_targp,
XFS_FSB_TO_BB(mp, d - 1),
XFS_FSB_TO_BB(mp, 1), 0, &bp);
if (error) {
cmn_err(CE_WARN,
"XFS: realtime mount -- xfs_read_buf failed, returned %d", error);
......
......@@ -57,6 +57,7 @@ struct xfs_mount;
#define XFS_SB_VERSION_DALIGNBIT 0x0100
#define XFS_SB_VERSION_SHAREDBIT 0x0200
#define XFS_SB_VERSION_LOGV2BIT 0x0400
#define XFS_SB_VERSION_SECTORBIT 0x0800
#define XFS_SB_VERSION_EXTFLGBIT 0x1000
#define XFS_SB_VERSION_DIRV2BIT 0x2000
#define XFS_SB_VERSION_OKSASHFBITS \
......@@ -69,7 +70,8 @@ struct xfs_mount;
XFS_SB_VERSION_ALIGNBIT | \
XFS_SB_VERSION_DALIGNBIT | \
XFS_SB_VERSION_SHAREDBIT | \
XFS_SB_VERSION_LOGV2BIT)
XFS_SB_VERSION_LOGV2BIT | \
XFS_SB_VERSION_SECTORBIT)
#define XFS_SB_VERSION_OKSASHBITS \
(XFS_SB_VERSION_NUMBITS | \
XFS_SB_VERSION_REALFBITS | \
......@@ -78,14 +80,15 @@ struct xfs_mount;
(XFS_SB_VERSION_NUMBITS | \
XFS_SB_VERSION_OKREALFBITS | \
XFS_SB_VERSION_OKSASHFBITS)
#define XFS_SB_VERSION_MKFS(ia,dia,extflag,dirv2,na) \
#define XFS_SB_VERSION_MKFS(ia,dia,extflag,dirv2,na,sflag) \
(((ia) || (dia) || (extflag) || (dirv2) || (na)) ? \
(XFS_SB_VERSION_4 | \
((ia) ? XFS_SB_VERSION_ALIGNBIT : 0) | \
((dia) ? XFS_SB_VERSION_DALIGNBIT : 0) | \
((extflag) ? XFS_SB_VERSION_EXTFLGBIT : 0) | \
((dirv2) ? XFS_SB_VERSION_DIRV2BIT : 0) | \
((na) ? XFS_SB_VERSION_LOGV2BIT : 0)) : \
((na) ? XFS_SB_VERSION_LOGV2BIT : 0) | \
((sflag) ? XFS_SB_VERSION_SECTORBIT : 0)) : \
XFS_SB_VERSION_1)
typedef struct xfs_sb
......@@ -441,6 +444,15 @@ int xfs_sb_version_subextflgbit(xfs_sb_t *sbp);
((sbp)->sb_versionnum & ~XFS_SB_VERSION_EXTFLGBIT))
#endif
#if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_SB_VERSION_HASSECTOR)
int xfs_sb_version_hassector(xfs_sb_t *sbp);
#define XFS_SB_VERSION_HASSECTOR(sbp) xfs_sb_version_hassector(sbp)
#else
#define XFS_SB_VERSION_HASSECTOR(sbp) \
((XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) && \
((sbp)->sb_versionnum & XFS_SB_VERSION_SECTORBIT))
#endif
/*
* end of superblock version macros
*/
......@@ -486,7 +498,6 @@ xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp);
* File system sector to basic block conversions.
*/
#define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log)
#define XFS_LOGS_TO_BB(mp,sec) ((sec) << ((mp)->m_sb.sb_logsectlog - BBSHIFT))
#define XFS_BB_TO_FSS(mp,bb) \
(((bb) + (XFS_FSS_TO_BB(mp,1) - 1)) >> (mp)->m_sectbb_log)
#define XFS_BB_TO_FSST(mp,bb) ((bb) >> (mp)->m_sectbb_log)
......@@ -509,8 +520,7 @@ xfs_sb_t *xfs_buf_to_sbp(struct xfs_buf *bp);
/*
* File system block to byte conversions.
*/
#define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << \
(mp)->m_sb.sb_blocklog)
#define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog)
#define XFS_B_TO_FSB(mp,b) \
((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog)
#define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog)
......
......@@ -451,9 +451,13 @@ xfs_mount(
xfs_size_buftarg(mp->m_ddev_targp, mp->m_sb.sb_blocksize,
mp->m_sb.sb_sectsize);
if (logdev && logdev != ddev)
xfs_size_buftarg(mp->m_logdev_targp, mp->m_sb.sb_blocksize,
mp->m_sb.sb_logsectsize);
if (logdev && logdev != ddev) {
unsigned int ss = BBSIZE;
if (XFS_SB_VERSION_HASSECTOR(&mp->m_sb))
ss = mp->m_sb.sb_logsectsize;
xfs_size_buftarg(mp->m_logdev_targp, mp->m_sb.sb_blocksize, ss);
}
if (rtdev)
xfs_size_buftarg(mp->m_logdev_targp, mp->m_sb.sb_blocksize,
mp->m_sb.sb_blocksize);
......
......@@ -4660,9 +4660,10 @@ xfsidbg_xmount(xfs_mount_t *mp)
kdb_printf("dalign %d swidth %d sinoalign %d attr_magicpct %d dir_magicpct %d\n",
mp->m_dalign, mp->m_swidth, mp->m_sinoalign,
mp->m_attr_magicpct, mp->m_dir_magicpct);
kdb_printf("mk_sharedro %d dirversion %d dirblkfsbs %d &dirops 0x%p\n",
mp->m_mk_sharedro, mp->m_dirversion, mp->m_dirblkfsbs,
&mp->m_dirops);
kdb_printf("mk_sharedro %d inode_quiesce %d sectbb_log %d\n",
mp->m_mk_sharedro, mp->m_inode_quiesce, mp->m_sectbb_log);
kdb_printf("dirversion %d dirblkfsbs %d &dirops 0x%p\n",
mp->m_dirversion, mp->m_dirblkfsbs, &mp->m_dirops);
kdb_printf("dirblksize %d dirdatablk 0x%Lx dirleafblk 0x%Lx dirfreeblk 0x%Lx\n",
mp->m_dirblksize,
(xfs_dfiloff_t)mp->m_dirdatablk,
......
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