Skip to content

Commit

Permalink
Merge branch 'master' into parallel_arc_evict
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Stetsenko <[email protected]>
  • Loading branch information
alex-stetsenko authored Dec 10, 2024
2 parents 40d0f59 + e0039c7 commit 558bb2c
Show file tree
Hide file tree
Showing 95 changed files with 1,070 additions and 492 deletions.
2 changes: 1 addition & 1 deletion META
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Release: 1
Release-Tags: relext
License: CDDL
Author: OpenZFS
Linux-Maximum: 6.11
Linux-Maximum: 6.12
Linux-Minimum: 4.18
111 changes: 86 additions & 25 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,17 +1967,53 @@ dump_dedup_ratio(const ddt_stat_t *dds)
static void
dump_ddt_log(ddt_t *ddt)
{
if (ddt->ddt_version != DDT_VERSION_FDT ||
!(ddt->ddt_flags & DDT_FLAG_LOG))
return;

for (int n = 0; n < 2; n++) {
ddt_log_t *ddl = &ddt->ddt_log[n];

uint64_t count = avl_numnodes(&ddl->ddl_tree);
if (count == 0)
continue;
char flagstr[64] = {0};
if (ddl->ddl_flags > 0) {
flagstr[0] = ' ';
int c = 1;
if (ddl->ddl_flags & DDL_FLAG_FLUSHING)
c += strlcpy(&flagstr[c], " FLUSHING",
sizeof (flagstr) - c);
if (ddl->ddl_flags & DDL_FLAG_CHECKPOINT)
c += strlcpy(&flagstr[c], " CHECKPOINT",
sizeof (flagstr) - c);
if (ddl->ddl_flags &
~(DDL_FLAG_FLUSHING|DDL_FLAG_CHECKPOINT))
c += strlcpy(&flagstr[c], " UNKNOWN",
sizeof (flagstr) - c);
flagstr[1] = '[';
flagstr[c++] = ']';
}

printf(DMU_POOL_DDT_LOG ": %lu log entries\n",
zio_checksum_table[ddt->ddt_checksum].ci_name, n, count);
uint64_t count = avl_numnodes(&ddl->ddl_tree);

if (dump_opt['D'] < 4)
printf(DMU_POOL_DDT_LOG ": flags=0x%02x%s; obj=%llu; "
"len=%llu; txg=%llu; entries=%llu\n",
zio_checksum_table[ddt->ddt_checksum].ci_name, n,
ddl->ddl_flags, flagstr,
(u_longlong_t)ddl->ddl_object,
(u_longlong_t)ddl->ddl_length,
(u_longlong_t)ddl->ddl_first_txg, (u_longlong_t)count);

if (ddl->ddl_flags & DDL_FLAG_CHECKPOINT) {
const ddt_key_t *ddk = &ddl->ddl_checkpoint;
printf(" checkpoint: "
"%016llx:%016llx:%016llx:%016llx:%016llx\n",
(u_longlong_t)ddk->ddk_cksum.zc_word[0],
(u_longlong_t)ddk->ddk_cksum.zc_word[1],
(u_longlong_t)ddk->ddk_cksum.zc_word[2],
(u_longlong_t)ddk->ddk_cksum.zc_word[3],
(u_longlong_t)ddk->ddk_prop);
}

if (count == 0 || dump_opt['D'] < 4)
continue;

ddt_lightweight_entry_t ddlwe;
Expand All @@ -1991,7 +2027,7 @@ dump_ddt_log(ddt_t *ddt)
}

static void
dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
dump_ddt_object(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
{
char name[DDT_NAMELEN];
ddt_lightweight_entry_t ddlwe;
Expand All @@ -2016,11 +2052,8 @@ dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)

ddt_object_name(ddt, type, class, name);

(void) printf("%s: %llu entries, size %llu on disk, %llu in core\n",
name,
(u_longlong_t)count,
(u_longlong_t)dspace,
(u_longlong_t)mspace);
(void) printf("%s: dspace=%llu; mspace=%llu; entries=%llu\n", name,
(u_longlong_t)dspace, (u_longlong_t)mspace, (u_longlong_t)count);

if (dump_opt['D'] < 3)
return;
Expand All @@ -2043,24 +2076,52 @@ dump_ddt(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
(void) printf("\n");
}

static void
dump_ddt(ddt_t *ddt)
{
if (!ddt || ddt->ddt_version == DDT_VERSION_UNCONFIGURED)
return;

char flagstr[64] = {0};
if (ddt->ddt_flags > 0) {
flagstr[0] = ' ';
int c = 1;
if (ddt->ddt_flags & DDT_FLAG_FLAT)
c += strlcpy(&flagstr[c], " FLAT",
sizeof (flagstr) - c);
if (ddt->ddt_flags & DDT_FLAG_LOG)
c += strlcpy(&flagstr[c], " LOG",
sizeof (flagstr) - c);
if (ddt->ddt_flags & ~DDT_FLAG_MASK)
c += strlcpy(&flagstr[c], " UNKNOWN",
sizeof (flagstr) - c);
flagstr[1] = '[';
flagstr[c] = ']';
}

printf("DDT-%s: version=%llu [%s]; flags=0x%02llx%s; rootobj=%llu\n",
zio_checksum_table[ddt->ddt_checksum].ci_name,
(u_longlong_t)ddt->ddt_version,
(ddt->ddt_version == 0) ? "LEGACY" :
(ddt->ddt_version == 1) ? "FDT" : "UNKNOWN",
(u_longlong_t)ddt->ddt_flags, flagstr,
(u_longlong_t)ddt->ddt_dir_object);

for (ddt_type_t type = 0; type < DDT_TYPES; type++)
for (ddt_class_t class = 0; class < DDT_CLASSES; class++)
dump_ddt_object(ddt, type, class);

dump_ddt_log(ddt);
}

static void
dump_all_ddts(spa_t *spa)
{
ddt_histogram_t ddh_total = {{{0}}};
ddt_stat_t dds_total = {0};

for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
ddt_t *ddt = spa->spa_ddt[c];
if (!ddt || ddt->ddt_version == DDT_VERSION_UNCONFIGURED)
continue;
for (ddt_type_t type = 0; type < DDT_TYPES; type++) {
for (ddt_class_t class = 0; class < DDT_CLASSES;
class++) {
dump_ddt(ddt, type, class);
}
}
dump_ddt_log(ddt);
}
for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++)
dump_ddt(spa->spa_ddt[c]);

ddt_get_dedup_stats(spa, &dds_total);

Expand Down Expand Up @@ -6892,7 +6953,7 @@ iterate_deleted_livelists(spa_t *spa, ll_iter_t func, void *arg)
for (zap_cursor_init(&zc, mos, zap_obj);
zap_cursor_retrieve(&zc, attrp) == 0;
(void) zap_cursor_advance(&zc)) {
dsl_deadlist_open(&ll, mos, attrp->za_first_integer);
VERIFY0(dsl_deadlist_open(&ll, mos, attrp->za_first_integer));
func(&ll, arg);
dsl_deadlist_close(&ll);
}
Expand Down
22 changes: 11 additions & 11 deletions cmd/zdb/zdb_il.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ zil_prt_rec_create(zilog_t *zilog, int txtype, const void *arg)
const lr_create_t *lrc = arg;
const _lr_create_t *lr = &lrc->lr_create;
time_t crtime = lr->lr_crtime[0];
char *name, *link;
const char *name, *link;
lr_attr_t *lrattr;

name = (char *)(lr + 1);
name = (const char *)&lrc->lr_data[0];

if (lr->lr_common.lrc_txtype == TX_CREATE_ATTR ||
lr->lr_common.lrc_txtype == TX_MKDIR_ATTR) {
lrattr = (lr_attr_t *)(lr + 1);
lrattr = (lr_attr_t *)&lrc->lr_data[0];
name += ZIL_XVAT_SIZE(lrattr->lr_attr_masksize);
}

if (txtype == TX_SYMLINK) {
link = name + strlen(name) + 1;
link = (const char *)&lrc->lr_data[strlen(name) + 1];
(void) printf("%s%s -> %s\n", tab_prefix, name, link);
} else if (txtype != TX_MKXATTR) {
(void) printf("%s%s\n", tab_prefix, name);
Expand All @@ -104,7 +104,7 @@ zil_prt_rec_remove(zilog_t *zilog, int txtype, const void *arg)
const lr_remove_t *lr = arg;

(void) printf("%sdoid %llu, name %s\n", tab_prefix,
(u_longlong_t)lr->lr_doid, (char *)(lr + 1));
(u_longlong_t)lr->lr_doid, (const char *)&lr->lr_data[0]);
}

