]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: replace libxfs_getbuf with libxfs_buf_get
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Sun, 1 Mar 2020 17:34:10 +0000 (12:34 -0500)
Change all the libxfs_getbuf calls to libxfs_buf_get to match the
kernel interface, since one is a #define of the other.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/cache.h
libxfs/libxfs_api_defs.h
libxfs/libxfs_io.h
libxfs/libxfs_priv.h
libxfs/rdwr.c
mkfs/xfs_mkfs.c
repair/phase5.c

index 552b92489e4699443b4fb64c3397899d3f78188a..334ad26309e26dcd9d3a612fb37d262e9cd33699 100644 (file)
@@ -33,7 +33,7 @@ enum {
  * For prefetch support, the top half of the range starts at
  * CACHE_PREFETCH_PRIORITY and everytime the buffer is fetched and is at or
  * above this priority level, it is reduced to below this level (refer to
- * libxfs_getbuf).
+ * libxfs_buf_get).
  *
  * If we have dirty nodes, we can't recycle them until they've been cleaned. To
  * keep these out of the reclaimable lists (as there can be lots of them) give
index 8bca7ddfa534e241ef774d22f9b38311f4e6f442..6d86774f336bcc4f0dbc163e5d2d4d6d969e1a9f 100644 (file)
@@ -44,6 +44,7 @@
 #define xfs_btree_del_cursor           libxfs_btree_del_cursor
 #define xfs_btree_init_block           libxfs_btree_init_block
 #define xfs_buf_delwri_submit          libxfs_buf_delwri_submit
+#define xfs_buf_get                    libxfs_buf_get
 #define xfs_buf_relse                  libxfs_buf_relse
 #define xfs_bunmapi                    libxfs_bunmapi
 #define xfs_calc_dquots_per_chunk      libxfs_calc_dquots_per_chunk
index 3ddfc0c83ee7d56ebd748c622d89a64c0df7af81..50b7cef8a40ccd93af4c410c0182c5afaac0c39d 100644 (file)
@@ -139,7 +139,7 @@ extern struct cache_operations      libxfs_bcache_operations;
 #define libxfs_writebuf(buf, flags) \
        libxfs_trace_writebuf(__FUNCTION__, __FILE__, __LINE__, \
                              (buf), (flags))
-#define libxfs_getbuf(dev, daddr, len) \
+#define libxfs_buf_get(dev, daddr, len) \
        libxfs_trace_getbuf(__FUNCTION__, __FILE__, __LINE__, \
                            (dev), (daddr), (len))
 #define libxfs_getbuf_map(dev, map, nmaps, flags) \
@@ -159,8 +159,9 @@ extern xfs_buf_t *libxfs_trace_readbuf_map(const char *, const char *, int,
                        const struct xfs_buf_ops *);
 extern int     libxfs_trace_writebuf(const char *, const char *, int,
                        xfs_buf_t *, int);
-extern xfs_buf_t *libxfs_trace_getbuf(const char *, const char *, int,
-                       struct xfs_buftarg *, xfs_daddr_t, int);
+struct xfs_buf *libxfs_trace_getbuf(const char *func, const char *file,
+                       int line, struct xfs_buftarg *btp, xfs_daddr_t daddr,
+                       size_t len);
 extern xfs_buf_t *libxfs_trace_getbuf_map(const char *, const char *, int,
                        struct xfs_buftarg *, struct xfs_buf_map *, int, int);
 extern xfs_buf_t *libxfs_trace_getbuf_flags(const char *, const char *, int,
@@ -175,14 +176,24 @@ extern xfs_buf_t *libxfs_readbuf(struct xfs_buftarg *, xfs_daddr_t, int, int,
 extern xfs_buf_t *libxfs_readbuf_map(struct xfs_buftarg *, struct xfs_buf_map *,
                        int, int, const struct xfs_buf_ops *);
 extern int     libxfs_writebuf(xfs_buf_t *, int);
-extern xfs_buf_t *libxfs_getbuf(struct xfs_buftarg *, xfs_daddr_t, int);
 extern xfs_buf_t *libxfs_getbuf_map(struct xfs_buftarg *,
                        struct xfs_buf_map *, int, int);
 extern xfs_buf_t *libxfs_getbuf_flags(struct xfs_buftarg *, xfs_daddr_t,
                        int, unsigned int);
 void   libxfs_buf_relse(struct xfs_buf *bp);
 
-#endif
+static inline struct xfs_buf*
+libxfs_buf_get(
+       struct xfs_buftarg      *target,
+       xfs_daddr_t             blkno,
+       size_t                  numblks)
+{
+       DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
+
+       return libxfs_getbuf_map(target, &map, 1, 0);
+}
+
+#endif /* XFS_BUF_TRACING */
 
 extern void    libxfs_readbuf_verify(struct xfs_buf *bp,
                        const struct xfs_buf_ops *ops);
index 4bd3c462cf1c674e7189fcf9f67538f7dd0235ee..0f26120fca1b8e3490ec8e8a2b9bab4e87e37c09 100644 (file)
@@ -377,7 +377,6 @@ roundup_64(uint64_t x, uint32_t y)
        (len) = __bar; /* no set-but-unused warning */  \
        NULL;                                           \
 })
