#include "proto.h"
#include <ini.h>
-#define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog)))
-#define GIGABYTES(count, blog) ((uint64_t)(count) << (30 - (blog)))
-#define MEGABYTES(count, blog) ((uint64_t)(count) << (20 - (blog)))
+/* Convert a quantity of mega/giga/terabytes into units of blocks */
+#define TERABLOCKS(count, blog) ((uint64_t)(count) << (40 - (blog)))
+#define GIGABLOCKS(count, blog) ((uint64_t)(count) << (30 - (blog)))
+#define MEGABLOCKS(count, blog) ((uint64_t)(count) << (20 - (blog)))
/*
* Realistically, the log should never be smaller than 64MB. Studies by the
* latency of the xlog grant head waitqueue when running a heavy metadata
* update workload when the log size is at least 64MB.
*/
-#define XFS_MIN_REALISTIC_LOG_BLOCKS(blog) (MEGABYTES(64, (blog)))
+#define XFS_MIN_REALISTIC_LOG_BLOCKS(blog) (MEGABLOCKS(64, (blog)))
/*
* Use this macro before we have superblock and mount structure to
*
* 64MB * (8 / 7) * 4 = 293MB
*/
- if (mp->m_sb.sb_dblocks < MEGABYTES(300, mp->m_sb.sb_blocklog)) {
+ if (mp->m_sb.sb_dblocks < MEGABLOCKS(300, mp->m_sb.sb_blocklog)) {
fprintf(stderr,
_("Filesystem must be larger than 300MB.\n"));
usage();
BBTOB(ft->data.sunit), BBTOB(ft->data.swidth));
ft->data.sunit = 0;
ft->data.swidth = 0;
- } else if (cfg->dblocks < GIGABYTES(1, cfg->blocklog)) {
+ } else if (cfg->dblocks < GIGABLOCKS(1, cfg->blocklog)) {
/*
* Don't use automatic stripe detection if the device
* size is less than 1GB because the performance gains
*/
try_threads = nr_threads;
try_agsize = cfg->dblocks / try_threads;
- if (try_agsize < GIGABYTES(4, cfg->blocklog)) {
+ if (try_agsize < GIGABLOCKS(4, cfg->blocklog)) {
do {
try_threads--;
if (try_threads <= def_agcount) {
}
try_agsize = cfg->dblocks / try_threads;
- } while (try_agsize < GIGABYTES(4, cfg->blocklog));
+ } while (try_agsize < GIGABLOCKS(4, cfg->blocklog));
goto out;
}
*/
try_threads = nr_threads;
try_rgsize = cfg->rtblocks / try_threads;
- if (try_rgsize < GIGABYTES(4, cfg->blocklog)) {
+ if (try_rgsize < GIGABLOCKS(4, cfg->blocklog)) {
do {
try_threads--;
if (try_threads <= def_rgcount) {
}
try_rgsize = cfg->rtblocks / try_threads;
- } while (try_rgsize < GIGABYTES(4, cfg->blocklog));
+ } while (try_rgsize < GIGABLOCKS(4, cfg->blocklog));
goto out;
}
* If nobody specified a realtime device or the rtgroup size,
* try 1TB, rounded down to the nearest rt extent.
*/
- cfg->rgsize = TERABYTES(1, cfg->blocklog);
+ cfg->rgsize = TERABLOCKS(1, cfg->blocklog);
cfg->rgsize -= cfg->rgsize % cfg->rtextblocks;
cfg->rgcount = 0;
} else if (cfg->rtblocks < cfg->rtextblocks * 2) {
(cfg->rtblocks % cfg->rgcount != 0);
} else {
/* 256MB zones just like typical SMR HDDs */
- cfg->rgsize = MEGABYTES(256, cfg->blocklog);
+ cfg->rgsize = MEGABLOCKS(256, cfg->blocklog);
cfg->rgcount = cfg->rtblocks / cfg->rgsize +
(cfg->rtblocks % cfg->rgsize != 0);
}
* - under 1 TB, use XFS_DFL_IMAXIMUM_PCT (25%).
*/
- if (cfg->dblocks < TERABYTES(1, cfg->blocklog))
+ if (cfg->dblocks < TERABLOCKS(1, cfg->blocklog))
cfg->imaxpct = XFS_DFL_IMAXIMUM_PCT;
- else if (cfg->dblocks < TERABYTES(50, cfg->blocklog))
+ else if (cfg->dblocks < TERABLOCKS(50, cfg->blocklog))
cfg->imaxpct = 5;
else
cfg->imaxpct = 1;
* If this filesystem is smaller than a gigabyte, there's little to be
* gained from making the log larger.
*/
- if (cfg->dblocks < GIGABYTES(1, cfg->blocklog))
+ if (cfg->dblocks < GIGABLOCKS(1, cfg->blocklog))
goto out;
/*
XFS_MIN_REALISTIC_LOG_BLOCKS(cfg->blocklog));
/* And for a tiny filesystem, use the absolute minimum size */
- if (cfg->dblocks < MEGABYTES(300, cfg->blocklog))
+ if (cfg->dblocks < MEGABLOCKS(300, cfg->blocklog))
cfg->logblocks = min_logblocks;
/* Ensure the chosen size fits within log size requirements */