Skip to content

Commit

Permalink
TEST ONLY Force blk-mq to be unsettable for sanity
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Hutter <[email protected]>
Requires-builders: fedora38
  • Loading branch information
tonyhutter committed May 23, 2023
1 parent a0df678 commit 6f432ec
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/sys/zil.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ extern void zil_kstat_values_update(zil_kstat_values_t *zs,

extern int zil_replay_disable;

void zil_log(zilog_t *zilog, const char* fmt, ...);
void zil_log_print(zilog_t *zilog);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions include/sys/zil_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ typedef struct zil_vdev_node {

#define ZIL_PREV_BLKS 16

#define ZIL_LOG_LEN 150
/*
* Stable storage intent log management structure. One per dataset.
*/
Expand Down Expand Up @@ -225,6 +226,9 @@ struct zilog {

/* Pointer for per dataset zil sums */
zil_sums_t *zl_sums;

uint64_t pos;
char log[ZIL_LOG_LEN][80];
};

typedef struct zil_bp_node {
Expand Down
4 changes: 2 additions & 2 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,8 +1602,8 @@ MODULE_PARM_DESC(zvol_volmode, "Default volmode property value");
module_param(zvol_blk_mq_queue_depth, uint, 0644);
MODULE_PARM_DESC(zvol_blk_mq_queue_depth, "Default blk-mq queue depth");

module_param(zvol_use_blk_mq, uint, 0644);
MODULE_PARM_DESC(zvol_use_blk_mq, "Use the blk-mq API for zvols");
// module_param(zvol_use_blk_mq, uint, 0644);
// MODULE_PARM_DESC(zvol_use_blk_mq, "Use the blk-mq API for zvols");

module_param(zvol_blk_mq_blocks_per_thread, uint, 0644);
MODULE_PARM_DESC(zvol_blk_mq_blocks_per_thread,
Expand Down
43 changes: 42 additions & 1 deletion module/zfs/zil.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
#include <sys/brt.h>
#include <sys/wmsum.h>

#ifdef _KERNEL
#include <linux/module.h> /* Needed by all modules */
#endif


/*
* The ZFS Intent Log (ZIL) saves "transaction records" (itxs) of system
* calls that change the file system. Each itx has enough information to
Expand Down Expand Up @@ -146,6 +151,32 @@ static uint64_t zil_slog_bulk = 768 * 1024;
static kmem_cache_t *zil_lwb_cache;
static kmem_cache_t *zil_zcw_cache;

void zil_log(zilog_t *zilog, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
uint64_t pos = zilog->pos;
zilog->pos += 1;

if (pos > ZIL_LOG_LEN)
goto end;

vsprintf(zilog->log[pos], fmt, args);
end:
va_end(args);
}

void zil_log_print(zilog_t *zilog __attribute__((unused)))
{
#ifdef _KERNEL
uint64_t i;
for (i = 0; i < zilog->pos; i++) {
if (zilog->log[i][0] != 0)
printk("%llu: %s\n", i, zilog->log[i]);
}
#endif
}

static int
zil_bp_compare(const void *x1, const void *x2)
{
Expand Down Expand Up @@ -894,15 +925,23 @@ zil_create(zilog_t *zilog)
boolean_t fastwrite = FALSE;
boolean_t slog = FALSE;
dsl_dataset_t *ds = dmu_objset_ds(zilog->zl_os);
static int print_once = 0;


/*
* Wait for any previous destroy to complete.
*/
txg_wait_synced(zilog->zl_dmu_pool, zilog->zl_destroy_txg);

if (print_once % 1000 == 0 || zh->zh_replay_seq == 0) {
zil_log_print(zilog);
}
print_once++;

ASSERT3U(zh->zh_claim_txg, ==, 0);

ASSERT(zh->zh_replay_seq == 0);


blk = zh->zh_log;

Expand Down Expand Up @@ -1131,6 +1170,7 @@ zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
if (zh->zh_claim_txg == 0 && !BP_IS_HOLE(&zh->zh_log)) {
(void) zil_parse(zilog, zil_claim_log_block,
zil_claim_log_record, tx, first_txg, B_FALSE);
zil_log(zilog, "%s: setting %p to %d\n", __func__, zh, first_txg);
zh->zh_claim_txg = first_txg;
zh->zh_claim_blk_seq = zilog->zl_parse_blk_seq;
zh->zh_claim_lr_seq = zilog->zl_parse_lr_seq;
Expand Down Expand Up @@ -3392,7 +3432,7 @@ zil_sync(zilog_t *zilog, dmu_tx_t *tx)
dsl_dataset_t *ds = dmu_objset_ds(zilog->zl_os);

ASSERT(list_is_empty(&zilog->zl_lwb_list));

zil_log(zilog, "%s: %p memsetting zh", __func__, zh);
memset(zh, 0, sizeof (zil_header_t));
memset(zilog->zl_replayed_seq, 0,
sizeof (zilog->zl_replayed_seq));
Expand Down Expand Up @@ -3535,6 +3575,7 @@ zil_alloc(objset_t *os, zil_header_t *zh_phys)

zilog = kmem_zalloc(sizeof (zilog_t), KM_SLEEP);

zil_log(zilog, "%s: allocated %p\n", __func__, zh_phys);
zilog->zl_header = zh_phys;
zilog->zl_os = os;
zilog->zl_spa = dmu_objset_spa(os);
Expand Down

0 comments on commit 6f432ec

Please sign in to comment.