usr/src/uts/common/fs/zfs/zfs_log.c
author Joshua M. Clulow <jmc@joyent.com>
Mon, 04 Mar 2013 23:52:56 +0000
changeset 14188 afe390b9f1e0
parent 14046 6a5a2f4a47db
permissions -rw-r--r--
4020 Make ldi_ev_remove_callbacks safe to use in LDI callbacks Reviewed by: Robert Mustacchi <[email protected]> Approved by: Dan McDonald <[email protected]>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     1
/*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     2
 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     3
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
     5
 * Common Development and Distribution License (the "License").
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
     6
 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     7
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    11
 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    12
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    18
 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    19
 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    20
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    21
/*
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
    22
 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    23
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    24
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    25
#include <sys/types.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    26
#include <sys/param.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    27
#include <sys/systm.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    28
#include <sys/sysmacros.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    29
#include <sys/cmn_err.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    30
#include <sys/kmem.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    31
#include <sys/thread.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    32
#include <sys/file.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    33
#include <sys/vfs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    34
#include <sys/zfs_znode.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    35
#include <sys/zfs_dir.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    36
#include <sys/zil.h>
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
    37
#include <sys/zil_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    38
#include <sys/byteorder.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    39
#include <sys/policy.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    40
#include <sys/stat.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    41
#include <sys/mode.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    42
#include <sys/acl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    43
#include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    44
#include <sys/spa.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    45
#include <sys/zfs_fuid.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    46
#include <sys/ddi.h>
8227
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    47
#include <sys/dsl_dataset.h>
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    48
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    49
/*
8227
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    50
 * These zfs_log_* functions must be called within a dmu tx, in one
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    51
 * of 2 contexts depending on zilog->z_replay:
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    52
 *
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    53
 * Non replay mode
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    54
 * ---------------
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    55
 * We need to record the transaction so that if it is committed to
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    56
 * the Intent Log then it can be replayed.  An intent log transaction
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    57
 * structure (itx_t) is allocated and all the information necessary to
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    58
 * possibly replay the transaction is saved in it. The itx is then assigned
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    59
 * a sequence number and inserted in the in-memory list anchored in the zilog.
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    60
 *
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    61
 * Replay mode
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    62
 * -----------
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    63
 * We need to mark the intent log record as replayed in the log header.
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    64
 * This is done in the same transaction as the replay so that they
f7d7be9b1f56 6765294 Refactor replay
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 7360
diff changeset
    65
 * commit atomically.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    66
 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    67
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    68
int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    69
zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    70
{
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    71
	int isxvattr = (vap->va_mask & AT_XVATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    72
	switch (type) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    73
	case Z_FILE:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    74
		if (vsecp == NULL && !isxvattr)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    75
			return (TX_CREATE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    76
		if (vsecp && isxvattr)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    77
			return (TX_CREATE_ACL_ATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    78
		if (vsecp)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    79
			return (TX_CREATE_ACL);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    80
		else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    81
			return (TX_CREATE_ATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    82
		/*NOTREACHED*/
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    83
	case Z_DIR:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    84
		if (vsecp == NULL && !isxvattr)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    85
			return (TX_MKDIR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    86
		if (vsecp && isxvattr)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    87
			return (TX_MKDIR_ACL_ATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    88
		if (vsecp)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    89
			return (TX_MKDIR_ACL);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    90
		else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    91
			return (TX_MKDIR_ATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    92
	case Z_XATTRDIR:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    93
		return (TX_MKXATTR);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    94
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    95
	ASSERT(0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    96
	return (TX_MAX_TYPE);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    97
}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
    98
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
    99
/*
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   100
 * build up the log data necessary for logging xvattr_t
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   101
 * First lr_attr_t is initialized.  following the lr_attr_t
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   102
 * is the mapsize and attribute bitmap copied from the xvattr_t.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   103
 * Following the bitmap and bitmapsize two 64 bit words are reserved
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   104
 * for the create time which may be set.  Following the create time
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   105
 * records a single 64 bit integer which has the bits to set on
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   106
 * replay for the xvattr.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   107
 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   108
static void
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   109
zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   110
{
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   111
	uint32_t	*bitmap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   112
	uint64_t	*attrs;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   113
	uint64_t	*crtime;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   114
	xoptattr_t	*xoap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   115
	void		*scanstamp;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   116
	int		i;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   117
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   118
	xoap = xva_getxoptattr(xvap);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   119
	ASSERT(xoap);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   120
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   121
	lrattr->lr_attr_masksize = xvap->xva_mapsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   122
	bitmap = &lrattr->lr_attr_bitmap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   123
	for (i = 0; i != xvap->xva_mapsize; i++, bitmap++) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   124
		*bitmap = xvap->xva_reqattrmap[i];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   125
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   126
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   127
	/* Now pack the attributes up in a single uint64_t */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   128
	attrs = (uint64_t *)bitmap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   129
	crtime = attrs + 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   130
	scanstamp = (caddr_t)(crtime + 2);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   131
	*attrs = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   132
	if (XVA_ISSET_REQ(xvap, XAT_READONLY))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   133
		*attrs |= (xoap->xoa_readonly == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   134
		    XAT0_READONLY;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   135
	if (XVA_ISSET_REQ(xvap, XAT_HIDDEN))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   136
		*attrs |= (xoap->xoa_hidden == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   137
		    XAT0_HIDDEN;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   138
	if (XVA_ISSET_REQ(xvap, XAT_SYSTEM))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   139
		*attrs |= (xoap->xoa_system == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   140
		    XAT0_SYSTEM;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   141
	if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   142
		*attrs |= (xoap->xoa_archive == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   143
		    XAT0_ARCHIVE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   144
	if (XVA_ISSET_REQ(xvap, XAT_IMMUTABLE))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   145
		*attrs |= (xoap->xoa_immutable == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   146
		    XAT0_IMMUTABLE;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   147
	if (XVA_ISSET_REQ(xvap, XAT_NOUNLINK))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   148
		*attrs |= (xoap->xoa_nounlink == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   149
		    XAT0_NOUNLINK;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   150
	if (XVA_ISSET_REQ(xvap, XAT_APPENDONLY))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   151
		*attrs |= (xoap->xoa_appendonly == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   152
		    XAT0_APPENDONLY;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   153
	if (XVA_ISSET_REQ(xvap, XAT_OPAQUE))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   154
		*attrs |= (xoap->xoa_opaque == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   155
		    XAT0_APPENDONLY;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   156
	if (XVA_ISSET_REQ(xvap, XAT_NODUMP))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   157
		*attrs |= (xoap->xoa_nodump == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   158
		    XAT0_NODUMP;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   159
	if (XVA_ISSET_REQ(xvap, XAT_AV_QUARANTINED))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   160
		*attrs |= (xoap->xoa_av_quarantined == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   161
		    XAT0_AV_QUARANTINED;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   162
	if (XVA_ISSET_REQ(xvap, XAT_AV_MODIFIED))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   163
		*attrs |= (xoap->xoa_av_modified == 0) ? 0 :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   164
		    XAT0_AV_MODIFIED;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   165
	if (XVA_ISSET_REQ(xvap, XAT_CREATETIME))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   166
		ZFS_TIME_ENCODE(&xoap->xoa_createtime, crtime);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   167
	if (XVA_ISSET_REQ(xvap, XAT_AV_SCANSTAMP))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   168
		bcopy(xoap->xoa_av_scanstamp, scanstamp, AV_SCANSTAMP_SZ);
10793
34709091de6d 6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents: 10310
diff changeset
   169
	if (XVA_ISSET_REQ(xvap, XAT_REPARSE))
34709091de6d 6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents: 10310
diff changeset
   170
		*attrs |= (xoap->xoa_reparse == 0) ? 0 :
34709091de6d 6886081 Solaris needs reparse point support (PSARC 2009/387)
Dai Ngo <dai.ngo@sun.com>
parents: 10310
diff changeset
   171
		    XAT0_REPARSE;
13094
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   172
	if (XVA_ISSET_REQ(xvap, XAT_OFFLINE))
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   173
		*attrs |= (xoap->xoa_offline == 0) ? 0 :
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   174
		    XAT0_OFFLINE;
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   175
	if (XVA_ISSET_REQ(xvap, XAT_SPARSE))
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   176
		*attrs |= (xoap->xoa_sparse == 0) ? 0 :
81ec56bf6147 6972305 Preferred DC not selected after setting pdc via sharectl
joyce mcintosh <Joyce.McIntosh@Sun.COM>
parents: 12771
diff changeset
   177
		    XAT0_SPARSE;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   178
}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   179
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   180
static void *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   181
zfs_log_fuid_ids(zfs_fuid_info_t *fuidp, void *start)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   182
{
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   183
	zfs_fuid_t *zfuid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   184
	uint64_t *fuidloc = start;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   185
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   186
	/* First copy in the ACE FUIDs */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   187
	for (zfuid = list_head(&fuidp->z_fuids); zfuid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   188
	    zfuid = list_next(&fuidp->z_fuids, zfuid)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   189
		*fuidloc++ = zfuid->z_logfuid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   190
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   191
	return (fuidloc);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   192
}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   193
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   194
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   195
static void *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   196
zfs_log_fuid_domains(zfs_fuid_info_t *fuidp, void *start)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   197
{
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   198
	zfs_fuid_domain_t *zdomain;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   199
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   200
	/* now copy in the domain info, if any */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   201
	if (fuidp->z_domain_str_sz != 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   202
		for (zdomain = list_head(&fuidp->z_domains); zdomain;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   203
		    zdomain = list_next(&fuidp->z_domains, zdomain)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   204
			bcopy((void *)zdomain->z_domain, start,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   205
			    strlen(zdomain->z_domain) + 1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   206
			start = (caddr_t)start +
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   207
			    strlen(zdomain->z_domain) + 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   208
		}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   209
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   210
	return (start);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   211
}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   212
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   213
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   214
 * Handles TX_CREATE, TX_CREATE_ATTR, TX_MKDIR, TX_MKDIR_ATTR and
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   215
 * TK_MKXATTR transactions.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   216
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   217
 * TX_CREATE and TX_MKDIR are standard creates, but they may have FUID
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   218
 * domain information appended prior to the name.  In this case the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   219
 * uid/gid in the log record will be a log centric FUID.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   220
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   221
 * TX_CREATE_ACL_ATTR and TX_MKDIR_ACL_ATTR handle special creates that
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   222
 * may contain attributes, ACL and optional fuid information.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   223
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   224
 * TX_CREATE_ACL and TX_MKDIR_ACL handle special creates that specify
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   225
 * and ACL and normal users/groups in the ACEs.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   226
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   227
 * There may be an optional xvattr attribute information similar
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   228
 * to zfs_log_setattr.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   229
 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   230
 * Also, after the file name "domain" strings may be appended.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   231
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   232
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   233
zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   234
    znode_t *dzp, znode_t *zp, char *name, vsecattr_t *vsecp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   235
    zfs_fuid_info_t *fuidp, vattr_t *vap)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   236
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   237
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   238
	lr_create_t *lr;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   239
	lr_acl_create_t *lracl;
13952
7a22d0770fc8 3522 zfs module should not allow uninitialized variables
George Wilson <george.wilson@delphix.com>
parents: 13094
diff changeset
   240
	size_t aclsize = (vsecp != NULL) ? vsecp->vsa_aclentsz : 0;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   241
	size_t xvatsize = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   242
	size_t txsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   243
	xvattr_t *xvap = (xvattr_t *)vap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   244
	void *end;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   245
	size_t lrsize;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   246
	size_t namesize = strlen(name) + 1;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   247
	size_t fuidsz = 0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   248
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   249
	if (zil_replaying(zilog, tx))
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   250
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   251
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   252
	/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   253
	 * If we have FUIDs present then add in space for
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   254
	 * domains and ACE fuid's if any.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   255
	 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   256
	if (fuidp) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   257
		fuidsz += fuidp->z_domain_str_sz;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   258
		fuidsz += fuidp->z_fuid_cnt * sizeof (uint64_t);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   259
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   260
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   261
	if (vap->va_mask & AT_XVATTR)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   262
		xvatsize = ZIL_XVAT_SIZE(xvap->xva_mapsize);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   263
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   264
	if ((int)txtype == TX_CREATE_ATTR || (int)txtype == TX_MKDIR_ATTR ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   265
	    (int)txtype == TX_CREATE || (int)txtype == TX_MKDIR ||
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   266
	    (int)txtype == TX_MKXATTR) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   267
		txsize = sizeof (*lr) + namesize + fuidsz + xvatsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   268
		lrsize = sizeof (*lr);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   269
	} else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   270
		txsize =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   271
		    sizeof (lr_acl_create_t) + namesize + fuidsz +
5435
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   272
		    ZIL_ACE_LENGTH(aclsize) + xvatsize;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   273
		lrsize = sizeof (lr_acl_create_t);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   274
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   275
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   276
	itx = zil_itx_create(txtype, txsize);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   277
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   278
	lr = (lr_create_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   279
	lr->lr_doid = dzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   280
	lr->lr_foid = zp->z_id;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   281
	lr->lr_mode = zp->z_mode;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   282
	if (!IS_EPHEMERAL(zp->z_uid)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   283
		lr->lr_uid = (uint64_t)zp->z_uid;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   284
	} else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   285
		lr->lr_uid = fuidp->z_fuid_owner;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   286
	}
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   287
	if (!IS_EPHEMERAL(zp->z_gid)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   288
		lr->lr_gid = (uint64_t)zp->z_gid;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   289
	} else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   290
		lr->lr_gid = fuidp->z_fuid_group;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   291
	}
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   292
	(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(zp->z_zfsvfs), &lr->lr_gen,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   293
	    sizeof (uint64_t));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   294
	(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(zp->z_zfsvfs),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   295
	    lr->lr_crtime, sizeof (uint64_t) * 2);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   296
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   297
	if (sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(zp->z_zfsvfs), &lr->lr_rdev,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   298
	    sizeof (lr->lr_rdev)) != 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   299
		lr->lr_rdev = 0;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   300
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   301
	/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   302
	 * Fill in xvattr info if any
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   303
	 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   304
	if (vap->va_mask & AT_XVATTR) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   305
		zfs_log_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), xvap);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   306
		end = (caddr_t)lr + lrsize + xvatsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   307
	} else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   308
		end = (caddr_t)lr + lrsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   309
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   310
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   311
	/* Now fill in any ACL info */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   312
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   313
	if (vsecp) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   314
		lracl = (lr_acl_create_t *)&itx->itx_lr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   315
		lracl->lr_aclcnt = vsecp->vsa_aclcnt;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   316
		lracl->lr_acl_bytes = aclsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   317
		lracl->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   318
		lracl->lr_fuidcnt  = fuidp ? fuidp->z_fuid_cnt : 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   319
		if (vsecp->vsa_aclflags & VSA_ACE_ACLFLAGS)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   320
			lracl->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   321
		else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   322
			lracl->lr_acl_flags = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   323
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   324
		bcopy(vsecp->vsa_aclentp, end, aclsize);
5435
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   325
		end = (caddr_t)end + ZIL_ACE_LENGTH(aclsize);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   326
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   327
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   328
	/* drop in FUID info */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   329
	if (fuidp) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   330
		end = zfs_log_fuid_ids(fuidp, end);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   331
		end = zfs_log_fuid_domains(fuidp, end);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   332
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   333
	/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   334
	 * Now place file name in log record
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   335
	 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   336
	bcopy(name, end, namesize);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   337
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   338
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   339
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   340
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   341
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   342
 * Handles both TX_REMOVE and TX_RMDIR transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   343
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   344
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   345
zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   346
	znode_t *dzp, char *name, uint64_t foid)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   347
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   348
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   349
	lr_remove_t *lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   350
	size_t namesize = strlen(name) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   351
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   352
	if (zil_replaying(zilog, tx))
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   353
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   354
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   355
	itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   356
	lr = (lr_remove_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   357
	lr->lr_doid = dzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   358
	bcopy(name, (char *)(lr + 1), namesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   359
12700
0f31afc2abec 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c (fix 32bit build)
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 12699
diff changeset
   360
	itx->itx_oid = foid;
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   361
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   362
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   363
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   364
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   365
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   366
 * Handles TX_LINK transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   367
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   368
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   369
zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   370
	znode_t *dzp, znode_t *zp, char *name)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   371
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   372
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   373
	lr_link_t *lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   374
	size_t namesize = strlen(name) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   375
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   376
	if (zil_replaying(zilog, tx))
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   377
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   378
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   379
	itx = zil_itx_create(txtype, sizeof (*lr) + namesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   380
	lr = (lr_link_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   381
	lr->lr_doid = dzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   382
	lr->lr_link_obj = zp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   383
	bcopy(name, (char *)(lr + 1), namesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   384
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   385
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   386
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   387
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   388
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   389
 * Handles TX_SYMLINK transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   390
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   391
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   392
zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   393
    znode_t *dzp, znode_t *zp, char *name, char *link)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   394
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   395
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   396
	lr_create_t *lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   397
	size_t namesize = strlen(name) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   398
	size_t linksize = strlen(link) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   399
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   400
	if (zil_replaying(zilog, tx))
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   401
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   402
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   403
	itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   404
	lr = (lr_create_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   405
	lr->lr_doid = dzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   406
	lr->lr_foid = zp->z_id;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   407
	lr->lr_uid = zp->z_uid;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   408
	lr->lr_gid = zp->z_gid;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   409
	lr->lr_mode = zp->z_mode;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   410
	(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(zp->z_zfsvfs), &lr->lr_gen,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   411
	    sizeof (uint64_t));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   412
	(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(zp->z_zfsvfs),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 10922
diff changeset
   413
	    lr->lr_crtime, sizeof (uint64_t) * 2);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   414
	bcopy(name, (char *)(lr + 1), namesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   415
	bcopy(link, (char *)(lr + 1) + namesize, linksize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   416
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   417
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   418
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   419
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   420
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   421
 * Handles TX_RENAME transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   422
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   423
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   424
zfs_log_rename(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
12771
9e4f2f9983b9 6834694 zfs renames can potentially be committed without the data
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 12700
diff changeset
   425
	znode_t *sdzp, char *sname, znode_t *tdzp, char *dname, znode_t *szp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   426
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   427
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   428
	lr_rename_t *lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   429
	size_t snamesize = strlen(sname) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   430
	size_t dnamesize = strlen(dname) + 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   431
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   432
	if (zil_replaying(zilog, tx))
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   433
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   434
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   435
	itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   436
	lr = (lr_rename_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   437
	lr->lr_sdoid = sdzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   438
	lr->lr_tdoid = tdzp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   439
	bcopy(sname, (char *)(lr + 1), snamesize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   440
	bcopy(dname, (char *)(lr + 1) + snamesize, dnamesize);
12771
9e4f2f9983b9 6834694 zfs renames can potentially be committed without the data
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 12700
diff changeset
   441
	itx->itx_oid = szp->z_id;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   442
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   443
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   444
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   445
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   446
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   447
 * Handles TX_WRITE transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   448
 */
2237
45affe88ed99 6416482 filebench oltp workload hangs in zfs
maybee
parents: 1669
diff changeset
   449
ssize_t zfs_immediate_write_sz = 32768;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   450
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   451
void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   452
zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype,
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   453
	znode_t *zp, offset_t off, ssize_t resid, int ioflag)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   454
{
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   455
	itx_wr_state_t write_state;
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   456
	boolean_t slogging;
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   457
	uintptr_t fsync_cnt;
10310
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   458
	ssize_t immediate_write_sz;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   459
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   460
	if (zil_replaying(zilog, tx) || zp->z_unlinked)
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   461
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   462
10310
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   463
	immediate_write_sz = (zilog->zl_logbias == ZFS_LOGBIAS_THROUGHPUT)
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   464
	    ? 0 : zfs_immediate_write_sz;
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   465
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   466
	slogging = spa_has_slogs(zilog->zl_spa) &&
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   467
	    (zilog->zl_logbias == ZFS_LOGBIAS_LATENCY);
ba87b3315737 PSARC 2009/423 ZFS logbias property
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9512
diff changeset
   468
	if (resid > immediate_write_sz && !slogging && resid <= zp->z_blksz)
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   469
		write_state = WR_INDIRECT;
6396
09c523979832 6683293 concurrent O_DSYNC writes to a fileset can be much improved over NFS
perrin
parents: 6101
diff changeset
   470
	else if (ioflag & (FSYNC | FDSYNC))
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   471
		write_state = WR_COPIED;
3638
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3461
diff changeset
   472
	else
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   473
		write_state = WR_NEED_COPY;
3638
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3461
diff changeset
   474
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   475
	if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) {
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   476
		(void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1));
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   477
	}
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   478
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   479
	while (resid) {
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   480
		itx_t *itx;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   481
		lr_write_t *lr;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   482
		ssize_t len;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   483
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   484
		/*
7360
75a2fa5e303d 6730484 assertion failed: (error && error != 150)
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 6514
diff changeset
   485
		 * If the write would overflow the largest block then split it.
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   486
		 */
7360
75a2fa5e303d 6730484 assertion failed: (error && error != 150)
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 6514
diff changeset
   487
		if (write_state != WR_INDIRECT && resid > ZIL_MAX_LOG_DATA)
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   488
			len = SPA_MAXBLOCKSIZE >> 1;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   489
		else
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   490
			len = resid;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   491
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   492
		itx = zil_itx_create(txtype, sizeof (*lr) +
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   493
		    (write_state == WR_COPIED ? len : 0));
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   494
		lr = (lr_write_t *)&itx->itx_lr;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   495
		if (write_state == WR_COPIED && dmu_read(zp->z_zfsvfs->z_os,
9512
64cafcbcc337 6801810 Commit of aligned streaming rewrites to ZIL device causes unwanted disk reads
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9401
diff changeset
   496
		    zp->z_id, off, len, lr + 1, DMU_READ_NO_PREFETCH) != 0) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   497
			zil_itx_destroy(itx);
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   498
			itx = zil_itx_create(txtype, sizeof (*lr));
3638
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3461
diff changeset
   499
			lr = (lr_write_t *)&itx->itx_lr;
1669
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   500
			write_state = WR_NEED_COPY;
3521dbbcb2e8 6343608 ZFS file range locking
perrin
parents: 789
diff changeset
   501
		}
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   502
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   503
		itx->itx_wr_state = write_state;
6101
915df4cedbc9 6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents: 5435
diff changeset
   504
		if (write_state == WR_NEED_COPY)
915df4cedbc9 6658511 zl_itx_list_sz incorrect for WR_NEED_COPY writes
perrin
parents: 5435
diff changeset
   505
			itx->itx_sod += len;
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   506
		lr->lr_foid = zp->z_id;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   507
		lr->lr_offset = off;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   508
		lr->lr_length = len;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   509
		lr->lr_blkoff = 0;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   510
		BP_ZERO(&lr->lr_blkptr);
3638
6b28ebc717aa 6496357 spec_fsync() is useless on devices that do write caching
billm
parents: 3461
diff changeset
   511
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   512
		itx->itx_private = zp->z_zfsvfs;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   513
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   514
		if (!(ioflag & (FSYNC | FDSYNC)) && (zp->z_sync_cnt == 0) &&
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   515
		    (fsync_cnt == 0))
4720
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   516
			itx->itx_sync = B_FALSE;
8edc0d2e6f3f 6535160 Lock contention on zl_lock from zil_commit
fr157268
parents: 4620
diff changeset
   517
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   518
		zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   519
4620
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   520
		off += len;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   521
		resid -= len;
4895df7f426f 6574298 slog still uses main pool for dmu_sync()
perrin
parents: 3638
diff changeset
   522
	}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   523
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   524
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   525
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   526
 * Handles TX_TRUNCATE transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   527
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   528
void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   529
zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   530
	znode_t *zp, uint64_t off, uint64_t len)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   531
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   532
	itx_t *itx;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   533
	lr_truncate_t *lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   534
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   535
	if (zil_replaying(zilog, tx) || zp->z_unlinked)
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   536
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   537
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   538
	itx = zil_itx_create(txtype, sizeof (*lr));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   539
	lr = (lr_truncate_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   540
	lr->lr_foid = zp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   541
	lr->lr_offset = off;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   542
	lr->lr_length = len;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   543
3063
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
   544
	itx->itx_sync = (zp->z_sync_cnt != 0);
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   545
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   546
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   547
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   548
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   549
 * Handles TX_SETATTR transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   550
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   551
void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   552
zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   553
	znode_t *zp, vattr_t *vap, uint_t mask_applied, zfs_fuid_info_t *fuidp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   554
{
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   555
	itx_t		*itx;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   556
	lr_setattr_t	*lr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   557
	xvattr_t	*xvap = (xvattr_t *)vap;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   558
	size_t		recsize = sizeof (lr_setattr_t);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   559
	void		*start;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   560
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   561
	if (zil_replaying(zilog, tx) || zp->z_unlinked)
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   562
		return;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   563
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   564
	/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   565
	 * If XVATTR set, then log record size needs to allow
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   566
	 * for lr_attr_t + xvattr mask, mapsize and create time
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   567
	 * plus actual attribute values
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   568
	 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   569
	if (vap->va_mask & AT_XVATTR)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   570
		recsize = sizeof (*lr) + ZIL_XVAT_SIZE(xvap->xva_mapsize);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   571
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   572
	if (fuidp)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   573
		recsize += fuidp->z_domain_str_sz;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   574
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   575
	itx = zil_itx_create(txtype, recsize);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   576
	lr = (lr_setattr_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   577
	lr->lr_foid = zp->z_id;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   578
	lr->lr_mask = (uint64_t)mask_applied;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   579
	lr->lr_mode = (uint64_t)vap->va_mode;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   580
	if ((mask_applied & AT_UID) && IS_EPHEMERAL(vap->va_uid))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   581
		lr->lr_uid = fuidp->z_fuid_owner;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   582
	else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   583
		lr->lr_uid = (uint64_t)vap->va_uid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   584
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   585
	if ((mask_applied & AT_GID) && IS_EPHEMERAL(vap->va_gid))
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   586
		lr->lr_gid = fuidp->z_fuid_group;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   587
	else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   588
		lr->lr_gid = (uint64_t)vap->va_gid;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   589
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   590
	lr->lr_size = (uint64_t)vap->va_size;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   591
	ZFS_TIME_ENCODE(&vap->va_atime, lr->lr_atime);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   592
	ZFS_TIME_ENCODE(&vap->va_mtime, lr->lr_mtime);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   593
	start = (lr_setattr_t *)(lr + 1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   594
	if (vap->va_mask & AT_XVATTR) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   595
		zfs_log_xvattr((lr_attr_t *)start, xvap);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   596
		start = (caddr_t)start + ZIL_XVAT_SIZE(xvap->xva_mapsize);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   597
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   598
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   599
	/*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   600
	 * Now stick on domain information if any on end
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   601
	 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   602
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   603
	if (fuidp)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   604
		(void) zfs_log_fuid_domains(fuidp, start);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   605
3063
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
   606
	itx->itx_sync = (zp->z_sync_cnt != 0);
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   607
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   608
}
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   609
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   610
/*
14046
6a5a2f4a47db 3742 zfs comments need cleaner, more consistent style
Will Andrews <will@firepipe.net>
parents: 13952
diff changeset
   611
 * Handles TX_ACL transactions.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   612
 */
2638
4f583dfeae92 6413510 zfs: writing to ZFS filesystem slows down fsync() on other files in the same FS
perrin
parents: 2237
diff changeset
   613
void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   614
zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   615
    vsecattr_t *vsecp, zfs_fuid_info_t *fuidp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   616
{
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   617
	itx_t *itx;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   618
	lr_acl_v0_t *lrv0;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   619
	lr_acl_t *lr;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   620
	int txtype;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   621
	int lrsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   622
	size_t txsize;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   623
	size_t aclbytes = vsecp->vsa_aclentsz;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   624
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10793
diff changeset
   625
	if (zil_replaying(zilog, tx) || zp->z_unlinked)
6514
852c82a1989c 6689561 zfs_replay_acl_v0() doesn't completely initialize vsecattr
marks
parents: 6396
diff changeset
   626
		return;
852c82a1989c 6689561 zfs_replay_acl_v0() doesn't completely initialize vsecattr
marks
parents: 6396
diff changeset
   627
852c82a1989c 6689561 zfs_replay_acl_v0() doesn't completely initialize vsecattr
marks
parents: 6396
diff changeset
   628
	txtype = (zp->z_zfsvfs->z_version < ZPL_VERSION_FUID) ?
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   629
	    TX_ACL_V0 : TX_ACL;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   630
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   631
	if (txtype == TX_ACL)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   632
		lrsize = sizeof (*lr);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   633
	else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   634
		lrsize = sizeof (*lrv0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   635
5435
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   636
	txsize = lrsize +
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   637
	    ((txtype == TX_ACL) ? ZIL_ACE_LENGTH(aclbytes) : aclbytes) +
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   638
	    (fuidp ? fuidp->z_domain_str_sz : 0) +
6514
852c82a1989c 6689561 zfs_replay_acl_v0() doesn't completely initialize vsecattr
marks
parents: 6396
diff changeset
   639
	    sizeof (uint64_t) * (fuidp ? fuidp->z_fuid_cnt : 0);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   640
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   641
	itx = zil_itx_create(txtype, txsize);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   642
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   643
	lr = (lr_acl_t *)&itx->itx_lr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   644
	lr->lr_foid = zp->z_id;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   645
	if (txtype == TX_ACL) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   646
		lr->lr_acl_bytes = aclbytes;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   647
		lr->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   648
		lr->lr_fuidcnt = fuidp ? fuidp->z_fuid_cnt : 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   649
		if (vsecp->vsa_mask & VSA_ACE_ACLFLAGS)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   650
			lr->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   651
		else
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   652
			lr->lr_acl_flags = 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   653
	}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   654
	lr->lr_aclcnt = (uint64_t)vsecp->vsa_aclcnt;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   655
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   656
	if (txtype == TX_ACL_V0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   657
		lrv0 = (lr_acl_v0_t *)lr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   658
		bcopy(vsecp->vsa_aclentp, (ace_t *)(lrv0 + 1), aclbytes);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   659
	} else {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   660
		void *start = (ace_t *)(lr + 1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   661
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   662
		bcopy(vsecp->vsa_aclentp, start, aclbytes);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   663
5435
1be0be66916d 6624956 zfs_log_fuid_ids can cause panic on sparc
marks
parents: 5331
diff changeset
   664
		start = (caddr_t)start + ZIL_ACE_LENGTH(aclbytes);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   665
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   666
		if (fuidp) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   667
			start = zfs_log_fuid_ids(fuidp, start);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   668
			(void) zfs_log_fuid_domains(fuidp, start);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   669
		}
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 4720
diff changeset
   670
	}
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   671
3063
b252896b372b 6341569 zio_alloc_blk() vdev distribution performs badly
perrin
parents: 2638
diff changeset
   672
	itx->itx_sync = (zp->z_sync_cnt != 0);
12699
36aebb51164a 6913010 assertion failed: error||lr->lr_length <= zp->z_blksz, file: ../../common/fs/zfs/zfs_vnops.c
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 11935
diff changeset
   673
	zil_itx_assign(zilog, itx, tx);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
   674
}