Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jwk404 committed Jul 21, 2022
2 parents 470f24b + bf61a50 commit fe74aa6
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 79 deletions.
9 changes: 8 additions & 1 deletion cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3590,8 +3590,15 @@ dump_object(objset_t *os, uint64_t object, int verbosity,
*print_header = B_TRUE;
}

if (verbosity >= 5)
if (verbosity >= 5) {
if (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR) {
char blkbuf[BP_SPRINTF_LEN];
snprintf_blkptr_compact(blkbuf, sizeof (blkbuf),
DN_SPILL_BLKPTR(dn->dn_phys), B_FALSE);
(void) printf("\nSpill block: %s\n", blkbuf);
}
dump_indirect(dn);
}

if (verbosity >= 5) {
/*
Expand Down
6 changes: 3 additions & 3 deletions cmd/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3027,7 +3027,7 @@ ztest_zil_remount(ztest_ds_t *zd, uint64_t id)
zil_close(zd->zd_zilog);

/* zfsvfs_setup() */
VERIFY3P(zil_open(os, ztest_get_data), ==, zd->zd_zilog);
VERIFY3P(zil_open(os, ztest_get_data, NULL), ==, zd->zd_zilog);
zil_replay(os, zd, ztest_replay_vector);

(void) pthread_rwlock_unlock(&zd->zd_zilog_lock);
Expand Down Expand Up @@ -4534,7 +4534,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
/*
* Open the intent log for it.
*/
zilog = zil_open(os, ztest_get_data);
zilog = zil_open(os, ztest_get_data, NULL);

/*
* Put some objects in there, do a little I/O to them,
Expand Down Expand Up @@ -7508,7 +7508,7 @@ ztest_dataset_open(int d)
zilog->zl_parse_lr_count,
zilog->zl_replaying_seq);

zilog = zil_open(os, ztest_get_data);
zilog = zil_open(os, ztest_get_data, NULL);

if (zilog->zl_replaying_seq != 0 &&
zilog->zl_replaying_seq < committed_seq)
Expand Down
8 changes: 7 additions & 1 deletion include/sys/dataset_kstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <sys/wmsum.h>
#include <sys/dmu.h>
#include <sys/kstat.h>
#include <sys/zil.h>

typedef struct dataset_sum_stats_t {
wmsum_t dss_writes;
Expand All @@ -56,14 +57,19 @@ typedef struct dataset_kstat_values {
* entry is removed from the unlinked set
*/
kstat_named_t dkv_nunlinked;
/*
* Per dataset zil kstats
*/
zil_kstat_values_t dkv_zil_stats;
} dataset_kstat_values_t;

typedef struct dataset_kstats {
dataset_sum_stats_t dk_sums;
zil_sums_t dk_zil_sums;
kstat_t *dk_kstats;
} dataset_kstats_t;

void dataset_kstats_create(dataset_kstats_t *, objset_t *);
int dataset_kstats_create(dataset_kstats_t *, objset_t *);
void dataset_kstats_destroy(dataset_kstats_t *);

void dataset_kstats_update_write_kstats(dataset_kstats_t *, int64_t);
Expand Down
45 changes: 38 additions & 7 deletions include/sys/zil.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sys/zio.h>
#include <sys/dmu.h>
#include <sys/zio_crypt.h>
#include <sys/wmsum.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -485,12 +486,36 @@ typedef struct zil_stats {
* zil_commit call. Keep a count of how often that occurs.
*/
kstat_named_t zil_skip_zil_commit;
} zil_stats_t;

#define ZIL_STAT_INCR(stat, val) \
atomic_add_64(&zil_stats.stat.value.ui64, (val));
#define ZIL_STAT_BUMP(stat) \
ZIL_STAT_INCR(stat, 1);
} zil_kstat_values_t;

