/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
*/
#include <sys/spa_impl.h>
#include <sys/dsl_synctask.h>
#include <sys/dmu_objset.h>
#include <sys/dsl_dataset.h>
#include "zfs_comutil.h"
#ifdef _KERNEL
#endif
/*
* Routines to manage the on-disk history log.
*
* The history log is stored as a dmu object containing
* <packed record length, record nvlist> tuples.
*
* Where "record nvlist" is a nvlist containing uint64_ts and strings, and
* "packed record length" is the packed length of the "record nvlist" stored
* as a little endian uint64_t.
*
* The log is implemented as a ring buffer, though the original creation
* of the pool ('zpool create') is never overwritten.
*
* The history log is tracked as object 'spa_t::spa_history'. The bonus buffer
* of 'spa_history' stores the offsets for logging/retrieving history as
* 'spa_history_phys_t'. 'sh_pool_create_len' is the ending offset in bytes of
* where the 'zpool create' record is stored. This allows us to never
* overwrite the original creation of the pool. 'sh_phys_max_off' is the
* physical ending offset in bytes of the log. This tells you the length of
* the buffer. 'sh_eof' is the logical EOF (in bytes). Whenever a record
* is added, 'sh_eof' is incremented by the the size of the record.
* 'sh_eof' is never decremented. 'sh_bof' is the logical BOF (in bytes).
* This is where the consumer should start reading from after reading in
* the 'zpool create' portion of the log.
*
* 'sh_records_lost' keeps track of how many records have been overwritten
* and permanently lost.
*/
/* convert a logical offset to physical */
static uint64_t
{
+ shpp->sh_pool_create_len);
}
void
{
sizeof (spa_history_phys_t), tx);
/*
* Figure out maximum size of history log. We set it at
* 0.1% of pool size, with a max of 1G and min of 128KB.
*/
}
/*
* Change 'sh_bof' to the beginning of the next record.
*/
static int
{
int err;
buf, DMU_READ_PREFETCH)) != 0)
return (err);
return (err);
}
shpp->sh_records_lost++;
return (0);
}
static int
{
int err;
/* see if we need to reset logical BOF */
return (err);
}
}
len -= firstwrite;
if (len > 0) {
/* write out the rest at the beginning of physical file */
}
return (0);
}
static char *
spa_history_zone(void)
{
#ifdef _KERNEL
if (INGLOBALZONE(curproc))
return (NULL);
#else
return (NULL);
#endif
}
/*
* Write out a history event.
*/
/*ARGSUSED*/
static void
{
int ret;
/*
* If we have an older pool that doesn't have a command
* history object, create it now.
*/
if (!spa->spa_history)
/*
* Get the offset of where we need to write via the bonus buffer.
* Update the offset when the write completes.
*/
#ifdef ZFS_DEBUG
{
}
#endif
#ifdef _KERNEL
#endif
zfs_dbgmsg("command: %s",
zfs_dbgmsg("txg %lld %s %s (id %llu) %s",
} else {
zfs_dbgmsg("txg %lld %s %s",
}
zfs_dbgmsg("ioctl %s",
}
/* write out the packed length as little endian */
if (!ret)
/* The first command is the create, which we keep forever */
}
}
/*
* Write out a history event.
*/
int
{
int err;
return (err);
}
int
{
int err = 0;
if (err) {
return (err);
}
if (spa_history_zone() != NULL) {
spa_history_zone());
}
/* Kick this off asynchronously; errors are ignored. */
/* spa_history_log_sync will free nvl */
return (err);
}
/*
* Read out the command history.
*/
int
{
int err;
/*
* If the command history doesn't exist (older pool),
* that's ok, just return ENOENT.
*/
if (!spa->spa_history)
/*
* The history is logged asynchronously, so when they request
* the first chunk of history, make sure everything has been
* synced to disk so that we get it.
*/
return (err);
#ifdef ZFS_DEBUG
{
}
#endif
/* read in just the zpool create history */
phys_read_off = *offp;
} else {
/*
* Need to reset passed in offset to BOF if the passed in
* offset has since been overwritten.
*/
/*
* Read up to the minimum of what the user passed down or
* the EOF (physical or logical). If we hit physical EOF,
* use 'leftover' to read from the physical BOF.
*/
if (phys_read_off <= phys_eof) {
} else {
}
}
}
/* offset for consumer to use next */
/* tell the consumer how much you actually read */
if (read_len == 0) {
return (0);
}
}
return (err);
}
/*
* The nvlist will be consumed by this call.
*/
static void
{
char *msg;
/*
* If this is part of creating a pool, not everything is
* initialized yet, so don't bother logging the internal events.
* Likewise if the pool is not writeable.
*/
return;
}
if (dmu_tx_is_syncing(tx)) {
} else {
}
/* spa_history_log_sync() will free nvl */
}
void
{
/* create a tx if we didn't get one */
return;
}
}
/* if we didn't get a tx from the caller, commit the one we made */
}
void
{
}
void
{
}
void
{
"pool version %llu; software version %llu/%d; uts %s %s %s %s",
}