Commit a8acad70 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: kill XBF_LOCK

Buffers are always returned locked from the lookup routines. Hence
we don't need to tell the lookup routines to return locked buffers,
on to try and lock them. Remove XBF_LOCK from all the callers and
from internal buffer cache usage.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 795cac72
...@@ -1988,8 +1988,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args) ...@@ -1988,8 +1988,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno, error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
blkcnt, XBF_LOCK | XBF_DONT_BLOCK, blkcnt, XBF_DONT_BLOCK, &bp);
&bp);
if (error) if (error)
return(error); return(error);
...@@ -2116,7 +2115,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args) ...@@ -2116,7 +2115,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount); blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
XBF_LOCK | XBF_DONT_BLOCK); XBF_DONT_BLOCK);
if (!bp) if (!bp)
return ENOMEM; return ENOMEM;
......
...@@ -2983,7 +2983,7 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp, ...@@ -2983,7 +2983,7 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
map.br_blockcount); map.br_blockcount);
bp = xfs_trans_get_buf(*trans, bp = xfs_trans_get_buf(*trans,
dp->i_mount->m_ddev_targp, dp->i_mount->m_ddev_targp,
dblkno, dblkcnt, XBF_LOCK); dblkno, dblkcnt, 0);
if (!bp) if (!bp)
return ENOMEM; return ENOMEM;
xfs_trans_binval(*trans, bp); xfs_trans_binval(*trans, bp);
......
...@@ -185,7 +185,7 @@ xfs_buf_alloc( ...@@ -185,7 +185,7 @@ xfs_buf_alloc(
/* /*
* We don't want certain flags to appear in b_flags. * We don't want certain flags to appear in b_flags.
*/ */
flags &= ~(XBF_LOCK|XBF_MAPPED|XBF_DONT_BLOCK|XBF_READ_AHEAD); flags &= ~(XBF_MAPPED|XBF_DONT_BLOCK|XBF_READ_AHEAD);
atomic_set(&bp->b_hold, 1); atomic_set(&bp->b_hold, 1);
atomic_set(&bp->b_lru_ref, 1); atomic_set(&bp->b_lru_ref, 1);
...@@ -584,19 +584,14 @@ xfs_buf_get( ...@@ -584,19 +584,14 @@ xfs_buf_get(
if (unlikely(error)) { if (unlikely(error)) {
xfs_warn(target->bt_mount, xfs_warn(target->bt_mount,
"%s: failed to map pages\n", __func__); "%s: failed to map pages\n", __func__);
goto no_buffer; xfs_buf_relse(bp);
return NULL;
} }
} }
XFS_STATS_INC(xb_get); XFS_STATS_INC(xb_get);
trace_xfs_buf_get(bp, flags, _RET_IP_); trace_xfs_buf_get(bp, flags, _RET_IP_);
return bp; return bp;
no_buffer:
if (flags & (XBF_LOCK | XBF_TRYLOCK))
xfs_buf_unlock(bp);
xfs_buf_rele(bp);
return NULL;
} }
STATIC int STATIC int
...@@ -639,7 +634,8 @@ xfs_buf_read( ...@@ -639,7 +634,8 @@ xfs_buf_read(
* Read ahead call which is already satisfied, * Read ahead call which is already satisfied,
* drop the buffer * drop the buffer
*/ */
goto no_buffer; xfs_buf_relse(bp);
return NULL;
} else { } else {
/* We do not want read in the flags */ /* We do not want read in the flags */
bp->b_flags &= ~XBF_READ; bp->b_flags &= ~XBF_READ;
...@@ -647,12 +643,6 @@ xfs_buf_read( ...@@ -647,12 +643,6 @@ xfs_buf_read(
} }
return bp; return bp;
no_buffer:
if (flags & (XBF_LOCK | XBF_TRYLOCK))
xfs_buf_unlock(bp);
xfs_buf_rele(bp);
return NULL;
} }
/* /*
......
...@@ -52,7 +52,6 @@ typedef enum { ...@@ -52,7 +52,6 @@ typedef enum {
#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */ #define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */
/* flags used only as arguments to access routines */ /* flags used only as arguments to access routines */
#define XBF_LOCK (1 << 15)/* lock requested */
#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ #define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */
#define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */ #define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */
...@@ -74,8 +73,7 @@ typedef unsigned int xfs_buf_flags_t; ...@@ -74,8 +73,7 @@ typedef unsigned int xfs_buf_flags_t;
{ XBF_SYNCIO, "SYNCIO" }, \ { XBF_SYNCIO, "SYNCIO" }, \
{ XBF_FUA, "FUA" }, \ { XBF_FUA, "FUA" }, \
{ XBF_FLUSH, "FLUSH" }, \ { XBF_FLUSH, "FLUSH" }, \
{ XBF_LOCK, "LOCK" }, /* should never be set */\ { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\
{ XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\
{ XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\
{ _XBF_PAGES, "PAGES" }, \ { _XBF_PAGES, "PAGES" }, \
{ _XBF_KMEM, "KMEM" }, \ { _XBF_KMEM, "KMEM" }, \
......
...@@ -193,7 +193,7 @@ xfs_growfs_data_private( ...@@ -193,7 +193,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), XBF_LOCK | XBF_MAPPED); XFS_FSS_TO_BB(mp, 1), XBF_MAPPED);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error0; goto error0;
...@@ -230,7 +230,7 @@ xfs_growfs_data_private( ...@@ -230,7 +230,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), XBF_LOCK | XBF_MAPPED); XFS_FSS_TO_BB(mp, 1), XBF_MAPPED);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error0; goto error0;
...@@ -259,8 +259,7 @@ xfs_growfs_data_private( ...@@ -259,8 +259,7 @@ 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), BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
XBF_LOCK | XBF_MAPPED);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error0; goto error0;
...@@ -286,8 +285,7 @@ xfs_growfs_data_private( ...@@ -286,8 +285,7 @@ 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), BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
XBF_LOCK | XBF_MAPPED);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error0; goto error0;
...@@ -314,8 +312,7 @@ xfs_growfs_data_private( ...@@ -314,8 +312,7 @@ 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), BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
XBF_LOCK | XBF_MAPPED);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error0; goto error0;
......
...@@ -200,8 +200,7 @@ xfs_ialloc_inode_init( ...@@ -200,8 +200,7 @@ xfs_ialloc_inode_init(
*/ */
d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster)); d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster));
fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
mp->m_bsize * blks_per_cluster, mp->m_bsize * blks_per_cluster, 0);
XBF_LOCK);
if (!fbuf) if (!fbuf)
return ENOMEM; return ENOMEM;
/* /*
......
...@@ -226,7 +226,7 @@ xfs_inotobp( ...@@ -226,7 +226,7 @@ xfs_inotobp(
if (error) if (error)
return error; return error;
error = xfs_imap_to_bp(mp, tp, &imap, &bp, XBF_LOCK, imap_flags); error = xfs_imap_to_bp(mp, tp, &imap, &bp, 0, imap_flags);
if (error) if (error)
return error; return error;
...@@ -782,8 +782,7 @@ xfs_iread( ...@@ -782,8 +782,7 @@ xfs_iread(
/* /*
* Get pointers to the on-disk inode and the buffer containing it. * Get pointers to the on-disk inode and the buffer containing it.
*/ */
error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, 0, iget_flags);
XBF_LOCK, iget_flags);
if (error) if (error)
return error; return error;
dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
...@@ -1342,7 +1341,7 @@ xfs_iunlink( ...@@ -1342,7 +1341,7 @@ xfs_iunlink(
* Here we put the head pointer into our next pointer, * Here we put the head pointer into our next pointer,
* and then we fall through to point the head at us. * and then we fall through to point the head at us.
*/ */
error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
if (error) if (error)
return error; return error;
...@@ -1423,7 +1422,7 @@ xfs_iunlink_remove( ...@@ -1423,7 +1422,7 @@ xfs_iunlink_remove(
* of dealing with the buffer when there is no need to * of dealing with the buffer when there is no need to
* change it. * change it.
*/ */
error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
if (error) { if (error) {
xfs_warn(mp, "%s: xfs_itobp() returned error %d.", xfs_warn(mp, "%s: xfs_itobp() returned error %d.",
__func__, error); __func__, error);
...@@ -1484,7 +1483,7 @@ xfs_iunlink_remove( ...@@ -1484,7 +1483,7 @@ xfs_iunlink_remove(
* Now last_ibp points to the buffer previous to us on * Now last_ibp points to the buffer previous to us on
* the unlinked list. Pull us from the list. * the unlinked list. Pull us from the list.
*/ */
error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
if (error) { if (error) {
xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.", xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.",
__func__, error); __func__, error);
...@@ -1566,8 +1565,7 @@ xfs_ifree_cluster( ...@@ -1566,8 +1565,7 @@ xfs_ifree_cluster(
* to mark all the active inodes on the buffer stale. * to mark all the active inodes on the buffer stale.
*/ */
bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
mp->m_bsize * blks_per_cluster, mp->m_bsize * blks_per_cluster, 0);
XBF_LOCK);
if (!bp) if (!bp)
return ENOMEM; return ENOMEM;
...@@ -1737,7 +1735,7 @@ xfs_ifree( ...@@ -1737,7 +1735,7 @@ xfs_ifree(
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, XBF_LOCK); error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0);
if (error) if (error)
return error; return error;
......
...@@ -2131,7 +2131,7 @@ xlog_recover_buffer_pass2( ...@@ -2131,7 +2131,7 @@ xlog_recover_buffer_pass2(
trace_xfs_log_recover_buf_recover(log, buf_f); trace_xfs_log_recover_buf_recover(log, buf_f);
buf_flags = XBF_LOCK; buf_flags = 0;
if (!(buf_f->blf_flags & XFS_BLF_INODE_BUF)) if (!(buf_f->blf_flags & XFS_BLF_INODE_BUF))
buf_flags |= XBF_MAPPED; buf_flags |= XBF_MAPPED;
...@@ -2229,8 +2229,7 @@ xlog_recover_inode_pass2( ...@@ -2229,8 +2229,7 @@ xlog_recover_inode_pass2(
} }
trace_xfs_log_recover_inode_recover(log, in_f); trace_xfs_log_recover_inode_recover(log, in_f);
bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0);
XBF_LOCK);
if (!bp) { if (!bp) {
error = ENOMEM; error = ENOMEM;
goto error; goto error;
...@@ -3103,7 +3102,7 @@ xlog_recover_process_one_iunlink( ...@@ -3103,7 +3102,7 @@ xlog_recover_process_one_iunlink(
/* /*
* Get the on disk inode to find the next inode in the bucket. * Get the on disk inode to find the next inode in the bucket.
*/ */
error = xfs_itobp(mp, NULL, ip, &dip, &ibp, XBF_LOCK); error = xfs_itobp(mp, NULL, ip, &dip, &ibp, 0);
if (error) if (error)
goto fail_iput; goto fail_iput;
......
...@@ -114,7 +114,7 @@ xfs_read_buf( ...@@ -114,7 +114,7 @@ xfs_read_buf(
int error; int error;
if (!flags) if (!flags)
flags = XBF_LOCK | XBF_MAPPED; flags = XBF_MAPPED;
bp = xfs_buf_read(target, blkno, len, flags); bp = xfs_buf_read(target, blkno, len, flags);
if (!bp) if (!bp)
......
...@@ -142,7 +142,7 @@ xfs_trans_get_buf(xfs_trans_t *tp, ...@@ -142,7 +142,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
xfs_buf_log_item_t *bip; xfs_buf_log_item_t *bip;
if (flags == 0) if (flags == 0)
flags = XBF_LOCK | XBF_MAPPED; flags = XBF_MAPPED;
/* /*
* Default to a normal get_buf() call if the tp is NULL. * Default to a normal get_buf() call if the tp is NULL.
...@@ -275,7 +275,7 @@ xfs_trans_read_buf( ...@@ -275,7 +275,7 @@ xfs_trans_read_buf(
int error; int error;
if (flags == 0) if (flags == 0)
flags = XBF_LOCK | XBF_MAPPED; flags = XBF_MAPPED;
/* /*
* Default to a normal get_buf() call if the tp is NULL. * Default to a normal get_buf() call if the tp is NULL.
......
...@@ -82,7 +82,7 @@ xfs_readlink_bmap( ...@@ -82,7 +82,7 @@ xfs_readlink_bmap(
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(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_DONT_BLOCK); XBF_MAPPED | XBF_DONT_BLOCK);
if (!bp) if (!bp)
return XFS_ERROR(ENOMEM); return XFS_ERROR(ENOMEM);
error = bp->b_error; error = bp->b_error;
......
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