]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: rework xfs_buf_incore() API
authorDave Chinner <dchinner@redhat.com>
Fri, 15 Jul 2022 17:51:42 +0000 (10:51 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 26 Jul 2022 19:54:56 +0000 (12:54 -0700)
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 <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
libxfs/libxfs_priv.h
libxfs/xfs_attr_remote.c

index fcdcfebf60f627c30fcc916f873ebf7c5064d4cc..ad920cd9b6dd18b4208a47f40ef12983253ee6f1 100644 (file)
@@ -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)
index 330c9262c671d7afd62baf079309ef087e3ff522..4f2b93f81bacc5990c3127433933353dee06f75b 100644 (file)
@@ -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;
 }