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-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1669 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
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 | 23 |
*/ |
24 |
||
25 |
#include <sys/types.h> |
|
26 |
#include <sys/param.h> |
|
27 |
#include <sys/systm.h> |
|
28 |
#include <sys/sysmacros.h> |
|
29 |
#include <sys/cmn_err.h> |
|
30 |
#include <sys/kmem.h> |
|
31 |
#include <sys/thread.h> |
|
32 |
#include <sys/file.h> |
|
33 |
#include <sys/vfs.h> |
|
34 |
#include <sys/zfs_znode.h> |
|
35 |
#include <sys/zfs_dir.h> |
|
36 |
#include <sys/zil.h> |
|
4620 | 37 |
#include <sys/zil_impl.h> |
789 | 38 |
#include <sys/byteorder.h> |
39 |
#include <sys/policy.h> |
|
40 |
#include <sys/stat.h> |
|
41 |
#include <sys/mode.h> |
|
42 |
#include <sys/acl.h> |
|
43 |
#include <sys/dmu.h> |
|
44 |
#include <sys/spa.h> |
|
5331 | 45 |
#include <sys/zfs_fuid.h> |
789 | 46 |
#include <sys/ddi.h> |
8227 | 47 |
#include <sys/dsl_dataset.h> |
48 |
||
789 | 49 |
/* |
8227 | 50 |
* These zfs_log_* functions must be called within a dmu tx, in one |
51 |
* of 2 contexts depending on zilog->z_replay: |
|
52 |
* |
|
53 |
* Non replay mode |
|
54 |
* --------------- |
|
55 |
* We need to record the transaction so that if it is committed to |
|
56 |
* the Intent Log then it can be replayed. An intent log transaction |
|
57 |
* structure (itx_t) is allocated and all the information necessary to |
|
58 |
* possibly replay the transaction is saved in it. The itx is then assigned |
|
59 |
* a sequence number and inserted in the in-memory list anchored in the zilog. |
|
60 |
* |
|
61 |
* Replay mode |
|
62 |
* ----------- |
|
63 |
* We need to mark the intent log record as replayed in the log header. |
|
64 |
* This is done in the same transaction as the replay so that they |
|
65 |
* commit atomically. |
|
789 | 66 |
*/ |
67 |
||
5331 | 68 |
int |
69 |
zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap) |
|
70 |
{ |
|
71 |
int isxvattr = (vap->va_mask & AT_XVATTR); |
|
72 |
switch (type) { |
|
73 |
case Z_FILE: |
|
74 |
if (vsecp == NULL && !isxvattr) |
|
75 |
return (TX_CREATE); |
|
76 |
if (vsecp && isxvattr) |
|
77 |
return (TX_CREATE_ACL_ATTR); |
|
78 |
if (vsecp) |
|
79 |
return (TX_CREATE_ACL); |
|
80 |
else |
|
81 |
return (TX_CREATE_ATTR); |
|
82 |
/*NOTREACHED*/ |
|
83 |
case Z_DIR: |
|
84 |
if (vsecp == NULL && !isxvattr) |
|
85 |
return (TX_MKDIR); |
|
86 |
if (vsecp && isxvattr) |
|
87 |
return (TX_MKDIR_ACL_ATTR); |
|
88 |
if (vsecp) |
|
89 |
return (TX_MKDIR_ACL); |
|
90 |
else |
|
91 |
return (TX_MKDIR_ATTR); |
|
92 |
case Z_XATTRDIR: |
|
93 |
return (TX_MKXATTR); |
|
94 |
} |
|
95 |
ASSERT(0); |
|
96 |
return (TX_MAX_TYPE); |
|
97 |
} |
|
98 |
||
789 | 99 |
/* |
5331 | 100 |
* build up the log data necessary for logging xvattr_t |
101 |
* First lr_attr_t is initialized. following the lr_attr_t |
|
102 |
* is the mapsize and attribute bitmap copied from the xvattr_t. |
|
103 |
* Following the bitmap and bitmapsize two 64 bit words are reserved |
|
104 |
* for the create time which may be set. Following the create time |
|
105 |
* records a single 64 bit integer which has the bits to set on |
|
106 |
* replay for the xvattr. |
|
107 |
*/ |
|
108 |
static void |
|
109 |
zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap) |
|
110 |
{ |
|
111 |
uint32_t *bitmap; |
|
112 |
uint64_t *attrs; |
|
113 |
uint64_t *crtime; |
|
114 |
xoptattr_t *xoap; |
|
115 |
void *scanstamp; |
|
116 |
int i; |
|
117 |
||
118 |
xoap = xva_getxoptattr(xvap); |
|
119 |
ASSERT(xoap); |
|
120 |
||
121 |
lrattr->lr_attr_masksize = xvap->xva_mapsize; |
|
122 |
bitmap = &lrattr->lr_attr_bitmap; |
|
123 |
for (i = 0; i != xvap->xva_mapsize; i++, bitmap++) { |
|
124 |
*bitmap = xvap->xva_reqattrmap[i]; |
|
125 |
} |
|
126 |
||
127 |
/* Now pack the attributes up in a single uint64_t */ |
|
128 |
attrs = (uint64_t *)bitmap; |
|
129 |
crtime = attrs + 1; |
|
130 |
scanstamp = (caddr_t)(crtime + 2); |
|
131 |
*attrs = 0; |
|
132 |
if (XVA_ISSET_REQ(xvap, XAT_READONLY)) |
|
133 |
*attrs |= (xoap->xoa_readonly == 0) ? 0 : |
|
134 |
XAT0_READONLY; |
|
135 |
if (XVA_ISSET_REQ(xvap, XAT_HIDDEN)) |
|
136 |
*attrs |= (xoap->xoa_hidden == 0) ? 0 : |
|
137 |
XAT0_HIDDEN; |
|
138 |
if (XVA_ISSET_REQ(xvap, XAT_SYSTEM)) |
|
139 |
*attrs |= (xoap->xoa_system == 0) ? 0 : |
|
140 |
XAT0_SYSTEM; |
|
141 |
if (XVA_ISSET_REQ(xvap, XAT_ARCHIVE)) |
|
142 |
*attrs |= (xoap->xoa_archive == 0) ? 0 : |
|
143 |
XAT0_ARCHIVE; |
|
144 |
if (XVA_ISSET_REQ(xvap, XAT_IMMUTABLE)) |
|
145 |
*attrs |= (xoap->xoa_immutable == 0) ? 0 : |
|
146 |
XAT0_IMMUTABLE; |
|
147 |
if (XVA_ISSET_REQ(xvap, XAT_NOUNLINK)) |
|
148 |
*attrs |= (xoap->xoa_nounlink == 0) ? 0 : |
|
149 |
XAT0_NOUNLINK; |
|
150 |
if (XVA_ISSET_REQ(xvap, XAT_APPENDONLY)) |
|
151 |
*attrs |= (xoap->xoa_appendonly == 0) ? 0 : |
|
152 |
XAT0_APPENDONLY; |
|
153 |
if (XVA_ISSET_REQ(xvap, XAT_OPAQUE)) |
|
154 |
*attrs |= (xoap->xoa_opaque == 0) ? 0 : |
|
155 |
XAT0_APPENDONLY; |
|
156 |
if (XVA_ISSET_REQ(xvap, XAT_NODUMP)) |
|
157 |
*attrs |= (xoap->xoa_nodump == 0) ? 0 : |
|
158 |
XAT0_NODUMP; |
|
159 |
if (XVA_ISSET_REQ(xvap, XAT_AV_QUARANTINED)) |
|
160 |
*attrs |= (xoap->xoa_av_quarantined == 0) ? 0 : |
|
161 |
XAT0_AV_QUARANTINED; |
|
162 |
if (XVA_ISSET_REQ(xvap, XAT_AV_MODIFIED)) |
|
163 |
*attrs |= (xoap->xoa_av_modified == 0) ? 0 : |
|
164 |
XAT0_AV_MODIFIED; |
|
165 |
if (XVA_ISSET_REQ(xvap, XAT_CREATETIME)) |
|
166 |
ZFS_TIME_ENCODE(&xoap->xoa_createtime, crtime); |
|
167 |
if (XVA_ISSET_REQ(xvap, XAT_AV_SCANSTAMP)) |
|
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 | 178 |
} |
179 |
||
180 |
static void * |
|
181 |
zfs_log_fuid_ids(zfs_fuid_info_t *fuidp, void *start) |
|
182 |
{ |
|
183 |
zfs_fuid_t *zfuid; |
|
184 |
uint64_t *fuidloc = start; |
|
185 |
||
186 |
/* First copy in the ACE FUIDs */ |
|
187 |
for (zfuid = list_head(&fuidp->z_fuids); zfuid; |
|
188 |
zfuid = list_next(&fuidp->z_fuids, zfuid)) { |
|
189 |
*fuidloc++ = zfuid->z_logfuid; |
|
190 |
} |
|
191 |
return (fuidloc); |
|
192 |
} |
|
193 |
||
194 |
||
195 |
static void * |
|
196 |
zfs_log_fuid_domains(zfs_fuid_info_t *fuidp, void *start) |
|
197 |
{ |
|
198 |
zfs_fuid_domain_t *zdomain; |
|
199 |
||
200 |
/* now copy in the domain info, if any */ |
|
201 |
if (fuidp->z_domain_str_sz != 0) { |
|
202 |
for (zdomain = list_head(&fuidp->z_domains); zdomain; |
|
203 |
zdomain = list_next(&fuidp->z_domains, zdomain)) { |
|
204 |
bcopy((void *)zdomain->z_domain, start, |
|
205 |
strlen(zdomain->z_domain) + 1); |
|
206 |
start = (caddr_t)start + |
|
207 |
strlen(zdomain->z_domain) + 1; |
|
208 |
} |
|
209 |
} |
|
210 |
return (start); |
|
211 |
} |
|
212 |
||
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 | 216 |
* |
217 |
* TX_CREATE and TX_MKDIR are standard creates, but they may have FUID |
|
218 |
* domain information appended prior to the name. In this case the |
|
219 |
* uid/gid in the log record will be a log centric FUID. |
|
220 |
* |
|
221 |
* TX_CREATE_ACL_ATTR and TX_MKDIR_ACL_ATTR handle special creates that |
|
222 |
* may contain attributes, ACL and optional fuid information. |
|
223 |
* |
|
224 |
* TX_CREATE_ACL and TX_MKDIR_ACL handle special creates that specify |
|
225 |
* and ACL and normal users/groups in the ACEs. |
|
226 |
* |
|
227 |
* There may be an optional xvattr attribute information similar |
|
228 |
* to zfs_log_setattr. |
|
229 |
* |
|
230 |
* Also, after the file name "domain" strings may be appended. |
|
789 | 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 | 233 |
zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, |
234 |
znode_t *dzp, znode_t *zp, char *name, vsecattr_t *vsecp, |
|
235 |
zfs_fuid_info_t *fuidp, vattr_t *vap) |
|
789 | 236 |
{ |
237 |
itx_t *itx; |
|
238 |
lr_create_t *lr; |
|
5331 | 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 | 241 |
size_t xvatsize = 0; |
242 |
size_t txsize; |
|
243 |
xvattr_t *xvap = (xvattr_t *)vap; |
|
244 |
void *end; |
|
245 |
size_t lrsize; |
|
789 | 246 |
size_t namesize = strlen(name) + 1; |
5331 | 247 |
size_t fuidsz = 0; |
789 | 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 | 251 |
|
5331 | 252 |
/* |
253 |
* If we have FUIDs present then add in space for |
|
254 |
* domains and ACE fuid's if any. |
|
255 |
*/ |
|
256 |
if (fuidp) { |
|
257 |
fuidsz += fuidp->z_domain_str_sz; |
|
258 |
fuidsz += fuidp->z_fuid_cnt * sizeof (uint64_t); |
|
259 |
} |
|
260 |
||
261 |
if (vap->va_mask & AT_XVATTR) |
|
262 |
xvatsize = ZIL_XVAT_SIZE(xvap->xva_mapsize); |
|
263 |
||
264 |
if ((int)txtype == TX_CREATE_ATTR || (int)txtype == TX_MKDIR_ATTR || |
|
265 |
(int)txtype == TX_CREATE || (int)txtype == TX_MKDIR || |
|
266 |
(int)txtype == TX_MKXATTR) { |
|
267 |
txsize = sizeof (*lr) + namesize + fuidsz + xvatsize; |
|
268 |
lrsize = sizeof (*lr); |
|
269 |
} else { |
|
270 |
txsize = |
|
271 |
sizeof (lr_acl_create_t) + namesize + fuidsz + |
|
5435 | 272 |
ZIL_ACE_LENGTH(aclsize) + xvatsize; |
5331 | 273 |
lrsize = sizeof (lr_acl_create_t); |
274 |
} |
|
275 |
||
276 |
itx = zil_itx_create(txtype, txsize); |
|
277 |
||
789 | 278 |
lr = (lr_create_t *)&itx->itx_lr; |
279 |
lr->lr_doid = dzp->z_id; |
|
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 | 284 |
} else { |
285 |
lr->lr_uid = fuidp->z_fuid_owner; |
|
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 | 289 |
} else { |
290 |
lr->lr_gid = fuidp->z_fuid_group; |
|
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 | 300 |
|
301 |
/* |
|
302 |
* Fill in xvattr info if any |
|
303 |
*/ |
|
304 |
if (vap->va_mask & AT_XVATTR) { |
|
305 |
zfs_log_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), xvap); |
|
306 |
end = (caddr_t)lr + lrsize + xvatsize; |
|
307 |
} else { |
|
308 |
end = (caddr_t)lr + lrsize; |
|
309 |
} |
|
310 |
||
311 |
/* Now fill in any ACL info */ |
|
312 |
||
313 |
if (vsecp) { |
|
314 |
lracl = (lr_acl_create_t *)&itx->itx_lr; |
|
315 |
lracl->lr_aclcnt = vsecp->vsa_aclcnt; |
|
316 |
lracl->lr_acl_bytes = aclsize; |
|
317 |
lracl->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0; |
|
318 |
lracl->lr_fuidcnt = fuidp ? fuidp->z_fuid_cnt : 0; |
|
319 |
if (vsecp->vsa_aclflags & VSA_ACE_ACLFLAGS) |
|
320 |
lracl->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags; |
|
321 |
else |
|
322 |
lracl->lr_acl_flags = 0; |
|
323 |
||
324 |
bcopy(vsecp->vsa_aclentp, end, aclsize); |
|
5435 | 325 |
end = (caddr_t)end + ZIL_ACE_LENGTH(aclsize); |
5331 | 326 |
} |
327 |
||
328 |
/* drop in FUID info */ |
|
329 |
if (fuidp) { |
|
330 |
end = zfs_log_fuid_ids(fuidp, end); |
|
331 |
end = zfs_log_fuid_domains(fuidp, end); |
|
332 |
} |
|
333 |
/* |
|
334 |
* Now place file name in log record |
|
335 |
*/ |
|
336 |
bcopy(name, end, namesize); |
|
789 | 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 | 339 |
} |
340 |
||
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 | 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 | 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 | 347 |
{ |
348 |
itx_t *itx; |
|
349 |
lr_remove_t *lr; |
|
350 |
size_t namesize = strlen(name) + 1; |
|
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 | 354 |
|
355 |
itx = zil_itx_create(txtype, sizeof (*lr) + namesize); |
|
356 |
lr = (lr_remove_t *)&itx->itx_lr; |
|
357 |
lr->lr_doid = dzp->z_id; |
|
358 |
bcopy(name, (char *)(lr + 1), namesize); |
|
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 | 363 |
} |
364 |
||
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 | 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 | 369 |
zfs_log_link(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, |
789 | 370 |
znode_t *dzp, znode_t *zp, char *name) |
371 |
{ |
|
372 |
itx_t *itx; |
|
373 |
lr_link_t *lr; |
|
374 |
size_t namesize = strlen(name) + 1; |
|
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 | 378 |
|
379 |
itx = zil_itx_create(txtype, sizeof (*lr) + namesize); |
|
380 |
lr = (lr_link_t *)&itx->itx_lr; |
|
381 |
lr->lr_doid = dzp->z_id; |
|
382 |
lr->lr_link_obj = zp->z_id; |
|
383 |
bcopy(name, (char *)(lr + 1), namesize); |
|
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 | 386 |
} |
387 |
||
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 | 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 | 392 |
zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, |
393 |
znode_t *dzp, znode_t *zp, char *name, char *link) |
|
789 | 394 |
{ |
395 |
itx_t *itx; |
|
396 |
lr_create_t *lr; |
|
397 |
size_t namesize = strlen(name) + 1; |
|
398 |
size_t linksize = strlen(link) + 1; |
|
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 | 402 |
|
403 |
itx = zil_itx_create(txtype, sizeof (*lr) + namesize + linksize); |
|
404 |
lr = (lr_create_t *)&itx->itx_lr; |
|
405 |
lr->lr_doid = dzp->z_id; |
|
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 | 414 |
bcopy(name, (char *)(lr + 1), namesize); |
415 |
bcopy(link, (char *)(lr + 1) + namesize, linksize); |
|
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 | 418 |
} |
419 |
||
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 | 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 | 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 | 426 |
{ |
427 |
itx_t *itx; |
|
428 |
lr_rename_t *lr; |
|
429 |
size_t snamesize = strlen(sname) + 1; |
|
430 |
size_t dnamesize = strlen(dname) + 1; |
|
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 | 434 |
|
435 |
itx = zil_itx_create(txtype, sizeof (*lr) + snamesize + dnamesize); |
|
436 |
lr = (lr_rename_t *)&itx->itx_lr; |
|
437 |
lr->lr_sdoid = sdzp->z_id; |
|
438 |
lr->lr_tdoid = tdzp->z_id; |
|
439 |
bcopy(sname, (char *)(lr + 1), snamesize); |
|
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 | 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 | 444 |
} |
445 |
||
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 | 448 |
*/ |
2237 | 449 |
ssize_t zfs_immediate_write_sz = 32768; |
789 | 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 | 452 |
zfs_log_write(zilog_t *zilog, dmu_tx_t *tx, int txtype, |
4620 | 453 |
znode_t *zp, offset_t off, ssize_t resid, int ioflag) |
789 | 454 |
{ |
1669 | 455 |
itx_wr_state_t write_state; |
4620 | 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 | 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 | 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 | 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 | 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 | 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 | 479 |
while (resid) { |
480 |
itx_t *itx; |
|
481 |
lr_write_t *lr; |
|
482 |
ssize_t len; |
|
483 |
||
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 | 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 | 488 |
len = SPA_MAXBLOCKSIZE >> 1; |
489 |
else |
|
490 |
len = resid; |
|
491 |
||
492 |
itx = zil_itx_create(txtype, sizeof (*lr) + |
|
493 |
(write_state == WR_COPIED ? len : 0)); |
|
494 |
lr = (lr_write_t *)&itx->itx_lr; |
|
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 | 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 | 500 |
write_state = WR_NEED_COPY; |
501 |
} |
|
4620 | 502 |
|
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 | 506 |
lr->lr_foid = zp->z_id; |
507 |
lr->lr_offset = off; |
|
508 |
lr->lr_length = len; |
|
509 |
lr->lr_blkoff = 0; |
|
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 | 512 |
itx->itx_private = zp->z_zfsvfs; |
789 | 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 | 519 |
|
4620 | 520 |
off += len; |
521 |
resid -= len; |
|
522 |
} |
|
789 | 523 |
} |
524 |
||
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 | 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 | 529 |
zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype, |
530 |
znode_t *zp, uint64_t off, uint64_t len) |
|
531 |
{ |
|
532 |
itx_t *itx; |
|
533 |
lr_truncate_t *lr; |
|
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 | 537 |
|
538 |
itx = zil_itx_create(txtype, sizeof (*lr)); |
|
539 |
lr = (lr_truncate_t *)&itx->itx_lr; |
|
540 |
lr->lr_foid = zp->z_id; |
|
541 |
lr->lr_offset = off; |
|
542 |
lr->lr_length = len; |
|
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 | 546 |
} |
547 |
||
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 | 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 | 552 |
zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, |
5331 | 553 |
znode_t *zp, vattr_t *vap, uint_t mask_applied, zfs_fuid_info_t *fuidp) |
789 | 554 |
{ |
5331 | 555 |
itx_t *itx; |
556 |
lr_setattr_t *lr; |
|
557 |
xvattr_t *xvap = (xvattr_t *)vap; |
|
558 |
size_t recsize = sizeof (lr_setattr_t); |
|
559 |
void *start; |
|
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 | 563 |
|
5331 | 564 |
/* |
565 |
* If XVATTR set, then log record size needs to allow |
|
566 |
* for lr_attr_t + xvattr mask, mapsize and create time |
|
567 |
* plus actual attribute values |
|
568 |
*/ |
|
569 |
if (vap->va_mask & AT_XVATTR) |
|
570 |
recsize = sizeof (*lr) + ZIL_XVAT_SIZE(xvap->xva_mapsize); |
|
571 |
||
572 |
if (fuidp) |
|
573 |
recsize += fuidp->z_domain_str_sz; |
|
574 |
||
575 |
itx = zil_itx_create(txtype, recsize); |
|
789 | 576 |
lr = (lr_setattr_t *)&itx->itx_lr; |
577 |
lr->lr_foid = zp->z_id; |
|
578 |
lr->lr_mask = (uint64_t)mask_applied; |
|
579 |
lr->lr_mode = (uint64_t)vap->va_mode; |
|
5331 | 580 |
if ((mask_applied & AT_UID) && IS_EPHEMERAL(vap->va_uid)) |
581 |
lr->lr_uid = fuidp->z_fuid_owner; |
|
582 |
else |
|
583 |
lr->lr_uid = (uint64_t)vap->va_uid; |
|
584 |
||
585 |
if ((mask_applied & AT_GID) && IS_EPHEMERAL(vap->va_gid)) |
|
586 |
lr->lr_gid = fuidp->z_fuid_group; |
|
587 |
else |
|
588 |
lr->lr_gid = (uint64_t)vap->va_gid; |
|
589 |
||
789 | 590 |
lr->lr_size = (uint64_t)vap->va_size; |
591 |
ZFS_TIME_ENCODE(&vap->va_atime, lr->lr_atime); |
|
592 |
ZFS_TIME_ENCODE(&vap->va_mtime, lr->lr_mtime); |
|
5331 | 593 |
start = (lr_setattr_t *)(lr + 1); |
594 |
if (vap->va_mask & AT_XVATTR) { |
|
595 |
zfs_log_xvattr((lr_attr_t *)start, xvap); |
|
596 |
start = (caddr_t)start + ZIL_XVAT_SIZE(xvap->xva_mapsize); |
|
597 |
} |
|
598 |
||
599 |
/* |
|
600 |
* Now stick on domain information if any on end |
|
601 |
*/ |
|
602 |
||
603 |
if (fuidp) |
|
604 |
(void) zfs_log_fuid_domains(fuidp, start); |
|
789 | 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 | 608 |
} |
609 |
||
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 | 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 | 614 |
zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp, |
615 |
vsecattr_t *vsecp, zfs_fuid_info_t *fuidp) |
|
789 | 616 |
{ |
617 |
itx_t *itx; |
|
5331 | 618 |
lr_acl_v0_t *lrv0; |
789 | 619 |
lr_acl_t *lr; |
5331 | 620 |
int txtype; |
621 |
int lrsize; |
|
622 |
size_t txsize; |
|
623 |
size_t aclbytes = vsecp->vsa_aclentsz; |
|
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 | 629 |
TX_ACL_V0 : TX_ACL; |
630 |
||
631 |
if (txtype == TX_ACL) |
|
632 |
lrsize = sizeof (*lr); |
|
633 |
else |
|
634 |
lrsize = sizeof (*lrv0); |
|
789 | 635 |
|
5435 | 636 |
txsize = lrsize + |
637 |
((txtype == TX_ACL) ? ZIL_ACE_LENGTH(aclbytes) : aclbytes) + |
|
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 | 640 |
|
641 |
itx = zil_itx_create(txtype, txsize); |
|
642 |
||
789 | 643 |
lr = (lr_acl_t *)&itx->itx_lr; |
644 |
lr->lr_foid = zp->z_id; |
|
5331 | 645 |
if (txtype == TX_ACL) { |
646 |
lr->lr_acl_bytes = aclbytes; |
|
647 |
lr->lr_domcnt = fuidp ? fuidp->z_domain_cnt : 0; |
|
648 |
lr->lr_fuidcnt = fuidp ? fuidp->z_fuid_cnt : 0; |
|
649 |
if (vsecp->vsa_mask & VSA_ACE_ACLFLAGS) |
|
650 |
lr->lr_acl_flags = (uint64_t)vsecp->vsa_aclflags; |
|
651 |
else |
|
652 |
lr->lr_acl_flags = 0; |
|
653 |
} |
|
654 |
lr->lr_aclcnt = (uint64_t)vsecp->vsa_aclcnt; |
|
655 |
||
656 |
if (txtype == TX_ACL_V0) { |
|
657 |
lrv0 = (lr_acl_v0_t *)lr; |
|
658 |
bcopy(vsecp->vsa_aclentp, (ace_t *)(lrv0 + 1), aclbytes); |
|
659 |
} else { |
|
660 |
void *start = (ace_t *)(lr + 1); |
|
661 |
||
662 |
bcopy(vsecp->vsa_aclentp, start, aclbytes); |
|
663 |
||
5435 | 664 |
start = (caddr_t)start + ZIL_ACE_LENGTH(aclbytes); |
5331 | 665 |
|
666 |
if (fuidp) { |
|
667 |
start = zfs_log_fuid_ids(fuidp, start); |
|
668 |
(void) zfs_log_fuid_domains(fuidp, start); |
|
669 |
} |
|
670 |
} |
|
789 | 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 | 674 |
} |