typedef struct zil_sums {
wmsum_t zil_commit_count;
wmsum_t zil_commit_writer_count;
wmsum_t zil_itx_count;
wmsum_t zil_itx_indirect_count;
wmsum_t zil_itx_indirect_bytes;
wmsum_t zil_itx_copied_count;
wmsum_t zil_itx_copied_bytes;
wmsum_t zil_itx_needcopy_count;
wmsum_t zil_itx_needcopy_bytes;
wmsum_t zil_itx_metaslab_normal_count;
wmsum_t zil_itx_metaslab_normal_bytes;
wmsum_t zil_itx_metaslab_slog_count;
wmsum_t zil_itx_metaslab_slog_bytes;
wmsum_t zil_slog_alloc_failures;
wmsum_t zil_skip_zil_commit;
} zil_sums_t;

#define ZIL_STAT_INCR(zil, stat, val) \
do { \
int64_t tmpval = (val); \
wmsum_add(&(zil_sums_global.stat), tmpval); \
if ((zil)->zl_sums) \
wmsum_add(&((zil)->zl_sums->stat), tmpval); \
} while (0)

#define ZIL_STAT_BUMP(zil, stat) \
ZIL_STAT_INCR(zil, stat, 1);

typedef int zil_parse_blk_func_t(zilog_t *zilog, const blkptr_t *bp, void *arg,
uint64_t txg);
Expand All @@ -510,7 +535,8 @@ extern void zil_fini(void);
extern zilog_t *zil_alloc(objset_t *os, zil_header_t *zh_phys);
extern void zil_free(zilog_t *zilog);

extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data);
extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data,
zil_sums_t *zil_sums);
extern void zil_close(zilog_t *zilog);

extern void zil_replay(objset_t *os, void *arg,
Expand Down Expand Up @@ -550,6 +576,11 @@ extern void zil_set_logbias(zilog_t *zilog, uint64_t slogval);
extern uint64_t zil_max_copied_data(zilog_t *zilog);
extern uint64_t zil_max_log_data(zilog_t *zilog);

extern void zil_sums_init(zil_sums_t *zs);
extern void zil_sums_fini(zil_sums_t *zs);
extern void zil_kstat_values_update(zil_kstat_values_t *zs,
zil_sums_t *zil_sums);

extern int zil_replay_disable;

#ifdef __cplusplus
Expand Down
3 changes: 3 additions & 0 deletions include/sys/zil_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ struct zilog {
* (see zil_max_copied_data()).
*/
uint64_t zl_max_block_size;

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

typedef struct zil_bp_node {
Expand Down
2 changes: 2 additions & 0 deletions include/sys/zio.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ extern void spa_handle_ignored_writes(spa_t *spa);
/* zbookmark_phys functions */
boolean_t zbookmark_subtree_completed(const struct dnode_phys *dnp,
const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block);
boolean_t zbookmark_subtree_tbd(const struct dnode_phys *dnp,
const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block);
int zbookmark_compare(uint16_t dbss1, uint8_t ibs1, uint16_t dbss2,
uint8_t ibs2, const zbookmark_phys_t *zb1, const zbookmark_phys_t *zb2);

Expand Down
12 changes: 9 additions & 3 deletions module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,8 +1027,6 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
if (error)
return (error);

zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data);

/*
* If we are not mounting (ie: online recv), then we don't
* have to worry about replaying the log as we blocked all
Expand All @@ -1038,7 +1036,11 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
boolean_t readonly;

ASSERT3P(zfsvfs->z_kstat.dk_kstats, ==, NULL);
dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os);
error = dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os);
if (error)
return (error);
zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data,
&zfsvfs->z_kstat.dk_zil_sums);

/*
* During replay we remove the read only flag to
Expand Down Expand Up @@ -1109,6 +1111,10 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
/* restore readonly bit */
if (readonly != 0)
zfsvfs->z_vfs->vfs_flag |= VFS_RDONLY;
} else {
ASSERT3P(zfsvfs->z_kstat.dk_kstats, !=, NULL);
zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data,
&zfsvfs->z_kstat.dk_zil_sums);
}