static void
Expand All @@ -115,7 +115,7 @@ zil_prt_rec_link(zilog_t *zilog, int txtype, const void *arg)

(void) printf("%sdoid %llu, link_obj %llu, name %s\n", tab_prefix,
(u_longlong_t)lr->lr_doid, (u_longlong_t)lr->lr_link_obj,
(char *)(lr + 1));
(const char *)&lr->lr_data[0]);
}

static void
Expand All @@ -124,8 +124,8 @@ zil_prt_rec_rename(zilog_t *zilog, int txtype, const void *arg)
(void) zilog, (void) txtype;
const lr_rename_t *lrr = arg;
const _lr_rename_t *lr = &lrr->lr_rename;
char *snm = (char *)(lr + 1);
char *tnm = snm + strlen(snm) + 1;
const char *snm = (const char *)&lrr->lr_data[0];
const char *tnm = (const char *)&lrr->lr_data[strlen(snm) + 1];

(void) printf("%ssdoid %llu, tdoid %llu\n", tab_prefix,
(u_longlong_t)lr->lr_sdoid, (u_longlong_t)lr->lr_tdoid);
Expand Down Expand Up @@ -211,7 +211,7 @@ zil_prt_rec_write(zilog_t *zilog, int txtype, const void *arg)

/* data is stored after the end of the lr_write record */
data = abd_alloc(lr->lr_length, B_FALSE);
abd_copy_from_buf(data, lr + 1, lr->lr_length);
abd_copy_from_buf(data, &lr->lr_data[0], lr->lr_length);
}

