zfs_log.c revision 31e69ea4bce567a03de57e063cb36ef69af61470
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/zfs_znode.h>
#include <sys/zil_impl.h>
#include <sys/byteorder.h>
#include <sys/zfs_fuid.h>
/*
* 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.
*/
int
{
switch (type) {
case Z_FILE:
return (TX_CREATE);
return (TX_CREATE_ACL_ATTR);
if (vsecp)
return (TX_CREATE_ACL);
else
return (TX_CREATE_ATTR);
/*NOTREACHED*/
case Z_DIR:
return (TX_MKDIR);
return (TX_MKDIR_ACL_ATTR);
if (vsecp)
return (TX_MKDIR_ACL);
else
return (TX_MKDIR_ATTR);
case Z_XATTRDIR:
return (TX_MKXATTR);
}
ASSERT(0);
return (TX_MAX_TYPE);
}
/*
* build up the log data necessary for logging xvattr_t
* First lr_attr_t is initialized. following the lr_attr_t
* is the mapsize and attribute bitmap copied from the xvattr_t.
* Following the bitmap and bitmapsize two 64 bit words are reserved
* for the create time which may be set. Following the create time
* records a single 64 bit integer which has the bits to set on
* replay for the xvattr.
*/
static void
{
void *scanstamp;
int i;
}
/* Now pack the attributes up in a single uint64_t */
*attrs = 0;
}
static void *
{
/* First copy in the ACE FUIDs */
}
return (fuidloc);
}
static void *
{
/* now copy in the domain info, if any */
if (fuidp->z_domain_str_sz != 0) {
}
}
return (start);
}
/*
* zfs_log_create() is used to handle TX_CREATE, TX_CREATE_ATTR, TX_MKDIR,
* TX_MKDIR_ATTR and TX_MKXATTR
* transactions.
*
* TX_CREATE and TX_MKDIR are standard creates, but they may have FUID
* domain information appended prior to the name. In this case the
*
* TX_CREATE_ACL_ATTR and TX_MKDIR_ACL_ATTR handle special creates that
* may contain attributes, ACL and optional fuid information.
*
* TX_CREATE_ACL and TX_MKDIR_ACL handle special creates that specify
*
* There may be an optional xvattr attribute information similar
* to zfs_log_setattr.
*
* Also, after the file name "domain" strings may be appended.
*/
void
{
void *end;
return;
/*
* If we have FUIDs present then add in space for
* domains and ACE fuid's if any.
*/
if (fuidp) {
}
(int)txtype == TX_MKXATTR) {
} else {
txsize =
lrsize = sizeof (lr_acl_create_t);
}
} else {
}
} else {
}
/*
* Fill in xvattr info if any
*/
} else {
}
/* Now fill in any ACL info */
if (vsecp) {
else
lracl->lr_acl_flags = 0;
}
/* drop in FUID info */
if (fuidp) {
}
/*
* Now place file name in log record
*/
}
/*
* zfs_log_remove() handles both TX_REMOVE and TX_RMDIR transactions.
*/
void
{
return;
}
/*
* zfs_log_link() handles TX_LINK transactions.
*/
void
{
return;
}
/*
* zfs_log_symlink() handles TX_SYMLINK transactions.
*/
void
{
return;
}
/*
* zfs_log_rename() handles TX_RENAME transactions.
*/
void
{
return;
}
/*
* zfs_log_write() handles TX_WRITE transactions.
*/
sizeof (lr_write_t))
void
{
return;
/*
* Writes are handled in three different ways:
*
* WR_INDIRECT:
* If the write is greater than zfs_immediate_write_sz and there are
* no separate logs in this pool then later *if* we need to log the
* write then dmu_sync() is used to immediately write the block and
* its block pointer is put in the log record.
* WR_COPIED:
* If we know we'll immediately be committing the
* transaction (FSYNC or FDSYNC), the we allocate a larger
* log record here for the data and copy the data in.
* WR_NEED_COPY:
* Otherwise we don't allocate a buffer, and *if* we need to
* flush the write later then a buffer is allocated and
* we retrieve the data using the dmu.
*/
else
}
while (resid) {
lr_write_t *lr;
/*
* If there are slogs and the write would overflow the largest
* block, then because we don't want to use the main pool
* to dmu_sync, we have to split the write.
*/
else
}
if (write_state == WR_NEED_COPY)
else
}
}
/*
* zfs_log_truncate() handles TX_TRUNCATE transactions.
*/
void
{
return;
}
/*
* zfs_log_setattr() handles TX_SETATTR transactions.
*/
void
{
void *start;
return;
/*
* If XVATTR set, then log record size needs to allow
* for lr_attr_t + xvattr mask, mapsize and create time
* plus actual attribute values
*/
if (fuidp)
else
else
}
/*
* Now stick on domain information if any on end
*/
if (fuidp)
}
/*
* zfs_log_acl() handles TX_ACL transactions.
*/
void
{
int txtype;
int lrsize;
return;
else
else
lr->lr_acl_flags = 0;
}
} else {
if (fuidp) {
}
}
}