/*
Expand Down
10 changes: 6 additions & 4 deletions module/os/freebsd/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ zvol_ensure_zilog(zvol_state_t *zv)
}
if (zv->zv_zilog == NULL) {
zv->zv_zilog = zil_open(zv->zv_objset,
zvol_get_data);
zvol_get_data, &zv->zv_kstat.dk_zil_sums);
zv->zv_flags |= ZVOL_WRITTEN_TO;
/* replay / destroy done in zvol_os_create_minor() */
VERIFY0(zv->zv_zilog->zl_header->zh_flags &
Expand Down Expand Up @@ -1422,8 +1422,12 @@ zvol_os_create_minor(const char *name)
zv->zv_volsize = volsize;
zv->zv_objset = os;

ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL);
error = dataset_kstats_create(&zv->zv_kstat, zv->zv_objset);
if (error)
goto out_dmu_objset_disown;
ASSERT3P(zv->zv_zilog, ==, NULL);
zv->zv_zilog = zil_open(os, zvol_get_data);
zv->zv_zilog = zil_open(os, zvol_get_data, &zv->zv_kstat.dk_zil_sums);
if (spa_writeable(dmu_objset_spa(os))) {
if (zil_replay_disable)
zil_destroy(zv->zv_zilog, B_FALSE);
Expand All @@ -1432,8 +1436,6 @@ zvol_os_create_minor(const char *name)
}
zil_close(zv->zv_zilog);
zv->zv_zilog = NULL;
ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL);
dataset_kstats_create(&zv->zv_kstat, zv->zv_objset);

/* TODO: prefetch for geom tasting */

Expand Down
12 changes: 9 additions & 3 deletions module/os/linux/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,16 +848,18 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
if (error)
return (error);

zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data);

/*
* If we are not mounting (ie: online recv), then we don't
* have to worry about replaying the log as we blocked all
* operations out since we closed the ZIL.
*/
if (mounting) {
ASSERT3P(zfsvfs->z_kstat.dk_kstats, ==, NULL);
dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os);
error = dataset_kstats_create(&zfsvfs->z_kstat, zfsvfs->z_os);
if (error)
return (error);
zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data,
&zfsvfs->z_kstat.dk_zil_sums);

/*
* During replay we remove the read only flag to
Expand Down Expand Up @@ -921,6 +923,10 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
/* restore readonly bit */
if (readonly != 0)
readonly_changed_cb(zfsvfs, B_TRUE);
} else {
ASSERT3P(zfsvfs->z_kstat.dk_kstats, !=, NULL);
zfsvfs->z_log = zil_open(zfsvfs->z_os, zfs_get_data,
&zfsvfs->z_kstat.dk_zil_sums);
}

/*
Expand Down
10 changes: 6 additions & 4 deletions module/os/linux/zfs/zvol_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ zvol_request_impl(zvol_state_t *zv, struct bio *bio, struct request *rq,
rw_enter(&zv->zv_suspend_lock, RW_WRITER);
if (zv->zv_zilog == NULL) {
zv->zv_zilog = zil_open(zv->zv_objset,
zvol_get_data);
zvol_get_data, &zv->zv_kstat.dk_zil_sums);
zv->zv_flags |= ZVOL_WRITTEN_TO;
/* replay / destroy done in zvol_create_minor */
VERIFY0((zv->zv_zilog->zl_header->zh_flags &
Expand Down Expand Up @@ -1426,8 +1426,12 @@ zvol_os_create_minor(const char *name)
blk_queue_flag_set(QUEUE_FLAG_SCSI_PASSTHROUGH, zv->zv_zso->zvo_queue);
#endif

ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL);
error = dataset_kstats_create(&zv->zv_kstat, zv->zv_objset);
if (error)
goto out_dmu_objset_disown;
ASSERT3P(zv->zv_zilog, ==, NULL);
zv->zv_zilog = zil_open(os, zvol_get_data);
zv->zv_zilog = zil_open(os, zvol_get_data, &zv->zv_kstat.dk_zil_sums);
if (spa_writeable(dmu_objset_spa(os))) {
if (zil_replay_disable)
zil_destroy(zv->zv_zilog, B_FALSE);
Expand All @@ -1436,8 +1440,6 @@ zvol_os_create_minor(const char *name)
}
zil_close(zv->zv_zilog);
zv->zv_zilog = NULL;
ASSERT3P(zv->zv_kstat.dk_kstats, ==, NULL);
dataset_kstats_create(&zv->zv_kstat, zv->zv_objset);

/*
* When udev detects the addition of the device it will immediately
Expand Down
Loading

0 comments on commit fe74aa6

Please sign in to comment.