xref: /titanic_41/usr/src/cmd/fs.d/cachefs/cfsd/cfsd_logelem.c (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Methods of the cfsd_logelem* classes.
31  */
32 
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <stddef.h>
36 #include <string.h>
37 #include <synch.h>
38 #include <unistd.h>
39 #include <stdarg.h>
40 #include <string.h>
41 #include <libintl.h>
42 #include <errno.h>
43 #include <locale.h>
44 #include <sys/utsname.h>
45 #include <sys/vfs.h>
46 #include <sys/cred.h>
47 #include <sys/param.h>
48 #include <sys/types.h>
49 #include <sys/fs/cachefs_fs.h>
50 #include <sys/fs/cachefs_dlog.h>
51 #include <sys/fs/cachefs_ioctl.h>
52 #include <mdbug/mdbug.h>
53 
54 #include "cfsd.h"
55 #include "cfsd_maptbl.h"
56 #include "cfsd_logfile.h"
57 #include "cfsd_kmod.h"
58 #include "cfsd_logelem.h"
59 
60 
61 #define	dl_ctime dl_times.tm_ctime
62 #define	dl_mtime dl_times.tm_mtime
63 #define	TIMECHANGE(A, B) (memcmp(&A, &B, sizeof (A)) != 0)
64 #define	X_OPTIMIZED -2
65 #define	X_CONFLICT -3
66 
67 
68 /*
69  * -----------------------------------------------------------------
70  *			cfsd_logelem_create
71  *
72  * Description:
73  *	Constructor for the cfsd_logelem abstract base class.
74  * Arguments:
75  * Returns:
76  * Preconditions:
77  */
78 
79 cfsd_logelem_object_t *
80 cfsd_logelem_create(cfsd_maptbl_object_t *maptbl_object_p,
81 	cfsd_logfile_object_t *logfile_object_p,
82 	cfsd_kmod_object_t *kmod_object_p)
83 {
84 	cfsd_logelem_object_t *logelem_object_p;
85 
86 	dbug_enter("cfsd_logelem_create");
87 
88 	logelem_object_p = cfsd_calloc(sizeof (cfsd_logelem_object_t));
89 	logelem_object_p->i_maptbl_object_p = maptbl_object_p;
90 	logelem_object_p->i_logfile_object_p = logfile_object_p;
91 	logelem_object_p->i_kmod_object_p = kmod_object_p;
92 
93 	logelem_object_p->i_entp = logfile_object_p->i_cur_entry;
94 	logelem_object_p->i_offset = logfile_object_p->i_cur_offset;
95 	dbug_assert(logelem_object_p->i_entp);
96 	logelem_object_p->i_messagep[0] = '\0';
97 	logelem_object_p->i_type = NO_OBJECT_TYPE;
98 
99 	dbug_leave("cfsd_logelem_create");
100 	return (logelem_object_p);
101 }
102 
103 /*
104  * -----------------------------------------------------------------
105  *			cfsd_logelem_destroy
106  *
107  * Description:
108  *	Destructor for the cfsd_logelem abstract base class.
109  * Arguments:
110  * Returns:
111  * Preconditions:
112  */
113 
114 
115 void
116 cfsd_logelem_destroy(cfsd_logelem_object_t *logelem_object_p)
117 {
118 	dbug_enter("cfsd_logelem_destroy");
119 	cfsd_free(logelem_object_p);
120 	dbug_leave("cfsd_logelem_destroy");
121 }
122 /*
123  * -----------------------------------------------------------------
124  *			logelem_print_cred
125  *
126  * Description:
127  * Arguments:
128  *	credp
129  * Returns:
130  * Preconditions:
131  *	precond(credp)
132  */
133 
134 void
135 logelem_print_cred(dl_cred_t *credp)
136 {
137 	char buf[12 * NGROUPS_MAX_DEFAULT];
138 	char format[10];
139 	int xx;
140 
141 	dbug_enter("logelem_print_cred");
142 	dbug_precond(credp);
143 
144 	buf[0] = '\0';
145 	dbug_print(("dump", "credentials"));
146 	dbug_print(("dump", "  uid %d, gid %d",
147 	    credp->cr_uid, credp->cr_gid));
148 	dbug_print(("dump", "  ruid %d, rgid %d, suid %d, sgid %d",
149 	    credp->cr_ruid, credp->cr_rgid,
150 	    credp->cr_suid, credp->cr_sgid));
151 
152 	for (xx = 0; xx < credp->cr_ngroups; xx++) {
153 		sprintf(format, " %d", credp->cr_groups[xx]);
154 		strlcat(buf, format, sizeof (buf));
155 	}
156 	dbug_print(("dump", "  ngroups %d,  %s", credp->cr_ngroups, buf));
157 	dbug_leave("logelem_print_cred");
158 }
159 
160 /*
161  * -----------------------------------------------------------------
162  *			logelem_print_attr
163  *
164  * Description:
165  * Arguments:
166  *	vattrp
167  * Returns:
168  * Preconditions:
169  *	precond(vattrp)
170  */
171 
172 void
173 logelem_print_attr(cfs_vattr_t *vp)
174 {
175 	dbug_enter("logelem_print_attr");
176 	dbug_precond(vp);
177 
178 	dbug_print(("dump", "attributes"));
179 	dbug_print(("dump", "  mask 0x%x", vp->va_mask));
180 	if (vp->va_mask & AT_TYPE)
181 		dbug_print(("dump", "  type %d", vp->va_type));
182 	if (vp->va_mask & AT_MODE)
183 		dbug_print(("dump", "  mode 0%o", vp->va_mode));
184 	if (vp->va_mask & AT_UID)
185 		dbug_print(("dump", "  uid %d", vp->va_uid));
186 	if (vp->va_mask & AT_GID)
187 		dbug_print(("dump", "  gid %d", vp->va_gid));
188 	if (vp->va_mask & AT_FSID)
189 		dbug_print(("dump", "  fsid %08x", vp->va_fsid));
190 	if (vp->va_mask & AT_NODEID)
191 		dbug_print(("dump", "  nodeid %08x", vp->va_nodeid));
192 	if (vp->va_mask & AT_NLINK)
193 		dbug_print(("dump", "  nlink %d", vp->va_nlink));
194 	if (vp->va_mask & AT_SIZE)
195 		dbug_print(("dump", "  size %d", vp->va_size));
196 	if (vp->va_mask & AT_ATIME)
197 		dbug_print(("dump", "  atime %08x %08x",
198 		    vp->va_atime.tv_sec, vp->va_atime.tv_nsec));
199 	if (vp->va_mask & AT_MTIME)
200 		dbug_print(("dump", "  mtime %08x %08x",
201 		    vp->va_mtime.tv_sec, vp->va_mtime.tv_nsec));
202 	if (vp->va_mask & AT_CTIME)
203 		dbug_print(("dump", "  ctime %08x %08x",
204 		    vp->va_ctime.tv_sec, vp->va_ctime.tv_nsec));
205 	if (vp->va_mask & AT_RDEV)
206 		dbug_print(("dump", "  rdev %08x", vp->va_rdev));
207 	if (vp->va_mask & AT_BLKSIZE)
208 		dbug_print(("dump", "  blksize %08x", vp->va_blksize));
209 	if (vp->va_mask & AT_NBLOCKS)
210 		dbug_print(("dump", "  nblocks %d", vp->va_nblocks));
211 	if (vp->va_mask & AT_SEQ)
212 		dbug_print(("dump", "  seq %d", vp->va_seq));
213 	dbug_leave("logelem_print_attr");
214 }
215 
216 /*
217  * -----------------------------------------------------------------
218  *			logelem_format_fid
219  *
220  * Description:
221  * Arguments:
222  *	fidp
223  * Returns:
224  * Preconditions:
225  *	precond(fidp)
226  */
227 
228 void
229 logelem_format_fid(cfsd_logelem_object_t *logelem_object_p, cfs_fid_t *fidp)
230 {
231 	uint_t val;
232 	int index;
233 	char format[10];
234 	logelem_object_p->i_fidbuf[0] = '\0';
235 
236 	for (index = 0; index < (int)fidp->fid_len; index += sizeof (uint_t)) {
237 		memcpy(&val, &fidp->fid_data[index], sizeof (uint_t));
238 		snprintf(format, sizeof (format), "%08x ", val);
239 		strlcat(logelem_object_p->i_fidbuf, format,
240 		    sizeof (logelem_object_p->i_fidbuf));
241 	}
242 }
243 
244 
245 /*
246  * -----------------------------------------------------------------
247  *			logelem_lostfound
248  *
249  * Description:
250  *	Called when there is a conflict on a file.
251  * Arguments:
252  *	cidp	cid of file to move to lost+found
253  *	pcidp	parent cid if known, else null
254  *	namep	name of file if known, else null
255  * Returns:
256  *	Returns 0 for success, EIO if file could not be moved.
257  * Preconditions:
258  *	precond(cidp)
259  */
260 
261 int
262 logelem_lostfound(cfsd_logelem_object_t *logelem_object_p,
263 	cfs_cid_t *cidp,
264 	cfs_cid_t *pcidp,
265 	const char *namep,
266 	dl_cred_t *cred)
267 {
268 	struct cfs_dlog_mapping_space map;
269 	int xx;
270 	cfs_fid_t *fp, dirfid;
271 	cachefsio_getinfo_t ginfo;
272 	char namebuf[MAXNAMELEN];
273 	int gotdirfid = 0;
274 	int wrotefile = 0;
275 	char *np;
276 	char namebuf2[MAXNAMELEN * 3];
277 	int foundname = 0;
278 	int index;
279 	char *machnamep;
280 	struct utsname info;
281 	int len;
282 	cfs_fid_t filefid;
283 	struct cfs_vattr vattr;
284 	char newname[MAXNAMELEN];
285 	char mesgbuf[MAXNAMELEN * 3];
286 #define	MAXTRIES 10
287 
288 	dbug_enter("logelem_lostfound");
289 	dbug_precond(cidp);
290 	dbug_precond(cred);
291 
292 	/* make an alternate name for the file */
293 	if (namep == NULL)
294 		sprintf(namebuf, "fileno_%"PRIx64, cidp->cid_fileno);
295 
296 	/* get info about the file from the cache */
297 	xx = kmod_getinfo(logelem_object_p->i_kmod_object_p, cidp, &ginfo);
298 	if (xx) {
299 		if (namep == NULL) {
300 			namep = namebuf;
301 		}
302 		logelem_log_opskipped(logelem_object_p, namep);
303 		dbug_leave("logelem_lostfound");
304 		return (0);
305 	}
306 
307 	/* determine what we want to call this file */
308 	if (namep == NULL) {
309 		if (ginfo.gi_name[0] == '\0')
310 			namep = namebuf;
311 		else
312 			namep = ginfo.gi_name;
313 	}
314 
315 	/* if not a regular file or not modified */
316 	if ((ginfo.gi_attr.va_type != VREG) || !ginfo.gi_modified) {
317 		logelem_log_opskipped(logelem_object_p, namep);
318 		dbug_leave("logelem_lostfound");
319 		return (0);
320 	}
321 
322 	/* get the fid of the parent directory from the passed in cid */
323 	if (pcidp) {
324 		/* see if we have a valid mapping for the parent cid */
325 		xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
326 		    *pcidp, &map);
327 		if (xx == -1) {
328 			logelem_log_opskipped(logelem_object_p, namep);
329 			dbug_leave("logelem_lostfound");
330 			return (EIO);
331 		}
332 		if ((xx == 0) && (0 < map.ms_fid)) {
333 			xx = logfile_offset(
334 			    logelem_object_p->i_logfile_object_p,
335 			    map.ms_fid, (caddr_t *)&fp);
336 			if (xx) {
337 				logelem_log_opskipped(logelem_object_p, namep);
338 				dbug_leave("logelem_lostfound");
339 				return (EIO);
340 			}
341 			if (fp->fid_len) {
342 				gotdirfid = 1;
343 				dirfid = *fp;
344 			}
345 		}
346 
347 		/* otherwise try to get the fid from the cache */
348 		if (gotdirfid == 0) {
349 			xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
350 			    pcidp, &dirfid);
351 			if (xx == 0)
352 				gotdirfid = 1;
353 		}
354 	}
355 
356 	/* if not parent fid yet, try to get one from the dir in the cache */
357 	if ((gotdirfid == 0) && ginfo.gi_pcid.cid_fileno) {
358 		/* see if we have a valid mapping for the cache parent cid */
359 		xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
360 		    ginfo.gi_pcid, &map);
361 		if (xx == -1) {
362 			logelem_log_opskipped(logelem_object_p, namep);
363 			dbug_leave("logelem_lostfound");
364 			return (EIO);
365 		}
366 		if ((xx == 0) && (0 < map.ms_fid)) {
367 			xx = logfile_offset(
368 			    logelem_object_p->i_logfile_object_p,
369 			    map.ms_fid, (caddr_t *)&fp);
370 			if (xx) {
371 				logelem_log_opskipped(logelem_object_p, namep);
372 				dbug_leave("logelem_lostfound");
373 				return (EIO);
374 			}
375 			if (fp->fid_len) {
376 				gotdirfid = 1;
377 				dirfid = *fp;
378 			}
379 		}
380 
381 		/* otherwise try to get the fid from the cache */
382 		if (gotdirfid == 0) {
383 			xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
384 			    &ginfo.gi_pcid, &dirfid);
385 			if (xx == 0)
386 				gotdirfid = 1;
387 		}
388 	}
389 
390 
391 	/* if we found a parent directory */
392 	if (gotdirfid) {
393 		/* get the host name */
394 		xx = uname(&info);
395 		if (xx == -1)
396 			machnamep = "client";
397 		else
398 			machnamep = info.nodename;
399 
400 		/* find a name we can call this file */
401 		for (index = 0; index < MAXTRIES; index++) {
402 			/* construct the name */
403 			snprintf(namebuf2, sizeof (namebuf2),
404 			    "%s.conflict.%s.%x", machnamep, namep, index);
405 			len = strlen(namebuf2) + 1;
406 			if (len > MAXNAMELEN)
407 				np = &namebuf2[len - MAXNAMELEN];
408 			else
409 				np = namebuf2;
410 
411 			/* see if it exists */
412 			xx = kmod_getattrname(
413 			    logelem_object_p->i_kmod_object_p,
414 			    &dirfid, np, cred, NULL, NULL);
415 
416 			/* timeout error, pass the error back up */
417 			if ((xx == ETIMEDOUT) || (xx == EIO)) {
418 				dbug_leave("logelem_lostfound");
419 				return (ETIMEDOUT);
420 			}
421 			/* file does not exist, so try to use it */
422 			if (xx == ENOENT) {
423 				foundname = 1;
424 				break;
425 			}
426 
427 			/* any other error on the directory, give up */
428 			if (xx)
429 				break;
430 		}
431 
432 		/* if we found a name */
433 		if (foundname) {
434 			/* set up attributes for the file */
435 			vattr.va_type = VREG;
436 			vattr.va_mode = ginfo.gi_attr.va_mode;
437 			vattr.va_mask = AT_TYPE | AT_MODE | AT_SIZE;
438 			vattr.va_size = 0;
439 
440 			/* create the file */
441 			xx = kmod_create(logelem_object_p->i_kmod_object_p,
442 			    &dirfid, np, NULL, &vattr, NONEXCL, VWRITE,
443 			    cred, &filefid, NULL, NULL);
444 			if (xx == 0) {
445 				/* write the file */
446 				xx = kmod_pushback(
447 				    logelem_object_p->i_kmod_object_p,
448 				    cidp, &filefid, cred, NULL, NULL, 0);
449 				if (xx == 0) {
450 					wrotefile = 1;
451 					snprintf(mesgbuf, sizeof (mesgbuf),
452 					    gettext("File %s renamed as %s on "
453 					    "server."),
454 					    namep, np);
455 					logelem_resolution(logelem_object_p,
456 					    mesgbuf);
457 				}
458 			}
459 		}
460 
461 	}
462 
463 	/* if we could not write the file to the server, move to lost+found */
464 	if (wrotefile == 0) {
465 
466 		/* move the file to lost+found */
467 		xx = kmod_lostfound(logelem_object_p->i_kmod_object_p,
468 		    cidp, namep, newname);
469 		if (xx == EINVAL) {
470 			dbug_assert(0);
471 			logelem_log_opskipped(logelem_object_p, namep);
472 			dbug_leave("logelem_lostfound");
473 			return (0);
474 		} else if (xx) {
475 			snprintf(mesgbuf, sizeof (mesgbuf),
476 			    gettext("Cannot move %s to lost+found.  "),
477 			    namep);
478 			strlcat(mesgbuf,
479 			    gettext("Run cachefs fsck on the file system."),
480 			    sizeof (mesgbuf));
481 			logelem_resolution(logelem_object_p, mesgbuf);
482 			return (EIO);
483 		} else {
484 			snprintf(mesgbuf, sizeof (mesgbuf),
485 			    gettext("Moved %s to %s/%s/%s."), namep,
486 			    logelem_object_p->i_kmod_object_p->i_path,
487 			    CACHEFS_LOSTFOUND_NAME, newname);
488 			logelem_resolution(logelem_object_p, mesgbuf);
489 		}
490 	}
491 
492 	/* set the mapping to indicate conflict */
493 	map.ms_cid = *cidp;
494 	map.ms_fid = X_CONFLICT;
495 	map.ms_times = 0;
496 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
497 	if (xx) {
498 		dbug_leave("logelem_lostfound");
499 		return (EIO);
500 	}
501 	dbug_leave("logelem_lostfound");
502 	return (xx);
503 }
504 
505 /*
506  * -----------------------------------------------------------------
507  *			logelem_problem
508  *
509  * Description:
510  *	Specifies the problem string.
511  *	Pass a variable number of strings.
512  *	They are concatinated together to form the message.
513  *	Terminate the argument list with NULL.
514  * Arguments:
515  *	strp
516  * Returns:
517  * Preconditions:
518  *	precond(strp)
519  */
520 
521 void
522 logelem_problem(cfsd_logelem_object_t *logelem_object_p, char *strp)
523 {
524 	dbug_enter("logelem_problem");
525 	dbug_precond(strp);
526 
527 	logelem_message(logelem_object_p, gettext("cachefsd: Problem: "), strp);
528 	dbug_leave("logelem_problem");
529 }
530 
531 /*
532  * -----------------------------------------------------------------
533  *			logelem_resolution
534  *
535  * Description:
536  *	Specifies the resolution string.
537  *	Pass a variable number of strings.
538  *	They are concatinated together to form the message.
539  *	Terminate the argument list with NULL.
540  * Arguments:
541  *	strp
542  * Returns:
543  * Preconditions:
544  *	precond(strp)
545  */
546 
547 void
548 logelem_resolution(cfsd_logelem_object_t *logelem_object_p, char *strp)
549 {
550 	dbug_enter("logelem_resolution");
551 	dbug_precond(strp);
552 
553 	logelem_message(logelem_object_p, gettext("cachefsd: Resolution: "),
554 	    strp);
555 	dbug_leave("logelem_resolution");
556 }
557 /*
558  * -----------------------------------------------------------------
559  *			logelem_message_append
560  *
561  * Description:
562  * Arguments:
563  * Returns:
564  * Preconditions:
565  *	precond(strp1)
566  *	precond(strp1)
567  */
568 
569 void
570 logelem_message_append(char *strp1, char *strp2)
571 {
572 	dbug_enter("logelem_message_append");
573 	if ((strlen(strp1) + strlen(strp2)) < (size_t)CFSDMesgMax)
574 		strcat(strp1, strp2);
575 	else {
576 		fprintf(stderr,
577 		    gettext("cachefsd: log element message truncated\n"));
578 		strncat(strp1, strp2, CFSDMesgMax - (strlen(strp1) + 1));
579 	}
580 	dbug_leave("logelem_message_append");
581 }
582 /*
583  * -----------------------------------------------------------------
584  *			logelem_message
585  *
586  * Description:
587  * Arguments:
588  *	prefix
589  *	strp
590  * Returns:
591  * Preconditions:
592  *	precond(prefix)
593  *	precond(strp)
594  */
595 
596 void
597 logelem_message(cfsd_logelem_object_t *logelem_object_p,
598 	char *prefix,
599 	char *strp)
600 {
601 	dbug_enter("logelem_message");
602 
603 	dbug_precond(prefix);
604 	dbug_precond(strp);
605 
606 	logelem_message_append(logelem_object_p->i_messagep, prefix);
607 	logelem_message_append(logelem_object_p->i_messagep, strp);
608 	logelem_message_append(logelem_object_p->i_messagep, "\n");
609 	dbug_leave("logelem_message");
610 }
611 /*
612  * -----------------------------------------------------------------
613  *			logelem_log_opfailed
614  *
615  * Description:
616  * Arguments:
617  * Returns:
618  * Preconditions:
619  */
620 
621 void
622 logelem_log_opfailed(cfsd_logelem_object_t *logelem_object_p,
623 	char *opp, char *info, const char *namep, int xx)
624 {
625 	char mesgbuf[CFSDStrMax];
626 	char errorbuf[CFSDStrMax];
627 
628 	/*
629 	 * XXX need to change this so we don't assemble the message,
630 	 * this violates localization.
631 	 */
632 	snprintf(mesgbuf, sizeof (mesgbuf), gettext("%s failed"), opp);
633 	if (namep) {
634 		strlcat(mesgbuf, gettext(" on "), sizeof (mesgbuf));
635 		strlcat(mesgbuf, namep, sizeof (mesgbuf));
636 	}
637 	strlcat(mesgbuf, ".", sizeof (mesgbuf));
638 	if (info) {
639 		strlcat(mesgbuf, " ", sizeof (mesgbuf));
640 		strlcat(mesgbuf, info, sizeof (mesgbuf));
641 		strlcat(mesgbuf, ".", sizeof (mesgbuf));
642 	}
643 	if (xx) {
644 		snprintf(errorbuf, sizeof (errorbuf),
645 		    gettext(" Error: %s."), strerror(xx));
646 		strlcat(mesgbuf, errorbuf, sizeof (mesgbuf));
647 	}
648 	logelem_problem(logelem_object_p, mesgbuf);
649 }
650 /*
651  * -----------------------------------------------------------------
652  *			logelem_log_opskipped
653  *
654  * Description:
655  * Arguments:
656  * Returns:
657  * Preconditions:
658  */
659 
660 void
661 logelem_log_opskipped(cfsd_logelem_object_t *logelem_object_p,
662 	const char *namep)
663 {
664 	char mesgbuf[CFSDStrMax];
665 
666 	snprintf(mesgbuf, sizeof (mesgbuf),
667 	    gettext("Operation on %s skipped."), namep);
668 	logelem_resolution(logelem_object_p, mesgbuf);
669 }
670 /*
671  * -----------------------------------------------------------------
672  *			logelem_log_timelogmesg
673  *
674  * Description:
675  * Arguments:
676  * Returns:
677  * Preconditions:
678  */
679 
680 void
681 logelem_log_timelogmesg(cfsd_logelem_object_t *logelem_object_p,
682 	char *opp, const char *namep, char *mesgp, int time_log)
683 {
684 	char mesgbuf[CFSDStrMax];
685 
686 	/*
687 	 * XXX need to change this so we don't assemble the message,
688 	 * this violates localization.
689 	 */
690 	snprintf(mesgbuf, sizeof (mesgbuf), gettext("%s failed"), opp);
691 	if (namep) {
692 		strlcat(mesgbuf, gettext(" on "), sizeof (mesgbuf));
693 		strlcat(mesgbuf, namep, sizeof (mesgbuf));
694 	}
695 	strlcat(mesgbuf, ".", sizeof (mesgbuf));
696 	if (mesgp) {
697 		strlcat(mesgbuf, mesgp, sizeof (mesgbuf));
698 		strlcat(mesgbuf, ".", sizeof (mesgbuf));
699 	}
700 	strlcat(mesgbuf, " ", sizeof (mesgbuf));
701 	switch (time_log) {
702 	case 0:
703 		strlcat(mesgbuf, gettext("while rolling log."),
704 		    sizeof (mesgbuf));
705 		break;
706 	case 1:
707 		strlcat(mesgbuf, gettext("while disconnected."),
708 		    sizeof (mesgbuf));
709 		break;
710 
711 	default:
712 		strlcat(mesgbuf, gettext("while unknown operation."),
713 		    sizeof (mesgbuf));
714 		break;
715 	}
716 
717 	logelem_problem(logelem_object_p, mesgbuf);
718 }
719 
720 /*
721  *			cfsd_logelem_setattr_create
722  *
723  * Description:
724  * Arguments:
725  * Returns:
726  * Preconditions:
727  */
728 
729 
730 cfsd_logelem_object_t *
731 cfsd_logelem_setattr_create(cfsd_maptbl_object_t *maptbl_object_p,
732 	cfsd_logfile_object_t *logfile_object_p,
733 	cfsd_kmod_object_t *kmod_object_p)
734 {
735 	cfsd_logelem_object_t *logelem_object_p;
736 	cfsd_logelem_setattr_object_t *setattr_object_p;
737 
738 	dbug_enter("cfsd_logelem_setattr_create");
739 
740 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
741 	    logfile_object_p, kmod_object_p);
742 	logelem_object_p->i_type = SETATTR_OBJECT_TYPE;
743 
744 	setattr_object_p = SETATTR_OBJECT_PTR(logelem_object_p);
745 	setattr_object_p->i_up =
746 	    &logelem_object_p->i_entp->dl_u.dl_setattr;
747 	dbug_leave("cfsd_logelem_setattr_create");
748 	return (logelem_object_p);
749 }
750 
751 /*
752  *			cfsd_logelem_setsecattr_create
753  *
754  * Description:
755  * Arguments:
756  * Returns:
757  * Preconditions:
758  */
759 cfsd_logelem_object_t *
760 cfsd_logelem_setsecattr_create(cfsd_maptbl_object_t *maptbl_object_p,
761 	cfsd_logfile_object_t *logfile_object_p,
762 	cfsd_kmod_object_t *kmod_object_p)
763 {
764 	cfsd_logelem_object_t *logelem_object_p;
765 	cfsd_logelem_setsecattr_object_t *setsecattr_object_p;
766 
767 	dbug_enter("cfsd_logelem_setsecattr_create");
768 
769 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
770 	    logfile_object_p, kmod_object_p);
771 	logelem_object_p->i_type = SETSECATTR_OBJECT_TYPE;
772 
773 	setsecattr_object_p = SETSECATTR_OBJECT_PTR(logelem_object_p);
774 	setsecattr_object_p->i_up =
775 	    &logelem_object_p->i_entp->dl_u.dl_setsecattr;
776 	setsecattr_object_p->i_acl =
777 	    (const aclent_t *)
778 	    ((caddr_t)setsecattr_object_p->i_up->dl_buffer +
779 	    ((off_t)(setsecattr_object_p->i_up->dl_cred.cr_ngroups - 1)
780 	    * (off_t)sizeof (gid_t)));
781 	dbug_leave("cfsd_logelem_setsecattr_create");
782 	return (logelem_object_p);
783 }
784 /*
785  *			cfsd_logelem_create_create
786  *
787  * Description:
788  * Arguments:
789  * Returns:
790  * Preconditions:
791  */
792 
793 cfsd_logelem_object_t *
794 cfsd_logelem_create_create(cfsd_maptbl_object_t *maptbl_object_p,
795 	cfsd_logfile_object_t *logfile_object_p,
796 	cfsd_kmod_object_t *kmod_object_p)
797 {
798 	cfsd_logelem_object_t *logelem_object_p;
799 	cfsd_logelem_create_object_t *create_object_p;
800 
801 	dbug_enter("cfsd_logelem_create_create");
802 
803 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
804 	    logfile_object_p, kmod_object_p);
805 	logelem_object_p->i_type = CREATE_OBJECT_TYPE;
806 
807 	create_object_p = CREATE_OBJECT_PTR(logelem_object_p);
808 	create_object_p->i_up =
809 	    &logelem_object_p->i_entp->dl_u.dl_create;
810 	create_object_p->i_namep =
811 	    create_object_p->i_up->dl_buffer +
812 	    ((create_object_p->i_up->dl_cred.cr_ngroups - 1) *
813 	    sizeof (gid_t));
814 	dbug_leave("cfsd_logelem_create_create");
815 	return (logelem_object_p);
816 }
817 
818 /*
819  *			cfsd_logelem_remove_create
820  *
821  * Description:
822  * Arguments:
823  * Returns:
824  * Preconditions:
825  */
826 
827 cfsd_logelem_object_t *
828 cfsd_logelem_remove_create(cfsd_maptbl_object_t *maptbl_object_p,
829 	cfsd_logfile_object_t *logfile_object_p,
830 	cfsd_kmod_object_t *kmod_object_p)
831 {
832 	cfsd_logelem_object_t *logelem_object_p;
833 	cfsd_logelem_remove_object_t *remove_object_p;
834 
835 	dbug_enter("cfsd_logelem_remove_create");
836 
837 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
838 	    logfile_object_p, kmod_object_p);
839 	logelem_object_p->i_type = REMOVE_OBJECT_TYPE;
840 
841 	remove_object_p = REMOVE_OBJECT_PTR(logelem_object_p);
842 	remove_object_p->i_up =
843 	    &logelem_object_p->i_entp->dl_u.dl_remove;
844 	remove_object_p->i_namep =
845 	    remove_object_p->i_up->dl_buffer +
846 	    ((remove_object_p->i_up->dl_cred.cr_ngroups - 1) *
847 	    sizeof (gid_t));
848 	dbug_leave("cfsd_logelem_remove_create");
849 	return (logelem_object_p);
850 }
851 /*
852  * -----------------------------------------------------------------
853  *			cfsd_logelem_rmdir_create
854  *
855  * Description:
856  * Arguments:
857  * Returns:
858  * Preconditions:
859  */
860 
861 cfsd_logelem_object_t *
862 cfsd_logelem_rmdir_create(cfsd_maptbl_object_t *maptbl_object_p,
863 	cfsd_logfile_object_t *logfile_object_p,
864 	cfsd_kmod_object_t *kmod_object_p)
865 {
866 	cfsd_logelem_object_t *logelem_object_p;
867 	cfsd_logelem_rmdir_object_t *rmdir_object_p;
868 
869 	dbug_enter("cfsd_logelem_rmdir_create");
870 
871 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
872 	    logfile_object_p, kmod_object_p);
873 	logelem_object_p->i_type = RMDIR_OBJECT_TYPE;
874 
875 	rmdir_object_p = RMDIR_OBJECT_PTR(logelem_object_p);
876 	rmdir_object_p->i_up =
877 	    &logelem_object_p->i_entp->dl_u.dl_rmdir;
878 	rmdir_object_p->i_namep =
879 	    rmdir_object_p->i_up->dl_buffer +
880 	    ((rmdir_object_p->i_up->dl_cred.cr_ngroups - 1)
881 	    * sizeof (gid_t));
882 	dbug_leave("cfsd_logelem_rmdir_create");
883 	return (logelem_object_p);
884 }
885 /*
886  * -----------------------------------------------------------------
887  *			cfsd_logelem_mkdir_create
888  *
889  * Description:
890  * Arguments:
891  * Returns:
892  * Preconditions:
893  */
894 
895 cfsd_logelem_object_t *
896 cfsd_logelem_mkdir_create(cfsd_maptbl_object_t *maptbl_object_p,
897 	cfsd_logfile_object_t *logfile_object_p,
898 	cfsd_kmod_object_t *kmod_object_p)
899 {
900 	cfsd_logelem_object_t *logelem_object_p;
901 	cfsd_logelem_mkdir_object_t *mkdir_object_p;
902 
903 	dbug_enter("cfsd_logelem_mkdir_create");
904 
905 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
906 	    logfile_object_p, kmod_object_p);
907 	logelem_object_p->i_type = MKDIR_OBJECT_TYPE;
908 
909 	mkdir_object_p = MKDIR_OBJECT_PTR(logelem_object_p);
910 	mkdir_object_p->i_up =
911 	    &logelem_object_p->i_entp->dl_u.dl_mkdir;
912 	mkdir_object_p->i_namep =
913 	    mkdir_object_p->i_up->dl_buffer +
914 	    ((mkdir_object_p->i_up->dl_cred.cr_ngroups - 1) *
915 	    sizeof (gid_t));
916 	dbug_leave("cfsd_logelem_mkdir_create");
917 	return (logelem_object_p);
918 }
919 /*
920  * -----------------------------------------------------------------
921  *			cfsd_logelem_link_create
922  *
923  * Description:
924  * Arguments:
925  * Returns:
926  * Preconditions:
927  */
928 
929 cfsd_logelem_object_t *
930 cfsd_logelem_link_create(cfsd_maptbl_object_t *maptbl_object_p,
931 	cfsd_logfile_object_t *logfile_object_p,
932 	cfsd_kmod_object_t *kmod_object_p)
933 {
934 	cfsd_logelem_object_t *logelem_object_p;
935 	cfsd_logelem_link_object_t *link_object_p;
936 
937 	dbug_enter("cfsd_logelem_link_create");
938 
939 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
940 	    logfile_object_p, kmod_object_p);
941 	logelem_object_p->i_type = LINK_OBJECT_TYPE;
942 
943 	link_object_p = LINK_OBJECT_PTR(logelem_object_p);
944 	link_object_p->i_up =
945 	    &logelem_object_p->i_entp->dl_u.dl_link;
946 	link_object_p->i_namep =
947 	    link_object_p->i_up->dl_buffer +
948 	    ((link_object_p->i_up->dl_cred.cr_ngroups - 1)
949 	    * sizeof (gid_t));
950 	dbug_leave("cfsd_logelem_link_create");
951 	return (logelem_object_p);
952 }
953 /*
954  * -----------------------------------------------------------------
955  *			cfsd_logelem_symlink_create
956  *
957  * Description:
958  * Arguments:
959  * Returns:
960  * Preconditions:
961  */
962 
963 cfsd_logelem_object_t *
964 cfsd_logelem_symlink_create(cfsd_maptbl_object_t *maptbl_object_p,
965 	cfsd_logfile_object_t *logfile_object_p,
966 	cfsd_kmod_object_t *kmod_object_p)
967 {
968 	cfsd_logelem_object_t *logelem_object_p;
969 	cfsd_logelem_symlink_object_t *symlink_object_p;
970 
971 	dbug_enter("cfsd_logelem_symlink_create");
972 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
973 	    logfile_object_p, kmod_object_p);
974 	logelem_object_p->i_type = SYMLINK_OBJECT_TYPE;
975 
976 	symlink_object_p = SYMLINK_OBJECT_PTR(logelem_object_p);
977 	symlink_object_p->i_up =
978 	    &logelem_object_p->i_entp->dl_u.dl_symlink;
979 	symlink_object_p->i_namep =
980 	    symlink_object_p->i_up->dl_buffer +
981 	    ((symlink_object_p->i_up->dl_cred.cr_ngroups - 1) *
982 	    sizeof (gid_t));
983 	symlink_object_p->i_contentsp =
984 	    symlink_object_p->i_namep +
985 	    strlen(symlink_object_p->i_namep) + 1;
986 	dbug_leave("cfsd_logelem_symlink_create");
987 	return (logelem_object_p);
988 }
989 /*
990  * -----------------------------------------------------------------
991  *			cfsd_logelem_rename_create
992  *
993  * Description:
994  * Arguments:
995  * Returns:
996  * Preconditions:
997  */
998 
999 cfsd_logelem_object_t *
1000 cfsd_logelem_rename_create(cfsd_maptbl_object_t *maptbl_object_p,
1001 	cfsd_logfile_object_t *logfile_object_p,
1002 	cfsd_kmod_object_t *kmod_object_p)
1003 {
1004 	cfsd_logelem_object_t *logelem_object_p;
1005 	cfsd_logelem_rename_object_t *rename_object_p;
1006 
1007 	dbug_enter("cfsd_logelem_rename_create");
1008 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
1009 	    logfile_object_p, kmod_object_p);
1010 	logelem_object_p->i_type = RENAME_OBJECT_TYPE;
1011 
1012 	rename_object_p = RENAME_OBJECT_PTR(logelem_object_p);
1013 	rename_object_p->i_up =
1014 	    &logelem_object_p->i_entp->dl_u.dl_rename;
1015 	rename_object_p->i_orignamep =
1016 	    rename_object_p->i_up->dl_buffer +
1017 	    ((rename_object_p->i_up->dl_cred.cr_ngroups - 1) *
1018 	    sizeof (gid_t));
1019 	rename_object_p->i_newnamep =
1020 	    rename_object_p->i_orignamep +
1021 	    strlen(rename_object_p->i_orignamep) + 1;
1022 	dbug_leave("cfsd_logelem_rename_create");
1023 	return (logelem_object_p);
1024 }
1025 /*
1026  *			cfsd_logelem_modified_create
1027  *
1028  * Description:
1029  * Arguments:
1030  * Returns:
1031  * Preconditions:
1032  */
1033 
1034 cfsd_logelem_object_t *
1035 cfsd_logelem_modified_create(cfsd_maptbl_object_t *maptbl_object_p,
1036 	cfsd_logfile_object_t *logfile_object_p,
1037 	cfsd_kmod_object_t *kmod_object_p)
1038 {
1039 	cfsd_logelem_object_t *logelem_object_p;
1040 	cfsd_logelem_modified_object_t *modified_object_p;
1041 
1042 	dbug_enter("cfsd_logelem_modified_create");
1043 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
1044 	    logfile_object_p, kmod_object_p);
1045 	logelem_object_p->i_type = MODIFIED_OBJECT_TYPE;
1046 
1047 	modified_object_p = MODIFIED_OBJECT_PTR(logelem_object_p);
1048 	modified_object_p->i_up =
1049 	    &logelem_object_p->i_entp->dl_u.dl_modify;
1050 	dbug_leave("cfsd_logelem_modified_create");
1051 	return (logelem_object_p);
1052 }
1053 /*
1054  *			cfsd_logelem_mapfid
1055  *
1056  * Description:
1057  * Arguments:
1058  * Returns:
1059  * Preconditions:
1060  */
1061 
1062 cfsd_logelem_object_t *
1063 cfsd_logelem_mapfid_create(cfsd_maptbl_object_t *maptbl_object_p,
1064 	cfsd_logfile_object_t *logfile_object_p,
1065 	cfsd_kmod_object_t *kmod_object_p)
1066 {
1067 	cfsd_logelem_object_t *logelem_object_p;
1068 	cfsd_logelem_mapfid_object_t *mapfid_object_p;
1069 
1070 	dbug_enter("cfsd_logelem_mapfid_create");
1071 	logelem_object_p = cfsd_logelem_create(maptbl_object_p,
1072 	    logfile_object_p, kmod_object_p);
1073 	logelem_object_p->i_type = MAPFID_OBJECT_TYPE;
1074 
1075 	mapfid_object_p = MAPFID_OBJECT_PTR(logelem_object_p);
1076 	mapfid_object_p->i_up =
1077 	    &logelem_object_p->i_entp->dl_u.dl_mapfid;
1078 	dbug_leave("cfsd_logelem_mapfid_create");
1079 	return (logelem_object_p);
1080 }
1081 /*
1082  *			logelem_roll
1083  *
1084  * Description:
1085  * Arguments:
1086  * Returns:
1087  * Preconditions:
1088  */
1089 
1090 int
1091 logelem_roll(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1092 {
1093 	int retval = 0;
1094 
1095 	dbug_enter("logelem_roll");
1096 
1097 	switch (logelem_object_p->i_type) {
1098 
1099 	case NO_OBJECT_TYPE:
1100 		dbug_assert(0);
1101 		retval = EIO;
1102 		break;
1103 
1104 	case SETATTR_OBJECT_TYPE:
1105 		retval = logelem_roll_setattr(logelem_object_p, seqp);
1106 		break;
1107 
1108 	case SETSECATTR_OBJECT_TYPE:
1109 		retval = logelem_roll_setsecattr(logelem_object_p, seqp);
1110 		break;
1111 
1112 	case CREATE_OBJECT_TYPE:
1113 		retval = logelem_roll_create(logelem_object_p, seqp);
1114 		break;
1115 
1116 	case REMOVE_OBJECT_TYPE:
1117 		retval = logelem_roll_remove(logelem_object_p, seqp);
1118 		break;
1119 
1120 	case RMDIR_OBJECT_TYPE:
1121 		retval = logelem_roll_rmdir(logelem_object_p, seqp);
1122 		break;
1123 
1124 	case MKDIR_OBJECT_TYPE:
1125 		retval = logelem_roll_mkdir(logelem_object_p, seqp);
1126 		break;
1127 
1128 	case LINK_OBJECT_TYPE:
1129 		retval = logelem_roll_link(logelem_object_p, seqp);
1130 		break;
1131 
1132 	case SYMLINK_OBJECT_TYPE:
1133 		retval = logelem_roll_symlink(logelem_object_p, seqp);
1134 		break;
1135 
1136 	case RENAME_OBJECT_TYPE:
1137 		retval = logelem_roll_rename(logelem_object_p, seqp);
1138 		break;
1139 
1140 	case MODIFIED_OBJECT_TYPE:
1141 		retval = logelem_roll_modified(logelem_object_p, seqp);
1142 		break;
1143 
1144 	case MAPFID_OBJECT_TYPE:
1145 		retval = logelem_roll_mapfid(logelem_object_p);
1146 		break;
1147 
1148 	default:
1149 		dbug_assert(0);
1150 		retval = EIO;
1151 	}
1152 	dbug_leave("logelem_roll");
1153 	return (retval);
1154 }
1155 /*
1156  *			logelem_roll_setattr
1157  *
1158  * Description:
1159  * Arguments:
1160  * Returns:
1161  * Preconditions:
1162  */
1163 
1164 int
1165 logelem_roll_setattr(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1166 {
1167 
1168 	int xx;
1169 	cfs_fid_t filefid, *fp;
1170 	struct cfs_dlog_mapping_space map;
1171 	cfs_dlog_tm_t *tmp;
1172 	cfs_timestruc_t ctime, mtime;
1173 	int time_log;
1174 	cfs_vattr_t va;
1175 	int conflict = 0;
1176 
1177 	dbug_enter("logelem_roll_setattr");
1178 
1179 	/* get the mapping for this cid if it exists */
1180 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1181 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_cid, &map);
1182 	if (xx == -1) {
1183 		logelem_log_opfailed(logelem_object_p, "Setattr",
1184 		    gettext("error mapping cid"), NULL, 0);
1185 		dbug_leave("logelem_roll_setattr");
1186 		return (EIO);
1187 	}
1188 	/* if a mapping was not found */
1189 	if (xx) {
1190 		/* dummy up mapping so we get values from the cache */
1191 		map.ms_cid = SETATTR_OBJECT(logelem_object_p).i_up->dl_cid;
1192 		map.ms_fid = 0;
1193 		map.ms_times = 0;
1194 	}
1195 
1196 	/* done if there was a conflict on the file */
1197 	if (map.ms_fid == X_CONFLICT) {
1198 		logelem_log_opfailed(logelem_object_p, "Setattr",
1199 		    gettext("file conflict"), NULL, 0);
1200 		dbug_leave("logelem_roll_setattr");
1201 		return (0);
1202 	}
1203 	/* done if the file is optimized out */
1204 	if (map.ms_fid == X_OPTIMIZED) {
1205 		dbug_leave("logelem_roll_setattr");
1206 		return (0);
1207 	}
1208 	/* if we have a fid in the mapping */
1209 	if (map.ms_fid) {
1210 		/* get the fid */
1211 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1212 		    map.ms_fid, (caddr_t *)&fp);
1213 		if (xx) {
1214 			logelem_log_opfailed(logelem_object_p, "Setattr",
1215 			    gettext("error getting logfile offset"), NULL, xx);
1216 			dbug_leave("logelem_roll_setattr");
1217 			return (EIO);
1218 		}
1219 		filefid = *fp;
1220 		dbug_assert(filefid.fid_len);
1221 	}
1222 
1223 	/* else get the fid from the cache */
1224 	else {
1225 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
1226 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid, &filefid);
1227 		if (xx == ENOENT) {
1228 			dbug_leave("logelem_roll_setattr");
1229 			return (0);
1230 		}
1231 		if (xx) {
1232 			logelem_log_opfailed(logelem_object_p, "Setattr",
1233 			    gettext("File is no longer in the cache"),
1234 			    NULL, xx);
1235 			xx = logelem_lostfound(logelem_object_p,
1236 			    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1237 			    NULL, NULL,
1238 			    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1239 			dbug_leave("logelem_roll_setattr");
1240 			return (xx);
1241 		}
1242 	}
1243 
1244 	/* if we have timestamps in the mapping */
1245 	if (map.ms_times) {
1246 		/* get the times */
1247 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1248 		    map.ms_times, (caddr_t *)&tmp);
1249 		if (xx) {
1250 			logelem_log_opfailed(logelem_object_p, "Setattr",
1251 			    gettext("error getting logfile offset"), NULL, xx);
1252 			dbug_leave("logelem_roll_setattr");
1253 			return (EIO);
1254 		}
1255 		ctime = tmp->tm_ctime;
1256 		mtime = tmp->tm_mtime;
1257 		time_log = 0;
1258 	}
1259 
1260 	/* else get the timestamps from the log entry */
1261 	else {
1262 		ctime = SETATTR_OBJECT(logelem_object_p).i_up->dl_ctime;
1263 		mtime = SETATTR_OBJECT(logelem_object_p).i_up->dl_mtime;
1264 		time_log = 1;
1265 	}
1266 
1267 	/* get the attributes of the file from the back fs */
1268 	xx = kmod_getattrfid(logelem_object_p->i_kmod_object_p, &filefid,
1269 	    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred, &va);
1270 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1271 		dbug_leave("logelem_roll_setattr");
1272 		return (ETIMEDOUT);
1273 	}
1274 	if (xx) {
1275 		logelem_log_opfailed(logelem_object_p, "Setattr",
1276 		    gettext("error getting attributes"), NULL, xx);
1277 		xx = logelem_lostfound(logelem_object_p,
1278 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1279 		    NULL, NULL,
1280 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1281 		dbug_leave("logelem_roll_setattr");
1282 		return (xx);
1283 	}
1284 
1285 
1286 	/* conflict if mtime changed */
1287 	if (TIMECHANGE(mtime, va.va_mtime)) {
1288 		logelem_log_timelogmesg(logelem_object_p, "Setattr",
1289 		    NULL, gettext("File modified"), time_log);
1290 		conflict = 1;
1291 	}
1292 
1293 	/* conflict if ctime changed */
1294 	else if (TIMECHANGE(ctime, va.va_ctime)) {
1295 		logelem_log_timelogmesg(logelem_object_p, "Setattr",
1296 		    NULL, gettext("File changed"), time_log);
1297 		conflict = 1;
1298 	}
1299 
1300 	/* if a conflict was detected */
1301 	if (conflict) {
1302 		logelem_log_opfailed(logelem_object_p, "Setattr",
1303 		    gettext("file conflict"), NULL, 0);
1304 		xx = logelem_lostfound(logelem_object_p,
1305 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1306 		    NULL, NULL,
1307 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1308 		dbug_leave("logelem_roll_setattr");
1309 		return (xx);
1310 	}
1311 
1312 	/* now do the setattr, get the new times */
1313 	xx = kmod_setattr(logelem_object_p->i_kmod_object_p,
1314 	    &filefid, &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1315 	    &SETATTR_OBJECT(logelem_object_p).i_up->dl_attrs,
1316 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_flags,
1317 	    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred,
1318 	    &SETATTR_OBJECT(logelem_object_p).i_up->dl_ctime,
1319 	    &SETATTR_OBJECT(logelem_object_p).i_up->dl_mtime);
1320 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1321 		dbug_leave("logelem_roll_setattr");
1322 		return (ETIMEDOUT);
1323 	}
1324 	if (xx) {
1325 		logelem_log_opfailed(logelem_object_p, "Setattr", NULL,
1326 		    NULL, xx);
1327 		xx = logelem_lostfound(logelem_object_p,
1328 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1329 		    NULL, NULL,
1330 		    &SETATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1331 		dbug_leave("logelem_roll_setattr");
1332 		return (xx);
1333 	}
1334 
1335 	/* update the mapping to point to the new times */
1336 	map.ms_times = logelem_object_p->i_offset +
1337 	    offsetof(cfs_dlog_entry_t, dl_u.dl_setattr.dl_times);
1338 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
1339 	if (xx) {
1340 		dbug_leave("logelem_roll_setattr");
1341 		return (EIO);
1342 	}
1343 	dbug_leave("logelem_roll_setattr");
1344 	return (0);
1345 }
1346 
1347 /*
1348  *			logelem_roll_setsecattr
1349  *
1350  * Description:
1351  * Arguments:
1352  * Returns:
1353  * Preconditions:
1354  */
1355 
1356 int
1357 logelem_roll_setsecattr(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1358 {
1359 	int xx;
1360 	cfs_fid_t filefid, *fp;
1361 	struct cfs_dlog_mapping_space map;
1362 	cfs_dlog_tm_t *tmp;
1363 	cfs_timestruc_t ctime, mtime;
1364 	int time_log;
1365 	cfs_vattr_t va;
1366 	int conflict = 0;
1367 
1368 	dbug_enter("logelem_roll_setsecattr");
1369 	/* get the mapping for this cid if it exists */
1370 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1371 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid, &map);
1372 	if (xx == -1) {
1373 		logelem_log_opfailed(logelem_object_p, "Setsecattr",
1374 		    gettext("error mapping cid"), NULL, 0);
1375 		dbug_leave("logelem_roll_setsecattr");
1376 		return (EIO);
1377 	}
1378 	/* if a mapping was not found */
1379 	if (xx) {
1380 		/* dummy up mapping so we get values from the cache */
1381 		map.ms_cid = SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid;
1382 		map.ms_fid = 0;
1383 		map.ms_times = 0;
1384 	}
1385 
1386 	/* done if there was a conflict on the file */
1387 	if (map.ms_fid == X_CONFLICT) {
1388 		logelem_log_opfailed(logelem_object_p, "Setsecattr",
1389 		    gettext("file conflict"), NULL, 0);
1390 		dbug_leave("logelem_roll_setsecattr");
1391 		return (0);
1392 	}
1393 	/* done if the file is optimized out */
1394 	if (map.ms_fid == X_OPTIMIZED) {
1395 		dbug_leave("logelem_roll_setsecattr");
1396 		return (0);
1397 	}
1398 	/* if we have a fid in the mapping */
1399 	if (map.ms_fid) {
1400 		/* get the fid */
1401 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1402 		    map.ms_fid, (caddr_t *)&fp);
1403 		if (xx) {
1404 			logelem_log_opfailed(logelem_object_p, "Setsecattr",
1405 			    gettext("error getting logfile offset"), NULL, 0);
1406 			dbug_leave("logelem_roll_setsecattr");
1407 			return (EIO);
1408 		}
1409 		filefid = *fp;
1410 		dbug_assert(filefid.fid_len);
1411 	}
1412 
1413 	/* else get the fid from the cache */
1414 	else {
1415 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
1416 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1417 		    &filefid);
1418 		if (xx == ENOENT) {
1419 			dbug_leave("logelem_roll_setsecattr");
1420 			return (0);
1421 		}
1422 		if (xx) {
1423 			logelem_log_opfailed(logelem_object_p, "Setsecattr",
1424 			    gettext("File is no longer in the cache"),
1425 			    NULL, xx);
1426 			xx = logelem_lostfound(logelem_object_p,
1427 			    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1428 			    NULL, NULL,
1429 			    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1430 			dbug_leave("logelem_roll_setsecattr");
1431 			return (xx);
1432 		}
1433 	}
1434 
1435 	/* if we have timestamps in the mapping */
1436 	if (map.ms_times) {
1437 		/* get the times */
1438 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1439 		    map.ms_times, (caddr_t *)&tmp);
1440 		if (xx) {
1441 			logelem_log_opfailed(logelem_object_p, "Setsecattr",
1442 			    gettext("error getting logfile offset"), NULL, 0);
1443 			dbug_leave("logelem_roll_setsecattr");
1444 			return (EIO);
1445 		}
1446 		ctime = tmp->tm_ctime;
1447 		mtime = tmp->tm_mtime;
1448 		time_log = 0;
1449 	}
1450 
1451 	/* else get the timestamps from the log entry */
1452 	else {
1453 		ctime = SETSECATTR_OBJECT(logelem_object_p).i_up->dl_ctime;
1454 		mtime = SETSECATTR_OBJECT(logelem_object_p).i_up->dl_mtime;
1455 		time_log = 1;
1456 	}
1457 
1458 	/* get the attributes of the file from the back fs */
1459 	xx = kmod_getattrfid(logelem_object_p->i_kmod_object_p, &filefid,
1460 	    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred, &va);
1461 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1462 		dbug_leave("logelem_roll_setsecattr");
1463 		return (ETIMEDOUT);
1464 	}
1465 	if (xx) {
1466 		logelem_log_opfailed(logelem_object_p, "Setsecattr",
1467 		    gettext("error getting attributes"), NULL, 0);
1468 		xx = logelem_lostfound(logelem_object_p,
1469 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1470 		    NULL, NULL,
1471 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1472 		dbug_leave("logelem_roll_setsecattr");
1473 		return (xx);
1474 	}
1475 
1476 	/* conflict if mtime changed */
1477 	if (TIMECHANGE(mtime, va.va_mtime)) {
1478 		logelem_log_timelogmesg(logelem_object_p, "Setsecattr",
1479 		    NULL, gettext("File modified"), time_log);
1480 		conflict = 1;
1481 	}
1482 
1483 	/* conflict if ctime changed */
1484 	else if (TIMECHANGE(ctime, va.va_ctime)) {
1485 		logelem_log_timelogmesg(logelem_object_p, "Setsecattr",
1486 		    NULL, gettext("File changed"), time_log);
1487 		conflict = 1;
1488 	}
1489 
1490 	/* if a conflict was detected */
1491 	if (conflict) {
1492 		logelem_log_opfailed(logelem_object_p, "Setsecattr",
1493 		    gettext("file conflict"), NULL, 0);
1494 		xx = logelem_lostfound(logelem_object_p,
1495 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1496 		    NULL, NULL,
1497 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1498 		dbug_leave("logelem_roll_setsecattr");
1499 		return (xx);
1500 	}
1501 
1502 	/* now do the setsecattr, get the new times */
1503 	xx = kmod_setsecattr(logelem_object_p->i_kmod_object_p, &filefid,
1504 	    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1505 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_mask,
1506 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_aclcnt,
1507 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_dfaclcnt,
1508 	    SETSECATTR_OBJECT(logelem_object_p).i_acl,
1509 	    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred,
1510 	    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_ctime,
1511 	    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_mtime);
1512 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1513 		dbug_leave("logelem_roll_setsecattr");
1514 		return (ETIMEDOUT);
1515 	}
1516 	if (xx) {
1517 		logelem_log_opfailed(logelem_object_p, "Setsecattr", NULL,
1518 		    NULL, xx);
1519 		xx = logelem_lostfound(logelem_object_p,
1520 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid,
1521 		    NULL, NULL,
1522 		    &SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred);
1523 		dbug_leave("logelem_roll_setsecattr");
1524 		return (xx);
1525 	}
1526 
1527 	/* update the mapping to point to the new times */
1528 	map.ms_times = logelem_object_p->i_offset +
1529 	    offsetof(cfs_dlog_entry_t, dl_u.dl_setsecattr.dl_times);
1530 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
1531 	if (xx) {
1532 		dbug_leave("logelem_roll_setsecattr");
1533 		return (EIO);
1534 	}
1535 	dbug_leave("logelem_roll_setsecattr");
1536 	return (0);
1537 }
1538 
1539 /*
1540  *			logelem_roll_create
1541  *
1542  * Description:
1543  * Arguments:
1544  * Returns:
1545  * Preconditions:
1546  */
1547 
1548 int
1549 logelem_roll_create(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1550 {
1551 	int xx;
1552 	cfs_fid_t *fp;
1553 	cfs_fid_t dirfid;
1554 	struct cfs_dlog_mapping_space map;
1555 	cfs_fid_t filefid2;
1556 	cfs_vattr_t va;
1557 
1558 	dbug_enter("logelem_roll_create");
1559 	/* if the file existed at the time of this operation */
1560 	dbug_assert(CREATE_OBJECT(logelem_object_p).i_up->dl_exists == 0);
1561 
1562 	/* see if the file no longer exists in the cache */
1563 #if 0
1564 	xx = kmod_exists(logelem_object_p->i_kmod_object_p,
1565 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid);
1566 	if (xx) {
1567 		dbug_assert(xx == ENOENT);
1568 
1569 		/* indicate ignore future operations on file */
1570 		map.ms_cid = CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid;
1571 		map.ms_fid = X_OPTIMIZED;
1572 		map.ms_times = 0;
1573 		xx = maptbl_set(maptbl_object_p, &map, 1);
1574 		dbug_leave("logelem_roll_create");
1575 		if (xx) {
1576 			dbug_leave("logelem_roll_create");
1577 			return (EIO);
1578 		}
1579 		dbug_leave("logelem_roll_create");
1580 		return (0);
1581 	}
1582 #endif
1583 
1584 	/* get the fid of the parent directory */
1585 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1586 	    CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid, &map);
1587 	if (xx == -1) {
1588 		logelem_log_opfailed(logelem_object_p, "Create",
1589 		    gettext("error mapping fid"), NULL, 0);
1590 		dbug_leave("logelem_roll_create");
1591 		return (EIO);
1592 	}
1593 	/* if error from getting map or no fid in map (ms_fid == 0) */
1594 	if (xx || (map.ms_fid <= 0)) {
1595 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
1596 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1597 		    &dirfid);
1598 		if (xx) {
1599 			logelem_log_opfailed(logelem_object_p, "Create",
1600 			    gettext("Parent directory no longer exists"),
1601 			    CREATE_OBJECT(logelem_object_p).i_namep, xx);
1602 			xx = logelem_lostfound(logelem_object_p,
1603 			    &CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid,
1604 			    &
1605 			    CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1606 			    CREATE_OBJECT(logelem_object_p).i_namep,
1607 			    &CREATE_OBJECT(logelem_object_p).i_up->dl_cred);
1608 			dbug_leave("logelem_roll_create");
1609 			return (xx);
1610 		}
1611 	} else {
1612 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1613 		    map.ms_fid, (caddr_t *)&fp);
1614 		if (xx) {
1615 			logelem_log_opfailed(logelem_object_p, "Create",
1616 			    gettext("error getting logfile offset"), NULL, 0);
1617 			dbug_leave("logelem_roll_create");
1618 			return (EIO);
1619 		}
1620 		dirfid = *fp;
1621 		dbug_assert(dirfid.fid_len);
1622 	}
1623 
1624 	/* if the file exists on the back fs */
1625 	xx = kmod_getattrname(logelem_object_p->i_kmod_object_p, &dirfid,
1626 	    CREATE_OBJECT(logelem_object_p).i_namep,
1627 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_cred, &va, &filefid2);
1628 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1629 		dbug_leave("logelem_roll_create");
1630 		return (ETIMEDOUT);
1631 	}
1632 
1633 	/* if the file exists on the back file system */
1634 	if (xx == 0) {
1635 		logelem_log_opfailed(logelem_object_p, "Create",
1636 		    gettext("File created while disconnected"),
1637 		    CREATE_OBJECT(logelem_object_p).i_namep, xx);
1638 		xx = logelem_lostfound(logelem_object_p,
1639 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid,
1640 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1641 		    CREATE_OBJECT(logelem_object_p).i_namep,
1642 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_cred);
1643 		dbug_leave("logelem_roll_create");
1644 		return (xx);
1645 	}
1646 
1647 	/* do the create */
1648 	xx = kmod_create(logelem_object_p->i_kmod_object_p, &dirfid,
1649 	    CREATE_OBJECT(logelem_object_p).i_namep,
1650 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid,
1651 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_attrs, NONEXCL,
1652 	    CREATE_OBJECT(logelem_object_p).i_up->dl_mode,
1653 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_cred,
1654 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_fid,
1655 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_ctime,
1656 	    &CREATE_OBJECT(logelem_object_p).i_up->dl_mtime);
1657 	if (xx) {
1658 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
1659 			dbug_leave("logelem_roll_create");
1660 			return (ETIMEDOUT);
1661 		}
1662 		/* create failed move to lost and found */
1663 		logelem_log_opfailed(logelem_object_p, "Create", NULL,
1664 		    CREATE_OBJECT(logelem_object_p).i_namep, xx);
1665 		xx = logelem_lostfound(logelem_object_p,
1666 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid,
1667 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1668 		    CREATE_OBJECT(logelem_object_p).i_namep,
1669 		    &CREATE_OBJECT(logelem_object_p).i_up->dl_cred);
1670 		dbug_leave("logelem_roll_create");
1671 		return (xx);
1672 	}
1673 
1674 	/* update the mapping to point to the new fid and times */
1675 	map.ms_cid = CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid;
1676 	map.ms_fid = logelem_object_p->i_offset +
1677 	    offsetof(cfs_dlog_entry_t, dl_u.dl_create.dl_fid);
1678 	map.ms_times = logelem_object_p->i_offset +
1679 	    offsetof(cfs_dlog_entry_t, dl_u.dl_create.dl_times);
1680 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
1681 	if (xx) {
1682 		dbug_leave("logelem_roll_create");
1683 		return (EIO);
1684 	}
1685 	dbug_leave("logelem_roll_create");
1686 	return (0);
1687 }
1688 /*
1689  * -----------------------------------------------------------------
1690  *			logelem_roll_remove
1691  *
1692  * Description:
1693  * Arguments:
1694  * Returns:
1695  * Preconditions:
1696  */
1697 
1698 
1699 int
1700 logelem_roll_remove(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1701 {
1702 
1703 	int xx;
1704 	cfs_fid_t *fp;
1705 	cfs_fid_t dirfid;
1706 	struct cfs_dlog_mapping_space map, dirmap;
1707 	cfs_timestruc_t ctime, mtime;
1708 	int time_log;
1709 	cfs_dlog_tm_t *tmp;
1710 	cfs_fid_t filefid2;
1711 	cfs_vattr_t va;
1712 	cfs_timestruc_t *ctimep;
1713 
1714 	dbug_enter("logelem_roll_remove");
1715 	/* get the mapping for this cid if it exists */
1716 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1717 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_child_cid, &map);
1718 	if (xx == -1) {
1719 		logelem_log_opfailed(logelem_object_p, "Remove",
1720 		    gettext("error mapping cid"), NULL, 0);
1721 		dbug_leave("logelem_roll_remove");
1722 		return (EIO);
1723 	}
1724 
1725 	/* done if there was a conflict on the file */
1726 	if (map.ms_fid == X_CONFLICT) {
1727 		logelem_log_opfailed(logelem_object_p, "Remove",
1728 		    gettext("file conflict"), NULL, 0);
1729 		dbug_leave("logelem_roll_remove");
1730 		return (0);
1731 	}
1732 
1733 	/* done if the file is optimized out */
1734 	if (map.ms_fid == X_OPTIMIZED) {
1735 		dbug_leave("logelem_roll_remove");
1736 		return (0);
1737 	}
1738 
1739 	/* if a mapping was not found */
1740 	if (xx) {
1741 		/* dummy up mapping so we get values from the cache */
1742 		map.ms_cid = REMOVE_OBJECT(logelem_object_p).i_up->dl_child_cid;
1743 		map.ms_fid = 0;
1744 		map.ms_times = 0;
1745 	}
1746 
1747 	/* if we have timestamps in the mapping */
1748 	if (map.ms_times) {
1749 		/* get the times */
1750 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1751 		    map.ms_times, (caddr_t *)&tmp);
1752 		if (xx) {
1753 			logelem_log_opfailed(logelem_object_p, "Remove",
1754 			    gettext("error getting logfile offset"), NULL, 0);
1755 			dbug_leave("logelem_roll_remove");
1756 			return (EIO);
1757 		}
1758 		ctime = tmp->tm_ctime;
1759 		mtime = tmp->tm_mtime;
1760 		time_log = 0;
1761 	}
1762 
1763 	/* else get the timestamps from the log entry */
1764 	else {
1765 		ctime = REMOVE_OBJECT(logelem_object_p).i_up->dl_ctime;
1766 		mtime = REMOVE_OBJECT(logelem_object_p).i_up->dl_mtime;
1767 		time_log = 1;
1768 	}
1769 
1770 	/* get the fid of the parent directory */
1771 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1772 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_parent_cid, &dirmap);
1773 	if (xx == -1) {
1774 		logelem_log_opfailed(logelem_object_p, "Remove",
1775 		    gettext("error mapping fid"), NULL, 0);
1776 		dbug_leave("logelem_roll_remove");
1777 		return (EIO);
1778 	}
1779 	/* if error from getting map or no fid in map (ms_fid == 0) */
1780 	if (xx || (dirmap.ms_fid <= 0)) {
1781 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
1782 		    &REMOVE_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1783 		    &dirfid);
1784 		if (xx) {
1785 			logelem_log_opfailed(logelem_object_p, "Remove",
1786 			    gettext("Parent directory no longer exists"),
1787 			    REMOVE_OBJECT(logelem_object_p).i_namep, xx);
1788 			logelem_log_opskipped(logelem_object_p,
1789 			    REMOVE_OBJECT(logelem_object_p).i_namep);
1790 			dbug_leave("logelem_roll_remove");
1791 			return (0);
1792 		}
1793 	} else {
1794 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1795 		    dirmap.ms_fid, (caddr_t *)&fp);
1796 		if (xx) {
1797 			logelem_log_opfailed(logelem_object_p, "Remove",
1798 			    gettext("error getting logfile offset"), NULL, 0);
1799 			dbug_leave("logelem_roll_remove");
1800 			return (EIO);
1801 		}
1802 		dirfid = *fp;
1803 		dbug_assert(dirfid.fid_len);
1804 	}
1805 
1806 	/* get file attributes */
1807 	xx = kmod_getattrname(logelem_object_p->i_kmod_object_p, &dirfid,
1808 	    REMOVE_OBJECT(logelem_object_p).i_namep,
1809 	    &REMOVE_OBJECT(logelem_object_p).i_up->dl_cred,
1810 	    &va, &filefid2);
1811 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
1812 		dbug_leave("logelem_roll_remove");
1813 		return (ETIMEDOUT);
1814 	}
1815 
1816 	/* if the file no longer exists on the back fs */
1817 	if (xx == ENOENT) {
1818 		logelem_log_opfailed(logelem_object_p, "Remove",
1819 		    gettext("File no longer exists."),
1820 		    REMOVE_OBJECT(logelem_object_p).i_namep, xx);
1821 		logelem_log_opskipped(logelem_object_p,
1822 		    REMOVE_OBJECT(logelem_object_p).i_namep);
1823 		dbug_leave("logelem_roll_remove");
1824 		return (0);
1825 	} else if (xx) {
1826 		logelem_log_opfailed(logelem_object_p, "Remove",
1827 		    gettext("Cannot get file attributes from server"),
1828 		    REMOVE_OBJECT(logelem_object_p).i_namep, xx);
1829 		logelem_log_opskipped(logelem_object_p,
1830 		    REMOVE_OBJECT(logelem_object_p).i_namep);
1831 		dbug_leave("logelem_roll_remove");
1832 		return (0);
1833 	}
1834 
1835 	/* conflict if mtime changed */
1836 	if (TIMECHANGE(mtime, va.va_mtime)) {
1837 		logelem_log_timelogmesg(logelem_object_p, "Remove",
1838 		    REMOVE_OBJECT(logelem_object_p).i_namep,
1839 		    gettext("File modified"), time_log);
1840 		logelem_log_opskipped(logelem_object_p,
1841 		    REMOVE_OBJECT(logelem_object_p).i_namep);
1842 		dbug_leave("logelem_roll_remove");
1843 		return (0);
1844 	}
1845 
1846 	/* conflict if ctime changed */
1847 	else if (TIMECHANGE(ctime, va.va_ctime)) {
1848 		logelem_log_timelogmesg(logelem_object_p, "Remove",
1849 		    REMOVE_OBJECT(logelem_object_p).i_namep,
1850 		    gettext("File changed"), time_log);
1851 		logelem_log_opskipped(logelem_object_p,
1852 		    REMOVE_OBJECT(logelem_object_p).i_namep);
1853 		dbug_leave("logelem_roll_remove");
1854 		return (0);
1855 	}
1856 
1857 	ctimep = (va.va_nlink > 1) ?
1858 	    &REMOVE_OBJECT(logelem_object_p).i_up->dl_ctime : NULL;
1859 
1860 	/* do the remove */
1861 	xx = kmod_remove(logelem_object_p->i_kmod_object_p, &dirfid,
1862 	    &REMOVE_OBJECT(logelem_object_p).i_up->dl_child_cid,
1863 	    REMOVE_OBJECT(logelem_object_p).i_namep,
1864 	    &REMOVE_OBJECT(logelem_object_p).i_up->dl_cred, ctimep);
1865 	if (xx) {
1866 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
1867 			dbug_leave("logelem_roll_remove");
1868 			return (ETIMEDOUT);
1869 		}
1870 
1871 		/* remove failed */
1872 		logelem_log_opfailed(logelem_object_p, "Remove", NULL,
1873 		    REMOVE_OBJECT(logelem_object_p).i_namep, xx);
1874 		logelem_log_opskipped(logelem_object_p,
1875 		    REMOVE_OBJECT(logelem_object_p).i_namep);
1876 		dbug_leave("logelem_roll_remove");
1877 		return (0);
1878 	}
1879 
1880 	/* record new ctime if multiple links to file */
1881 	if (ctimep) {
1882 		REMOVE_OBJECT(logelem_object_p).i_up->dl_mtime = mtime;
1883 		map.ms_times = logelem_object_p->i_offset +
1884 		    offsetof(cfs_dlog_entry_t, dl_u.dl_remove.dl_times);
1885 		xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
1886 		if (xx) {
1887 			dbug_leave("logelem_roll_remove");
1888 			return (EIO);
1889 		}
1890 	}
1891 
1892 	dbug_leave("logelem_roll_remove");
1893 	return (0);
1894 }
1895 /*
1896  * -----------------------------------------------------------------
1897  *			logelem_roll_rmdir
1898  *
1899  * Description:
1900  * Arguments:
1901  * Returns:
1902  * Preconditions:
1903  */
1904 
1905 int
1906 logelem_roll_rmdir(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1907 {
1908 	int xx;
1909 	cfs_fid_t *fp;
1910 	cfs_fid_t dirfid;
1911 	struct cfs_dlog_mapping_space map;
1912 
1913 	dbug_enter("logelem_roll_rmdir");
1914 
1915 	/* get the fid of the parent directory */
1916 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1917 	    RMDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid, &map);
1918 	if (xx == -1) {
1919 		logelem_log_opfailed(logelem_object_p, "Remove Directory",
1920 		    gettext("error mapping fid"), NULL, 0);
1921 		dbug_leave("logelem_roll_rmdir");
1922 		return (EIO);
1923 	}
1924 	/* if error from getting map or no fid in map (ms_fid == 0) */
1925 	if (xx || (map.ms_fid <= 0)) {
1926 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
1927 		    &RMDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid,
1928 		    &dirfid);
1929 		if (xx) {
1930 			logelem_log_opfailed(logelem_object_p,
1931 			    gettext("Remove Directory"),
1932 			    gettext("Parent directory no longer exists"),
1933 			    RMDIR_OBJECT(logelem_object_p).i_namep, xx);
1934 			logelem_log_opskipped(logelem_object_p,
1935 			    RMDIR_OBJECT(logelem_object_p).i_namep);
1936 			dbug_leave("logelem_roll_rmdir");
1937 			return (0);
1938 		}
1939 	} else {
1940 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
1941 		    map.ms_fid, (caddr_t *)&fp);
1942 		if (xx) {
1943 			logelem_log_opfailed(logelem_object_p,
1944 			    "Remove Directory",
1945 			    gettext("error getting logfile offset"), NULL, 0);
1946 			dbug_leave("logelem_roll_rmdir");
1947 			return (EIO);
1948 		}
1949 		dirfid = *fp;
1950 		dbug_assert(dirfid.fid_len);
1951 	}
1952 
1953 	/* perform the rmdir */
1954 	xx = kmod_rmdir(logelem_object_p->i_kmod_object_p, &dirfid,
1955 	    RMDIR_OBJECT(logelem_object_p).i_namep,
1956 	    &RMDIR_OBJECT(logelem_object_p).i_up->dl_cred);
1957 	if (xx) {
1958 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
1959 			dbug_leave("logelem_roll_rmdir");
1960 			return (ETIMEDOUT);
1961 		}
1962 
1963 		logelem_log_opfailed(logelem_object_p, "Remove Directory", NULL,
1964 		    RMDIR_OBJECT(logelem_object_p).i_namep, xx);
1965 		logelem_log_opskipped(logelem_object_p,
1966 		    RMDIR_OBJECT(logelem_object_p).i_namep);
1967 		dbug_leave("logelem_roll_rmdir");
1968 		return (0);
1969 	}
1970 	dbug_leave("logelem_roll_rmdir");
1971 	return (0);
1972 }
1973 /*
1974  * -----------------------------------------------------------------
1975  *			logelem_roll_mkdir
1976  *
1977  * Description:
1978  * Arguments:
1979  * Returns:
1980  * Preconditions:
1981  */
1982 
1983 int
1984 logelem_roll_mkdir(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
1985 {
1986 	int xx;
1987 	cfs_fid_t *fp;
1988 	cfs_fid_t dirfid;
1989 	struct cfs_dlog_mapping_space map;
1990 
1991 	dbug_enter("logelem_roll_mkdir");
1992 
1993 	/* get the fid of the parent directory */
1994 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
1995 	    MKDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid, &map);
1996 	if (xx == -1) {
1997 		logelem_log_opfailed(logelem_object_p, "Create Directory",
1998 		    gettext("error mapping fid"), NULL, 0);
1999 		dbug_leave("logelem_roll_mkdir");
2000 		return (EIO);
2001 	}
2002 	/* if error from getting map or no fid in map (ms_fid == 0) */
2003 	if (xx || (map.ms_fid <= 0)) {
2004 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2005 		    &MKDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid,
2006 		    &dirfid);
2007 		if (xx) {
2008 			logelem_log_opfailed(logelem_object_p,
2009 			    "Create Directory",
2010 			    gettext("Parent directory no longer exists"),
2011 			    MKDIR_OBJECT(logelem_object_p).i_namep, xx);
2012 			logelem_log_opskipped(logelem_object_p,
2013 			    MKDIR_OBJECT(logelem_object_p).i_namep);
2014 			dbug_leave("logelem_roll_mkdir");
2015 			return (0);
2016 		}
2017 	} else {
2018 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2019 		    map.ms_fid, (caddr_t *)&fp);
2020 		if (xx) {
2021 			logelem_log_opfailed(logelem_object_p,
2022 			    "Create Directory",
2023 			    gettext("error getting logfile offset"), NULL, 0);
2024 			dbug_leave("logelem_roll_mkdir");
2025 			return (EIO);
2026 		}
2027 		dirfid = *fp;
2028 		dbug_assert(dirfid.fid_len);
2029 	}
2030 
2031 	/* perform the mkdir */
2032 	xx = kmod_mkdir(logelem_object_p->i_kmod_object_p, &dirfid,
2033 	    MKDIR_OBJECT(logelem_object_p).i_namep,
2034 	    &MKDIR_OBJECT(logelem_object_p).i_up->dl_child_cid,
2035 	    &MKDIR_OBJECT(logelem_object_p).i_up->dl_attrs,
2036 	    &MKDIR_OBJECT(logelem_object_p).i_up->dl_cred,
2037 	    &MKDIR_OBJECT(logelem_object_p).i_up->dl_fid);
2038 	if (xx) {
2039 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
2040 			dbug_leave("logelem_roll_mkdir");
2041 			return (ETIMEDOUT);
2042 		}
2043 
2044 		logelem_log_opfailed(logelem_object_p, "Create Directory", NULL,
2045 		    MKDIR_OBJECT(logelem_object_p).i_namep, xx);
2046 		logelem_log_opskipped(logelem_object_p,
2047 		    MKDIR_OBJECT(logelem_object_p).i_namep);
2048 		dbug_leave("logelem_roll_mkdir");
2049 		return (0);
2050 	}
2051 
2052 	/* update the mapping to point to the new fid */
2053 	map.ms_cid = MKDIR_OBJECT(logelem_object_p).i_up->dl_child_cid;
2054 	map.ms_fid = logelem_object_p->i_offset +
2055 	    offsetof(cfs_dlog_entry_t, dl_u.dl_mkdir.dl_fid);
2056 	map.ms_times = 0;
2057 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2058 	if (xx) {
2059 		dbug_leave("logelem_roll_mkdir");
2060 		return (EIO);
2061 	}
2062 
2063 	dbug_leave("logelem_roll_mkdir");
2064 	return (0);
2065 }
2066 
2067 /*
2068  * -----------------------------------------------------------------
2069  *			logelem_roll_link
2070  *
2071  * Description:
2072  * Arguments:
2073  * Returns:
2074  * Preconditions:
2075  */
2076 
2077 int
2078 logelem_roll_link(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
2079 {
2080 	int xx;
2081 	cfs_fid_t *fp;
2082 	cfs_fid_t dirfid, linkfid;
2083 	struct cfs_dlog_mapping_space map, dirmap;
2084 	cfs_timestruc_t ctime, mtime;
2085 	cfs_dlog_tm_t *tmp;
2086 	int time_log;
2087 	cfs_vattr_t va;
2088 
2089 	dbug_enter("logelem_roll_link");
2090 
2091 	/* get the mapping for the child cid if it exists */
2092 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2093 	    LINK_OBJECT(logelem_object_p).i_up->dl_child_cid, &map);
2094 	if (xx == -1) {
2095 		logelem_log_opfailed(logelem_object_p, "Link",
2096 		    gettext("error mapping cid"), NULL, 0);
2097 		dbug_leave("logelem_roll_link");
2098 		return (EIO);
2099 	}
2100 	/* if a mapping was not found */
2101 	if (xx) {
2102 		/* dummy up mapping so we get values from the cache */
2103 		map.ms_cid = LINK_OBJECT(logelem_object_p).i_up->dl_child_cid;
2104 		map.ms_fid = 0;
2105 		map.ms_times = 0;
2106 	}
2107 
2108 	/* done if there was a conflict on the file */
2109 	if (map.ms_fid == X_CONFLICT) {
2110 		logelem_log_opfailed(logelem_object_p, "Link",
2111 		    gettext("file conflict"), NULL, 0);
2112 		dbug_leave("logelem_roll_link");
2113 		return (0);
2114 	}
2115 	/* done if the file is optimized out */
2116 	if (map.ms_fid == X_OPTIMIZED) {
2117 		dbug_leave("logelem_roll_link");
2118 		return (0);
2119 	}
2120 	/* if we have a fid in the mapping */
2121 	if (map.ms_fid) {
2122 		/* get the fid */
2123 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2124 		    map.ms_fid, (caddr_t *)&fp);
2125 		if (xx) {
2126 			logelem_log_opfailed(logelem_object_p, "Link",
2127 			    gettext("error getting logfile offset"), NULL, 0);
2128 			dbug_leave("logelem_roll_link");
2129 			return (EIO);
2130 		}
2131 		linkfid = *fp;
2132 		dbug_assert(linkfid.fid_len);
2133 	}
2134 
2135 	/* else get the fid from the cache */
2136 	else {
2137 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2138 		    &LINK_OBJECT(logelem_object_p).i_up->dl_child_cid,
2139 		    &linkfid);
2140 		if (xx == ENOENT) {
2141 			dbug_leave("logelem_roll_link");
2142 			return (0);
2143 		}
2144 		if (xx) {
2145 			logelem_log_opfailed(logelem_object_p, "Link",
2146 			    gettext("File is no longer in the cache"),
2147 			    LINK_OBJECT(logelem_object_p).i_namep, xx);
2148 			logelem_log_opskipped(logelem_object_p,
2149 			    LINK_OBJECT(logelem_object_p).i_namep);
2150 			dbug_leave("logelem_roll_link");
2151 			return (0);
2152 		}
2153 	}
2154 
2155 	/* if we have timestamps in the mapping */
2156 	if (map.ms_times) {
2157 		/* get the times */
2158 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2159 		    map.ms_times, (caddr_t *)&tmp);
2160 		if (xx) {
2161 			logelem_log_opfailed(logelem_object_p, "Link",
2162 			    gettext("error getting logfile offset"), NULL, 0);
2163 			dbug_leave("logelem_roll_link");
2164 			return (EIO);
2165 		}
2166 		ctime = tmp->tm_ctime;
2167 		mtime = tmp->tm_mtime;
2168 		time_log = 0;
2169 	}
2170 
2171 	/* else get the timestamps from the log entry */
2172 	else {
2173 		ctime = LINK_OBJECT(logelem_object_p).i_up->dl_ctime;
2174 		mtime = LINK_OBJECT(logelem_object_p).i_up->dl_mtime;
2175 		time_log = 1;
2176 	}
2177 
2178 	/* get the attributes of the file from the back fs */
2179 	xx = kmod_getattrfid(logelem_object_p->i_kmod_object_p, &linkfid,
2180 	    &LINK_OBJECT(logelem_object_p).i_up->dl_cred, &va);
2181 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
2182 		dbug_leave("logelem_roll_link");
2183 		return (ETIMEDOUT);
2184 	}
2185 	if (xx) {
2186 		logelem_log_opfailed(logelem_object_p, "Link",
2187 		    gettext("error getting attributes"), NULL, xx);
2188 		logelem_log_opskipped(logelem_object_p,
2189 		    LINK_OBJECT(logelem_object_p).i_namep);
2190 		dbug_leave("logelem_roll_link");
2191 		return (0);
2192 	}
2193 
2194 	/* conflict if mtime changed */
2195 	if (TIMECHANGE(mtime, va.va_mtime)) {
2196 		logelem_log_timelogmesg(logelem_object_p, "Link",
2197 		    LINK_OBJECT(logelem_object_p).i_namep,
2198 		    gettext("File modified"), time_log);
2199 		logelem_log_opskipped(logelem_object_p,
2200 		    LINK_OBJECT(logelem_object_p).i_namep);
2201 		dbug_leave("logelem_roll_link");
2202 		return (0);
2203 	}
2204 
2205 	/* conflict if ctime changed */
2206 	else if (TIMECHANGE(ctime, va.va_ctime)) {
2207 		logelem_log_timelogmesg(logelem_object_p, "Link",
2208 		    LINK_OBJECT(logelem_object_p).i_namep,
2209 		    gettext("File changed"), time_log);
2210 		logelem_log_opskipped(logelem_object_p,
2211 		    LINK_OBJECT(logelem_object_p).i_namep);
2212 		dbug_leave("logelem_roll_link");
2213 		return (0);
2214 	}
2215 
2216 	/* get the fid of the parent directory */
2217 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2218 	    LINK_OBJECT(logelem_object_p).i_up->dl_parent_cid, &dirmap);
2219 	if (xx == -1) {
2220 		logelem_log_opfailed(logelem_object_p, "Link",
2221 		    gettext("error mapping fid"), NULL, 0);
2222 		dbug_leave("logelem_roll_link");
2223 		return (EIO);
2224 	}
2225 	/* if error from getting map or no fid in map (ms_fid == 0) */
2226 	if (xx || (dirmap.ms_fid <= 0)) {
2227 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2228 		    &LINK_OBJECT(logelem_object_p).i_up->dl_parent_cid,
2229 		    &dirfid);
2230 		if (xx) {
2231 			logelem_log_opfailed(logelem_object_p, "Link",
2232 			    gettext("Parent directory no longer exists"),
2233 			    LINK_OBJECT(logelem_object_p).i_namep, xx);
2234 			logelem_log_opskipped(logelem_object_p,
2235 			    LINK_OBJECT(logelem_object_p).i_namep);
2236 			dbug_leave("logelem_roll_link");
2237 			return (0);
2238 		}
2239 	} else {
2240 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2241 		    dirmap.ms_fid, (caddr_t *)&fp);
2242 		if (xx) {
2243 			logelem_log_opfailed(logelem_object_p, "Link",
2244 			    gettext("error getting logfile offset"), NULL, 0);
2245 			dbug_leave("logelem_roll_link");
2246 			return (EIO);
2247 		}
2248 		dirfid = *fp;
2249 		dbug_assert(dirfid.fid_len);
2250 	}
2251 
2252 	/* do the link */
2253 	xx = kmod_link(logelem_object_p->i_kmod_object_p, &dirfid,
2254 	    LINK_OBJECT(logelem_object_p).i_namep, &linkfid,
2255 	    &LINK_OBJECT(logelem_object_p).i_up->dl_child_cid,
2256 	    &LINK_OBJECT(logelem_object_p).i_up->dl_cred,
2257 	    &LINK_OBJECT(logelem_object_p).i_up->dl_ctime);
2258 	if (xx) {
2259 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
2260 			dbug_leave("logelem_roll_link");
2261 			return (ETIMEDOUT);
2262 		}
2263 
2264 		logelem_log_opfailed(logelem_object_p, "Link", NULL,
2265 		    LINK_OBJECT(logelem_object_p).i_namep, xx);
2266 		logelem_log_opskipped(logelem_object_p,
2267 		    LINK_OBJECT(logelem_object_p).i_namep);
2268 		dbug_leave("logelem_roll_link");
2269 		return (0);
2270 	}
2271 
2272 	/* update the mapping with the new time */
2273 	LINK_OBJECT(logelem_object_p).i_up->dl_mtime = mtime;
2274 	map.ms_times = logelem_object_p->i_offset +
2275 	    offsetof(cfs_dlog_entry_t, dl_u.dl_link.dl_times);
2276 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2277 	if (xx) {
2278 		dbug_leave("logelem_roll_link");
2279 		return (EIO);
2280 	}
2281 	dbug_leave("logelem_roll_link");
2282 	return (0);
2283 }
2284 /*
2285  * -----------------------------------------------------------------
2286  *			logelem_roll_symlink
2287  *
2288  * Description:
2289  * Arguments:
2290  * Returns:
2291  * Preconditions:
2292  */
2293 
2294 int
2295 logelem_roll_symlink(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
2296 {
2297 	int xx;
2298 	cfs_fid_t *fp;
2299 	cfs_fid_t dirfid;
2300 	struct cfs_dlog_mapping_space map;
2301 
2302 	dbug_enter("logelem_roll_symlink");
2303 
2304 	/* see if the symlink no longer exists in the cache */
2305 #if 0
2306 	xx = kmod_exists(logelem_object_p->i_kmod_object_p,
2307 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_child_cid);
2308 	if (xx) {
2309 		dbug_assert(xx == ENOENT);
2310 
2311 		/* indicate ignore future operations on symlink */
2312 		map.ms_cid =
2313 		    SYMLINK_OBJECT(logelem_object_p).i_up->dl_child_cid;
2314 		map.ms_fid = X_OPTIMIZED;
2315 		map.ms_times = 0;
2316 		xx = maptbl_set(maptbl_object_p, &map, 1);
2317 		if (xx) {
2318 			dbug_leave("logelem_roll_symlink");
2319 			return (EIO);
2320 		}
2321 		dbug_leave("logelem_roll_symlink");
2322 		return (0);
2323 	}
2324 #endif
2325 
2326 	/* get the fid of the parent directory */
2327 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2328 	    SYMLINK_OBJECT(logelem_object_p).i_up->dl_parent_cid, &map);
2329 	if (xx == -1) {
2330 		logelem_log_opfailed(logelem_object_p, "Symink",
2331 		    gettext("error mapping fid"), NULL, 0);
2332 		dbug_leave("logelem_roll_symlink");
2333 		return (EIO);
2334 	}
2335 	/* if error from getting map or no fid in map (ms_fid == 0) */
2336 	if (xx || (map.ms_fid <= 0)) {
2337 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2338 		    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_parent_cid,
2339 		    &dirfid);
2340 		if (xx) {
2341 			logelem_log_opfailed(logelem_object_p, "Symlink",
2342 			    gettext("Parent directory no longer exists"),
2343 			    SYMLINK_OBJECT(logelem_object_p).i_namep, xx);
2344 			logelem_log_opskipped(logelem_object_p,
2345 			    SYMLINK_OBJECT(logelem_object_p).i_namep);
2346 			dbug_leave("logelem_roll_symlink");
2347 			return (0);
2348 		}
2349 	} else {
2350 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2351 		    map.ms_fid, (caddr_t *)&fp);
2352 		if (xx) {
2353 			logelem_log_opfailed(logelem_object_p, "Symlink",
2354 			    gettext("error getting logfile offset"), NULL, 0);
2355 			dbug_leave("logelem_roll_symlink");
2356 			return (EIO);
2357 		}
2358 		dirfid = *fp;
2359 		dbug_assert(dirfid.fid_len);
2360 	}
2361 
2362 	/* if the file exists on the back fs */
2363 	xx = kmod_getattrname(logelem_object_p->i_kmod_object_p, &dirfid,
2364 	    SYMLINK_OBJECT(logelem_object_p).i_namep,
2365 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_cred,
2366 	    NULL, NULL);
2367 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
2368 		dbug_leave("logelem_roll_symlink");
2369 		return (ETIMEDOUT);
2370 	}
2371 	/* if the file exists on the back file system */
2372 	if (xx == 0) {
2373 		logelem_log_opfailed(logelem_object_p, "Symlink",
2374 		    gettext("File created while disconnected"),
2375 		    SYMLINK_OBJECT(logelem_object_p).i_namep, xx);
2376 		logelem_log_opskipped(logelem_object_p,
2377 		    SYMLINK_OBJECT(logelem_object_p).i_namep);
2378 		dbug_leave("logelem_roll_symlink");
2379 		return (0);
2380 	}
2381 
2382 	/* do the symlink */
2383 	xx = kmod_symlink(logelem_object_p->i_kmod_object_p, &dirfid,
2384 	    SYMLINK_OBJECT(logelem_object_p).i_namep,
2385 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_child_cid,
2386 	    SYMLINK_OBJECT(logelem_object_p).i_contentsp,
2387 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_attrs,
2388 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_cred,
2389 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_fid,
2390 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_ctime,
2391 	    &SYMLINK_OBJECT(logelem_object_p).i_up->dl_mtime);
2392 	if (xx) {
2393 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
2394 			dbug_leave("logelem_roll_symlink");
2395 			return (ETIMEDOUT);
2396 		}
2397 		logelem_log_opfailed(logelem_object_p, "Symlink", NULL,
2398 		    SYMLINK_OBJECT(logelem_object_p).i_namep, xx);
2399 		logelem_log_opskipped(logelem_object_p,
2400 		    SYMLINK_OBJECT(logelem_object_p).i_namep);
2401 		dbug_leave("logelem_roll_symlink");
2402 		return (0);
2403 	}
2404 
2405 	/* update the mapping to point to the new fid and times */
2406 	map.ms_cid = SYMLINK_OBJECT(logelem_object_p).i_up->dl_child_cid;
2407 	map.ms_fid = logelem_object_p->i_offset +
2408 	    offsetof(cfs_dlog_entry_t, dl_u.dl_symlink.dl_fid);
2409 	map.ms_times = logelem_object_p->i_offset +
2410 	    offsetof(cfs_dlog_entry_t, dl_u.dl_symlink.dl_times);
2411 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2412 	if (xx) {
2413 		dbug_leave("logelem_roll_symlink");
2414 		return (EIO);
2415 	}
2416 	dbug_leave("logelem_roll_symlink");
2417 	return (0);
2418 }
2419 /*
2420  * -----------------------------------------------------------------
2421  *			logelem_roll_rename
2422  *
2423  * Description:
2424  * Arguments:
2425  * Returns:
2426  * Preconditions:
2427  */
2428 
2429 int
2430 logelem_roll_rename(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
2431 {
2432 	int xx;
2433 	cfs_fid_t *fp;
2434 	cfs_fid_t odirfid, ndirfid;
2435 	struct cfs_dlog_mapping_space map, dirmap, delmap;
2436 	cfs_dlog_tm_t *tmp;
2437 	cfs_vattr_t va;
2438 	cfs_timestruc_t mtime, ctime;
2439 	cfs_timestruc_t delmtime, delctime;
2440 	cfs_timestruc_t *delctimep = NULL;
2441 	int time_log;
2442 
2443 	dbug_enter("logelem_roll_rename");
2444 
2445 	/* get the mapping for the child cid if it exists */
2446 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2447 	    RENAME_OBJECT(logelem_object_p).i_up->dl_child_cid, &map);
2448 	if (xx == -1) {
2449 		logelem_log_opfailed(logelem_object_p, "Rename",
2450 		    gettext("error mapping cid"), NULL, 0);
2451 		dbug_leave("logelem_roll_rename");
2452 		return (EIO);
2453 	}
2454 	/* if a mapping was not found */
2455 	if (xx) {
2456 		/* dummy up mapping so we get values from the cache */
2457 		map.ms_cid = RENAME_OBJECT(logelem_object_p).i_up->dl_child_cid;
2458 		map.ms_fid = 0;
2459 		map.ms_times = 0;
2460 	}
2461 
2462 	/* done if there was a conflict on the file */
2463 	if (map.ms_fid == X_CONFLICT) {
2464 		logelem_log_opfailed(logelem_object_p, "Rename",
2465 		    gettext("file conflict"), NULL, 0);
2466 		dbug_leave("logelem_roll_rename");
2467 		return (0);
2468 	}
2469 	/* done if the file is optimized out */
2470 	if (map.ms_fid == X_OPTIMIZED) {
2471 		dbug_leave("logelem_roll_rename");
2472 		return (0);
2473 	}
2474 	/* if we have timestamps in the mapping */
2475 	if (map.ms_times) {
2476 		/* get the times */
2477 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2478 		    map.ms_times, (caddr_t *)&tmp);
2479 		if (xx) {
2480 			logelem_log_opfailed(logelem_object_p, "Rename",
2481 			    gettext("error getting logfile offset"), NULL, 0);
2482 			dbug_leave("logelem_roll_rename");
2483 			return (EIO);
2484 		}
2485 		ctime = tmp->tm_ctime;
2486 		mtime = tmp->tm_mtime;
2487 		time_log = 0;
2488 	}
2489 
2490 	/* else get the timestamps from the log entry */
2491 	else {
2492 		ctime = RENAME_OBJECT(logelem_object_p).i_up->dl_ctime;
2493 		mtime = RENAME_OBJECT(logelem_object_p).i_up->dl_mtime;
2494 		time_log = 1;
2495 	}
2496 
2497 	/* get the fid of the old parent directory */
2498 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2499 	    RENAME_OBJECT(logelem_object_p).i_up->dl_oparent_cid, &dirmap);
2500 	if (xx == -1) {
2501 		logelem_log_opfailed(logelem_object_p, "Rename",
2502 		    gettext("error mapping fid"), NULL, 0);
2503 		dbug_leave("logelem_roll_rename");
2504 		return (EIO);
2505 	}
2506 	/* if error from getting map or no fid in map (ms_fid == 0) */
2507 	if (xx || (dirmap.ms_fid <= 0)) {
2508 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2509 		    &RENAME_OBJECT(logelem_object_p).i_up->dl_oparent_cid,
2510 		    &odirfid);
2511 		if (xx) {
2512 			logelem_log_opfailed(logelem_object_p, "Rename",
2513 			    gettext("Original directory no longer exists"),
2514 			    RENAME_OBJECT(logelem_object_p).i_orignamep, xx);
2515 			logelem_log_opskipped(logelem_object_p,
2516 			    RENAME_OBJECT(logelem_object_p).i_orignamep);
2517 			dbug_leave("logelem_roll_rename");
2518 			return (0);
2519 		}
2520 	} else {
2521 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2522 		    dirmap.ms_fid, (caddr_t *)&fp);
2523 		if (xx) {
2524 			logelem_log_opfailed(logelem_object_p, "Rename",
2525 			    gettext("error getting logfile offset"), NULL, 0);
2526 			dbug_leave("logelem_roll_rename");
2527 			return (EIO);
2528 		}
2529 		odirfid = *fp;
2530 		dbug_assert(odirfid.fid_len);
2531 	}
2532 
2533 	/* get the fid of the new parent directory */
2534 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2535 	    RENAME_OBJECT(logelem_object_p).i_up->dl_nparent_cid, &dirmap);
2536 	if (xx == -1) {
2537 		logelem_log_opfailed(logelem_object_p, "Rename",
2538 		    gettext("error mapping fid"), NULL, 0);
2539 		dbug_leave("logelem_roll_rename");
2540 		return (EIO);
2541 	}
2542 	/* if error from getting map or no fid in map (ms_fid == 0) */
2543 	if (xx || (dirmap.ms_fid <= 0)) {
2544 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2545 		    &RENAME_OBJECT(logelem_object_p).i_up->dl_nparent_cid,
2546 		    &ndirfid);
2547 		if (xx) {
2548 			logelem_log_opfailed(logelem_object_p, "Rename",
2549 			    gettext("Target directory no longer exists"),
2550 			    RENAME_OBJECT(logelem_object_p).i_orignamep, xx);
2551 			logelem_log_opskipped(logelem_object_p,
2552 			    RENAME_OBJECT(logelem_object_p).i_orignamep);
2553 			dbug_leave("logelem_roll_rename");
2554 			return (0);
2555 		}
2556 	} else {
2557 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2558 		    dirmap.ms_fid, (caddr_t *)&fp);
2559 		if (xx) {
2560 			logelem_log_opfailed(logelem_object_p, "Rename",
2561 			    gettext("error getting logfile offset"), NULL, 0);
2562 			dbug_leave("logelem_roll_rename");
2563 			return (EIO);
2564 		}
2565 		ndirfid = *fp;
2566 		dbug_assert(ndirfid.fid_len);
2567 	}
2568 
2569 	/* get the attributes of the file from the back fs */
2570 	xx = kmod_getattrname(logelem_object_p->i_kmod_object_p, &odirfid,
2571 	    RENAME_OBJECT(logelem_object_p).i_orignamep,
2572 	    &RENAME_OBJECT(logelem_object_p).i_up->dl_cred,
2573 	    &va, NULL);
2574 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
2575 		dbug_leave("logelem_roll_rename");
2576 		return (ETIMEDOUT);
2577 	}
2578 	if (xx) {
2579 		logelem_log_opfailed(logelem_object_p, "Rename",
2580 		    gettext("Cannot get attributes on file"),
2581 		    RENAME_OBJECT(logelem_object_p).i_orignamep, xx);
2582 		logelem_log_opskipped(logelem_object_p,
2583 		    RENAME_OBJECT(logelem_object_p).i_orignamep);
2584 		dbug_leave("logelem_roll_rename");
2585 		return (0);
2586 	}
2587 
2588 	/* conflict if mtime changed */
2589 	if (TIMECHANGE(mtime, va.va_mtime)) {
2590 		logelem_log_timelogmesg(logelem_object_p, "Rename",
2591 		    RENAME_OBJECT(logelem_object_p).i_orignamep,
2592 		    gettext("File modified"), time_log);
2593 		logelem_log_opskipped(logelem_object_p,
2594 		    RENAME_OBJECT(logelem_object_p).i_orignamep);
2595 		dbug_leave("logelem_roll_rename");
2596 		return (0);
2597 	}
2598 
2599 	/* conflict if ctime changed */
2600 	else if (TIMECHANGE(ctime, va.va_ctime)) {
2601 		logelem_log_timelogmesg(logelem_object_p, "Rename",
2602 		    RENAME_OBJECT(logelem_object_p).i_orignamep,
2603 		    gettext("File changed"), time_log);
2604 		logelem_log_opskipped(logelem_object_p,
2605 		    RENAME_OBJECT(logelem_object_p).i_orignamep);
2606 		dbug_leave("logelem_roll_rename");
2607 		return (0);
2608 	}
2609 
2610 	/* if we are also deleting a file */
2611 	if (RENAME_OBJECT(logelem_object_p).i_up->dl_del_cid.cid_fileno != 0) {
2612 		/* get the mapping for the deleted cid if it exists */
2613 		xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2614 		    RENAME_OBJECT(logelem_object_p).i_up->dl_del_cid, &delmap);
2615 		if (xx == -1) {
2616 			logelem_log_opfailed(logelem_object_p, "Rename",
2617 			    gettext("error mapping cid"), NULL, 0);
2618 			dbug_leave("logelem_roll_rename");
2619 			return (EIO);
2620 		}
2621 		/* if a mapping was not found */
2622 		if (xx) {
2623 			/* dummy up mapping so we get values from the cache */
2624 			delmap.ms_cid =
2625 			    RENAME_OBJECT(logelem_object_p).i_up->dl_del_cid;
2626 			delmap.ms_fid = 0;
2627 			delmap.ms_times = 0;
2628 		}
2629 
2630 		/* if we have timestamps in the mapping */
2631 		if (delmap.ms_times) {
2632 			/* get the times */
2633 			xx = logfile_offset(
2634 			    logelem_object_p->i_logfile_object_p,
2635 			    delmap.ms_times, (caddr_t *)&tmp);
2636 			if (xx) {
2637 				logelem_log_opfailed(logelem_object_p, "Rename",
2638 				    gettext("error getting logfile offset"),
2639 				    NULL, 0);
2640 				dbug_leave("logelem_roll_rename");
2641 				return (EIO);
2642 			}
2643 			delctime = tmp->tm_ctime;
2644 			delmtime = tmp->tm_mtime;
2645 			time_log = 0;
2646 		}
2647 
2648 		/* else get the timestamps from the log entry */
2649 		else {
2650 			delctime = RENAME_OBJECT(logelem_object_p).
2651 			    i_up->dl_del_times.tm_ctime;
2652 			delmtime = RENAME_OBJECT(logelem_object_p).
2653 			    i_up->dl_del_times.tm_mtime;
2654 			time_log = 1;
2655 		}
2656 
2657 		/* get the attributes of the target file from the back fs */
2658 		xx = kmod_getattrname(logelem_object_p->i_kmod_object_p,
2659 		    &ndirfid,
2660 		    RENAME_OBJECT(logelem_object_p).i_newnamep,
2661 		    &RENAME_OBJECT(logelem_object_p).i_up->dl_cred,
2662 		    &va, NULL);
2663 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
2664 			dbug_leave("logelem_roll_rename");
2665 			return (ETIMEDOUT);
2666 		}
2667 		if (xx) {
2668 			logelem_log_opfailed(logelem_object_p, "Rename",
2669 			    gettext("Cannot get attributes on file"),
2670 			    RENAME_OBJECT(logelem_object_p).i_orignamep, xx);
2671 			logelem_log_opskipped(logelem_object_p,
2672 			    RENAME_OBJECT(logelem_object_p).i_orignamep);
2673 			dbug_leave("logelem_roll_rename");
2674 			return (0);
2675 		}
2676 
2677 		/* conflict if mtime changed */
2678 		if (TIMECHANGE(delmtime, va.va_mtime)) {
2679 			logelem_log_timelogmesg(logelem_object_p, "Rename",
2680 			    RENAME_OBJECT(logelem_object_p).i_orignamep,
2681 			    gettext("Target modified"), time_log);
2682 			logelem_log_opskipped(logelem_object_p,
2683 			    RENAME_OBJECT(logelem_object_p).i_orignamep);
2684 			dbug_leave("logelem_roll_rename");
2685 			return (0);
2686 
2687 		}
2688 
2689 		/* conflict if ctime changed */
2690 		else if (TIMECHANGE(delctime, va.va_ctime)) {
2691 			logelem_log_timelogmesg(logelem_object_p, "Rename",
2692 			    RENAME_OBJECT(logelem_object_p).i_orignamep,
2693 			    gettext("Target changed"), time_log);
2694 			logelem_log_opskipped(logelem_object_p,
2695 			    RENAME_OBJECT(logelem_object_p).i_orignamep);
2696 			dbug_leave("logelem_roll_rename");
2697 			return (0);
2698 		}
2699 
2700 		delctimep = (va.va_nlink > 1) ?
2701 		    &RENAME_OBJECT(logelem_object_p).
2702 		    i_up->dl_del_times.tm_ctime : NULL;
2703 	}
2704 
2705 	/* perform the rename */
2706 	xx = kmod_rename(logelem_object_p->i_kmod_object_p, &odirfid,
2707 	    RENAME_OBJECT(logelem_object_p).i_orignamep, &ndirfid,
2708 	    RENAME_OBJECT(logelem_object_p).i_newnamep,
2709 	    &RENAME_OBJECT(logelem_object_p).i_up->dl_child_cid,
2710 	    &RENAME_OBJECT(logelem_object_p).i_up->dl_cred,
2711 	    &RENAME_OBJECT(logelem_object_p).i_up->dl_ctime, delctimep,
2712 	    &RENAME_OBJECT(logelem_object_p).i_up->dl_del_cid);
2713 	if (xx) {
2714 		if ((xx == ETIMEDOUT) || (xx == EIO)) {
2715 			dbug_leave("logelem_roll_rename");
2716 			return (ETIMEDOUT);
2717 		}
2718 		logelem_log_opfailed(logelem_object_p, "Rename", NULL,
2719 		    RENAME_OBJECT(logelem_object_p).i_orignamep, xx);
2720 		logelem_log_opskipped(logelem_object_p,
2721 		    RENAME_OBJECT(logelem_object_p).i_orignamep);
2722 		dbug_leave("logelem_roll_rename");
2723 		return (0);
2724 	}
2725 
2726 	/* update the mapping to point to the new times for the file */
2727 	RENAME_OBJECT(logelem_object_p).i_up->dl_mtime = mtime;
2728 	map.ms_times = logelem_object_p->i_offset +
2729 	    offsetof(cfs_dlog_entry_t, dl_u.dl_rename.dl_times);
2730 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2731 	if (xx) {
2732 		dbug_leave("logelem_roll_rename");
2733 		return (EIO);
2734 	}
2735 	/* if we deleted a file with links left */
2736 	if (delctimep) {
2737 		/* update the mapping  to the new times for the deleted file */
2738 		RENAME_OBJECT(logelem_object_p).i_up->dl_del_times.tm_mtime =
2739 		    delmtime;
2740 		delmap.ms_times = logelem_object_p->i_offset +
2741 		    offsetof(cfs_dlog_entry_t, dl_u.dl_rename.dl_del_times);
2742 		xx = maptbl_set(logelem_object_p->i_maptbl_object_p,
2743 		    &delmap, 1);
2744 		if (xx) {
2745 			dbug_leave("logelem_roll_rename");
2746 			return (EIO);
2747 		}
2748 	}
2749 
2750 	dbug_leave("logelem_roll_rename");
2751 	return (0);
2752 }
2753 /*
2754  *			logelem_roll_modified
2755  *
2756  * Description:
2757  * Arguments:
2758  * Returns:
2759  * Preconditions:
2760  */
2761 
2762 int
2763 logelem_roll_modified(cfsd_logelem_object_t *logelem_object_p, ulong_t *seqp)
2764 {
2765 	int xx;
2766 	cfs_fid_t filefid, *fp;
2767 	struct cfs_dlog_mapping_space map;
2768 	cfs_dlog_tm_t *tmp;
2769 	cfs_timestruc_t ctime, mtime;
2770 	int time_log;
2771 	cachefsio_getinfo_t ginfo;
2772 	cfs_vattr_t va;
2773 	int conflict = 0;
2774 
2775 	dbug_enter("logelem_roll_modified");
2776 
2777 	dbug_precond(seqp);
2778 
2779 	/* get the mapping for this cid if it exists */
2780 	xx = maptbl_get(logelem_object_p->i_maptbl_object_p,
2781 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid, &map);
2782 	if (xx == -1) {
2783 		logelem_log_opfailed(logelem_object_p, "Modified",
2784 		    gettext("error mapping cid"), NULL, 0);
2785 		dbug_leave("logelem_roll_modified");
2786 		return (EIO);
2787 	}
2788 	/* if a mapping was not found */
2789 	if (xx) {
2790 		/* dummy up mapping so we get values from the cache */
2791 		map.ms_cid = MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid;
2792 		map.ms_fid = 0;
2793 		map.ms_times = 0;
2794 	}
2795 
2796 	/* done if there was a conflict on the file */
2797 	if (map.ms_fid == X_CONFLICT) {
2798 		logelem_log_opfailed(logelem_object_p, "Modified",
2799 		    gettext("file conflict"), NULL, 0);
2800 		dbug_leave("logelem_roll_modified");
2801 		return (0);
2802 	}
2803 	/* done if the file is optimized out */
2804 	if (map.ms_fid == X_OPTIMIZED) {
2805 		dbug_leave("logelem_roll_modified");
2806 		return (0);
2807 	}
2808 	/* if we have a fid in the mapping */
2809 	if (map.ms_fid) {
2810 		/* get the fid */
2811 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2812 		    map.ms_fid, (caddr_t *)&fp);
2813 		if (xx) {
2814 			logelem_log_opfailed(logelem_object_p, "Modified",
2815 			    gettext("error getting logfile offset"), NULL, 0);
2816 			dbug_leave("logelem_roll_modified");
2817 			return (EIO);
2818 		}
2819 		filefid = *fp;
2820 		dbug_assert(filefid.fid_len);
2821 	}
2822 
2823 	/* else get the fid from the cache */
2824 	else {
2825 		xx = kmod_cidtofid(logelem_object_p->i_kmod_object_p,
2826 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid, &filefid);
2827 		if (xx == ENOENT) {
2828 			dbug_leave("logelem_roll_modified");
2829 			return (0);
2830 		}
2831 		if (xx) {
2832 			logelem_log_opfailed(logelem_object_p, "Write",
2833 			    gettext("File is no longer in the cache"),
2834 			    NULL, xx);
2835 			xx = logelem_lostfound(logelem_object_p,
2836 			    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid,
2837 			    NULL, NULL,
2838 			    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
2839 			dbug_leave("logelem_roll_modified");
2840 			return (xx);
2841 		}
2842 	}
2843 
2844 	/* get info about the file from the cache */
2845 	xx = kmod_getinfo(logelem_object_p->i_kmod_object_p,
2846 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid, &ginfo);
2847 	if (xx) {
2848 		logelem_log_opfailed(logelem_object_p, "Write",
2849 		    gettext("File is no longer in the cache"), NULL, xx);
2850 		xx = logelem_lostfound(logelem_object_p,
2851 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid,
2852 		    NULL, NULL,
2853 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
2854 		dbug_leave("logelem_roll_modified");
2855 		return (xx);
2856 	}
2857 
2858 	/* if we are not ready to process this write yet */
2859 	if (*seqp < ginfo.gi_seq) {
2860 		dbug_print(("info", "Defering writing of file '%s' "
2861 		    "current seq %d, metadata seq %d",
2862 		    ginfo.gi_name, *seqp, ginfo.gi_seq));
2863 		*seqp = ginfo.gi_seq;
2864 		dbug_leave("logelem_roll_modified");
2865 		return (EAGAIN);
2866 	} else {
2867 		dbug_print(("info", "Continue writing of file '%s' "
2868 		    "current seq %d, metadata seq %d",
2869 		    ginfo.gi_name, *seqp, ginfo.gi_seq));
2870 	}
2871 
2872 	/* if we have timestamps in the mapping */
2873 	if (map.ms_times) {
2874 		/* get the times */
2875 		xx = logfile_offset(logelem_object_p->i_logfile_object_p,
2876 		    map.ms_times, (caddr_t *)&tmp);
2877 		if (xx) {
2878 			logelem_log_opfailed(logelem_object_p, "Modified",
2879 			    gettext("error getting logfile offset"), NULL, 0);
2880 			dbug_leave("logelem_roll_modified");
2881 			return (EIO);
2882 		}
2883 		ctime = tmp->tm_ctime;
2884 		mtime = tmp->tm_mtime;
2885 		time_log = 0;
2886 	}
2887 
2888 	/* else get the timestamps from the log entry */
2889 	else {
2890 		ctime = MODIFIED_OBJECT(logelem_object_p).i_up->dl_ctime;
2891 		mtime = MODIFIED_OBJECT(logelem_object_p).i_up->dl_mtime;
2892 		time_log = 1;
2893 	}
2894 
2895 	/* get the attributes of the file from the back fs */
2896 	xx = kmod_getattrfid(logelem_object_p->i_kmod_object_p, &filefid,
2897 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred, &va);
2898 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
2899 		dbug_leave("logelem_roll_modified");
2900 		return (ETIMEDOUT);
2901 	}
2902 	if (xx) {
2903 		logelem_log_opfailed(logelem_object_p, "Modified",
2904 		    gettext("error getting attributes"), NULL, xx);
2905 		xx = logelem_lostfound(logelem_object_p,
2906 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid,
2907 		    NULL, NULL,
2908 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
2909 		dbug_leave("logelem_roll_modified");
2910 		return (xx);
2911 	}
2912 
2913 
2914 	/* conflict if mtime changed */
2915 	if (TIMECHANGE(mtime, va.va_mtime)) {
2916 		logelem_log_timelogmesg(logelem_object_p, "Write", NULL,
2917 		    gettext("File modified"), time_log);
2918 		conflict = 1;
2919 	}
2920 
2921 	/* conflict if ctime changed */
2922 	else if (TIMECHANGE(ctime, va.va_ctime)) {
2923 		logelem_log_timelogmesg(logelem_object_p, "Write", NULL,
2924 		    gettext("File changed"), time_log);
2925 		conflict = 1;
2926 	}
2927 
2928 	/* if a conflict was detected */
2929 	if (conflict) {
2930 		logelem_log_opfailed(logelem_object_p, "Modified",
2931 		    gettext("file conflict"), NULL, 0);
2932 		xx = logelem_lostfound(logelem_object_p,
2933 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid,
2934 		    NULL, NULL,
2935 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
2936 		dbug_leave("logelem_roll_modified");
2937 		return (xx);
2938 	}
2939 
2940 	/* now do the write, get the new times */
2941 	xx = kmod_pushback(logelem_object_p->i_kmod_object_p,
2942 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid, &filefid,
2943 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred,
2944 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_ctime,
2945 	    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_mtime, 1);
2946 	if ((xx == ETIMEDOUT) || (xx == EIO)) {
2947 		dbug_leave("logelem_roll_modified");
2948 		return (ETIMEDOUT);
2949 	}
2950 	if (xx) {
2951 		logelem_log_opfailed(logelem_object_p, "Write", NULL, NULL, xx);
2952 		xx = logelem_lostfound(logelem_object_p,
2953 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid,
2954 		    NULL, NULL,
2955 		    &MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
2956 		dbug_leave("logelem_roll_modified");
2957 		return (xx);
2958 	}
2959 
2960 	/* update the mapping to point to the new times */
2961 	map.ms_times = logelem_object_p->i_offset +
2962 	    offsetof(cfs_dlog_entry_t, dl_u.dl_modify.dl_times);
2963 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2964 	if (xx) {
2965 		dbug_leave("logelem_roll_modified");
2966 		return (EIO);
2967 	}
2968 	dbug_leave("logelem_roll_modified");
2969 	return (0);
2970 }
2971 /*
2972  *			logelem_roll_mapfid
2973  *
2974  * Description:
2975  * Arguments:
2976  * Returns:
2977  * Preconditions:
2978  */
2979 
2980 int
2981 logelem_roll_mapfid(cfsd_logelem_object_t *logelem_object_p)
2982 {
2983 	int xx;
2984 	struct cfs_dlog_mapping_space map;
2985 
2986 	dbug_enter("logelem_roll_mapfid");
2987 
2988 	/* map the cid to the fid */
2989 	dbug_assert(MAPFID_OBJECT(logelem_object_p).i_up->dl_fid.fid_len);
2990 	map.ms_cid = MAPFID_OBJECT(logelem_object_p).i_up->dl_cid;
2991 	map.ms_fid = logelem_object_p->i_offset +
2992 	    offsetof(cfs_dlog_entry_t, dl_u.dl_mapfid.dl_fid);
2993 	map.ms_times = 0;
2994 
2995 	xx = maptbl_set(logelem_object_p->i_maptbl_object_p, &map, 1);
2996 	if (xx) {
2997 		dbug_leave("logelem_roll_mapfid");
2998 		return (EIO);
2999 	}
3000 	dbug_leave("logelem_roll_mapfid");
3001 	return (0);
3002 }
3003 /*
3004  *			logelem_dump
3005  *
3006  * Description:
3007  * Arguments:
3008  * Returns:
3009  * Preconditions:
3010  */
3011 
3012 void
3013 logelem_dump(cfsd_logelem_object_t *logelem_object_p)
3014 {
3015 	dbug_enter("logelem_dump");
3016 
3017 	switch (logelem_object_p->i_type) {
3018 
3019 	case NO_OBJECT_TYPE:
3020 		dbug_assert(0);
3021 		break;
3022 
3023 	case SETATTR_OBJECT_TYPE:
3024 		logelem_dump_setattr(logelem_object_p);
3025 		break;
3026 
3027 	case SETSECATTR_OBJECT_TYPE:
3028 		logelem_dump_setsecattr(logelem_object_p);
3029 		break;
3030 
3031 	case CREATE_OBJECT_TYPE:
3032 		logelem_dump_create(logelem_object_p);
3033 		break;
3034 
3035 	case REMOVE_OBJECT_TYPE:
3036 		logelem_dump_remove(logelem_object_p);
3037 		break;
3038 
3039 	case RMDIR_OBJECT_TYPE:
3040 		logelem_dump_rmdir(logelem_object_p);
3041 		break;
3042 
3043 	case MKDIR_OBJECT_TYPE:
3044 		logelem_dump_mkdir(logelem_object_p);
3045 		break;
3046 
3047 	case LINK_OBJECT_TYPE:
3048 		logelem_dump_link(logelem_object_p);
3049 		break;
3050 
3051 	case SYMLINK_OBJECT_TYPE:
3052 		logelem_dump_symlink(logelem_object_p);
3053 		break;
3054 
3055 	case RENAME_OBJECT_TYPE:
3056 		logelem_dump_rename(logelem_object_p);
3057 		break;
3058 
3059 	case MODIFIED_OBJECT_TYPE:
3060 		logelem_dump_modified(logelem_object_p);
3061 		break;
3062 
3063 	case MAPFID_OBJECT_TYPE:
3064 		logelem_dump_mapfid(logelem_object_p);
3065 		break;
3066 
3067 	default:
3068 		dbug_assert(0);
3069 	}
3070 	dbug_leave("logelem_dump");
3071 }
3072 /*
3073  *			logelem_dump_setattr
3074  *
3075  * Description:
3076  * Arguments:
3077  * Returns:
3078  * Preconditions:
3079  */
3080 
3081 void
3082 logelem_dump_setattr(cfsd_logelem_object_t *logelem_object_p)
3083 {
3084 	dbug_enter("logelem_dump_setattr");
3085 
3086 	dbug_print(("dump", "SETATTR"));
3087 	dbug_print(("dump", "len %d, valid %d, seq %d",
3088 	    logelem_object_p->i_entp->dl_len,
3089 	    logelem_object_p->i_entp->dl_valid,
3090 	    logelem_object_p->i_entp->dl_seq));
3091 	dbug_print(("dump", "file  cid %"PRIx64", flags 0x%x",
3092 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_cid.cid_fileno,
3093 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_flags));
3094 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3095 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3096 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3097 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3098 	    SETATTR_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3099 	logelem_print_attr(&SETATTR_OBJECT(logelem_object_p).i_up->dl_attrs);
3100 	logelem_print_cred(&SETATTR_OBJECT(logelem_object_p).i_up->dl_cred);
3101 	dbug_leave("logelem_dump_setattr");
3102 }
3103 
3104 /*
3105  *			logelem_dump_setsecattr
3106  *
3107  * Description:
3108  * Arguments:
3109  * Returns:
3110  * Preconditions:
3111  */
3112 
3113 void
3114 logelem_dump_setsecattr(cfsd_logelem_object_t *logelem_object_p)
3115 {
3116 	dbug_enter("logelem_dump_setsecattr");
3117 
3118 	dbug_print(("dump", "SETSECATTR"));
3119 	dbug_print(("dump", "len %d, valid %d, seq %d",
3120 	    logelem_object_p->i_entp->dl_len,
3121 	    logelem_object_p->i_entp->dl_valid,
3122 	    logelem_object_p->i_entp->dl_seq));
3123 	dbug_print(("dump", "file  cid %"PRIx64,
3124 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cid.cid_fileno));
3125 	dbug_print(("dump", "aclcnt %d dfaclcnt %d",
3126 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_aclcnt,
3127 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_dfaclcnt));
3128 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3129 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3130 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3131 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3132 	    SETSECATTR_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3133 	logelem_print_cred(&SETSECATTR_OBJECT(logelem_object_p).i_up->dl_cred);
3134 	dbug_leave("logelem_dump_setsecattr");
3135 }
3136 
3137 
3138 /*
3139  *			logelem_dump_create
3140  *
3141  * Description:
3142  * Arguments:
3143  * Returns:
3144  * Preconditions:
3145  */
3146 
3147 void
3148 logelem_dump_create(cfsd_logelem_object_t *logelem_object_p)
3149 {
3150 	dbug_enter("logelem_dump_create");
3151 
3152 	dbug_print(("dump", "CREATE"));
3153 	dbug_print(("dump", "len %d, valid %d, seq %d",
3154 	    logelem_object_p->i_entp->dl_len,
3155 	    logelem_object_p->i_entp->dl_valid,
3156 	    logelem_object_p->i_entp->dl_seq));
3157 	dbug_print(("dump", "directory cid %"PRIx64,
3158 	    CREATE_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3159 	dbug_print(("dump", "file	  cid %"PRIx64,
3160 	    CREATE_OBJECT(logelem_object_p).i_up->dl_new_cid.cid_fileno));
3161 	dbug_print(("dump", "name \"%s\"",
3162 	    CREATE_OBJECT(logelem_object_p).i_namep));
3163 	dbug_print(("dump", "exclusive %d, mode 0%o, destexists %d",
3164 	    CREATE_OBJECT(logelem_object_p).i_up->dl_excl,
3165 	    CREATE_OBJECT(logelem_object_p).i_up->dl_mode,
3166 	    CREATE_OBJECT(logelem_object_p).i_up->dl_exists));
3167 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3168 	    CREATE_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3169 	    CREATE_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3170 	    CREATE_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3171 	    CREATE_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3172 	logelem_print_attr(&CREATE_OBJECT(logelem_object_p).i_up->dl_attrs);
3173 	logelem_print_cred(&CREATE_OBJECT(logelem_object_p).i_up->dl_cred);
3174 	dbug_leave("logelem_dump_create");
3175 }
3176 
3177 
3178 /*
3179  * -----------------------------------------------------------------
3180  *			logelem_dump_remove
3181  *
3182  * Description:
3183  * Arguments:
3184  * Returns:
3185  * Preconditions:
3186  */
3187 
3188 void
3189 logelem_dump_remove(cfsd_logelem_object_t *logelem_object_p)
3190 {
3191 	dbug_enter("logelem_dump_remove");
3192 
3193 	dbug_print(("dump", "REMOVE"));
3194 	dbug_print(("dump", "len %d, valid %d, seq %d",
3195 	    logelem_object_p->i_entp->dl_len,
3196 	    logelem_object_p->i_entp->dl_valid,
3197 	    logelem_object_p->i_entp->dl_seq));
3198 	dbug_print(("dump", "file %s cid %"PRIx64", dir cid %"PRIx64,
3199 	    REMOVE_OBJECT(logelem_object_p).i_namep,
3200 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_child_cid.cid_fileno,
3201 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3202 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3203 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3204 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3205 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3206 	    REMOVE_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3207 	logelem_print_cred(&REMOVE_OBJECT(logelem_object_p).i_up->dl_cred);
3208 	dbug_leave("logelem_dump_remove");
3209 }
3210 
3211 /*
3212  * -----------------------------------------------------------------
3213  *			logelem_dump_rmdir
3214  *
3215  * Description:
3216  * Arguments:
3217  * Returns:
3218  * Preconditions:
3219  */
3220 
3221 void
3222 logelem_dump_rmdir(cfsd_logelem_object_t *logelem_object_p)
3223 {
3224 	dbug_enter("logelem_dump_rmdir");
3225 
3226 	dbug_print(("dump", "RMDIR"));
3227 	dbug_print(("dump", "len %d, valid %d, seq %d",
3228 	    logelem_object_p->i_entp->dl_len,
3229 	    logelem_object_p->i_entp->dl_valid,
3230 	    logelem_object_p->i_entp->dl_seq));
3231 	dbug_print(("dump", "dir name %s, dir cid %"PRIx64,
3232 	    RMDIR_OBJECT(logelem_object_p).i_namep,
3233 	    RMDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3234 	logelem_print_cred(&RMDIR_OBJECT(logelem_object_p).i_up->dl_cred);
3235 	dbug_leave("logelem_dump_rmdir");
3236 }
3237 
3238 /*
3239  * -----------------------------------------------------------------
3240  *			logelem_dump_mkdir
3241  *
3242  * Description:
3243  * Arguments:
3244  * Returns:
3245  * Preconditions:
3246  */
3247 
3248 void
3249 logelem_dump_mkdir(cfsd_logelem_object_t *logelem_object_p)
3250 {
3251 	dbug_enter("logelem_dump_mkdir");
3252 
3253 	dbug_print(("dump", "MKDIR"));
3254 	dbug_print(("dump", "len %d, valid %d, seq %d",
3255 	    logelem_object_p->i_entp->dl_len,
3256 	    logelem_object_p->i_entp->dl_valid,
3257 	    logelem_object_p->i_entp->dl_seq));
3258 	dbug_print(("dump", "file %s cid %"PRIx64", dir cid %"PRIx64,
3259 	    MKDIR_OBJECT(logelem_object_p).i_namep,
3260 	    MKDIR_OBJECT(logelem_object_p).i_up->dl_child_cid.cid_fileno,
3261 	    MKDIR_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3262 	logelem_print_attr(&MKDIR_OBJECT(logelem_object_p).i_up->dl_attrs);
3263 	logelem_print_cred(&MKDIR_OBJECT(logelem_object_p).i_up->dl_cred);
3264 	dbug_leave("logelem_dump_mkdir");
3265 }
3266 
3267 /*
3268  * -----------------------------------------------------------------
3269  *			logelem_dump_link
3270  *
3271  * Description:
3272  * Arguments:
3273  * Returns:
3274  * Preconditions:
3275  */
3276 
3277 void
3278 logelem_dump_link(cfsd_logelem_object_t *logelem_object_p)
3279 {
3280 	dbug_enter("logelem_dump_link");
3281 
3282 	dbug_print(("dump", "LINK"));
3283 	dbug_print(("dump", "len %d, valid %d, seq %d",
3284 	    logelem_object_p->i_entp->dl_len,
3285 	    logelem_object_p->i_entp->dl_valid,
3286 	    logelem_object_p->i_entp->dl_seq));
3287 	dbug_print(("dump", "name %s, cid to link %"PRIx64", dir cid %"PRIx64,
3288 	    LINK_OBJECT(logelem_object_p).i_namep,
3289 	    LINK_OBJECT(logelem_object_p).i_up->dl_child_cid.cid_fileno,
3290 	    LINK_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3291 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3292 	    LINK_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3293 	    LINK_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3294 	    LINK_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3295 	    LINK_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3296 	logelem_print_cred(&LINK_OBJECT(logelem_object_p).i_up->dl_cred);
3297 	dbug_leave("logelem_dump_link");
3298 }
3299 /*
3300  * -----------------------------------------------------------------
3301  *			logelem_dump_symlink
3302  *
3303  * Description:
3304  * Arguments:
3305  * Returns:
3306  * Preconditions:
3307  */
3308 
3309 void
3310 logelem_dump_symlink(cfsd_logelem_object_t *logelem_object_p)
3311 {
3312 	dbug_enter("logelem_dump_symlink");
3313 
3314 	dbug_print(("dump", "SYMLINK"));
3315 	dbug_print(("dump", "len %d, valid %d, seq %d",
3316 	    logelem_object_p->i_entp->dl_len,
3317 	    logelem_object_p->i_entp->dl_valid,
3318 	    logelem_object_p->i_entp->dl_seq));
3319 	dbug_print(("dump", "dir cid %"PRIx64,
3320 	    SYMLINK_OBJECT(logelem_object_p).i_up->dl_parent_cid.cid_fileno));
3321 	dbug_print(("dump", "name %s, contents %s, file cid %"PRIx64,
3322 	    SYMLINK_OBJECT(logelem_object_p).i_namep,
3323 	    SYMLINK_OBJECT(logelem_object_p).i_contentsp,
3324 	    SYMLINK_OBJECT(logelem_object_p).i_up->dl_child_cid.cid_fileno));
3325 	logelem_print_attr(&SYMLINK_OBJECT(logelem_object_p).i_up->dl_attrs);
3326 	logelem_print_cred(&SYMLINK_OBJECT(logelem_object_p).i_up->dl_cred);
3327 	dbug_leave("logelem_dump_symlink");
3328 }
3329 /*
3330  * -----------------------------------------------------------------
3331  *			logelem_dump_rename
3332  *
3333  * Description:
3334  * Arguments:
3335  * Returns:
3336  * Preconditions:
3337  */
3338 
3339 void
3340 logelem_dump_rename(cfsd_logelem_object_t *logelem_object_p)
3341 {
3342 	dbug_enter("logelem_dump_rename");
3343 
3344 	dbug_print(("dump", "RENAME"));
3345 	dbug_print(("dump", "len %d, valid %d, seq %d",
3346 	    logelem_object_p->i_entp->dl_len,
3347 	    logelem_object_p->i_entp->dl_valid,
3348 	    logelem_object_p->i_entp->dl_seq));
3349 	dbug_print(("dump", "orig dir cid %"PRIx64", new dir cid %"PRIx64,
3350 	    RENAME_OBJECT(logelem_object_p).i_up->dl_oparent_cid.cid_fileno,
3351 	    RENAME_OBJECT(logelem_object_p).i_up->dl_nparent_cid.cid_fileno));
3352 	dbug_print(("dump", "file cid %"PRIx64,
3353 	    RENAME_OBJECT(logelem_object_p).i_up->dl_child_cid.cid_fileno));
3354 	dbug_print(("dump", "orig name '%s', new name '%s'",
3355 	    RENAME_OBJECT(logelem_object_p).i_orignamep,
3356 	    RENAME_OBJECT(logelem_object_p).i_newnamep));
3357 	dbug_print(("dump", "file ctime %x %x, mtime %x %x",
3358 	    RENAME_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3359 	    RENAME_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3360 	    RENAME_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3361 	    RENAME_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3362 	dbug_print(("dump", "deleted cid %"PRIx64,
3363 	    RENAME_OBJECT(logelem_object_p).i_up->dl_del_cid.cid_fileno));
3364 	dbug_print(("dump", "deleted ctime %x %x, mtime %x %x",
3365 	    RENAME_OBJECT(logelem_object_p).i_up->dl_del_times.tm_ctime.tv_sec,
3366 	    RENAME_OBJECT(logelem_object_p).i_up->dl_del_times.tm_ctime.tv_nsec,
3367 	    RENAME_OBJECT(logelem_object_p).i_up->dl_del_times.tm_mtime.tv_sec,
3368 	    RENAME_OBJECT(logelem_object_p).i_up->dl_del_times.tm_mtime.
3369 	    tv_nsec));
3370 	logelem_print_cred(&RENAME_OBJECT(logelem_object_p).i_up->dl_cred);
3371 	dbug_leave("logelem_dump_rename");
3372 }
3373 /*
3374  *			logelem_dump_modified
3375  *
3376  * Description:
3377  * Arguments:
3378  * Returns:
3379  * Preconditions:
3380  */
3381 
3382 void
3383 logelem_dump_modified(cfsd_logelem_object_t *logelem_object_p)
3384 {
3385 	dbug_enter("logelem_dump_modified");
3386 
3387 	dbug_print(("dump", "MODIFIED"));
3388 	dbug_print(("dump", "len %d, valid %d, seq %d",
3389 	    logelem_object_p->i_entp->dl_len,
3390 	    logelem_object_p->i_entp->dl_valid,
3391 	    logelem_object_p->i_entp->dl_seq));
3392 	dbug_print(("dump", "file	  cid %"PRIx64,
3393 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_cid.cid_fileno));
3394 	dbug_print(("dump", "ctime %x %x, mtime %x %x",
3395 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_ctime.tv_sec,
3396 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_ctime.tv_nsec,
3397 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_mtime.tv_sec,
3398 	    MODIFIED_OBJECT(logelem_object_p).i_up->dl_mtime.tv_nsec));
3399 	logelem_print_cred(&MODIFIED_OBJECT(logelem_object_p).i_up->dl_cred);
3400 	dbug_leave("logelem_dump_modified");
3401 }
3402 /*
3403  *			logelem_dump_mapfid
3404  *
3405  * Description:
3406  * Arguments:
3407  * Returns:
3408  * Preconditions:
3409  */
3410 
3411 void
3412 logelem_dump_mapfid(cfsd_logelem_object_t *logelem_object_p)
3413 {
3414 	dbug_enter("logelem_dump_mapfid");
3415 	dbug_print(("dump", "MAPFID"));
3416 	dbug_print(("dump", "file	  cid %"PRIx64,
3417 	    MAPFID_OBJECT(logelem_object_p).i_up->dl_cid.cid_fileno));
3418 	logelem_format_fid(logelem_object_p,
3419 	    &MAPFID_OBJECT(logelem_object_p).i_up->dl_fid);
3420 	dbug_print(("dump", "fid '%s'", logelem_object_p->i_fidbuf));
3421 	dbug_enter("logelem_dump_mapfid");
3422 }
3423