aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2011-09-18 16:40:45 -0400
committerAlex Elder <aelder@sgi.com>2011-10-11 22:15:03 -0400
commit5c8ed2021ff291f5e399a9b43c4f699b2fc58fbb (patch)
tree36d8375935324279fb27e50daa7fc6873ff68cea /fs
parentaef9a89586fc8475bf0333b8736d5aa8aa6f4897 (diff)
xfs: introduce xfs_bmapi_read()
xfs_bmapi() currently handles both extent map reading and allocation. As a result, the code is littered with "if (wr)" branches to conditionally do allocation operations if required. This makes the code much harder to follow and causes significant indent issues with the code. Given that read mapping is much simpler than allocation, we can split out read mapping from xfs_bmapi() and reuse the logic that we have already factored out do do all the hard work of handling the extent map manipulations. The results in a much simpler function for the common extent read operations, and will allow the allocation code to be simplified in another commit. Once xfs_bmapi_read() is implemented, convert all the callers of xfs_bmapi() that are only reading extents to use the new function. Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Alex Elder <aelder@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_aops.c8
-rw-r--r--fs/xfs/xfs_attr.c30
-rw-r--r--fs/xfs/xfs_attr_leaf.c5
-rw-r--r--fs/xfs/xfs_bmap.c104
-rw-r--r--fs/xfs/xfs_bmap.h4
-rw-r--r--fs/xfs/xfs_da_btree.c9
-rw-r--r--fs/xfs/xfs_dir2_leaf.c6
-rw-r--r--fs/xfs/xfs_dquot.c5
-rw-r--r--fs/xfs/xfs_file.c10
-rw-r--r--fs/xfs/xfs_inode.c12
-rw-r--r--fs/xfs/xfs_iomap.c4
-rw-r--r--fs/xfs/xfs_qm.c7
-rw-r--r--fs/xfs/xfs_vnodeops.c24
13 files changed, 151 insertions, 77 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 22aadf667862..11b2aad982d4 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -315,8 +315,8 @@ xfs_map_blocks(
315 count = mp->m_maxioffset - offset; 315 count = mp->m_maxioffset - offset;
316 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count); 316 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
317 offset_fsb = XFS_B_TO_FSBT(mp, offset); 317 offset_fsb = XFS_B_TO_FSBT(mp, offset);
318 error = xfs_bmapi(NULL, ip, offset_fsb, end_fsb - offset_fsb, 318 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
319 bmapi_flags, NULL, 0, imap, &nimaps, NULL); 319 imap, &nimaps, bmapi_flags);
320 xfs_iunlock(ip, XFS_ILOCK_SHARED); 320 xfs_iunlock(ip, XFS_ILOCK_SHARED);
321 321
322 if (error) 322 if (error)
@@ -1138,8 +1138,8 @@ __xfs_get_blocks(
1138 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size); 1138 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + size);
1139 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1139 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1140 1140
1141 error = xfs_bmapi(NULL, ip, offset_fsb, end_fsb - offset_fsb, 1141 error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb,
1142 XFS_BMAPI_ENTIRE, NULL, 0, &imap, &nimaps, NULL); 1142 &imap, &nimaps, XFS_BMAPI_ENTIRE);
1143 if (error) 1143 if (error)
1144 goto out_unlock; 1144 goto out_unlock;
1145 1145
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index c7dab0c0bdda..41ef02b7185a 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1963,10 +1963,9 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
1963 lblkno = args->rmtblkno; 1963 lblkno = args->rmtblkno;
1964 while (valuelen > 0) { 1964 while (valuelen > 0) {
1965 nmap = ATTR_RMTVALUE_MAPSIZE; 1965 nmap = ATTR_RMTVALUE_MAPSIZE;
1966 error = xfs_bmapi(args->trans, args->dp, (xfs_fileoff_t)lblkno, 1966 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
1967 args->rmtblkcnt, 1967 args->rmtblkcnt, map, &nmap,
1968 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 1968 XFS_BMAPI_ATTRFORK);
1969 NULL, 0, map, &nmap, NULL);
1970 if (error) 1969 if (error)
1971 return(error); 1970 return(error);
1972 ASSERT(nmap >= 1); 1971 ASSERT(nmap >= 1);
@@ -2092,14 +2091,11 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2092 */ 2091 */
2093 xfs_bmap_init(args->flist, args->firstblock); 2092 xfs_bmap_init(args->flist, args->firstblock);
2094 nmap = 1; 2093 nmap = 1;
2095 error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno, 2094 error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
2096 args->rmtblkcnt, 2095 args->rmtblkcnt, &map, &nmap,
2097 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2096 XFS_BMAPI_ATTRFORK);
2098 args->firstblock, 0, &map, &nmap, 2097 if (error)
2099 NULL);
2100 if (error) {
2101 return(error); 2098 return(error);
2102 }
2103 ASSERT(nmap == 1); 2099 ASSERT(nmap == 1);
2104 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 2100 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2105 (map.br_startblock != HOLESTARTBLOCK)); 2101 (map.br_startblock != HOLESTARTBLOCK));
@@ -2155,16 +2151,12 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
2155 /* 2151 /*
2156 * Try to remember where we decided to put the value. 2152 * Try to remember where we decided to put the value.
2157 */ 2153 */
2158 xfs_bmap_init(args->flist, args->firstblock);
2159 nmap = 1; 2154 nmap = 1;
2160 error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno, 2155 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno,
2161 args->rmtblkcnt, 2156 args->rmtblkcnt, &map, &nmap,
2162 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2157 XFS_BMAPI_ATTRFORK);
2163 args->firstblock, 0, &map, &nmap, 2158 if (error)
2164 args->flist);
2165 if (error) {
2166 return(error); 2159 return(error);
2167 }
2168 ASSERT(nmap == 1); 2160 ASSERT(nmap == 1);
2169 ASSERT((map.br_startblock != DELAYSTARTBLOCK) && 2161 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2170 (map.br_startblock != HOLESTARTBLOCK)); 2162 (map.br_startblock != HOLESTARTBLOCK));
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 58c3add07b65..d4906e7c9787 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -2926,9 +2926,8 @@ xfs_attr_leaf_freextent(xfs_trans_t **trans, xfs_inode_t *dp,
2926 * Try to remember where we decided to put the value. 2926 * Try to remember where we decided to put the value.
2927 */ 2927 */
2928 nmap = 1; 2928 nmap = 1;
2929 error = xfs_bmapi(*trans, dp, (xfs_fileoff_t)tblkno, tblkcnt, 2929 error = xfs_bmapi_read(dp, (xfs_fileoff_t)tblkno, tblkcnt,
2930 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA, 2930 &map, &nmap, XFS_BMAPI_ATTRFORK);
2931 NULL, 0, &map, &nmap, NULL);
2932 if (error) { 2931 if (error) {
2933 return(error); 2932 return(error);
2934 } 2933 }
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 59f63949d3bc..fc5acf0b921e 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -4350,6 +4350,98 @@ xfs_bmapi_update_map(
4350} 4350}
4351 4351
4352/* 4352/*
4353 * Map file blocks to filesystem blocks without allocation.
4354 */
4355int
4356xfs_bmapi_read(
4357 struct xfs_inode *ip,
4358 xfs_fileoff_t bno,
4359 xfs_filblks_t len,
4360 struct xfs_bmbt_irec *mval,
4361 int *nmap,
4362 int flags)
4363{
4364 struct xfs_mount *mp = ip->i_mount;
4365 struct xfs_ifork *ifp;
4366 struct xfs_bmbt_irec got;
4367 struct xfs_bmbt_irec prev;
4368 xfs_fileoff_t obno;
4369 xfs_fileoff_t end;
4370 xfs_extnum_t lastx;
4371 int error;
4372 int eof;
4373 int n = 0;
4374 int whichfork = (flags & XFS_BMAPI_ATTRFORK) ?
4375 XFS_ATTR_FORK : XFS_DATA_FORK;
4376
4377 ASSERT(*nmap >= 1);
4378 ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK|XFS_BMAPI_ENTIRE|
4379 XFS_BMAPI_IGSTATE)));
4380
4381 if (unlikely(XFS_TEST_ERROR(
4382 (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
4383 XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
4384 mp, XFS_ERRTAG_BMAPIFORMAT, XFS_RANDOM_BMAPIFORMAT))) {
4385 XFS_ERROR_REPORT("xfs_bmapi_read", XFS_ERRLEVEL_LOW, mp);
4386 return XFS_ERROR(EFSCORRUPTED);
4387 }
4388
4389 if (XFS_FORCED_SHUTDOWN(mp))
4390 return XFS_ERROR(EIO);
4391
4392 XFS_STATS_INC(xs_blk_mapr);
4393
4394 ifp = XFS_IFORK_PTR(ip, whichfork);
4395 ASSERT(ifp->if_ext_max ==
4396 XFS_IFORK_SIZE(ip, whichfork) / (uint)sizeof(xfs_bmbt_rec_t));
4397
4398 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
4399 error = xfs_iread_extents(NULL, ip, whichfork);
4400 if (error)
4401 return error;
4402 }
4403
4404 xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got, &prev);
4405 end = bno + len;
4406 obno = bno;
4407
4408 while (bno < end && n < *nmap) {
4409 /* Reading past eof, act as though there's a hole up to end. */
4410 if (eof)
4411 got.br_startoff = end;
4412 if (got.br_startoff > bno) {
4413 /* Reading in a hole. */
4414 mval->br_startoff = bno;
4415 mval->br_startblock = HOLESTARTBLOCK;
4416 mval->br_blockcount =
4417 XFS_FILBLKS_MIN(len, got.br_startoff - bno);
4418 mval->br_state = XFS_EXT_NORM;
4419 bno += mval->br_blockcount;
4420 len -= mval->br_blockcount;
4421 mval++;
4422 n++;
4423 continue;
4424 }
4425
4426 /* set up the extent map to return. */
4427 xfs_bmapi_trim_map(mval, &got, &bno, len, obno, end, n, flags);
4428 xfs_bmapi_update_map(&mval, &bno, &len, obno, end, &n, flags);
4429
4430 /* If we're done, stop now. */
4431 if (bno >= end || n >= *nmap)
4432 break;
4433
4434 /* Else go on to the next record. */
4435 if (++lastx < ifp->if_bytes / sizeof(xfs_bmbt_rec_t))
4436 xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
4437 else
4438 eof = 1;
4439 }
4440 *nmap = n;
4441 return 0;
4442}
4443
4444/*
4353 * Map file blocks to filesystem blocks. 4445 * Map file blocks to filesystem blocks.
4354 * File range is given by the bno/len pair. 4446 * File range is given by the bno/len pair.
4355 * Adds blocks to file if a write ("flags & XFS_BMAPI_WRITE" set) 4447 * Adds blocks to file if a write ("flags & XFS_BMAPI_WRITE" set)
@@ -5490,10 +5582,9 @@ xfs_getbmap(
5490 5582
5491 do { 5583 do {
5492 nmap = (nexleft > subnex) ? subnex : nexleft; 5584 nmap = (nexleft > subnex) ? subnex : nexleft;
5493 error = xfs_bmapi(NULL, ip, XFS_BB_TO_FSBT(mp, bmv->bmv_offset), 5585 error = xfs_bmapi_read(ip, XFS_BB_TO_FSBT(mp, bmv->bmv_offset),
5494 XFS_BB_TO_FSB(mp, bmv->bmv_length), 5586 XFS_BB_TO_FSB(mp, bmv->bmv_length),
5495 bmapi_flags, NULL, 0, map, &nmap, 5587 map, &nmap, bmapi_flags);
5496 NULL);
5497 if (error) 5588 if (error)
5498 goto out_free_map; 5589 goto out_free_map;
5499 ASSERT(nmap <= subnex); 5590 ASSERT(nmap <= subnex);
@@ -6084,9 +6175,8 @@ xfs_bmap_punch_delalloc_range(
6084 * trying to remove a real extent (which requires a 6175 * trying to remove a real extent (which requires a
6085 * transaction) or a hole, which is probably a bad idea... 6176 * transaction) or a hole, which is probably a bad idea...
6086 */ 6177 */
6087 error = xfs_bmapi(NULL, ip, start_fsb, 1, 6178 error = xfs_bmapi_read(ip, start_fsb, 1, &imap, &nimaps,
6088 XFS_BMAPI_ENTIRE, NULL, 0, &imap, 6179 XFS_BMAPI_ENTIRE);
6089 &nimaps, NULL);
6090 6180
6091 if (error) { 6181 if (error) {
6092 /* something screwed, just bail */ 6182 /* something screwed, just bail */
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index c62234bde053..16257c6eba71 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -294,6 +294,10 @@ xfs_bmapi(
294 int *nmap, /* i/o: mval size/count */ 294 int *nmap, /* i/o: mval size/count */
295 xfs_bmap_free_t *flist); /* i/o: list extents to free */ 295 xfs_bmap_free_t *flist); /* i/o: list extents to free */
296 296
297int xfs_bmapi_read(struct xfs_inode *ip, xfs_fileoff_t bno,
298 xfs_filblks_t len, struct xfs_bmbt_irec *mval,
299 int *nmap, int flags);
300
297/* 301/*
298 * Map file blocks to filesystem blocks, simple version. 302 * Map file blocks to filesystem blocks, simple version.
299 * One block only, read-only. 303 * One block only, read-only.
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index ee9d5427fcd4..44dfa39099ef 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -1995,11 +1995,10 @@ xfs_da_do_buf(
1995 } else { 1995 } else {
1996 mapp = kmem_alloc(sizeof(*mapp) * nfsb, KM_SLEEP); 1996 mapp = kmem_alloc(sizeof(*mapp) * nfsb, KM_SLEEP);
1997 nmap = nfsb; 1997 nmap = nfsb;
1998 if ((error = xfs_bmapi(trans, dp, (xfs_fileoff_t)bno, 1998 error = xfs_bmapi_read(dp, (xfs_fileoff_t)bno, nfsb,
1999 nfsb, 1999 mapp, &nmap,
2000 XFS_BMAPI_METADATA | 2000 xfs_bmapi_aflag(whichfork));
2001 xfs_bmapi_aflag(whichfork), 2001 if (error)
2002 NULL, 0, mapp, &nmap, NULL)))
2003 goto exit0; 2002 goto exit0;
2004 } 2003 }
2005 } else { 2004 } else {
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index ca2386d82cdf..66e108f561a3 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -888,12 +888,10 @@ xfs_dir2_leaf_getdents(
888 * we already have in the table. 888 * we already have in the table.
889 */ 889 */
890 nmap = map_size - map_valid; 890 nmap = map_size - map_valid;
891 error = xfs_bmapi(NULL, dp, 891 error = xfs_bmapi_read(dp, map_off,
892 map_off,
893 xfs_dir2_byte_to_da(mp, 892 xfs_dir2_byte_to_da(mp,
894 XFS_DIR2_LEAF_OFFSET) - map_off, 893 XFS_DIR2_LEAF_OFFSET) - map_off,
895 XFS_BMAPI_METADATA, NULL, 0, 894 &map[map_valid], &nmap, 0);
896 &map[map_valid], &nmap, NULL);
897 /* 895 /*
898 * Don't know if we should ignore this or 896 * Don't know if we should ignore this or
899 * try to return an error. 897 * try to return an error.
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 0c5fe66ce92b..c377961657ee 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -488,9 +488,8 @@ xfs_qm_dqtobp(
488 /* 488 /*
489 * Find the block map; no allocations yet 489 * Find the block map; no allocations yet
490 */ 490 */
491 error = xfs_bmapi(NULL, quotip, dqp->q_fileoffset, 491 error = xfs_bmapi_read(quotip, dqp->q_fileoffset,
492 XFS_DQUOT_CLUSTER_SIZE_FSB, XFS_BMAPI_METADATA, 492 XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);
493 NULL, 0, &map, &nmaps, NULL);
494 493
495 xfs_iunlock(quotip, XFS_ILOCK_SHARED); 494 xfs_iunlock(quotip, XFS_ILOCK_SHARED);
496 if (error) 495 if (error)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 06fe97e56e48..558543c146b3 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -509,11 +509,9 @@ xfs_zero_last_block(
509 509
510 last_fsb = XFS_B_TO_FSBT(mp, isize); 510 last_fsb = XFS_B_TO_FSBT(mp, isize);
511 nimaps = 1; 511 nimaps = 1;
512 error = xfs_bmapi(NULL, ip, last_fsb, 1, 0, NULL, 0, &imap, 512 error = xfs_bmapi_read(ip, last_fsb, 1, &imap, &nimaps, 0);
513 &nimaps, NULL); 513 if (error)
514 if (error) {
515 return error; 514 return error;
516 }
517 ASSERT(nimaps > 0); 515 ASSERT(nimaps > 0);
518 /* 516 /*
519 * If the block underlying isize is just a hole, then there 517 * If the block underlying isize is just a hole, then there
@@ -604,8 +602,8 @@ xfs_zero_eof(
604 while (start_zero_fsb <= end_zero_fsb) { 602 while (start_zero_fsb <= end_zero_fsb) {
605 nimaps = 1; 603 nimaps = 1;
606 zero_count_fsb = end_zero_fsb - start_zero_fsb + 1; 604 zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;
607 error = xfs_bmapi(NULL, ip, start_zero_fsb, zero_count_fsb, 605 error = xfs_bmapi_read(ip, start_zero_fsb, zero_count_fsb,
608 0, NULL, 0, &imap, &nimaps, NULL); 606 &imap, &nimaps, 0);
609 if (error) { 607 if (error) {
610 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL)); 608 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_IOLOCK_EXCL));
611 return error; 609 return error;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index d689253fdfda..f690d3a10b34 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1187,6 +1187,7 @@ xfs_isize_check(
1187 xfs_fileoff_t map_first; 1187 xfs_fileoff_t map_first;
1188 int nimaps; 1188 int nimaps;
1189 xfs_bmbt_irec_t imaps[2]; 1189 xfs_bmbt_irec_t imaps[2];
1190 int error;
1190 1191
1191 if (!S_ISREG(ip->i_d.di_mode)) 1192 if (!S_ISREG(ip->i_d.di_mode))
1192 return; 1193 return;
@@ -1203,13 +1204,12 @@ xfs_isize_check(
1203 * The filesystem could be shutting down, so bmapi may return 1204 * The filesystem could be shutting down, so bmapi may return
1204 * an error. 1205 * an error.
1205 */ 1206 */
1206 if (xfs_bmapi(NULL, ip, map_first, 1207 error = xfs_bmapi_read(ip, map_first,
1207 (XFS_B_TO_FSB(mp, 1208 (XFS_B_TO_FSB(mp,
1208 (xfs_ufsize_t)XFS_MAXIOFFSET(mp)) - 1209 (xfs_ufsize_t)XFS_MAXIOFFSET(mp)) - map_first),
1209 map_first), 1210 imaps, &nimaps, XFS_BMAPI_ENTIRE);
1210 XFS_BMAPI_ENTIRE, NULL, 0, imaps, &nimaps, 1211 if (error)
1211 NULL)) 1212 return;
1212 return;
1213 ASSERT(nimaps == 1); 1213 ASSERT(nimaps == 1);
1214 ASSERT(imaps[0].br_startblock == HOLESTARTBLOCK); 1214 ASSERT(imaps[0].br_startblock == HOLESTARTBLOCK);
1215} 1215}
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 091d82b94c4d..544f053860f1 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -300,8 +300,8 @@ xfs_iomap_eof_want_preallocate(
300 while (count_fsb > 0) { 300 while (count_fsb > 0) {
301 imaps = nimaps; 301 imaps = nimaps;
302 firstblock = NULLFSBLOCK; 302 firstblock = NULLFSBLOCK;
303 error = xfs_bmapi(NULL, ip, start_fsb, count_fsb, 0, 303 error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps,
304 &firstblock, 0, imap, &imaps, NULL); 304 0);
305 if (error) 305 if (error)
306 return error; 306 return error;
307 for (n = 0; n < imaps; n++) { 307 for (n = 0; n < imaps; n++) {
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index f51bef885e6d..ddaf97a57ec6 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -1347,11 +1347,8 @@ xfs_qm_dqiterate(
1347 * the inode is never added to the transaction. 1347 * the inode is never added to the transaction.
1348 */ 1348 */
1349 xfs_ilock(qip, XFS_ILOCK_SHARED); 1349 xfs_ilock(qip, XFS_ILOCK_SHARED);
1350 error = xfs_bmapi(NULL, qip, lblkno, 1350 error = xfs_bmapi_read(qip, lblkno, maxlblkcnt - lblkno,
1351 maxlblkcnt - lblkno, 1351 map, &nmaps, 0);
1352 XFS_BMAPI_METADATA,
1353 NULL,
1354 0, map, &nmaps, NULL);
1355 xfs_iunlock(qip, XFS_ILOCK_SHARED); 1352 xfs_iunlock(qip, XFS_ILOCK_SHARED);
1356 if (error) 1353 if (error)
1357 break; 1354 break;
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 0d1caec873a1..63874a87b378 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -72,8 +72,8 @@ xfs_readlink_bmap(
72 xfs_buf_t *bp; 72 xfs_buf_t *bp;
73 int error = 0; 73 int error = 0;
74 74
75 error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0, 75 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, pathlen), mval, &nmaps,
76 mval, &nmaps, NULL); 76 0);
77 if (error) 77 if (error)
78 goto out; 78 goto out;
79 79
@@ -178,8 +178,7 @@ xfs_free_eofblocks(
178 178
179 nimaps = 1; 179 nimaps = 1;
180 xfs_ilock(ip, XFS_ILOCK_SHARED); 180 xfs_ilock(ip, XFS_ILOCK_SHARED);
181 error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0, 181 error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
182 NULL, 0, &imap, &nimaps, NULL);
183 xfs_iunlock(ip, XFS_ILOCK_SHARED); 182 xfs_iunlock(ip, XFS_ILOCK_SHARED);
184 183
185 if (!error && (nimaps != 0) && 184 if (!error && (nimaps != 0) &&
@@ -297,9 +296,9 @@ xfs_inactive_symlink_rmt(
297 done = 0; 296 done = 0;
298 xfs_bmap_init(&free_list, &first_block); 297 xfs_bmap_init(&free_list, &first_block);
299 nmaps = ARRAY_SIZE(mval); 298 nmaps = ARRAY_SIZE(mval);
300 if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size), 299 error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, size),
301 XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps, 300 mval, &nmaps, 0);
302 &free_list))) 301 if (error)
303 goto error0; 302 goto error0;
304 /* 303 /*
305 * Invalidate the block(s). 304 * Invalidate the block(s).
@@ -1981,8 +1980,7 @@ xfs_zero_remaining_bytes(
1981 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) { 1980 for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
1982 offset_fsb = XFS_B_TO_FSBT(mp, offset); 1981 offset_fsb = XFS_B_TO_FSBT(mp, offset);
1983 nimap = 1; 1982 nimap = 1;
1984 error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0, 1983 error = xfs_bmapi_read(ip, offset_fsb, 1, &imap, &nimap, 0);
1985 NULL, 0, &imap, &nimap, NULL);
1986 if (error || nimap < 1) 1984 if (error || nimap < 1)
1987 break; 1985 break;
1988 ASSERT(imap.br_blockcount >= 1); 1986 ASSERT(imap.br_blockcount >= 1);
@@ -2101,8 +2099,8 @@ xfs_free_file_space(
2101 */ 2099 */
2102 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) { 2100 if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
2103 nimap = 1; 2101 nimap = 1;
2104 error = xfs_bmapi(NULL, ip, startoffset_fsb, 2102 error = xfs_bmapi_read(ip, startoffset_fsb, 1,
2105 1, 0, NULL, 0, &imap, &nimap, NULL); 2103 &imap, &nimap, 0);
2106 if (error) 2104 if (error)
2107 goto out_unlock_iolock; 2105 goto out_unlock_iolock;
2108 ASSERT(nimap == 0 || nimap == 1); 2106 ASSERT(nimap == 0 || nimap == 1);
@@ -2116,8 +2114,8 @@ xfs_free_file_space(
2116 startoffset_fsb += mp->m_sb.sb_rextsize - mod; 2114 startoffset_fsb += mp->m_sb.sb_rextsize - mod;
2117 } 2115 }
2118 nimap = 1; 2116 nimap = 1;
2119 error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, 2117 error = xfs_bmapi_read(ip, endoffset_fsb - 1, 1,
2120 1, 0, NULL, 0, &imap, &nimap, NULL); 2118 &imap, &nimap, 0);
2121 if (error) 2119 if (error)
2122 goto out_unlock_iolock; 2120 goto out_unlock_iolock;
2123 ASSERT(nimap == 0 || nimap == 1); 2121 ASSERT(nimap == 0 || nimap == 1);