zfs_log.c revision c5c6ffa0498b9c8555798756141b4a3061a138c1
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * Common Development and Distribution License (the "License").
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
893a6d32980d24be1349478f44169009d4801c25ahrens * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens * All the functions in this file are used to construct the log entries
fa9e4066f08beec538e775443c5be79dd423fcabahrens * to record transactions. They allocate * a intent log transaction
fa9e4066f08beec538e775443c5be79dd423fcabahrens * structure (itx_t) and save within it all the information necessary to
fa9e4066f08beec538e775443c5be79dd423fcabahrens * possibly replay the transaction. The itx is then assigned a sequence
fa9e4066f08beec538e775443c5be79dd423fcabahrens * number and inserted in the in-memory list anchored in the zilog.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zfs_log_create() is used to handle TX_CREATE, TX_MKDIR and TX_MKXATTR
fa9e4066f08beec538e775443c5be79dd423fcabahrens * transactions.
b19a79ec1a527828a60c4d325ccd8dcbeb2b2e8bperrinzfs_log_create(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zfs_log_remove() handles both TX_REMOVE and TX_RMDIR transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, int txtype,
b19a79ec1a527828a60c4d325ccd8dcbeb2b2e8bperrin return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zfs_log_link() handles TX_LINK transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_link(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
b19a79ec1a527828a60c4d325ccd8dcbeb2b2e8bperrin * zfs_log_symlink() handles TX_SYMLINK transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize);
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zfs_log_rename() handles TX_RENAME transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp)
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize);
fa9e4066f08beec538e775443c5be79dd423fcabahrens bcopy(dname, (char *)(lr + 1) + snamesize, dnamesize);
6ce0521ac291be36119f359237066c4fb8088683perrin * zfs_log_write() handles TX_WRITE transactions.
6ce0521ac291be36119f359237066c4fb8088683perrinzfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens znode_t *zp, offset_t off, ssize_t len, int ioflag, uio_t *uio)
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin return (0);
6ce0521ac291be36119f359237066c4fb8088683perrin * Writes are handled in three different ways:
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * WR_INDIRECT:
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * If the write is greater than zfs_immediate_write_sz then
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * later *if* we need to log the write then dmu_sync() is used
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * to immediately write the block and it's block pointer is put
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * in the log record.
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * WR_COPIED:
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * If we know we'll immediately be committing the
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * transaction (FDSYNC (O_DSYNC)), the we allocate a larger
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * log record here for the data and copy the data in.
6ce0521ac291be36119f359237066c4fb8088683perrin * WR_NEED_COPY:
6ce0521ac291be36119f359237066c4fb8088683perrin * Otherwise we don't allocate a buffer, and *if* we need to
104e2ed78d9ef0a0f89f320108b8ca29ca3850d5perrin * flush the write later then a buffer is allocated and
feb08c6bb47ceffa5bb7a70f2c0549113f40fcc5billm * we retrieve the data using the dmu.
6ce0521ac291be36119f359237066c4fb8088683perrin (char *)itx + offsetof(itx_t, itx_lr) + sizeof (*lr), len);
6ce0521ac291be36119f359237066c4fb8088683perrin * xcopyin shouldn't error as we've already successfully
6ce0521ac291be36119f359237066c4fb8088683perrin * copied it to a dmu buffer. However if it does we'll get
6ce0521ac291be36119f359237066c4fb8088683perrin * the data from the dmu later.
6ce0521ac291be36119f359237066c4fb8088683perrin * zfs_log_truncate() handles TX_TRUNCATE transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
67bd71c6cc629bab3aa0d595c624a667f1574254perrin * zfs_log_setattr() handles TX_SETATTR transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrenszfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
67bd71c6cc629bab3aa0d595c624a667f1574254perrin * zfs_log_acl() handles TX_ACL transactions.
fa9e4066f08beec538e775443c5be79dd423fcabahrens return (0);
fa9e4066f08beec538e775443c5be79dd423fcabahrens itx = zil_itx_create(txtype, sizeof (*lr) + aclcnt * sizeof (ace_t));