]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: conditionalize log format record size optimization
authorBrian Foster <bfoster@redhat.com>
Fri, 18 Dec 2015 01:14:39 +0000 (12:14 +1100)
committerDave Chinner <david@fromorbit.com>
Fri, 18 Dec 2015 01:14:39 +0000 (12:14 +1100)
The libxfs log clear mechanism includes an optimization to use the
maximum log buffer size (256k) when the log is being fully written
(i.e., cycle != 1). This behavior is always enabled as no current
callers are concerned with the size of the records written to format the
log to a given cycle.

A log format command will be added to xfs_db to facilitate testing of
the userspace log format code (among other things). This command is not
performance oriented and prefers the ability to format the log with
varying record sizes.

Update libxfs_log_clear() to use a new parameter to enable or disable
the record size optimization. Note that the flag is a no-op when the
cycle == XLOG_INIT_CYCLE (e.g., mkfs).

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
copy/xfs_copy.c
db/metadump.c
db/sb.c
include/libxfs.h
libxfs/rdwr.c
mkfs/xfs_mkfs.c
repair/phase2.c
repair/xfs_repair.c

index 1dc7c6500bc69dd66d6c27054c0b21039d7b4bc8..62edfc834b2fdde213bba1fcbfe2bf4db4a62291 100644 (file)
@@ -1328,7 +1328,7 @@ format_log(
         */
        libxfs_log_clear(NULL, buf->data, logstart, length, &buf->owner->uuid,
                         xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
-                        mp->m_sb.sb_logsunit, XLOG_FMT, cycle);
+                        mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true);
        if (do_write(buf->owner, buf))
                target[tcarg->id].state = INACTIVE;
 }
index 8cdcb92e8848903b84710de29f7587454c2df802..8455fdd60f99d83b0f568e7a79463dc0bcd234ae 100644 (file)
@@ -2552,7 +2552,7 @@ copy_log(void)
 
                libxfs_log_clear(NULL, iocur_top->data, logstart, logblocks,
                                 &mp->m_sb.sb_uuid, logversion,
-                                mp->m_sb.sb_logsunit, XLOG_FMT, cycle);
+                                mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true);
                break;
        case 1:
                /* keep the dirty log */
diff --git a/db/sb.c b/db/sb.c
index 17d446ceca739252850727ec246aef6c816adea9..ee3927dd262695b0d63321535d4d6a9d9ef3bac2 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -288,7 +288,7 @@ sb_logzero(uuid_t *uuidp)
                        (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
                        uuidp,
                        xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
-                       mp->m_sb.sb_logsunit, XLOG_FMT, cycle);
+                       mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true);
        if (error) {
                dbprintf(_("ERROR: cannot clear the log\n"));
                return 0;
index 04c6f9c74e7b4a5ad0e250a85b1029b1c6b0b33a..bd51df0d7418e9a2b27913605779393f1751f072 100644 (file)
@@ -154,7 +154,7 @@ typedef char        *(libxfs_get_block_t)(char *, int, void *);
  */
 #define XLOG_INIT_CYCLE        1
 extern int     libxfs_log_clear(struct xfs_buftarg *, char *, xfs_daddr_t,
-                                uint, uuid_t *, int, int, int, int);
+                                uint, uuid_t *, int, int, int, int, bool);
 extern int     libxfs_log_header(char *, uuid_t *, int, int, int, xfs_lsn_t,
                                  xfs_lsn_t, libxfs_get_block_t *, void *);
 
index 16904d0b0022ea4ede076f508e4e34c5893dea08..7a049850971a3e76fb39d778696f4421bc56e01a 100644 (file)
@@ -162,7 +162,8 @@ libxfs_log_clear(
        int                     version,
        int                     sunit,          /* bytes */
        int                     fmt,
-       int                     cycle)
+       int                     cycle,
+       bool                    max)
 {
        struct xfs_buf          *bp = NULL;
        int                     len;
@@ -217,6 +218,14 @@ libxfs_log_clear(
        if (cycle == XLOG_INIT_CYCLE)
                return 0;
 
+       /*
+        * Bump the record size for a full log format if the caller allows it.
+        * This is primarily for performance reasons and most callers don't care
+        * about record size since the log is clean after we're done.
+        */
+       if (max)
+               len = BTOBB(BDSTRAT_SIZE);
+
        /*
         * Otherwise, fill everything beyond the initial record with records of
         * the previous cycle so the kernel head/tail detection works correctly.
@@ -233,7 +242,7 @@ libxfs_log_clear(
                dptr += BBTOB(len);
        end_blk = start + length;
 
-       len = min(end_blk - blk, BTOBB(BDSTRAT_SIZE));
+       len = min(end_blk - blk, len);
        while (blk < end_blk) {
                lsn = xlog_assign_lsn(cycle, blk - start);
                tail_lsn = xlog_assign_lsn(cycle, blk - start - len);
@@ -257,7 +266,7 @@ libxfs_log_clear(
                blk += len;
                if (dptr)
                        dptr += BBTOB(len);
-               len = min(end_blk - blk, BTOBB(BDSTRAT_SIZE));
+               len = min(end_blk - blk, len);
        }
 
        return 0;
index 7cba41a69dcbbc325394cc94c8130c27321d8349..546108dda9085942bd95a3174dc0c28d780d26b0 100644 (file)
@@ -2713,7 +2713,8 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
        libxfs_log_clear(mp->m_logdev_targp, NULL,
                XFS_FSB_TO_DADDR(mp, logstart),
                (xfs_extlen_t)XFS_FSB_TO_BB(mp, logblocks),
-               &sbp->sb_uuid, logversion, lsunit, XLOG_FMT, XLOG_INIT_CYCLE);
+               &sbp->sb_uuid, logversion, lsunit, XLOG_FMT, XLOG_INIT_CYCLE,
+               false);
 
        mp = libxfs_mount(mp, sbp, xi.ddev, xi.logdev, xi.rtdev, 0);
        if (mp == NULL) {
index cb24711d23fe4a7a4e7da772863932ce9d90afe1..e21ffa66cb3edc06b57a7de891b3f4bab31c4c08 100644 (file)
@@ -119,7 +119,7 @@ zero_log(
                        (xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
                        &mp->m_sb.sb_uuid,
                        xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
-                       mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE);
+                       mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE, true);
 
                /* update the log data structure with new state */
                error = xlog_find_tail(log, &head_blk, &tail_blk);
index 1aeac5ba456d9f225a1294e40f11138996bf9ab5..3eaced4b0be6ea0824d9bc8fd6096253e04f457a 100644 (file)
@@ -586,7 +586,7 @@ format_log_max_lsn(
        do_warn(_("Format log to cycle %d.\n"), new_cycle);
        libxfs_log_clear(log->l_dev, NULL, logstart, logblocks,
                         &mp->m_sb.sb_uuid, logversion, mp->m_sb.sb_logsunit,
-                        XLOG_FMT, new_cycle);
+                        XLOG_FMT, new_cycle, true);
 }
 
 int