-#define xfs_buf_get(devp,blkno,len)    (libxfs_getbuf((devp), (blkno), (len)))
 #define xfs_bwrite(bp)                 libxfs_writebuf((bp), 0)
 #define xfs_buf_oneshot(bp)            ((void) 0)
 
index a7f9c327494a8f000c81aef8c52e0fddf423bfaa..8fc9222e27a0f5021263944b908814d0fc0d5af1 100644 (file)
@@ -30,7 +30,7 @@
  * outside libxfs clears bp->b_error - very little code even checks it - so the
  * libxfs code is tripping on stale errors left by the userspace code.
  *
- * We can't clear errors or zero buffer contents in libxfs_getbuf-* like we do
+ * We can't clear errors or zero buffer contents in libxfs_buf_get-* like we do
  * in the kernel, because those functions are used by the libxfs_readbuf_*
  * functions and hence need to leave the buffers unchanged on cache hits. This
  * is actually the only way to gather a write error from a libxfs_writebuf()
@@ -44,7 +44,7 @@
  *
  * IOWs, userspace is behaving quite differently to the kernel and as a result
  * it leaks errors from reads, invalidations and writes through
- * libxfs_getbuf/libxfs_readbuf.
+ * libxfs_buf_get/libxfs_readbuf.
  *
  * The result of this is that until the userspace code outside libxfs is cleaned
  * up, functions that release buffers from userspace control (i.e
@@ -391,7 +391,6 @@ libxfs_log_header(
 #undef libxfs_readbuf
 #undef libxfs_readbuf_map
 #undef libxfs_writebuf
-#undef libxfs_getbuf
 #undef libxfs_getbuf_map
 #undef libxfs_getbuf_flags
 
@@ -400,7 +399,8 @@ xfs_buf_t   *libxfs_readbuf(struct xfs_buftarg *, xfs_daddr_t, int, int,
 xfs_buf_t      *libxfs_readbuf_map(struct xfs_buftarg *, struct xfs_buf_map *,
                                int, int, const struct xfs_buf_ops *);
 int            libxfs_writebuf(xfs_buf_t *, int);
-xfs_buf_t      *libxfs_getbuf(struct xfs_buftarg *, xfs_daddr_t, int);
+struct xfs_buf *libxfs_buf_get(struct xfs_buftarg *btp, xfs_daddr_t daddr,
+                               size_t len);
 xfs_buf_t      *libxfs_getbuf_map(struct xfs_buftarg *, struct xfs_buf_map *,
                                int, int);
 xfs_buf_t      *libxfs_getbuf_flags(struct xfs_buftarg *, xfs_daddr_t, int,
@@ -443,11 +443,19 @@ libxfs_trace_writebuf(const char *func, const char *file, int line, xfs_buf_t *b
        return libxfs_writebuf(bp, flags);
 }
 
-xfs_buf_t *
-libxfs_trace_getbuf(const char *func, const char *file, int line,
-               struct xfs_buftarg *btp, xfs_daddr_t blkno, int len)
+struct xfs_buf *
+libxfs_trace_getbuf(
+       const char              *func,
+       const char              *file,
+       int                     line,
+       struct xfs_buftarg      *btp,
+       xfs_daddr_t             blkno,
+       size_t                  len)
 {
-       xfs_buf_t       *bp = libxfs_getbuf(btp, blkno, len);
+       struct xfs_buf          *bp;
+       DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
+
+       bp = libxfs_getbuf_map(target, &map, 1, 0);
        __add_trace(bp, func, file, line);
        return bp;
 }
@@ -806,16 +814,6 @@ reset_buf_state(
                                LIBXFS_B_UPTODATE);
 }
 
-struct xfs_buf *
-libxfs_getbuf(struct xfs_buftarg *btp, xfs_daddr_t blkno, int len)
-{
-       struct xfs_buf  *bp;
-
-       bp = libxfs_getbuf_flags(btp, blkno, len, 0);
-       reset_buf_state(bp);
-       return bp;
-}
-
 static struct xfs_buf *
 __libxfs_getbuf_map(struct xfs_buftarg *btp, struct xfs_buf_map *map,
                    int nmaps, int flags)
index de6e0e2823a2ae578823de847e45977605be18af..edbb0ecc1117d7b4ec744f48d5ee8c6ac2f384d5 100644 (file)
@@ -3399,7 +3399,7 @@ prepare_devices(
         * the end of the device.  (MD sb is ~64k from the end, take out a wider
         * swath to be sure)
         */
-       buf = libxfs_getbuf(mp->m_ddev_targp, (xi->dsize - whack_blks),
+       buf = libxfs_buf_get(mp->m_ddev_targp, (xi->dsize - whack_blks),
                            whack_blks);
        memset(buf->b_addr, 0, WHACK_SIZE);
        libxfs_writebuf(buf, 0);
@@ -3411,13 +3411,14 @@ prepare_devices(
         * swap (somewhere around the page size), jfs (32k),
         * ext[2,3] and reiserfs (64k) - and hopefully all else.
         */
-       buf = libxfs_getbuf(mp->m_ddev_targp, 0, whack_blks);
+       buf = libxfs_buf_get(mp->m_ddev_targp, 0, whack_blks);
        memset(buf->b_addr, 0, WHACK_SIZE);
        libxfs_writebuf(buf, 0);
        libxfs_purgebuf(buf);
 
        /* OK, now write the superblock... */
-       buf = libxfs_getbuf(mp->m_ddev_targp, XFS_SB_DADDR, XFS_FSS_TO_BB(mp, 1));
+       buf = libxfs_buf_get(mp->m_ddev_targp, XFS_SB_DADDR,
+                       XFS_FSS_TO_BB(mp, 1));
        buf->b_ops = &xfs_sb_buf_ops;
        memset(buf->b_addr, 0, cfg->sectorsize);
        libxfs_sb_to_disk(buf->b_addr, sbp);
@@ -3437,7 +3438,7 @@ prepare_devices(
 
        /* finally, check we can write the last block in the realtime area */
        if (mp->m_rtdev_targp->dev && cfg->rtblocks > 0) {
-               buf = libxfs_getbuf(mp->m_rtdev_targp,
+               buf = libxfs_buf_get(mp->m_rtdev_targp,
                                    XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
                                    BTOBB(cfg->blocksize));
                memset(buf->b_addr, 0, cfg->blocksize);
index 7f7d3d180a454267190920bca167191c57fe29db..cdbf6697b11789dade999f0fc8e13119ef088999 100644 (file)
@@ -689,7 +689,7 @@ prop_freespace_cursor(xfs_mount_t *mp, xfs_agnumber_t agno,
 
                bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(agbno);
 
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                lptr->agbno = agbno;
@@ -767,7 +767,7 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
                lptr = &btree_curs->level[i];
 
                agbno = get_next_blockaddr(agno, i, btree_curs);
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
 
@@ -877,7 +877,7 @@ build_freespace_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
                        lptr->agbno = get_next_blockaddr(agno, 0, btree_curs);
                        bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(lptr->agbno);
 
-                       lptr->buf_p = libxfs_getbuf(mp->m_dev,
+                       lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, lptr->agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                }
@@ -1054,7 +1054,7 @@ prop_ino_cursor(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs,
 
                bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(agbno);
 
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                lptr->agbno = agbno;
@@ -1104,7 +1104,7 @@ build_agi(xfs_mount_t *mp, xfs_agnumber_t agno, bt_status_t *btree_curs,
        xfs_agi_t       *agi;
        int             i;
 
-       agi_buf = libxfs_getbuf(mp->m_dev,
+       agi_buf = libxfs_buf_get(mp->m_dev,
                        XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
                        mp->m_sb.sb_sectsize/BBSIZE);
        agi_buf->b_ops = &xfs_agi_buf_ops;
@@ -1174,7 +1174,7 @@ build_ino_tree(xfs_mount_t *mp, xfs_agnumber_t agno,
                lptr = &btree_curs->level[i];
 
                agbno = get_next_blockaddr(agno, i, btree_curs);
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
 
@@ -1306,7 +1306,7 @@ nextrec:
                        lptr->agbno = get_next_blockaddr(agno, 0, btree_curs);
                        bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(lptr->agbno);
 
-                       lptr->buf_p = libxfs_getbuf(mp->m_dev,
+                       lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, lptr->agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                }
@@ -1459,7 +1459,7 @@ prop_rmap_cursor(
 
                bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(agbno);
 
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                lptr->agbno = agbno;
@@ -1569,7 +1569,7 @@ build_rmap_tree(
                lptr = &btree_curs->level[i];
 
                agbno = get_next_blockaddr(agno, i, btree_curs);
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
 
@@ -1668,7 +1668,7 @@ _("Insufficient memory to construct reverse-map cursor."));
                        lptr->agbno = get_next_blockaddr(agno, 0, btree_curs);
                        bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(lptr->agbno);
 
-                       lptr->buf_p = libxfs_getbuf(mp->m_dev,
+                       lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, lptr->agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                }
@@ -1809,7 +1809,7 @@ prop_refc_cursor(
 
                bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(agbno);
 
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                lptr->agbno = agbno;
@@ -1874,7 +1874,7 @@ build_refcount_tree(
                lptr = &btree_curs->level[i];
 
                agbno = get_next_blockaddr(agno, i, btree_curs);
-               lptr->buf_p = libxfs_getbuf(mp->m_dev,
+               lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, agbno),
                                        XFS_FSB_TO_BB(mp, 1));
 
@@ -1961,7 +1961,7 @@ _("Insufficient memory to construct refcount cursor."));
                        lptr->agbno = get_next_blockaddr(agno, 0, btree_curs);
                        bt_hdr->bb_u.s.bb_rightsib = cpu_to_be32(lptr->agbno);
 
-                       lptr->buf_p = libxfs_getbuf(mp->m_dev,
+                       lptr->buf_p = libxfs_buf_get(mp->m_dev,
                                        XFS_AGB_TO_DADDR(mp, agno, lptr->agbno),
                                        XFS_FSB_TO_BB(mp, 1));
                }
@@ -1996,7 +1996,7 @@ build_agf_agfl(
        __be32                  *freelist;
        int                     error;
 
-       agf_buf = libxfs_getbuf(mp->m_dev,
+       agf_buf = libxfs_buf_get(mp->m_dev,
                        XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
                        mp->m_sb.sb_sectsize/BBSIZE);
        agf_buf->b_ops = &xfs_agf_buf_ops;
@@ -2068,7 +2068,7 @@ build_agf_agfl(
                platform_uuid_copy(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid);
 
        /* initialise the AGFL, then fill it if there are blocks left over. */
-       agfl_buf = libxfs_getbuf(mp->m_dev,
+       agfl_buf = libxfs_buf_get(mp->m_dev,
                        XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
                        mp->m_sb.sb_sectsize/BBSIZE);
        agfl_buf->b_ops = &xfs_agfl_buf_ops;