aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2009-11-24 13:02:23 -0500
committerAlex Elder <aelder@sgi.com>2009-12-11 16:11:21 -0500
commit6ad112bfb5af537e9e3103c807748bb4a99bbd9e (patch)
tree783d7ea24d916914914287f696c1a957e495bd59 /fs
parentc355c656fede21f6e967816a603905f0ad6a7311 (diff)
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c8
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.h9
-rw-r--r--fs/xfs/xfs_attr.c4
-rw-r--r--fs/xfs/xfs_fsops.c23
-rw-r--r--fs/xfs/xfs_log_recover.c16
-rw-r--r--fs/xfs/xfs_mount.c8
-rw-r--r--fs/xfs/xfs_rw.c8
-rw-r--r--fs/xfs/xfs_trans_buf.c13
-rw-r--r--fs/xfs/xfs_vnodeops.c5
9 files changed, 44 insertions, 50 deletions
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 965df1227d64..811237480734 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -582,7 +582,7 @@ found:
582 * although backing storage may not be. 582 * although backing storage may not be.
583 */ 583 */
584xfs_buf_t * 584xfs_buf_t *
585xfs_buf_get_flags( 585xfs_buf_get(
586 xfs_buftarg_t *target,/* target for buffer */ 586 xfs_buftarg_t *target,/* target for buffer */
587 xfs_off_t ioff, /* starting offset of range */ 587 xfs_off_t ioff, /* starting offset of range */
588 size_t isize, /* length of range */ 588 size_t isize, /* length of range */
@@ -661,7 +661,7 @@ _xfs_buf_read(
661} 661}
662 662
663xfs_buf_t * 663xfs_buf_t *
664xfs_buf_read_flags( 664xfs_buf_read(
665 xfs_buftarg_t *target, 665 xfs_buftarg_t *target,
666 xfs_off_t ioff, 666 xfs_off_t ioff,
667 size_t isize, 667 size_t isize,
@@ -671,7 +671,7 @@ xfs_buf_read_flags(
671 671
672 flags |= XBF_READ; 672 flags |= XBF_READ;
673 673
674 bp = xfs_buf_get_flags(target, ioff, isize, flags); 674 bp = xfs_buf_get(target, ioff, isize, flags);
675 if (bp) { 675 if (bp) {
676 if (!XFS_BUF_ISDONE(bp)) { 676 if (!XFS_BUF_ISDONE(bp)) {
677 XB_TRACE(bp, "read", (unsigned long)flags); 677 XB_TRACE(bp, "read", (unsigned long)flags);
@@ -718,7 +718,7 @@ xfs_buf_readahead(
718 return; 718 return;
719 719
720 flags |= (XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD); 720 flags |= (XBF_TRYLOCK|XBF_ASYNC|XBF_READ_AHEAD);
721 xfs_buf_read_flags(target, ioff, isize, flags); 721 xfs_buf_read(target, ioff, isize, flags);
722} 722}
723 723
724xfs_buf_t * 724xfs_buf_t *
diff --git a/fs/xfs/linux-2.6/xfs_buf.h b/fs/xfs/linux-2.6/xfs_buf.h
index 9b4d666ad31f..5f07dd91c5fa 100644
--- a/fs/xfs/linux-2.6/xfs_buf.h
+++ b/fs/xfs/linux-2.6/xfs_buf.h
@@ -186,15 +186,10 @@ extern xfs_buf_t *_xfs_buf_find(xfs_buftarg_t *, xfs_off_t, size_t,
186#define xfs_incore(buftarg,blkno,len,lockit) \ 186#define xfs_incore(buftarg,blkno,len,lockit) \
187 _xfs_buf_find(buftarg, blkno ,len, lockit, NULL) 187 _xfs_buf_find(buftarg, blkno ,len, lockit, NULL)
188 188
189extern xfs_buf_t *xfs_buf_get_flags(xfs_buftarg_t *, xfs_off_t, size_t, 189extern xfs_buf_t *xfs_buf_get(xfs_buftarg_t *, xfs_off_t, size_t,
190 xfs_buf_flags_t); 190 xfs_buf_flags_t);
191#define xfs_buf_get(target, blkno, len, flags) \ 191extern xfs_buf_t *xfs_buf_read(xfs_buftarg_t *, xfs_off_t, size_t,
192 xfs_buf_get_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
193
194extern xfs_buf_t *xfs_buf_read_flags(xfs_buftarg_t *, xfs_off_t, size_t,
195 xfs_buf_flags_t); 192 xfs_buf_flags_t);
196#define xfs_buf_read(target, blkno, len, flags) \
197 xfs_buf_read_flags((target), (blkno), (len), XBF_LOCK | XBF_MAPPED)
198 193
199extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *); 194extern xfs_buf_t *xfs_buf_get_empty(size_t, xfs_buftarg_t *);
200extern xfs_buf_t *xfs_buf_get_noaddr(size_t, xfs_buftarg_t *); 195extern xfs_buf_t *xfs_buf_get_noaddr(size_t, xfs_buftarg_t *);
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 4ece1906bd41..57825fe63cc5 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -2143,8 +2143,8 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2143 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock), 2143 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
2144 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount); 2144 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
2145 2145
2146 bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno, blkcnt, 2146 bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
2147 XFS_BUF_LOCK | XBF_DONT_BLOCK); 2147 XFS_BUF_LOCK | XBF_DONT_BLOCK);
2148 ASSERT(bp); 2148 ASSERT(bp);
2149 ASSERT(!XFS_BUF_GETERROR(bp)); 2149 ASSERT(!XFS_BUF_GETERROR(bp));
2150 2150
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 6f83f58c099f..36079aa91344 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -201,8 +201,8 @@ xfs_growfs_data_private(
201 * AG freelist header block 201 * AG freelist header block
202 */ 202 */
203 bp = xfs_buf_get(mp->m_ddev_targp, 203 bp = xfs_buf_get(mp->m_ddev_targp,
204 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), 204 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
205 XFS_FSS_TO_BB(mp, 1), 0); 205 XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED);
206 agf = XFS_BUF_TO_AGF(bp); 206 agf = XFS_BUF_TO_AGF(bp);
207 memset(agf, 0, mp->m_sb.sb_sectsize); 207 memset(agf, 0, mp->m_sb.sb_sectsize);
208 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); 208 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
@@ -233,8 +233,8 @@ xfs_growfs_data_private(
233 * AG inode header block 233 * AG inode header block
234 */ 234 */
235 bp = xfs_buf_get(mp->m_ddev_targp, 235 bp = xfs_buf_get(mp->m_ddev_targp,
236 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), 236 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
237 XFS_FSS_TO_BB(mp, 1), 0); 237 XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED);
238 agi = XFS_BUF_TO_AGI(bp); 238 agi = XFS_BUF_TO_AGI(bp);
239 memset(agi, 0, mp->m_sb.sb_sectsize); 239 memset(agi, 0, mp->m_sb.sb_sectsize);
240 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); 240 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
@@ -257,8 +257,9 @@ xfs_growfs_data_private(
257 * BNO btree root block 257 * BNO btree root block
258 */ 258 */
259 bp = xfs_buf_get(mp->m_ddev_targp, 259 bp = xfs_buf_get(mp->m_ddev_targp,
260 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), 260 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
261 BTOBB(mp->m_sb.sb_blocksize), 0); 261 BTOBB(mp->m_sb.sb_blocksize),
262 XBF_LOCK | XBF_MAPPED);
262 block = XFS_BUF_TO_BLOCK(bp); 263 block = XFS_BUF_TO_BLOCK(bp);
263 memset(block, 0, mp->m_sb.sb_blocksize); 264 memset(block, 0, mp->m_sb.sb_blocksize);
264 block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); 265 block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC);
@@ -278,8 +279,9 @@ xfs_growfs_data_private(
278 * CNT btree root block 279 * CNT btree root block
279 */ 280 */
280 bp = xfs_buf_get(mp->m_ddev_targp, 281 bp = xfs_buf_get(mp->m_ddev_targp,
281 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), 282 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
282 BTOBB(mp->m_sb.sb_blocksize), 0); 283 BTOBB(mp->m_sb.sb_blocksize),
284 XBF_LOCK | XBF_MAPPED);
283 block = XFS_BUF_TO_BLOCK(bp); 285 block = XFS_BUF_TO_BLOCK(bp);
284 memset(block, 0, mp->m_sb.sb_blocksize); 286 memset(block, 0, mp->m_sb.sb_blocksize);
285 block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); 287 block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC);
@@ -300,8 +302,9 @@ xfs_growfs_data_private(
300 * INO btree root block 302 * INO btree root block
301 */ 303 */
302 bp = xfs_buf_get(mp->m_ddev_targp, 304 bp = xfs_buf_get(mp->m_ddev_targp,
303 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), 305 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
304 BTOBB(mp->m_sb.sb_blocksize), 0); 306 BTOBB(mp->m_sb.sb_blocksize),
307 XBF_LOCK | XBF_MAPPED);
305 block = XFS_BUF_TO_BLOCK(bp); 308 block = XFS_BUF_TO_BLOCK(bp);
306 memset(block, 0, mp->m_sb.sb_blocksize); 309 memset(block, 0, mp->m_sb.sb_blocksize);
307 block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); 310 block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index b5b0d8055910..1ec98ed914d4 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2206,6 +2206,7 @@ xlog_recover_do_buffer_trans(
2206 xfs_daddr_t blkno; 2206 xfs_daddr_t blkno;
2207 int len; 2207 int len;
2208 ushort flags; 2208 ushort flags;
2209 uint buf_flags;
2209 2210
2210 buf_f = (xfs_buf_log_format_t *)item->ri_buf[0].i_addr; 2211 buf_f = (xfs_buf_log_format_t *)item->ri_buf[0].i_addr;
2211 2212
@@ -2246,12 +2247,11 @@ xlog_recover_do_buffer_trans(
2246 } 2247 }
2247 2248
2248 mp = log->l_mp; 2249 mp = log->l_mp;
2249 if (flags & XFS_BLI_INODE_BUF) { 2250 buf_flags = XFS_BUF_LOCK;
2250 bp = xfs_buf_read_flags(mp->m_ddev_targp, blkno, len, 2251 if (!(flags & XFS_BLI_INODE_BUF))
2251 XFS_BUF_LOCK); 2252 buf_flags |= XFS_BUF_MAPPED;
2252 } else { 2253
2253 bp = xfs_buf_read(mp->m_ddev_targp, blkno, len, 0); 2254 bp = xfs_buf_read(mp->m_ddev_targp, blkno, len, buf_flags);
2254 }
2255 if (XFS_BUF_ISERROR(bp)) { 2255 if (XFS_BUF_ISERROR(bp)) {
2256 xfs_ioerror_alert("xlog_recover_do..(read#1)", log->l_mp, 2256 xfs_ioerror_alert("xlog_recover_do..(read#1)", log->l_mp,
2257 bp, blkno); 2257 bp, blkno);
@@ -2350,8 +2350,8 @@ xlog_recover_do_inode_trans(
2350 goto error; 2350 goto error;
2351 } 2351 }
2352 2352
2353 bp = xfs_buf_read_flags(mp->m_ddev_targp, in_f->ilf_blkno, 2353 bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
2354 in_f->ilf_len, XFS_BUF_LOCK); 2354 XFS_BUF_LOCK);
2355 if (XFS_BUF_ISERROR(bp)) { 2355 if (XFS_BUF_ISERROR(bp)) {
2356 xfs_ioerror_alert("xlog_recover_do..(read#2)", mp, 2356 xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
2357 bp, in_f->ilf_blkno); 2357 bp, in_f->ilf_blkno);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 4d509f742bd2..7b14f0a0a5d8 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -583,8 +583,8 @@ xfs_readsb(xfs_mount_t *mp, int flags)
583 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp); 583 sector_size = xfs_getsize_buftarg(mp->m_ddev_targp);
584 extra_flags = XFS_BUF_LOCK | XFS_BUF_MANAGE | XFS_BUF_MAPPED; 584 extra_flags = XFS_BUF_LOCK | XFS_BUF_MANAGE | XFS_BUF_MAPPED;
585 585
586 bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR, 586 bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR, BTOBB(sector_size),
587 BTOBB(sector_size), extra_flags); 587 extra_flags);
588 if (!bp || XFS_BUF_ISERROR(bp)) { 588 if (!bp || XFS_BUF_ISERROR(bp)) {
589 xfs_fs_mount_cmn_err(flags, "SB read failed"); 589 xfs_fs_mount_cmn_err(flags, "SB read failed");
590 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM; 590 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
@@ -624,8 +624,8 @@ xfs_readsb(xfs_mount_t *mp, int flags)
624 XFS_BUF_UNMANAGE(bp); 624 XFS_BUF_UNMANAGE(bp);
625 xfs_buf_relse(bp); 625 xfs_buf_relse(bp);
626 sector_size = mp->m_sb.sb_sectsize; 626 sector_size = mp->m_sb.sb_sectsize;
627 bp = xfs_buf_read_flags(mp->m_ddev_targp, XFS_SB_DADDR, 627 bp = xfs_buf_read(mp->m_ddev_targp, XFS_SB_DADDR,
628 BTOBB(sector_size), extra_flags); 628 BTOBB(sector_size), extra_flags);
629 if (!bp || XFS_BUF_ISERROR(bp)) { 629 if (!bp || XFS_BUF_ISERROR(bp)) {
630 xfs_fs_mount_cmn_err(flags, "SB re-read failed"); 630 xfs_fs_mount_cmn_err(flags, "SB re-read failed");
631 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM; 631 error = bp ? XFS_BUF_GETERROR(bp) : ENOMEM;
diff --git a/fs/xfs/xfs_rw.c b/fs/xfs/xfs_rw.c
index 3f816ad7ff19..6fa10897d417 100644
--- a/fs/xfs/xfs_rw.c
+++ b/fs/xfs/xfs_rw.c
@@ -277,10 +277,10 @@ xfs_read_buf(
277 xfs_buf_t *bp; 277 xfs_buf_t *bp;
278 int error; 278 int error;
279 279
280 if (flags) 280 if (!flags)
281 bp = xfs_buf_read_flags(target, blkno, len, flags); 281 flags = XBF_LOCK | XBF_MAPPED;
282 else 282
283 bp = xfs_buf_read(target, blkno, len, flags); 283 bp = xfs_buf_read(target, blkno, len, flags);
284 if (!bp) 284 if (!bp)
285 return XFS_ERROR(EIO); 285 return XFS_ERROR(EIO);
286 error = XFS_BUF_GETERROR(bp); 286 error = XFS_BUF_GETERROR(bp);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index 218829e6a152..03a1f701fea8 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -79,11 +79,8 @@ xfs_trans_get_buf(xfs_trans_t *tp,
79 /* 79 /*
80 * Default to a normal get_buf() call if the tp is NULL. 80 * Default to a normal get_buf() call if the tp is NULL.
81 */ 81 */
82 if (tp == NULL) { 82 if (tp == NULL)
83 bp = xfs_buf_get_flags(target_dev, blkno, len, 83 return xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
84 flags | BUF_BUSY);
85 return(bp);
86 }
87 84
88 /* 85 /*
89 * If we find the buffer in the cache with this transaction 86 * If we find the buffer in the cache with this transaction
@@ -129,7 +126,7 @@ xfs_trans_get_buf(xfs_trans_t *tp,
129 * easily deadlock with our current transaction as well as cause 126 * easily deadlock with our current transaction as well as cause
130 * us to run out of stack space. 127 * us to run out of stack space.
131 */ 128 */
132 bp = xfs_buf_get_flags(target_dev, blkno, len, flags | BUF_BUSY); 129 bp = xfs_buf_get(target_dev, blkno, len, flags | BUF_BUSY);
133 if (bp == NULL) { 130 if (bp == NULL) {
134 return NULL; 131 return NULL;
135 } 132 }
@@ -302,7 +299,7 @@ xfs_trans_read_buf(
302 * Default to a normal get_buf() call if the tp is NULL. 299 * Default to a normal get_buf() call if the tp is NULL.
303 */ 300 */
304 if (tp == NULL) { 301 if (tp == NULL) {
305 bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); 302 bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
306 if (!bp) 303 if (!bp)
307 return (flags & XFS_BUF_TRYLOCK) ? 304 return (flags & XFS_BUF_TRYLOCK) ?
308 EAGAIN : XFS_ERROR(ENOMEM); 305 EAGAIN : XFS_ERROR(ENOMEM);
@@ -398,7 +395,7 @@ xfs_trans_read_buf(
398 * easily deadlock with our current transaction as well as cause 395 * easily deadlock with our current transaction as well as cause
399 * us to run out of stack space. 396 * us to run out of stack space.
400 */ 397 */
401 bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY); 398 bp = xfs_buf_read(target, blkno, len, flags | BUF_BUSY);
402 if (bp == NULL) { 399 if (bp == NULL) {
403 *bpp = NULL; 400 *bpp = NULL;
404 return 0; 401 return 0;
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index d98401470cf0..578f3f59b789 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -538,9 +538,8 @@ xfs_readlink_bmap(
538 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); 538 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
539 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 539 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
540 540
541 bp = xfs_buf_read_flags(mp->m_ddev_targp, d, BTOBB(byte_cnt), 541 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt),
542 XBF_LOCK | XBF_MAPPED | 542 XBF_LOCK | XBF_MAPPED | XBF_DONT_BLOCK);
543 XBF_DONT_BLOCK);
544 error = XFS_BUF_GETERROR(bp); 543 error = XFS_BUF_GETERROR(bp);
545 if (error) { 544 if (error) {
546 xfs_ioerror_alert("xfs_readlink", 545 xfs_ioerror_alert("xfs_readlink",