aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-04-23 01:58:54 -0400
committerBen Myers <bpm@sgi.com>2012-05-14 17:20:50 -0400
commita8acad70731e7d0585f25f33f8a009176f001f70 (patch)
tree07a14f8bde89e7947f56df7203530b7713b186ac /fs
parent795cac72e902496adac399389f9affe5d1ab821a (diff)
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: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_attr.c5
-rw-r--r--fs/xfs/xfs_attr_leaf.c2
-rw-r--r--fs/xfs/xfs_buf.c20
-rw-r--r--fs/xfs/xfs_buf.h4
-rw-r--r--fs/xfs/xfs_fsops.c13
-rw-r--r--fs/xfs/xfs_ialloc.c3
-rw-r--r--fs/xfs/xfs_inode.c16
-rw-r--r--fs/xfs/xfs_log_recover.c7
-rw-r--r--fs/xfs/xfs_rw.c2
-rw-r--r--fs/xfs/xfs_trans_buf.c4
-rw-r--r--fs/xfs/xfs_vnodeops.c2
11 files changed, 29 insertions, 49 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 6e9bd7e46982..c8ef9a9c312b 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1988,8 +1988,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
1988 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); 1988 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
1989 blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); 1989 blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
1990 error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno, 1990 error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
1991 blkcnt, XBF_LOCK | XBF_DONT_BLOCK, 1991 blkcnt, XBF_DONT_BLOCK, &bp);
1992 &bp);
1993 if (error) 1992 if (error)
1994 return(error); 1993 return(error);
1995 1994
@@ -2116,7 +2115,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2116 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount); 2115 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
2117 2116
2118 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt, 2117 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
2119 XBF_LOCK | XBF_DONT_BLOCK); 2118 XBF_DONT_BLOCK);
2120 if (!bp) 2119 if (!bp)
2121 return ENOMEM; 2120 return ENOMEM;
2122 2121
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 76d93dc953e1..3cd5dc668043 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -2983,7 +2983,7 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
2983 map.br_blockcount); 2983 map.br_blockcount);
2984 bp = xfs_trans_get_buf(*trans, 2984 bp = xfs_trans_get_buf(*trans,
2985 dp->i_mount->m_ddev_targp, 2985 dp->i_mount->m_ddev_targp,
2986 dblkno, dblkcnt, XBF_LOCK); 2986 dblkno, dblkcnt, 0);
2987 if (!bp) 2987 if (!bp)
2988 return ENOMEM; 2988 return ENOMEM;
2989 xfs_trans_binval(*trans, bp); 2989 xfs_trans_binval(*trans, bp);
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 942cf5051ab4..8366348aa1f9 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -185,7 +185,7 @@ xfs_buf_alloc(
185 /* 185 /*
186 * We don't want certain flags to appear in b_flags. 186 * We don't want certain flags to appear in b_flags.
187 */ 187 */
188 flags &= ~(XBF_LOCK|XBF_MAPPED|XBF_DONT_BLOCK|XBF_READ_AHEAD); 188 flags &= ~(XBF_MAPPED|XBF_DONT_BLOCK|XBF_READ_AHEAD);
189 189
190 atomic_set(&bp->b_hold, 1); 190 atomic_set(&bp->b_hold, 1);
191 atomic_set(&bp->b_lru_ref, 1); 191 atomic_set(&bp->b_lru_ref, 1);
@@ -584,19 +584,14 @@ found:
584 if (unlikely(error)) { 584 if (unlikely(error)) {
585 xfs_warn(target->bt_mount, 585 xfs_warn(target->bt_mount,
586 "%s: failed to map pages\n", __func__); 586 "%s: failed to map pages\n", __func__);
587 goto no_buffer; 587 xfs_buf_relse(bp);
588 return NULL;
588 } 589 }
589 } 590 }
590 591
591 XFS_STATS_INC(xb_get); 592 XFS_STATS_INC(xb_get);
592 trace_xfs_buf_get(bp, flags, _RET_IP_); 593 trace_xfs_buf_get(bp, flags, _RET_IP_);
593 return bp; 594 return bp;
594
595no_buffer:
596 if (flags & (XBF_LOCK | XBF_TRYLOCK))
597 xfs_buf_unlock(bp);
598 xfs_buf_rele(bp);
599 return NULL;
600} 595}
601 596
602STATIC int 597STATIC int
@@ -639,7 +634,8 @@ xfs_buf_read(
639 * Read ahead call which is already satisfied, 634 * Read ahead call which is already satisfied,
640 * drop the buffer 635 * drop the buffer
641 */ 636 */
642 goto no_buffer; 637 xfs_buf_relse(bp);
638 return NULL;
643 } else { 639 } else {
644 /* We do not want read in the flags */ 640 /* We do not want read in the flags */
645 bp->b_flags &= ~XBF_READ; 641 bp->b_flags &= ~XBF_READ;
@@ -647,12 +643,6 @@ xfs_buf_read(
647 } 643 }
648 644
649 return bp; 645 return bp;
650
651 no_buffer:
652 if (flags & (XBF_LOCK | XBF_TRYLOCK))
653 xfs_buf_unlock(bp);
654 xfs_buf_rele(bp);
655 return NULL;
656} 646}
657 647
658/* 648/*
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 5b048f7d13ea..512d9a6776a5 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -52,7 +52,6 @@ typedef enum {
52#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */ 52#define XBF_FLUSH (1 << 12)/* flush the disk cache before a write */
53 53
54/* flags used only as arguments to access routines */ 54/* flags used only as arguments to access routines */
55#define XBF_LOCK (1 << 15)/* lock requested */
56#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ 55#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */
57#define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */ 56#define XBF_DONT_BLOCK (1 << 17)/* do not block in current thread */
58 57
@@ -74,8 +73,7 @@ typedef unsigned int xfs_buf_flags_t;
74 { XBF_SYNCIO, "SYNCIO" }, \ 73 { XBF_SYNCIO, "SYNCIO" }, \
75 { XBF_FUA, "FUA" }, \ 74 { XBF_FUA, "FUA" }, \
76 { XBF_FLUSH, "FLUSH" }, \ 75 { XBF_FLUSH, "FLUSH" }, \
77 { XBF_LOCK, "LOCK" }, /* should never be set */\ 76 { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\
78 { XBF_TRYLOCK, "TRYLOCK" }, /* ditto */\
79 { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\ 77 { XBF_DONT_BLOCK, "DONT_BLOCK" }, /* ditto */\
80 { _XBF_PAGES, "PAGES" }, \ 78 { _XBF_PAGES, "PAGES" }, \
81 { _XBF_KMEM, "KMEM" }, \ 79 { _XBF_KMEM, "KMEM" }, \
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 019ba5c52a49..874d39883dab 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -193,7 +193,7 @@ xfs_growfs_data_private(
193 */ 193 */
194 bp = xfs_buf_get(mp->m_ddev_targp, 194 bp = xfs_buf_get(mp->m_ddev_targp,
195 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), 195 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
196 XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); 196 XFS_FSS_TO_BB(mp, 1), XBF_MAPPED);
197 if (!bp) { 197 if (!bp) {
198 error = ENOMEM; 198 error = ENOMEM;
199 goto error0; 199 goto error0;
@@ -230,7 +230,7 @@ xfs_growfs_data_private(
230 */ 230 */
231 bp = xfs_buf_get(mp->m_ddev_targp, 231 bp = xfs_buf_get(mp->m_ddev_targp,
232 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), 232 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
233 XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); 233 XFS_FSS_TO_BB(mp, 1), XBF_MAPPED);
234 if (!bp) { 234 if (!bp) {
235 error = ENOMEM; 235 error = ENOMEM;
236 goto error0; 236 goto error0;
@@ -259,8 +259,7 @@ xfs_growfs_data_private(
259 */ 259 */
260 bp = xfs_buf_get(mp->m_ddev_targp, 260 bp = xfs_buf_get(mp->m_ddev_targp,
261 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), 261 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
262 BTOBB(mp->m_sb.sb_blocksize), 262 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
263 XBF_LOCK | XBF_MAPPED);
264 if (!bp) { 263 if (!bp) {
265 error = ENOMEM; 264 error = ENOMEM;
266 goto error0; 265 goto error0;
@@ -286,8 +285,7 @@ xfs_growfs_data_private(
286 */ 285 */
287 bp = xfs_buf_get(mp->m_ddev_targp, 286 bp = xfs_buf_get(mp->m_ddev_targp,
288 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), 287 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
289 BTOBB(mp->m_sb.sb_blocksize), 288 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
290 XBF_LOCK | XBF_MAPPED);
291 if (!bp) { 289 if (!bp) {
292 error = ENOMEM; 290 error = ENOMEM;
293 goto error0; 291 goto error0;
@@ -314,8 +312,7 @@ xfs_growfs_data_private(
314 */ 312 */
315 bp = xfs_buf_get(mp->m_ddev_targp, 313 bp = xfs_buf_get(mp->m_ddev_targp,
316 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), 314 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
317 BTOBB(mp->m_sb.sb_blocksize), 315 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED);
318 XBF_LOCK | XBF_MAPPED);
319 if (!bp) { 316 if (!bp) {
320 error = ENOMEM; 317 error = ENOMEM;
321 goto error0; 318 goto error0;
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index dad1a31aa4fc..d094a23e1030 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -200,8 +200,7 @@ xfs_ialloc_inode_init(
200 */ 200 */
201 d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster)); 201 d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster));
202 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 202 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
203 mp->m_bsize * blks_per_cluster, 203 mp->m_bsize * blks_per_cluster, 0);
204 XBF_LOCK);
205 if (!fbuf) 204 if (!fbuf)
206 return ENOMEM; 205 return ENOMEM;
207 /* 206 /*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 65d7d994d499..f64b482a7953 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -226,7 +226,7 @@ xfs_inotobp(
226 if (error) 226 if (error)
227 return error; 227 return error;
228 228
229 error = xfs_imap_to_bp(mp, tp, &imap, &bp, XBF_LOCK, imap_flags); 229 error = xfs_imap_to_bp(mp, tp, &imap, &bp, 0, imap_flags);
230 if (error) 230 if (error)
231 return error; 231 return error;
232 232
@@ -782,8 +782,7 @@ xfs_iread(
782 /* 782 /*
783 * Get pointers to the on-disk inode and the buffer containing it. 783 * Get pointers to the on-disk inode and the buffer containing it.
784 */ 784 */
785 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, 785 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &bp, 0, iget_flags);
786 XBF_LOCK, iget_flags);
787 if (error) 786 if (error)
788 return error; 787 return error;
789 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset); 788 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
@@ -1342,7 +1341,7 @@ xfs_iunlink(
1342 * Here we put the head pointer into our next pointer, 1341 * Here we put the head pointer into our next pointer,
1343 * and then we fall through to point the head at us. 1342 * and then we fall through to point the head at us.
1344 */ 1343 */
1345 error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); 1344 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
1346 if (error) 1345 if (error)
1347 return error; 1346 return error;
1348 1347
@@ -1423,7 +1422,7 @@ xfs_iunlink_remove(
1423 * of dealing with the buffer when there is no need to 1422 * of dealing with the buffer when there is no need to
1424 * change it. 1423 * change it.
1425 */ 1424 */
1426 error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); 1425 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
1427 if (error) { 1426 if (error) {
1428 xfs_warn(mp, "%s: xfs_itobp() returned error %d.", 1427 xfs_warn(mp, "%s: xfs_itobp() returned error %d.",
1429 __func__, error); 1428 __func__, error);
@@ -1484,7 +1483,7 @@ xfs_iunlink_remove(
1484 * Now last_ibp points to the buffer previous to us on 1483 * Now last_ibp points to the buffer previous to us on
1485 * the unlinked list. Pull us from the list. 1484 * the unlinked list. Pull us from the list.
1486 */ 1485 */
1487 error = xfs_itobp(mp, tp, ip, &dip, &ibp, XBF_LOCK); 1486 error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
1488 if (error) { 1487 if (error) {
1489 xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.", 1488 xfs_warn(mp, "%s: xfs_itobp(2) returned error %d.",
1490 __func__, error); 1489 __func__, error);
@@ -1566,8 +1565,7 @@ xfs_ifree_cluster(
1566 * to mark all the active inodes on the buffer stale. 1565 * to mark all the active inodes on the buffer stale.
1567 */ 1566 */
1568 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, 1567 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
1569 mp->m_bsize * blks_per_cluster, 1568 mp->m_bsize * blks_per_cluster, 0);
1570 XBF_LOCK);
1571 1569
1572 if (!bp) 1570 if (!bp)
1573 return ENOMEM; 1571 return ENOMEM;
@@ -1737,7 +1735,7 @@ xfs_ifree(
1737 1735
1738 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); 1736 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1739 1737
1740 error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, XBF_LOCK); 1738 error = xfs_itobp(ip->i_mount, tp, ip, &dip, &ibp, 0);
1741 if (error) 1739 if (error)
1742 return error; 1740 return error;
1743 1741
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 8c826b00aac1..0d9bdb6bace4 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2131,7 +2131,7 @@ xlog_recover_buffer_pass2(
2131 2131
2132 trace_xfs_log_recover_buf_recover(log, buf_f); 2132 trace_xfs_log_recover_buf_recover(log, buf_f);
2133 2133
2134 buf_flags = XBF_LOCK; 2134 buf_flags = 0;
2135 if (!(buf_f->blf_flags & XFS_BLF_INODE_BUF)) 2135 if (!(buf_f->blf_flags & XFS_BLF_INODE_BUF))
2136 buf_flags |= XBF_MAPPED; 2136 buf_flags |= XBF_MAPPED;
2137 2137
@@ -2229,8 +2229,7 @@ xlog_recover_inode_pass2(
2229 } 2229 }
2230 trace_xfs_log_recover_inode_recover(log, in_f); 2230 trace_xfs_log_recover_inode_recover(log, in_f);
2231 2231
2232 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 2232 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len, 0);
2233 XBF_LOCK);
2234 if (!bp) { 2233 if (!bp) {
2235 error = ENOMEM; 2234 error = ENOMEM;
2236 goto error; 2235 goto error;
@@ -3103,7 +3102,7 @@ xlog_recover_process_one_iunlink(
3103 /* 3102 /*
3104 * Get the on disk inode to find the next inode in the bucket. 3103 * Get the on disk inode to find the next inode in the bucket.
3105 */ 3104 */
3106 error = xfs_itobp(mp, NULL, ip, &dip, &ibp, XBF_LOCK); 3105 error = xfs_itobp(mp, NULL, ip, &dip, &ibp, 0);
3107 if (error) 3106 if (error)
3108 goto fail_iput; 3107 goto fail_iput;
3109 3108
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index 597d044a09a1..2ce97758f4c7 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -114,7 +114,7 @@ xfs_read_buf(
114 int error; 114 int error;
115 115
116 if (!flags) 116 if (!flags)
117 flags = XBF_LOCK | XBF_MAPPED; 117 flags = XBF_MAPPED;
118 118
119 bp = xfs_buf_read(target, blkno, len, flags); 119 bp = xfs_buf_read(target, blkno, len, flags);
120 if (!bp) 120 if (!bp)
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 2ec196b6c079..f9cb7ee04dae 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -142,7 +142,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
142 xfs_buf_log_item_t *bip; 142 xfs_buf_log_item_t *bip;
143 143
144 if (flags == 0) 144 if (flags == 0)
145 flags = XBF_LOCK | XBF_MAPPED; 145 flags = XBF_MAPPED;
146 146
147 /* 147 /*
148 * Default to a normal get_buf() call if the tp is NULL. 148 * Default to a normal get_buf() call if the tp is NULL.
@@ -275,7 +275,7 @@ xfs_trans_read_buf(
275 int error; 275 int error;
276 276
277 if (flags == 0) 277 if (flags == 0)
278 flags = XBF_LOCK | XBF_MAPPED; 278 flags = XBF_MAPPED;
279 279
280 /* 280 /*
281 * Default to a normal get_buf() call if the tp is NULL. 281 * Default to a normal get_buf() call if the tp is NULL.
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 445c224742b8..8f99c7781f39 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -82,7 +82,7 @@ xfs_readlink_bmap(
82 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 82 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
83 83
84 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 84 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt),
85 XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK); 85 XBF_MAPPED | XBF_DONT_BLOCK);
86 if (!bp) 86 if (!bp)
87 return XFS_ERROR(ENOMEM); 87 return XFS_ERROR(ENOMEM);
88 error = bp->b_error; 88 error = bp->b_error;