From 0b2f4162ba2f07eb760834d5b7357267d2729852 Mon Sep 17 00:00:00 2001 From: Dave Chinner Date: Wed, 24 Aug 2022 10:23:01 +0200 Subject: [PATCH] xfs: rework xfs_buf_incore() API Source kernel commit: 85c73bf726e41be276bcad3325d9a8aef10be289 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 Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino --- libxfs/libxfs_priv.h | 12 +++++++++--- libxfs/xfs_attr_remote.c | 15 ++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index fcdcfebf6..ad920cd9b 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -430,10 +430,16 @@ howmany_64(uint64_t x, uint32_t y) #define _XBF_DQUOTS 0 /* dquot buffer */ #define _XBF_LOGRECOVERY 0 /* log recovery buffer */ -static inline struct xfs_buf *xfs_buf_incore(struct xfs_buftarg *target, - xfs_daddr_t blkno, size_t numblks, xfs_buf_flags_t flags) +static inline int +xfs_buf_incore( + struct xfs_buftarg *target, + xfs_daddr_t blkno, + size_t numblks, + xfs_buf_flags_t flags, + struct xfs_buf **bpp) { - return NULL; + *bpp = NULL; + return -ENOENT; } #define xfs_buf_oneshot(bp) ((void) 0) diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 330c9262c..4f2b93f81 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -542,6 +542,7 @@ xfs_attr_rmtval_stale( { struct xfs_mount *mp = ip->i_mount; struct xfs_buf *bp; + int error; ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); @@ -549,14 +550,18 @@ xfs_attr_rmtval_stale( XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) return -EFSCORRUPTED; - bp = xfs_buf_incore(mp->m_ddev_targp, + error = xfs_buf_incore(mp->m_ddev_targp, XFS_FSB_TO_DADDR(mp, map->br_startblock), - XFS_FSB_TO_BB(mp, map->br_blockcount), incore_flags); - if (bp) { - xfs_buf_stale(bp); - xfs_buf_relse(bp); + XFS_FSB_TO_BB(mp, map->br_blockcount), + incore_flags, &bp); + if (error) { + if (error == -ENOENT) + return 0; + return error; } + xfs_buf_stale(bp); + xfs_buf_relse(bp); return 0; } -- 2.47.3