]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: make xfs_buf_get_uncached 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: 2842b6db3d539bec08d080b22635b6e8acaa30ec

Convert xfs_buf_get_uncached() 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>
libxfs/libxfs_io.h
libxfs/rdwr.c
libxfs/xfs_ag.c
libxlog/xfs_log_recover.c
mkfs/xfs_mkfs.c

index 46d294ca571d85dd7a31b5e4d45f6011d5a01bd8..4f7467cdb8877953aa39eee07bb6add89e7dc243 100644 (file)
@@ -252,8 +252,8 @@ xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t len)
        return 0;
 }
 
-struct xfs_buf *libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen,
-               int flags);
+int libxfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags,
+               struct xfs_buf **bpp);
 int libxfs_buf_read_uncached(struct xfs_buftarg *targ, xfs_daddr_t daddr,
                size_t bblen, int flags, struct xfs_buf **bpp,
                const struct xfs_buf_ops *ops);
index 0bcc473045798bc5d3108339ecca5d216933f0d9..69f6b0e57384d60a80387632fd23079c540cf1ba 100644 (file)
@@ -896,13 +896,15 @@ libxfs_getbufr_uncached(
  * Allocate an uncached buffer that points nowhere.  The refcount will be 1,
  * and the cache node hash list will be empty to indicate that it's uncached.
  */
-struct xfs_buf *
+int
 libxfs_buf_get_uncached(
        struct xfs_buftarg      *targ,
        size_t                  bblen,
-       int                     flags)
+       int                     flags,
+       struct xfs_buf          **bpp)
 {
-       return libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+       *bpp = libxfs_getbufr_uncached(targ, XFS_BUF_DADDR_NULL, bblen);
+       return *bpp != NULL ? 0 : -ENOMEM;
 }
 
 /*
index 5bf6975df4133c078e7fb89894b12d1a4dcf44d1..73fb30cbcfac8817926e9e0abdef6ee67e25890b 100644 (file)
 #include "xfs_ag_resv.h"
 #include "xfs_health.h"
 
-static struct xfs_buf *
+static int
 xfs_get_aghdr_buf(
        struct xfs_mount        *mp,
        xfs_daddr_t             blkno,
        size_t                  numblks,
+       struct xfs_buf          **bpp,
        const struct xfs_buf_ops *ops)
 {
        struct xfs_buf          *bp;
+       int                     error;
 
-       bp = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0);
-       if (!bp)
-               return NULL;
+       error = xfs_buf_get_uncached(mp->m_ddev_targp, numblks, 0, &bp);
+       if (error)
+               return error;
 
        xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
        bp->b_bn = blkno;
        bp->b_maps[0].bm_bn = blkno;
        bp->b_ops = ops;
 
-       return bp;
+       *bpp = bp;
+       return 0;
 }
 
 static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id)
@@ -340,13 +343,13 @@ xfs_ag_init_hdr(
        struct aghdr_init_data  *id,
        aghdr_init_work_f       work,
        const struct xfs_buf_ops *ops)
-
 {
        struct xfs_buf          *bp;
+       int                     error;
 
-       bp = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, ops);
-       if (!bp)
-               return -ENOMEM;
+       error = xfs_get_aghdr_buf(mp, id->daddr, id->numblks, &bp, ops);
+       if (error)
+               return error;
 
        (*work)(mp, bp, id);
 
index e7e57bd2446856f67d58dcaeb886d1819dd87f8e..78fbafab702d107954b82d11078f4513efeb10d8 100644 (file)
@@ -35,11 +35,13 @@ xlog_buf_bbcount_valid(
  * to map to a range of nbblks basic blocks at any valid (basic
  * block) offset within the log.
  */
-xfs_buf_t *
+struct xfs_buf *
 xlog_get_bp(
        struct xlog     *log,
        int             nbblks)
 {
+       struct xfs_buf  *bp;
+
        if (!xlog_buf_bbcount_valid(log, nbblks)) {
                xfs_warn(log->l_mp, "Invalid block length (0x%x) for buffer",
                        nbblks);
@@ -67,7 +69,8 @@ xlog_get_bp(
                nbblks += log->l_sectBBsize;
        nbblks = round_up(nbblks, log->l_sectBBsize);
 
-       return libxfs_buf_get_uncached(log->l_dev, nbblks, 0);
+       libxfs_buf_get_uncached(log->l_dev, nbblks, 0, &bp);
+       return bp;
 }
 
 /*
index edf752f460c84b501fa77abdc6a726089b46264c..9ad5a6386bc0340bd2bdc7ec99fbedf463fa4e37 100644 (file)
@@ -3359,8 +3359,14 @@ alloc_write_buf(
        int                     bblen)
 {
        struct xfs_buf          *bp;
+       int                     error;
 
-       bp = libxfs_buf_get_uncached(btp, bblen, 0);
+       error = -libxfs_buf_get_uncached(btp, bblen, 0, &bp);
+       if (error) {
+               fprintf(stderr, _("Could not get memory for buffer, err=%d\n"),
+                               error);
+               exit(1);
+       }
        bp->b_bn = daddr;
        bp->b_maps[0].bm_bn = daddr;
        return bp;