(void) printf("%s", tab_prefix);
Expand Down Expand Up @@ -309,7 +309,7 @@ zil_prt_rec_setsaxattr(zilog_t *zilog, int txtype, const void *arg)
(void) zilog, (void) txtype;
const lr_setsaxattr_t *lr = arg;

char *name = (char *)(lr + 1);
const char *name = (const char *)&lr->lr_data[0];
(void) printf("%sfoid %llu\n", tab_prefix,
(u_longlong_t)lr->lr_foid);

Expand All @@ -318,7 +318,7 @@ zil_prt_rec_setsaxattr(zilog_t *zilog, int txtype, const void *arg)
(void) printf("%sXAT_VALUE NULL\n", tab_prefix);
} else {
(void) printf("%sXAT_VALUE ", tab_prefix);
char *val = name + (strlen(name) + 1);
const char *val = (const char *)&lr->lr_data[strlen(name) + 1];
for (int i = 0; i < lr->lr_size; i++) {
(void) printf("%c", *val);
val++;
Expand Down
32 changes: 25 additions & 7 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ get_usage(zpool_help_t idx)
return (gettext("\tinitialize [-c | -s | -u] [-w] <pool> "
"[<device> ...]\n"));
case HELP_SCRUB:
return (gettext("\tscrub [-s | -p] [-w] [-e] <pool> ...\n"));
return (gettext("\tscrub [-e | -s | -p | -C] [-w] "
"<pool> ...\n"));
case HELP_RESILVER:
return (gettext("\tresilver <pool> ...\n"));
case HELP_TRIM:
Expand Down Expand Up @@ -8429,12 +8430,13 @@ wait_callback(zpool_handle_t *zhp, void *data)
}

/*
* zpool scrub [-s | -p] [-w] [-e] <pool> ...
* zpool scrub [-e | -s | -p | -C] [-w] <pool> ...
*
* -e Only scrub blocks in the error log.
* -s Stop. Stops any in-progress scrub.
* -p Pause. Pause in-progress scrub.
* -w Wait. Blocks until scrub has completed.
* -C Scrub from last saved txg.
*/
int
zpool_do_scrub(int argc, char **argv)
Expand All @@ -8450,9 +8452,10 @@ zpool_do_scrub(int argc, char **argv)
boolean_t is_error_scrub = B_FALSE;
boolean_t is_pause = B_FALSE;
boolean_t is_stop = B_FALSE;
boolean_t is_txg_continue = B_FALSE;

/* check options */
while ((c = getopt(argc, argv, "spwe")) != -1) {
while ((c = getopt(argc, argv, "spweC")) != -1) {
switch (c) {
case 'e':
is_error_scrub = B_TRUE;
Expand All @@ -8466,6 +8469,9 @@ zpool_do_scrub(int argc, char **argv)
case 'w':
wait = B_TRUE;
break;
case 'C':
is_txg_continue = B_TRUE;
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
Expand All @@ -8477,6 +8483,18 @@ zpool_do_scrub(int argc, char **argv)
(void) fprintf(stderr, gettext("invalid option "
"combination :-s and -p are mutually exclusive\n"));
usage(B_FALSE);
} else if (is_pause && is_txg_continue) {
(void) fprintf(stderr, gettext("invalid option "
"combination :-p and -C are mutually exclusive\n"));
usage(B_FALSE);
} else if (is_stop && is_txg_continue) {
(void) fprintf(stderr, gettext("invalid option "
"combination :-s and -C are mutually exclusive\n"));
usage(B_FALSE);
} else if (is_error_scrub && is_txg_continue) {
(void) fprintf(stderr, gettext("invalid option "
"combination :-e and -C are mutually exclusive\n"));
usage(B_FALSE);
} else {
if (is_error_scrub)
cb.cb_type = POOL_SCAN_ERRORSCRUB;
Expand All @@ -8485,6 +8503,8 @@ zpool_do_scrub(int argc, char **argv)
cb.cb_scrub_cmd = POOL_SCRUB_PAUSE;
} else if (is_stop) {
cb.cb_type = POOL_SCAN_NONE;
} else if (is_txg_continue) {
cb.cb_scrub_cmd = POOL_SCRUB_FROM_LAST_TXG;
} else {
cb.cb_scrub_cmd = POOL_SCRUB_NORMAL;
}
Expand Down Expand Up @@ -10034,9 +10054,8 @@ print_removal_status(zpool_handle_t *zhp, pool_removal_stat_t *prs)
(void) printf(gettext("Removal of %s canceled on %s"),
vdev_name, ctime(&end));
} else {
uint64_t copied, total, elapsed, mins_left, hours_left;
uint64_t copied, total, elapsed, rate, mins_left, hours_left;
double fraction_done;
uint_t rate;

assert(prs->prs_state == DSS_SCANNING);

Expand Down Expand Up @@ -10132,9 +10151,8 @@ print_raidz_expand_status(zpool_handle_t *zhp, pool_raidz_expand_stat_t *pres)
copied_buf, time_buf, ctime((time_t *)&end));
} else {
char examined_buf[7], total_buf[7], rate_buf[7];
uint64_t copied, total, elapsed, secs_left;
uint64_t copied, total, elapsed, rate, secs_left;
double fraction_done;
uint_t rate;

assert(pres->pres_state == DSS_SCANNING);

Expand Down
2 changes: 1 addition & 1 deletion config/kernel-register_sysctl_table.m4
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_REGISTER_SYSCTL_SZ], [
ZFS_LINUX_TEST_SRC([has_register_sysctl_sz], [
#include <linux/sysctl.h>
],[
struct ctl_table test_table[] __attribute__((unused)) = {0};
struct ctl_table test_table[] __attribute__((unused)) = {{}};
register_sysctl_sz("", test_table, 0);
])
])
Expand Down
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
__FILE__, __FUNCTION__, __LINE__))

#define VERIFYF(cond, str, ...) do { \
if (unlikely(!cond)) \
if (unlikely(!(cond))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY(" #cond ") failed " str "\n", __VA_ARGS__);\
} while (0)
Expand Down
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/sys/sdt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

#include_next <sys/sdt.h>
#ifdef KDTRACE_HOOKS
/* BEGIN CSTYLED */
SDT_PROBE_DECLARE(sdt, , , set__error);

/* BEGIN CSTYLED */
#define SET_ERROR(err) ({ \
SDT_PROBE1(sdt, , , set__error, (uintptr_t)err); \
err; \
Expand Down
Loading

0 comments on commit 558bb2c

Please sign in to comment.