Commit 6ad112bf authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: simplify xfs_buf_get / xfs_buf_read interfaces

Currently the low-level buffer cache interfaces are highly confusing
as we have a _flags variant of each that does actually respect the
flags, and one without _flags which has a flags argument that gets
ignored and overriden with a default set.  Given that very few places
use the default arguments get rid of the duplication and convert all
callers to pass the flags explicitly.  Also remove the now confusing
_flags postfix.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent c355c656
...@@ -582,7 +582,7 @@ found: ...@@ -582,7 +582,7 @@ found:
* although backing storage may not be. * although backing storage may not be.
*/ */
xfs_buf_t * xfs_buf_t *
xfs_buf_get_flags( xfs_buf_get(
xfs_buftarg_t *target,/* target for buffer */ xfs_buftarg_t *target,/* target for buffer */
xfs_off_t ioff, /* starting offset of range */ xfs_off_t ioff, /* starting offset of range */
size_t isize, /* length of range */ size_t isize, /* length of range */
...@@ -661,7 +661,7 @@ _xfs_buf_read( ...@@ -661,7 +661,7 @@ _xfs_buf_read(
} }
xfs_buf_t * xfs_buf_t *
xfs_buf_read_flags( xfs_buf_read(
xfs_buftarg_t *target, xfs_buftarg_t *target,
xfs_off_t ioff, xfs_off_t ioff,
size_t isize, size_t isize,
...@@ -671,7 +671,7 @@ xfs_buf_read_flags( ...@@ -671,7 +671,7 @@ xfs_buf_read_flags(
flags |= XBF_READ; flags |= XBF_READ;
bp = xfs_buf_get_flags(target, ioff, isize, flags); bp = xfs_buf_get(target, ioff, isize, flags);
if (bp) { if (bp) {
if (!XFS_BUF_ISDONE(bp)) { if (!XFS_BUF_ISDONE(bp)) {
XB_TRACE(bp, "read", (unsigned long)flags); XB_TRACE(bp, "read", (unsigned long)flags);
...@@ -718,7 +718,7 @@ xfs_buf_readahead( ...@@ -718,7 +718,7 @@ xfs_buf_readahead(
return; return;
flags |= (XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD); flags |= (XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD);
xfs_buf_read_flags(target, ioff, isize, flags); xfs_buf_read(target, ioff, isize, flags);
} }
xfs_buf_t * xfs_buf_t *
......
...@@ -186,15 +186,10 @@ extern xfs_buf_t *_xfs_buf_find(xfs_buftarg_t *, xfs_off_t, size_t, ...@@ -186,15 +186,10 @@ extern xfs_buf_t *_xfs_buf_find(xfs_buftarg_t *, xfs_off_t, size_t,
#define xfs_incore(buftarg,blkno,len,lockit) \ #define xfs_incore(buftarg,blkno,len,lockit) \
_xfs_buf_find(buftarg, blkno ,len, lockit, NULL) _xfs_buf_find(buftarg, blkno ,len, lockit, NULL)
extern xfs_buf_t *xfs_buf_get_flags(xfs_buftarg_t *, xfs_off_t, size_t, extern xfs_buf_t *xfs_buf_get(xfs_buftarg_t *, xfs_off_t, size_t,
xfs_buf_flags_t); xfs_buf_flags_t);
#define xfs_buf_get(target, blkno, len, flags) \ extern xfs_buf_t *xfs_buf_read(xfs_buftarg_t *, xfs_off_t, size_t,
xfs_buf_get_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
extern xfs_buf_t *xfs_buf_read_flags(xfs_buftarg_t *, xfs_off_t, size_t,
xfs_buf_flags_t); xfs_buf_flags_t);
#define xfs_buf_read(target, blkno, len, flags) \
xfs_buf_read_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *); extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *);
extern xfs_buf_t *xfs_buf_get_noaddr(size_t, xfs_buftarg_t *); extern xfs_buf_t *xfs_buf_get_noaddr(size_t, xfs_buftarg_t *);
......
...@@ -2143,7 +2143,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) ...@@ -2143,7 +2143,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock), dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount); blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno, blkcnt, bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
XFS_BUF_LOCK | XBF_DONT_BLOCK); XFS_BUF_LOCK | XBF_DONT_BLOCK);
ASSERT(bp); ASSERT(bp);
ASSERT(!XFS_BUF_GETERROR(bp)); ASSERT(!XFS_BUF_GETERROR(bp));
......
...@@ -202,7 +202,7 @@ xfs_growfs_data_private( ...@@ -202,7 +202,7 @@ xfs_growfs_data_private(
*/ */
bp = xfs_buf_get(mp->m_ddev_targp, bp = xfs_buf_get(mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0); XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED);
agf = XFS_BUF_TO_AGF(bp); agf = XFS_BUF_TO_AGF(bp);
memset(agf, 0, mp->m_sb.sb_sectsize); memset(agf, 0, mp->m_sb.sb_sectsize);
agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
...@@ -234,7 +234,7 @@ xfs_growfs_data_private( ...@@ -234,7 +234,7 @@ xfs_growfs_data_private(
*/ */
bp = xfs_buf_get(mp->m_ddev_targp, bp = xfs_buf_get(mp->m_ddev_targp,
XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), 0); XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED);
agi = XFS_BUF_TO_AGI(bp); agi = XFS_BUF_TO_AGI(bp);
memset(agi, 0, mp->m_sb.sb_sectsize); memset(agi, 0, mp->m_sb.sb_sectsize);
agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
...@@ -258,7 +258,8 @@ xfs_growfs_data_private( ...@@ -258,7 +258,8 @@ xfs_growfs_data_private(
*/ */
bp = xfs_buf_get(mp->m_ddev_targp, bp = xfs_buf_get(mp->m_ddev_targp,
XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0); BTOBB(mp->m_sb.sb_blocksize),
XBF_LOCK | XBF_MAPPED);
block = XFS_BUF_TO_BLOCK(bp); block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize); memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC);
...@@ -279,7 +280,8 @@ xfs_growfs_data_private( ...@@ -279,7 +280,8 @@ xfs_growfs_data_private(
*/ */
bp = xfs_buf_get(mp->m_ddev_targp, bp = xfs_buf_get(mp->m_ddev_targp,
XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0); BTOBB(mp->m_sb.sb_blocksize),
XBF_LOCK | XBF_MAPPED);
block = XFS_BUF_TO_BLOCK(bp); block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize); memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC);
...@@ -301,7 +303,8 @@ xfs_growfs_data_private( ...@@ -301,7 +303,8 @@ xfs_growfs_data_private(
*/ */
bp = xfs_buf_get(mp->m_ddev_targp, bp = xfs_buf_get(mp->m_ddev_targp,
XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
BTOBB(mp->m_sb.sb_blocksize), 0); BTOBB(mp->m_sb.sb_blocksize),
XBF_LOCK | XBF_MAPPED);
block = XFS_BUF_TO_BLOCK(bp); block = XFS_BUF_TO_BLOCK(bp);
memset(block, 0, mp->m_sb.sb_blocksize); memset(block, 0, mp->m_sb.sb_blocksize);
block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC);
......
...@@ -2206,6 +2206,7 @@ xlog_recover_do_buffer_trans( ...@@ -2206,6 +2206,7 @@ xlog_recover_do_buffer_trans(
xfs_daddr_t blkno; xfs_daddr_t blkno;
int len; int len;
ushort flags; ushort flags;
uint buf_flags;
buf_f = (xfs_buf_log_format_t *)item->ri_buf[0].i_addr; buf_f = (xfs_buf_log_format_t *)item->ri_buf[0].i_addr;
...@@ -2246,12 +2247,11 @@ xlog_recover_do_buffer_trans( ...@@ -2246,12 +2247,11 @@ xlog_recover_do_buffer_trans(
} }
mp = log->l_mp; mp = log->l_mp;
if (flags & XFS_BLI_INODE_BUF) { buf_flags = XFS_BUF_LOCK;
bp = xfs_buf_read_flags(mp->m_ddev_targp, blkno, len, if (!(flags & XFS_BLI_INODE_BUF))
XFS_BUF_LOCK); buf_flags |= XFS_BUF_MAPPED;
} else {
bp = xfs_buf_read(mp->m_ddev_targp, blkno, len, 0); bp = xfs_buf_read(mp->m_ddev_targp, blkno, len, buf_flags);
}
if (XFS_BUF_ISERROR(bp)) { if (XFS_BUF_ISERROR(bp)) {
xfs_ioerror_alert("xlog_recover_do..(read#1)", log->l_mp, xfs_ioerror_alert("xlog_recover_do..(read#1)", log->l_mp,
bp, blkno); bp, blkno);
...@@ -2350,8 +2350,8 @@ xlog_recover_do_inode_trans( ...@@ -2350,8 +2350,8 @@ xlog_recover_do_inode_trans(
goto error; goto error;
} }
bp = xfs_buf_read_flags(mp->m_ddev_targp, in_f->ilf_blkno, bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
in_f->ilf_len, XFS_BUF_LOCK); XFS_BUF_LOCK);
if (XFS_BUF_ISERROR(bp)) { if (XFS_BUF_ISERROR(bp)) {
xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
bp, in_f->ilf_blkno); bp, in_f->ilf_blkno);
......
...@@ -583,8 +583,8 @@ xfs_readsb(xfs_mount_t *mp, int flags) ...@@ -583,8 +583,8 @@ xfs_readsb(xfs_mount_t *mp, int flags)
sector_size = xfs_getsize_buftarg(mp->m_ddev_targp); sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
extra_flags = XFS_BUF_LOCK | XFS_BUF_MANAGE | XFS_BUF_MAPPED; extra_flags = XFS_BUF_LOCK | XFS_BUF_MANAGE | XFS_BUF_MAPPED;
bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR, bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR, BTOBB(sector_size),
BTOBB(sector_size), extra_flags); extra_flags);
if (!bp || XFS_BUF_ISERROR(bp)) { if (!bp || XFS_BUF_ISERROR(bp)) {
xfs_fs_mount_cmn_err(flags, "SB read failed"); xfs_fs_mount_cmn_err(flags, "SB read failed");
error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM; error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
...@@ -624,7 +624,7 @@ xfs_readsb(xfs_mount_t *mp, int flags) ...@@ -624,7 +624,7 @@ xfs_readsb(xfs_mount_t *mp, int flags)
XFS_BUF_UNMANAGE(bp); XFS_BUF_UNMANAGE(bp);
xfs_buf_relse(bp); xfs_buf_relse(bp);
sector_size = mp->m_sb.sb_sectsize; sector_size = mp->m_sb.sb_sectsize;
bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR, bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR,
BTOBB(sector_size), extra_flags); BTOBB(sector_size), extra_flags);
if (!bp || XFS_BUF_ISERROR(bp)) { if (!bp || XFS_BUF_ISERROR(bp)) {
xfs_fs_mount_cmn_err(flags, "SB re-read failed"); xfs_fs_mount_cmn_err(flags, "SB re-read failed");
......
...@@ -277,9 +277,9 @@ xfs_read_buf( ...@@ -277,9 +277,9 @@ xfs_read_buf(
xfs_buf_t *bp; xfs_buf_t *bp;
int error; int error;
if (flags) if (!flags)
bp = xfs_buf_read_flags(target, blkno, len, flags); flags = XBF_LOCK | XBF_MAPPED;
else
bp = xfs_buf_read(target, blkno, len, flags); bp = xfs_buf_read(target, blkno, len, flags);
if (!bp) if (!bp)
return XFS_ERROR(EIO); return XFS_ERROR(EIO);
......
...@@ -79,11 +79,8 @@ xfs_trans_get_buf(xfs_trans_t *tp, ...@@ -79,11 +79,8 @@ xfs_trans_get_buf(xfs_trans_t *tp,
/* /*
* Default to a normal get_buf() call if the tp is NULL. * Default to a normal get_buf() call if the tp is NULL.
*/ */
if (tp == NULL) { if (tp == NULL)
bp = xfs_buf_get_flags(target_dev, blkno, len, return xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
flags | BUF_BUSY);
return(bp);
}
/* /*
* If we find the buffer in the cache with this transaction * If we find the buffer in the cache with this transaction
...@@ -129,7 +126,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, ...@@ -129,7 +126,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
* easily deadlock with our current transaction as well as cause * easily deadlock with our current transaction as well as cause
* us to run out of stack space. * us to run out of stack space.
*/ */
bp = xfs_buf_get_flags(target_dev, blkno, len, flags | BUF_BUSY); bp = xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
if (bp == NULL) { if (bp == NULL) {
return NULL; return NULL;
} }
...@@ -302,7 +299,7 @@ xfs_trans_read_buf( ...@@ -302,7 +299,7 @@ xfs_trans_read_buf(
* Default to a normal get_buf() call if the tp is NULL. * Default to a normal get_buf() call if the tp is NULL.
*/ */
if (tp == NULL) { if (tp == NULL) {
bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
if (!bp) if (!bp)
return (flags & XFS_BUF_TRYLOCK) ? return (flags & XFS_BUF_TRYLOCK) ?
EAGAIN : XFS_ERROR(ENOMEM); EAGAIN : XFS_ERROR(ENOMEM);
...@@ -398,7 +395,7 @@ xfs_trans_read_buf( ...@@ -398,7 +395,7 @@ xfs_trans_read_buf(
* easily deadlock with our current transaction as well as cause * easily deadlock with our current transaction as well as cause
* us to run out of stack space. * us to run out of stack space.
*/ */
bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
if (bp == NULL) { if (bp == NULL) {
*bpp = NULL; *bpp = NULL;
return 0; return 0;
......
...@@ -538,9 +538,8 @@ xfs_readlink_bmap( ...@@ -538,9 +538,8 @@ xfs_readlink_bmap(
d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
bp = xfs_buf_read_flags(mp->m_ddev_targp, d, BTOBB(byte_cnt), bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt),
XBF_LOCK | XBF_MAPPED | XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK);
XBF_DONT_BLOCK);
error = XFS_BUF_GETERROR(bp); error = XFS_BUF_GETERROR(bp);
if (error) { if (error) {
xfs_ioerror_alert("xfs_readlink", xfs_ioerror_alert("xfs_readlink",
......
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