Rebase master to b105

This commit is contained in:
Brian Behlendorf
2009-01-15 13:59:39 -08:00
parent 42bcb36c89
commit fb5f0bc833
50 changed files with 1602 additions and 849 deletions
+43 -5
View File
@@ -45,13 +45,33 @@
#include <sys/spa.h>
#include <sys/zfs_fuid.h>
#include <sys/ddi.h>
#include <sys/dsl_dataset.h>
#define ZFS_HANDLE_REPLAY(zilog, tx) \
if (zilog->zl_replay) { \
dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx); \
zilog->zl_replayed_seq[dmu_tx_get_txg(tx) & TXG_MASK] = \
zilog->zl_replaying_seq; \
return; \
}
/*
* All the functions in this file are used to construct the log entries
* to record transactions. They allocate * an intent log transaction
* structure (itx_t) and save within it all the information necessary to
* possibly replay the transaction. The itx is then assigned a sequence
* number and inserted in the in-memory list anchored in the zilog.
* These zfs_log_* functions must be called within a dmu tx, in one
* of 2 contexts depending on zilog->z_replay:
*
* Non replay mode
* ---------------
* We need to record the transaction so that if it is committed to
* the Intent Log then it can be replayed. An intent log transaction
* structure (itx_t) is allocated and all the information necessary to
* possibly replay the transaction is saved in it. The itx is then assigned
* a sequence number and inserted in the in-memory list anchored in the zilog.
*
* Replay mode
* -----------
* We need to mark the intent log record as replayed in the log header.
* This is done in the same transaction as the replay so that they
* commit atomically.
*/
int
@@ -231,6 +251,8 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
if (zilog == NULL)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
/*
* If we have FUIDs present then add in space for
* domains and ACE fuid's if any.
@@ -334,6 +356,8 @@ zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
if (zilog == NULL)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
lr = (lr_remove_t *)&itx->itx_lr;
lr->lr_doid = dzp->z_id;
@@ -358,6 +382,8 @@ zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
if (zilog == NULL)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
lr = (lr_link_t *)&itx->itx_lr;
lr->lr_doid = dzp->z_id;
@@ -385,6 +411,8 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
if (zilog == NULL)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize);
lr = (lr_create_t *)&itx->itx_lr;
lr->lr_doid = dzp->z_id;
@@ -419,6 +447,8 @@ zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
if (zilog == NULL)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize);
lr = (lr_rename_t *)&itx->itx_lr;
lr->lr_sdoid = sdzp->z_id;
@@ -451,6 +481,8 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
if (zilog == NULL || zp->z_unlinked)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
/*
* Writes are handled in three different ways:
*
@@ -549,6 +581,8 @@ zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
if (zilog == NULL || zp->z_unlinked)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
itx = zil_itx_create(txtype, sizeof (*lr));
lr = (lr_truncate_t *)&itx->itx_lr;
lr->lr_foid = zp->z_id;
@@ -578,6 +612,8 @@ zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
if (zilog == NULL || zp->z_unlinked)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
/*
* If XVATTR set, then log record size needs to allow
* for lr_attr_t + xvattr mask, mapsize and create time
@@ -644,6 +680,8 @@ zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp,
if (zilog == NULL || zp->z_unlinked)
return;
ZFS_HANDLE_REPLAY(zilog, tx); /* exits if replay */
txtype = (zp->z_zfsvfs->z_version < ZPL_VERSION_FUID) ?
TX_ACL_V0 : TX_ACL;