]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Cleanup logprint IO patterns by making it not use the libxfs buffer cache (uses raw...
authorNathan Scott <nathans@sgi.com>
Tue, 8 Aug 2006 15:35:06 +0000 (15:35 +0000)
committerNathan Scott <nathans@sgi.com>
Tue, 8 Aug 2006 15:35:06 +0000 (15:35 +0000)
Merge of master-melb:xfs-cmds:26732a by kenmcd.

include/libxfs.h
include/libxlog.h
libxfs/rdwr.c

index fa7cb9d6cd30b50b88f075d26967bd847d5189be..d4680dbae65d11de9ecb0777b907728827d8c18c 100644 (file)
@@ -262,6 +262,10 @@ extern xfs_buf_t   *libxfs_getbuf (dev_t, xfs_daddr_t, int);
 extern void    libxfs_putbuf (xfs_buf_t *);
 extern void    libxfs_purgebuf (xfs_buf_t *);
 
+/* Buffer (Raw) Interfaces */
+extern xfs_buf_t       *libxfs_getbufr (dev_t, xfs_daddr_t, int);
+extern void    libxfs_putbufr (xfs_buf_t *);
+
 extern int libxfs_bhash_size;
 extern int libxfs_ihash_size;
 
index cef47cd5b459d7b5fdffb4090dd2543a66e0b420..2717d38da109dc27443c34843176850a867e3e64 100644 (file)
@@ -79,8 +79,8 @@ extern void xlog_warn(char *fmt,...);
 extern void xlog_exit(char *fmt,...);
 extern void xlog_panic(char *fmt,...);
 
-#define xlog_get_bp(log,bbs)   libxfs_getbuf(x.logdev, (xfs_daddr_t)-1, (bbs))
-#define xlog_put_bp(bp)                libxfs_putbuf(bp)
+#define xlog_get_bp(log,bbs)   libxfs_getbufr(x.logdev, (xfs_daddr_t)-1, (bbs))
+#define xlog_put_bp(bp)                libxfs_putbufr(bp)
 #define xlog_bread(log,blkno,bbs,bp)   \
        (libxfs_readbufr(x.logdev,      \
                        (log)->l_logBBstart+(blkno), bp, (bbs), 1), 0)
index 76e0f109a112e6fcde7684cc0886d6d6c51cb318..d19022f29000ec7a923d2b3929841d609526e95f 100644 (file)
@@ -108,7 +108,7 @@ libxfs_log_clear(
        int                     sunit,
        int                     fmt)
 {
-       xfs_buf_t               *buf;
+       xfs_buf_t               *bp;
        int                     len;
 
        if (!device || !fs_uuid)
@@ -120,11 +120,11 @@ libxfs_log_clear(
        /* then write a log record header */
        len = ((version == 2) && sunit) ? BTOBB(sunit) : 2;
        len = MAX(len, 2);
-       buf = libxfs_getbuf(device, start, len);
-       libxfs_log_header(XFS_BUF_PTR(buf),
-                         fs_uuid, version, sunit, fmt, next, buf);
-       libxfs_writebufr(buf);
-       libxfs_putbuf(buf);
+       bp = libxfs_getbufr(device, start, len);
+       libxfs_log_header(XFS_BUF_PTR(bp),
+                         fs_uuid, version, sunit, fmt, next, bp);
+       bp->b_flags |= LIBXFS_B_DIRTY;
+       libxfs_putbufr(bp);
        return 0;
 }
 
@@ -238,6 +238,60 @@ libxfs_bprint(xfs_buf_t *bp)
                bp->b_flags, bp->b_node.cn_count);
 }
 
+static void
+libxfs_brelse(struct cache_node *node)
+{
+       xfs_buf_t               *bp = (xfs_buf_t *)node;
+       xfs_buf_log_item_t      *bip;
+       extern xfs_zone_t       *xfs_buf_item_zone;
+
+       if (bp != NULL) {
+               if (bp->b_flags & LIBXFS_B_DIRTY)
+                       libxfs_writebufr(bp);
+               bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
+               if (bip)
+                   libxfs_zone_free(xfs_buf_item_zone, bip);
+               free(bp->b_addr);
+               bp->b_addr = NULL;
+               bp->b_flags = 0;
+               free(bp);
+               bp = NULL;
+       }
+}
+
+static void
+libxfs_initbuf(xfs_buf_t *bp, dev_t device, xfs_daddr_t bno, unsigned int bytes)
+{
+       bp->b_flags = 0;
+       bp->b_blkno = bno;
+       bp->b_bcount = bytes;
+       bp->b_dev = device;
+       bp->b_addr = memalign(libxfs_device_alignment(), bytes);
+       if (!bp->b_addr) {
+               fprintf(stderr,
+                       _("%s: %s can't memalign %u bytes: %s\n"),
+                       progname, __FUNCTION__, bytes,
+                       strerror(errno));
+               exit(1);
+       }
+}
+
+xfs_buf_t *
+libxfs_getbufr(dev_t device, xfs_daddr_t blkno, int len)
+{
+       xfs_buf_t       *bp;
+
+       bp = libxfs_zone_zalloc(xfs_buf_zone);
+       libxfs_initbuf(bp, device, blkno, BBTOB(len));
+       return bp;
+}
+
+void
+libxfs_putbufr(xfs_buf_t *bp)
+{
+       libxfs_brelse((struct cache_node *)bp);
+}
+
 xfs_buf_t *
 libxfs_getbuf(dev_t device, xfs_daddr_t blkno, int len)
 {
@@ -254,18 +308,7 @@ libxfs_getbuf(dev_t device, xfs_daddr_t blkno, int len)
                fprintf(stderr, "%s: allocated buffer, key=%llu(%llu), %p\n",
                        __FUNCTION__, BBTOB(len), LIBXFS_BBTOOFF64(blkno), blkno, buf);
 #endif
-               bp->b_flags = 0;
-               bp->b_blkno = blkno;
-               bp->b_bcount = bytes;
-               bp->b_dev = device;
-               bp->b_addr = memalign(libxfs_device_alignment(), bytes);
-               if (!bp->b_addr) {
-                       fprintf(stderr,
-                               _("%s: %s can't memalign %d bytes: %s\n"),
-                               progname, __FUNCTION__, (int)bytes,
-                               strerror(errno));
-                       exit(1);
-               }
+               libxfs_initbuf(bp, device, blkno, bytes);
        }
        return bp;
 }
@@ -415,27 +458,6 @@ libxfs_bflush(struct cache_node *node)
                libxfs_writebufr(bp);
 }
 
-static void
-libxfs_brelse(struct cache_node *node)
-{
-       xfs_buf_t               *bp = (xfs_buf_t *)node;
-       xfs_buf_log_item_t      *bip;
-       extern xfs_zone_t       *xfs_buf_item_zone;
-
-       if (bp != NULL) {
-               if (bp->b_flags & LIBXFS_B_DIRTY)
-                       libxfs_writebufr(bp);
-               bip = XFS_BUF_FSPRIVATE(bp, xfs_buf_log_item_t *);
-               if (bip)
-                   libxfs_zone_free(xfs_buf_item_zone, bip);
-               free(bp->b_addr);
-               bp->b_addr = NULL;
-               bp->b_flags = 0;
-               free(bp);
-               bp = NULL;
-       }
-}
-
 void
 libxfs_bcache_purge(void)
 {