]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: make xfs_trans_get_buf_map return an error code
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Sat, 14 Mar 2020 03:01:00 +0000 (23:01 -0400)
Source kernel commit: 9676b54e6e28689af1b4247569f14466bdfc5390

Convert xfs_trans_get_buf_map() to return numeric error codes like most
everywhere else in xfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_trans.h
libxfs/trans.c
libxfs/xfs_da_btree.c

index cff275464c3725e6f74247e5e55a8dcf7f4801f8..33ab5d730318019431bac252837df96f058db9f7 100644 (file)
@@ -105,10 +105,9 @@ void       libxfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *,
                                uint, uint);
 bool   libxfs_trans_ordered_buf(xfs_trans_t *, struct xfs_buf *);
 
-struct xfs_buf *libxfs_trans_get_buf_map(struct xfs_trans *tp,
-                                       struct xfs_buftarg *btp,
-                                       struct xfs_buf_map *map, int nmaps,
-                                       xfs_buf_flags_t flags);
+int    libxfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *btp,
+               struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
+               struct xfs_buf **bpp);
 
 int    libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
                                  struct xfs_buftarg *btp,
@@ -123,8 +122,14 @@ libxfs_trans_get_buf(
        int                     numblks,
        uint                    flags)
 {
+       struct xfs_buf          *bp;
+       int                     error;
        DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
-       return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags);
+
+       error = libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, &bp);
+       if (error)
+               return NULL;
+       return bp;
 }
 
 static inline int
index 73f69bcea3c32faf88efc1faa8443bfcea548eb0..ddd07cff575f5635984ad8ec8e75735e946005c6 100644 (file)
@@ -415,24 +415,22 @@ libxfs_trans_bhold_release(
  * If the transaction pointer is NULL, make this just a normal
  * get_buf() call.
  */
-struct xfs_buf *
+int
 libxfs_trans_get_buf_map(
        struct xfs_trans        *tp,
        struct xfs_buftarg      *target,
        struct xfs_buf_map      *map,
        int                     nmaps,
-       xfs_buf_flags_t         flags)
+       xfs_buf_flags_t         flags,
+       struct xfs_buf          **bpp)
 {
        struct xfs_buf          *bp;
        struct xfs_buf_log_item *bip;
        int                     error;
 
-       if (!tp) {
-               error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
-               if (error)
-                       return NULL;
-               return bp;
-       }
+       *bpp = NULL;
+       if (!tp)
+               return libxfs_buf_get_map(target, map, nmaps, 0, bpp);
 
        /*
         * If we find the buffer in the cache with this transaction
@@ -447,18 +445,20 @@ libxfs_trans_get_buf_map(
                ASSERT(bip != NULL);
                bip->bli_recur++;
                trace_xfs_trans_get_buf_recur(bip);
-               return bp;
+               *bpp = bp;
+               return 0;
        }
 
        error = libxfs_buf_get_map(target, map, nmaps, 0, &bp);
        if (error)
-               return NULL;
+               return error;
 
        ASSERT(!bp->b_error);
 
        _libxfs_trans_bjoin(tp, bp, 1);
        trace_xfs_trans_get_buf(bp->b_log_item);
-       return bp;
+       *bpp = bp;
+       return 0;
 }
 
 xfs_buf_t *
index 5102c6e02bd307c71c9e31646cdc3cb01ff7fbce..3f40e99ee22c2292cb77662f42f948fae996a23f 100644 (file)
@@ -2588,13 +2588,9 @@ xfs_da_get_buf(
        if (error || nmap == 0)
                goto out_free;
 
-       bp = xfs_trans_get_buf_map(tp, mp->m_ddev_targp, mapp, nmap, 0);
-       error = bp ? bp->b_error : -EIO;
-       if (error) {
-               if (bp)
-                       xfs_trans_brelse(tp, bp);
+       error = xfs_trans_get_buf_map(tp, mp->m_ddev_targp, mapp, nmap, 0, &bp);
+       if (error)
                goto out_free;
-       }
 
        *bpp = bp;