Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xfs: rework xfs_buf_incore() API

Make it consistent with the other buffer APIs to return a error and
the buffer is placed in a parameter.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

authored by

Dave Chinner and committed by
Dave Chinner
85c73bf7 7561cea5

+41 -37
+10 -5
fs/xfs/libxfs/xfs_attr_remote.c
··· 543 543 { 544 544 struct xfs_mount *mp = ip->i_mount; 545 545 struct xfs_buf *bp; 546 + int error; 546 547 547 548 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 548 549 ··· 551 550 XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) 552 551 return -EFSCORRUPTED; 553 552 554 - bp = xfs_buf_incore(mp->m_ddev_targp, 553 + error = xfs_buf_incore(mp->m_ddev_targp, 555 554 XFS_FSB_TO_DADDR(mp, map->br_startblock), 556 - XFS_FSB_TO_BB(mp, map->br_blockcount), incore_flags); 557 - if (bp) { 558 - xfs_buf_stale(bp); 559 - xfs_buf_relse(bp); 555 + XFS_FSB_TO_BB(mp, map->br_blockcount), 556 + incore_flags, &bp); 557 + if (error) { 558 + if (error == -ENOENT) 559 + return 0; 560 + return error; 560 561 } 561 562 563 + xfs_buf_stale(bp); 564 + xfs_buf_relse(bp); 562 565 return 0; 563 566 } 564 567
+9 -6
fs/xfs/scrub/repair.c
··· 457 457 * assume it's owned by someone else. 458 458 */ 459 459 for_each_xbitmap_block(fsbno, bmr, n, bitmap) { 460 + int error; 461 + 460 462 /* Skip AG headers and post-EOFS blocks */ 461 463 if (!xfs_verify_fsbno(sc->mp, fsbno)) 462 464 continue; 463 - bp = xfs_buf_incore(sc->mp->m_ddev_targp, 465 + error = xfs_buf_incore(sc->mp->m_ddev_targp, 464 466 XFS_FSB_TO_DADDR(sc->mp, fsbno), 465 - XFS_FSB_TO_BB(sc->mp, 1), XBF_TRYLOCK); 466 - if (bp) { 467 - xfs_trans_bjoin(sc->tp, bp); 468 - xfs_trans_binval(sc->tp, bp); 469 - } 467 + XFS_FSB_TO_BB(sc->mp, 1), XBF_TRYLOCK, &bp); 468 + if (error) 469 + continue; 470 + 471 + xfs_trans_bjoin(sc->tp, bp); 472 + xfs_trans_binval(sc->tp, bp); 470 473 } 471 474 472 475 return 0;
+2 -17
fs/xfs/xfs_buf.c
··· 616 616 return 0; 617 617 } 618 618 619 - struct xfs_buf * 620 - xfs_buf_incore( 621 - struct xfs_buftarg *target, 622 - xfs_daddr_t blkno, 623 - size_t numblks, 624 - xfs_buf_flags_t flags) 625 - { 626 - struct xfs_buf *bp; 627 - int error; 628 - DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); 629 - 630 - error = xfs_buf_find(target, &map, 1, flags, NULL, &bp); 631 - if (error) 632 - return NULL; 633 - return bp; 634 - } 635 - 636 619 /* 637 620 * Assembles a buffer covering the specified range. The code is optimised for 638 621 * cache hits, as metadata intensive workloads will see 3 orders of magnitude ··· 639 656 goto found; 640 657 if (error != -ENOENT) 641 658 return error; 659 + if (flags & XBF_INCORE) 660 + return -ENOENT; 642 661 643 662 error = _xfs_buf_alloc(target, map, nmaps, flags, &new_bp); 644 663 if (error)
+16 -4
fs/xfs/xfs_buf.h
··· 42 42 #define _XBF_DELWRI_Q (1u << 22)/* buffer on a delwri queue */ 43 43 44 44 /* flags used only as arguments to access routines */ 45 + #define XBF_INCORE (1u << 29)/* lookup only, return if found in cache */ 45 46 #define XBF_TRYLOCK (1u << 30)/* lock requested, but do not wait */ 46 47 #define XBF_UNMAPPED (1u << 31)/* do not map the buffer */ 48 + 47 49 48 50 typedef unsigned int xfs_buf_flags_t; 49 51 ··· 65 63 { _XBF_KMEM, "KMEM" }, \ 66 64 { _XBF_DELWRI_Q, "DELWRI_Q" }, \ 67 65 /* The following interface flags should never be set */ \ 66 + { XBF_INCORE, "INCORE" }, \ 68 67 { XBF_TRYLOCK, "TRYLOCK" }, \ 69 68 { XBF_UNMAPPED, "UNMAPPED" } 70 69 ··· 199 196 }; 200 197 201 198 /* Finding and Reading Buffers */ 202 - struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target, 203 - xfs_daddr_t blkno, size_t numblks, 204 - xfs_buf_flags_t flags); 205 - 206 199 int xfs_buf_get_map(struct xfs_buftarg *target, struct xfs_buf_map *map, 207 200 int nmaps, xfs_buf_flags_t flags, struct xfs_buf **bpp); 208 201 int xfs_buf_read_map(struct xfs_buftarg *target, struct xfs_buf_map *map, ··· 207 208 void xfs_buf_readahead_map(struct xfs_buftarg *target, 208 209 struct xfs_buf_map *map, int nmaps, 209 210 const struct xfs_buf_ops *ops); 211 + 212 + static inline int 213 + xfs_buf_incore( 214 + struct xfs_buftarg *target, 215 + xfs_daddr_t blkno, 216 + size_t numblks, 217 + xfs_buf_flags_t flags, 218 + struct xfs_buf **bpp) 219 + { 220 + DEFINE_SINGLE_BUF_MAP(map, blkno, numblks); 221 + 222 + return xfs_buf_get_map(target, &map, 1, XBF_INCORE | flags, bpp); 223 + } 210 224 211 225 static inline int 212 226 xfs_buf_get(
+4 -5
fs/xfs/xfs_qm.c
··· 1229 1229 */ 1230 1230 if (!xfs_dqflock_nowait(dqp)) { 1231 1231 /* buf is pinned in-core by delwri list */ 1232 - bp = xfs_buf_incore(mp->m_ddev_targp, dqp->q_blkno, 1233 - mp->m_quotainfo->qi_dqchunklen, 0); 1234 - if (!bp) { 1235 - error = -EINVAL; 1232 + error = xfs_buf_incore(mp->m_ddev_targp, dqp->q_blkno, 1233 + mp->m_quotainfo->qi_dqchunklen, 0, &bp); 1234 + if (error) 1236 1235 goto out_unlock; 1237 - } 1236 + 1238 1237 xfs_buf_unlock(bp); 1239 1238 1240 1239 xfs_buf_delwri_pushbuf(bp, buffer_list);