]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: make xfs_trans_get_buf 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: ce92464c180b60e79022bdf1175b7737a11f59b7

Convert xfs_trans_get_buf() 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/xfs_btree.c
libxfs/xfs_ialloc.c
libxfs/xfs_sb.c
mkfs/proto.c

index 33ab5d730318019431bac252837df96f058db9f7..16e2a468224ee741b392661181855d9ed6ceaaee 100644 (file)
@@ -114,22 +114,18 @@ int       libxfs_trans_read_buf_map(struct xfs_mount *mp, struct xfs_trans *tp,
                                  struct xfs_buf_map *map, int nmaps,
                                  xfs_buf_flags_t flags, struct xfs_buf **bpp,
                                  const struct xfs_buf_ops *ops);
-static inline struct xfs_buf *
+static inline int
 libxfs_trans_get_buf(
        struct xfs_trans        *tp,
        struct xfs_buftarg      *btp,
        xfs_daddr_t             blkno,
        int                     numblks,
-       uint                    flags)
+       uint                    flags,
+       struct xfs_buf          **bpp)
 {
-       struct xfs_buf          *bp;
-       int                     error;
        DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
 
-       error = libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, &bp);
-       if (error)
-               return NULL;
-       return bp;
+       return libxfs_trans_get_buf_map(tp, btp, &map, 1, flags, bpp);
 }
 
 static inline int
index ead05a4648c918b273617ca5fd854f7792219328..aeaa9623500d481cbdd4014e0ea2e60b80d917d3 100644 (file)
@@ -685,11 +685,16 @@ xfs_btree_get_bufl(
        xfs_trans_t     *tp,            /* transaction pointer */
        xfs_fsblock_t   fsbno)          /* file system block number */
 {
+       struct xfs_buf          *bp;
        xfs_daddr_t             d;              /* real disk block address */
+       int                     error;
 
        ASSERT(fsbno != NULLFSBLOCK);
        d = XFS_FSB_TO_DADDR(mp, fsbno);
-       return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0);
+       error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0, &bp);
+       if (error)
+               return NULL;
+       return bp;
 }
 
 /*
@@ -703,12 +708,17 @@ xfs_btree_get_bufs(
        xfs_agnumber_t  agno,           /* allocation group number */
        xfs_agblock_t   agbno)          /* allocation group block number */
 {
+       struct xfs_buf          *bp;
        xfs_daddr_t             d;              /* real disk block address */
+       int                     error;
 
        ASSERT(agno != NULLAGNUMBER);
        ASSERT(agbno != NULLAGBLOCK);
        d = XFS_AGB_TO_DADDR(mp, agno, agbno);
-       return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0);
+       error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, 0, &bp);
+       if (error)
+               return NULL;
+       return bp;
 }
 
 /*
@@ -1267,11 +1277,10 @@ xfs_btree_get_buf_block(
        error = xfs_btree_ptr_to_daddr(cur, ptr, &d);
        if (error)
                return error;
-       *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
-                                mp->m_bsize, 0);
-
-       if (!*bpp)
-               return -ENOMEM;
+       error = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d, mp->m_bsize,
+                       0, bpp);
+       if (error)
+               return error;
 
        (*bpp)->b_ops = cur->bc_ops->buf_ops;
        *block = XFS_BUF_TO_BLOCK(*bpp);
index baa9955192e39fed9cb8dc8f65715605afd967e5..00b3326371568caa772038e2085403d99aab1235 100644 (file)
@@ -271,6 +271,7 @@ xfs_ialloc_inode_init(
        int                     i, j;
        xfs_daddr_t             d;
        xfs_ino_t               ino = 0;
+       int                     error;
 
        /*
         * Loop over the new block(s), filling in the inodes.  For small block
@@ -322,12 +323,11 @@ xfs_ialloc_inode_init(
                 */
                d = XFS_AGB_TO_DADDR(mp, agno, agbno +
                                (j * M_IGEO(mp)->blocks_per_cluster));
-               fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
-                                        mp->m_bsize *
-                                        M_IGEO(mp)->blocks_per_cluster,
-                                        XBF_UNMAPPED);
-               if (!fbuf)
-                       return -ENOMEM;
+               error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
+                               mp->m_bsize * M_IGEO(mp)->blocks_per_cluster,
+                               XBF_UNMAPPED, &fbuf);
+               if (error)
+                       return error;
 
                /* Initialize the inode buffers and log them appropriately. */
                fbuf->b_ops = &xfs_inode_buf_ops;
index d3d5e11dc188d19d4f25f761068999777eaab662..687e33d827e895e3a149b79d8f6dade04b228520 100644 (file)
@@ -1162,13 +1162,14 @@ xfs_sb_get_secondary(
        struct xfs_buf          **bpp)
 {
        struct xfs_buf          *bp;
+       int                     error;
 
        ASSERT(agno != 0 && agno != NULLAGNUMBER);
-       bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
+       error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
                        XFS_AG_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
-                       XFS_FSS_TO_BB(mp, 1), 0);
-       if (!bp)
-               return -ENOMEM;
+                       XFS_FSS_TO_BB(mp, 1), 0, &bp);
+       if (error)
+               return error;
        bp->b_ops = &xfs_sb_buf_ops;
        xfs_buf_oneshot(bp);
        *bpp = bp;
index 26a613fe33345834ab01fba685e9e60265233ce4..ab01c8b0d178d9aa5a8ddb6def63cfacda12aa12 100644 (file)
@@ -254,8 +254,14 @@ newfile(
                        exit(1);
                }
                d = XFS_FSB_TO_DADDR(mp, map.br_startblock);
-               bp = libxfs_trans_get_buf(logit ? tp : NULL, mp->m_dev, d,
-                       nb << mp->m_blkbb_log, 0);
+               error = -libxfs_trans_get_buf(logit ? tp : NULL, mp->m_dev, d,
+                               nb << mp->m_blkbb_log, 0, &bp);
+               if (error) {
+                       fprintf(stderr,
+                               _("%s: cannot allocate buffer for file\n"),
+                               progname);
+                       exit(1);
+               }
                memmove(bp->b_addr, buf, len);
                if (len < bp->b_bcount)
                        memset((char *)bp->b_addr + len, 0, bp->b_bcount - len);