1 /* Do not edit: automatically built by gen_rec.awk. */
5 #include "dbinc/crypto.h"
6 #include "dbinc/db_page.h"
7 #include "dbinc/db_am.h"
10 #include "dbinc/fop.h"
13 * PUBLIC: int __fop_create_42_read __P((ENV *, void *,
14 * PUBLIC: __fop_create_42_args **));
17 __fop_create_42_read(env, recbuf, argpp)
20 __fop_create_42_args **argpp;
22 __fop_create_42_args *argp;
26 if ((ret = __os_malloc(env,
27 sizeof(__fop_create_42_args) + sizeof(DB_TXN), &argp)) != 0)
30 argp->txnp = (DB_TXN *)&argp[1];
31 memset(argp->txnp, 0, sizeof(DB_TXN));
33 LOGCOPY_32(env, &argp->type, bp);
34 bp += sizeof(argp->type);
36 LOGCOPY_32(env, &argp->txnp->txnid, bp);
37 bp += sizeof(argp->txnp->txnid);
39 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
42 memset(&argp->name, 0, sizeof(argp->name));
43 LOGCOPY_32(env,&argp->name.size, bp);
44 bp += sizeof(u_int32_t);
46 bp += argp->name.size;
48 LOGCOPY_32(env, &argp->appname, bp);
49 bp += sizeof(argp->appname);
51 LOGCOPY_32(env, &argp->mode, bp);
52 bp += sizeof(argp->mode);
59 * PUBLIC: int __fop_create_read __P((ENV *, void *, __fop_create_args **));
62 __fop_create_read(env, recbuf, argpp)
65 __fop_create_args **argpp;
67 __fop_create_args *argp;
71 if ((ret = __os_malloc(env,
72 sizeof(__fop_create_args) + sizeof(DB_TXN), &argp)) != 0)
75 argp->txnp = (DB_TXN *)&argp[1];
76 memset(argp->txnp, 0, sizeof(DB_TXN));
78 LOGCOPY_32(env, &argp->type, bp);
79 bp += sizeof(argp->type);
81 LOGCOPY_32(env, &argp->txnp->txnid, bp);
82 bp += sizeof(argp->txnp->txnid);
84 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
87 memset(&argp->name, 0, sizeof(argp->name));
88 LOGCOPY_32(env,&argp->name.size, bp);
89 bp += sizeof(u_int32_t);
91 bp += argp->name.size;
93 memset(&argp->dirname, 0, sizeof(argp->dirname));
94 LOGCOPY_32(env,&argp->dirname.size, bp);
95 bp += sizeof(u_int32_t);
96 argp->dirname.data = bp;
97 bp += argp->dirname.size;
99 LOGCOPY_32(env, &argp->appname, bp);
100 bp += sizeof(argp->appname);
102 LOGCOPY_32(env, &argp->mode, bp);
103 bp += sizeof(argp->mode);
110 * PUBLIC: int __fop_create_log __P((ENV *, DB_TXN *, DB_LSN *,
111 * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t));
114 __fop_create_log(env, txnp, ret_lsnp, flags,
115 name, dirname, appname, mode)
126 DB_LSN *lsnp, null_lsn, *rlsnp;
128 u_int32_t zero, rectype, txn_num;
136 rectype = DB___fop_create;
140 if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
150 null_lsn.file = null_lsn.offset = 0;
152 if (TAILQ_FIRST(&txnp->kids) != NULL &&
153 (ret = __txn_activekids(env, rectype, txnp)) != 0)
156 * We need to assign begin_lsn while holding region mutex.
157 * That assignment is done inside the DbEnv->log_put call,
158 * so pass in the appropriate memory location to be filled
159 * in by the log_put code.
161 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
162 txn_num = txnp->txnid;
165 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
166 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
167 + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
170 if (CRYPTO_ON(env)) {
171 npad = env->crypto_handle->adj_size(logrec.size);
175 if (is_durable || txnp == NULL) {
177 __os_malloc(env, logrec.size, &logrec.data)) != 0)
180 if ((ret = __os_malloc(env,
181 logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
185 __os_malloc(env, logrec.size, &logrec.data)) != 0) {
190 logrec.data = lr->data;
194 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
198 LOGCOPY_32(env, bp, &rectype);
199 bp += sizeof(rectype);
201 LOGCOPY_32(env, bp, &txn_num);
202 bp += sizeof(txn_num);
204 LOGCOPY_FROMLSN(env, bp, lsnp);
205 bp += sizeof(DB_LSN);
209 LOGCOPY_32(env, bp, &zero);
210 bp += sizeof(u_int32_t);
212 LOGCOPY_32(env, bp, &name->size);
213 bp += sizeof(name->size);
214 memcpy(bp, name->data, name->size);
218 if (dirname == NULL) {
220 LOGCOPY_32(env, bp, &zero);
221 bp += sizeof(u_int32_t);
223 LOGCOPY_32(env, bp, &dirname->size);
224 bp += sizeof(dirname->size);
225 memcpy(bp, dirname->data, dirname->size);
229 LOGCOPY_32(env, bp, &appname);
230 bp += sizeof(appname);
232 LOGCOPY_32(env, bp, &mode);
236 (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
238 if (is_durable || txnp == NULL) {
239 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
240 flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
242 if (rlsnp != ret_lsnp)
249 * Set the debug bit if we are going to log non-durable
250 * transactions so they will be ignored by recovery.
252 memcpy(lr->data, logrec.data, logrec.size);
253 rectype |= DB_debug_FLAG;
254 LOGCOPY_32(env, logrec.data, &rectype);
256 if (!IS_REP_CLIENT(env))
258 rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
260 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
261 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
262 LSN_NOT_LOGGED(*ret_lsnp);
265 #ifdef LOG_DIAGNOSTIC
267 (void)__fop_create_print(env,
268 (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
272 __os_free(env, logrec.data);
274 if (is_durable || txnp == NULL)
275 __os_free(env, logrec.data);
281 * PUBLIC: int __fop_remove_read __P((ENV *, void *, __fop_remove_args **));
284 __fop_remove_read(env, recbuf, argpp)
287 __fop_remove_args **argpp;
289 __fop_remove_args *argp;
293 if ((ret = __os_malloc(env,
294 sizeof(__fop_remove_args) + sizeof(DB_TXN), &argp)) != 0)
297 argp->txnp = (DB_TXN *)&argp[1];
298 memset(argp->txnp, 0, sizeof(DB_TXN));
300 LOGCOPY_32(env, &argp->type, bp);
301 bp += sizeof(argp->type);
303 LOGCOPY_32(env, &argp->txnp->txnid, bp);
304 bp += sizeof(argp->txnp->txnid);
306 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
307 bp += sizeof(DB_LSN);
309 memset(&argp->name, 0, sizeof(argp->name));
310 LOGCOPY_32(env,&argp->name.size, bp);
311 bp += sizeof(u_int32_t);
312 argp->name.data = bp;
313 bp += argp->name.size;
315 memset(&argp->fid, 0, sizeof(argp->fid));
316 LOGCOPY_32(env,&argp->fid.size, bp);
317 bp += sizeof(u_int32_t);
319 bp += argp->fid.size;
321 LOGCOPY_32(env, &argp->appname, bp);
322 bp += sizeof(argp->appname);
329 * PUBLIC: int __fop_remove_log __P((ENV *, DB_TXN *, DB_LSN *,
330 * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t));
333 __fop_remove_log(env, txnp, ret_lsnp, flags,
344 DB_LSN *lsnp, null_lsn, *rlsnp;
346 u_int32_t zero, rectype, txn_num;
354 rectype = DB___fop_remove;
358 if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
368 null_lsn.file = null_lsn.offset = 0;
370 if (TAILQ_FIRST(&txnp->kids) != NULL &&
371 (ret = __txn_activekids(env, rectype, txnp)) != 0)
374 * We need to assign begin_lsn while holding region mutex.
375 * That assignment is done inside the DbEnv->log_put call,
376 * so pass in the appropriate memory location to be filled
377 * in by the log_put code.
379 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
380 txn_num = txnp->txnid;
383 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
384 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
385 + sizeof(u_int32_t) + (fid == NULL ? 0 : fid->size)
387 if (CRYPTO_ON(env)) {
388 npad = env->crypto_handle->adj_size(logrec.size);
392 if (is_durable || txnp == NULL) {
394 __os_malloc(env, logrec.size, &logrec.data)) != 0)
397 if ((ret = __os_malloc(env,
398 logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
402 __os_malloc(env, logrec.size, &logrec.data)) != 0) {
407 logrec.data = lr->data;
411 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
415 LOGCOPY_32(env, bp, &rectype);
416 bp += sizeof(rectype);
418 LOGCOPY_32(env, bp, &txn_num);
419 bp += sizeof(txn_num);
421 LOGCOPY_FROMLSN(env, bp, lsnp);
422 bp += sizeof(DB_LSN);
426 LOGCOPY_32(env, bp, &zero);
427 bp += sizeof(u_int32_t);
429 LOGCOPY_32(env, bp, &name->size);
430 bp += sizeof(name->size);
431 memcpy(bp, name->data, name->size);
437 LOGCOPY_32(env, bp, &zero);
438 bp += sizeof(u_int32_t);
440 LOGCOPY_32(env, bp, &fid->size);
441 bp += sizeof(fid->size);
442 memcpy(bp, fid->data, fid->size);
446 LOGCOPY_32(env, bp, &appname);
447 bp += sizeof(appname);
450 (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
452 if (is_durable || txnp == NULL) {
453 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
454 flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
456 if (rlsnp != ret_lsnp)
463 * Set the debug bit if we are going to log non-durable
464 * transactions so they will be ignored by recovery.
466 memcpy(lr->data, logrec.data, logrec.size);
467 rectype |= DB_debug_FLAG;
468 LOGCOPY_32(env, logrec.data, &rectype);
470 if (!IS_REP_CLIENT(env))
472 rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
474 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
475 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
476 LSN_NOT_LOGGED(*ret_lsnp);
479 #ifdef LOG_DIAGNOSTIC
481 (void)__fop_remove_print(env,
482 (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
486 __os_free(env, logrec.data);
488 if (is_durable || txnp == NULL)
489 __os_free(env, logrec.data);
495 * PUBLIC: int __fop_write_42_read __P((ENV *, void *,
496 * PUBLIC: __fop_write_42_args **));
499 __fop_write_42_read(env, recbuf, argpp)
502 __fop_write_42_args **argpp;
504 __fop_write_42_args *argp;
509 if ((ret = __os_malloc(env,
510 sizeof(__fop_write_42_args) + sizeof(DB_TXN), &argp)) != 0)
513 argp->txnp = (DB_TXN *)&argp[1];
514 memset(argp->txnp, 0, sizeof(DB_TXN));
516 LOGCOPY_32(env, &argp->type, bp);
517 bp += sizeof(argp->type);
519 LOGCOPY_32(env, &argp->txnp->txnid, bp);
520 bp += sizeof(argp->txnp->txnid);
522 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
523 bp += sizeof(DB_LSN);
525 memset(&argp->name, 0, sizeof(argp->name));
526 LOGCOPY_32(env,&argp->name.size, bp);
527 bp += sizeof(u_int32_t);
528 argp->name.data = bp;
529 bp += argp->name.size;
531 LOGCOPY_32(env, &argp->appname, bp);
532 bp += sizeof(argp->appname);
534 LOGCOPY_32(env, &argp->pgsize, bp);
535 bp += sizeof(argp->pgsize);
537 LOGCOPY_32(env, &uinttmp, bp);
538 argp->pageno = (db_pgno_t)uinttmp;
539 bp += sizeof(uinttmp);
541 LOGCOPY_32(env, &argp->offset, bp);
542 bp += sizeof(argp->offset);
544 memset(&argp->page, 0, sizeof(argp->page));
545 LOGCOPY_32(env,&argp->page.size, bp);
546 bp += sizeof(u_int32_t);
547 argp->page.data = bp;
548 bp += argp->page.size;
550 LOGCOPY_32(env, &argp->flag, bp);
551 bp += sizeof(argp->flag);
558 * PUBLIC: int __fop_write_read __P((ENV *, void *, __fop_write_args **));
561 __fop_write_read(env, recbuf, argpp)
564 __fop_write_args **argpp;
566 __fop_write_args *argp;
571 if ((ret = __os_malloc(env,
572 sizeof(__fop_write_args) + sizeof(DB_TXN), &argp)) != 0)
575 argp->txnp = (DB_TXN *)&argp[1];
576 memset(argp->txnp, 0, sizeof(DB_TXN));
578 LOGCOPY_32(env, &argp->type, bp);
579 bp += sizeof(argp->type);
581 LOGCOPY_32(env, &argp->txnp->txnid, bp);
582 bp += sizeof(argp->txnp->txnid);
584 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
585 bp += sizeof(DB_LSN);
587 memset(&argp->name, 0, sizeof(argp->name));
588 LOGCOPY_32(env,&argp->name.size, bp);
589 bp += sizeof(u_int32_t);
590 argp->name.data = bp;
591 bp += argp->name.size;
593 memset(&argp->dirname, 0, sizeof(argp->dirname));
594 LOGCOPY_32(env,&argp->dirname.size, bp);
595 bp += sizeof(u_int32_t);
596 argp->dirname.data = bp;
597 bp += argp->dirname.size;
599 LOGCOPY_32(env, &argp->appname, bp);
600 bp += sizeof(argp->appname);
602 LOGCOPY_32(env, &argp->pgsize, bp);
603 bp += sizeof(argp->pgsize);
605 LOGCOPY_32(env, &uinttmp, bp);
606 argp->pageno = (db_pgno_t)uinttmp;
607 bp += sizeof(uinttmp);
609 LOGCOPY_32(env, &argp->offset, bp);
610 bp += sizeof(argp->offset);
612 memset(&argp->page, 0, sizeof(argp->page));
613 LOGCOPY_32(env,&argp->page.size, bp);
614 bp += sizeof(u_int32_t);
615 argp->page.data = bp;
616 bp += argp->page.size;
618 LOGCOPY_32(env, &argp->flag, bp);
619 bp += sizeof(argp->flag);
626 * PUBLIC: int __fop_write_log __P((ENV *, DB_TXN *, DB_LSN *,
627 * PUBLIC: u_int32_t, const DBT *, const DBT *, u_int32_t, u_int32_t,
628 * PUBLIC: db_pgno_t, u_int32_t, const DBT *, u_int32_t));
631 __fop_write_log(env, txnp, ret_lsnp, flags,
632 name, dirname, appname, pgsize, pageno, offset,
648 DB_LSN *lsnp, null_lsn, *rlsnp;
650 u_int32_t zero, uinttmp, rectype, txn_num;
658 rectype = DB___fop_write;
662 if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
672 null_lsn.file = null_lsn.offset = 0;
674 if (TAILQ_FIRST(&txnp->kids) != NULL &&
675 (ret = __txn_activekids(env, rectype, txnp)) != 0)
678 * We need to assign begin_lsn while holding region mutex.
679 * That assignment is done inside the DbEnv->log_put call,
680 * so pass in the appropriate memory location to be filled
681 * in by the log_put code.
683 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
684 txn_num = txnp->txnid;
687 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
688 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
689 + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
694 + sizeof(u_int32_t) + (page == NULL ? 0 : page->size)
696 if (CRYPTO_ON(env)) {
697 npad = env->crypto_handle->adj_size(logrec.size);
701 if (is_durable || txnp == NULL) {
703 __os_malloc(env, logrec.size, &logrec.data)) != 0)
706 if ((ret = __os_malloc(env,
707 logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
711 __os_malloc(env, logrec.size, &logrec.data)) != 0) {
716 logrec.data = lr->data;
720 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
724 LOGCOPY_32(env, bp, &rectype);
725 bp += sizeof(rectype);
727 LOGCOPY_32(env, bp, &txn_num);
728 bp += sizeof(txn_num);
730 LOGCOPY_FROMLSN(env, bp, lsnp);
731 bp += sizeof(DB_LSN);
735 LOGCOPY_32(env, bp, &zero);
736 bp += sizeof(u_int32_t);
738 LOGCOPY_32(env, bp, &name->size);
739 bp += sizeof(name->size);
740 memcpy(bp, name->data, name->size);
744 if (dirname == NULL) {
746 LOGCOPY_32(env, bp, &zero);
747 bp += sizeof(u_int32_t);
749 LOGCOPY_32(env, bp, &dirname->size);
750 bp += sizeof(dirname->size);
751 memcpy(bp, dirname->data, dirname->size);
755 LOGCOPY_32(env, bp, &appname);
756 bp += sizeof(appname);
758 LOGCOPY_32(env, bp, &pgsize);
759 bp += sizeof(pgsize);
761 uinttmp = (u_int32_t)pageno;
762 LOGCOPY_32(env,bp, &uinttmp);
763 bp += sizeof(uinttmp);
765 LOGCOPY_32(env, bp, &offset);
766 bp += sizeof(offset);
770 LOGCOPY_32(env, bp, &zero);
771 bp += sizeof(u_int32_t);
773 LOGCOPY_32(env, bp, &page->size);
774 bp += sizeof(page->size);
775 memcpy(bp, page->data, page->size);
779 LOGCOPY_32(env, bp, &flag);
783 (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
785 if (is_durable || txnp == NULL) {
786 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
787 flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
789 if (rlsnp != ret_lsnp)
796 * Set the debug bit if we are going to log non-durable
797 * transactions so they will be ignored by recovery.
799 memcpy(lr->data, logrec.data, logrec.size);
800 rectype |= DB_debug_FLAG;
801 LOGCOPY_32(env, logrec.data, &rectype);
803 if (!IS_REP_CLIENT(env))
805 rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
807 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
808 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
809 LSN_NOT_LOGGED(*ret_lsnp);
812 #ifdef LOG_DIAGNOSTIC
814 (void)__fop_write_print(env,
815 (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
819 __os_free(env, logrec.data);
821 if (is_durable || txnp == NULL)
822 __os_free(env, logrec.data);
828 * PUBLIC: int __fop_rename_42_read __P((ENV *, void *,
829 * PUBLIC: __fop_rename_42_args **));
832 __fop_rename_42_read(env, recbuf, argpp)
835 __fop_rename_42_args **argpp;
837 __fop_rename_42_args *argp;
841 if ((ret = __os_malloc(env,
842 sizeof(__fop_rename_42_args) + sizeof(DB_TXN), &argp)) != 0)
845 argp->txnp = (DB_TXN *)&argp[1];
846 memset(argp->txnp, 0, sizeof(DB_TXN));
848 LOGCOPY_32(env, &argp->type, bp);
849 bp += sizeof(argp->type);
851 LOGCOPY_32(env, &argp->txnp->txnid, bp);
852 bp += sizeof(argp->txnp->txnid);
854 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
855 bp += sizeof(DB_LSN);
857 memset(&argp->oldname, 0, sizeof(argp->oldname));
858 LOGCOPY_32(env,&argp->oldname.size, bp);
859 bp += sizeof(u_int32_t);
860 argp->oldname.data = bp;
861 bp += argp->oldname.size;
863 memset(&argp->newname, 0, sizeof(argp->newname));
864 LOGCOPY_32(env,&argp->newname.size, bp);
865 bp += sizeof(u_int32_t);
866 argp->newname.data = bp;
867 bp += argp->newname.size;
869 memset(&argp->fileid, 0, sizeof(argp->fileid));
870 LOGCOPY_32(env,&argp->fileid.size, bp);
871 bp += sizeof(u_int32_t);
872 argp->fileid.data = bp;
873 bp += argp->fileid.size;
875 LOGCOPY_32(env, &argp->appname, bp);
876 bp += sizeof(argp->appname);
883 * PUBLIC: int __fop_rename_read __P((ENV *, void *, __fop_rename_args **));
886 __fop_rename_read(env, recbuf, argpp)
889 __fop_rename_args **argpp;
891 __fop_rename_args *argp;
895 if ((ret = __os_malloc(env,
896 sizeof(__fop_rename_args) + sizeof(DB_TXN), &argp)) != 0)
899 argp->txnp = (DB_TXN *)&argp[1];
900 memset(argp->txnp, 0, sizeof(DB_TXN));
902 LOGCOPY_32(env, &argp->type, bp);
903 bp += sizeof(argp->type);
905 LOGCOPY_32(env, &argp->txnp->txnid, bp);
906 bp += sizeof(argp->txnp->txnid);
908 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
909 bp += sizeof(DB_LSN);
911 memset(&argp->oldname, 0, sizeof(argp->oldname));
912 LOGCOPY_32(env,&argp->oldname.size, bp);
913 bp += sizeof(u_int32_t);
914 argp->oldname.data = bp;
915 bp += argp->oldname.size;
917 memset(&argp->newname, 0, sizeof(argp->newname));
918 LOGCOPY_32(env,&argp->newname.size, bp);
919 bp += sizeof(u_int32_t);
920 argp->newname.data = bp;
921 bp += argp->newname.size;
923 memset(&argp->dirname, 0, sizeof(argp->dirname));
924 LOGCOPY_32(env,&argp->dirname.size, bp);
925 bp += sizeof(u_int32_t);
926 argp->dirname.data = bp;
927 bp += argp->dirname.size;
929 memset(&argp->fileid, 0, sizeof(argp->fileid));
930 LOGCOPY_32(env,&argp->fileid.size, bp);
931 bp += sizeof(u_int32_t);
932 argp->fileid.data = bp;
933 bp += argp->fileid.size;
935 LOGCOPY_32(env, &argp->appname, bp);
936 bp += sizeof(argp->appname);
943 * PUBLIC: int __fop_rename_log __P((ENV *, DB_TXN *, DB_LSN *,
944 * PUBLIC: u_int32_t, const DBT *, const DBT *, const DBT *, const DBT *,
945 * PUBLIC: u_int32_t));
948 * PUBLIC: int __fop_rename_noundo_log __P((ENV *, DB_TXN *,
949 * PUBLIC: DB_LSN *, u_int32_t, const DBT *, const DBT *, const DBT *,
950 * PUBLIC: const DBT *, u_int32_t));
953 * PUBLIC: int __fop_rename_int_log __P((ENV *, DB_TXN *, DB_LSN *,
954 * PUBLIC: u_int32_t, const DBT *, const DBT *, const DBT *, const DBT *,
955 * PUBLIC: u_int32_t, u_int32_t));
958 __fop_rename_log(env, txnp, ret_lsnp, flags,
959 oldname, newname, dirname, fileid, appname)
971 return (__fop_rename_int_log(env, txnp, ret_lsnp, flags,
972 oldname, newname, dirname, fileid, appname, DB___fop_rename));
975 __fop_rename_noundo_log(env, txnp, ret_lsnp, flags,
976 oldname, newname, dirname, fileid, appname)
988 return (__fop_rename_int_log(env, txnp, ret_lsnp, flags,
989 oldname, newname, dirname, fileid, appname, DB___fop_rename_noundo));
992 __fop_rename_int_log(env, txnp, ret_lsnp, flags,
993 oldname, newname, dirname, fileid, appname, type)
1006 DB_LSN *lsnp, null_lsn, *rlsnp;
1008 u_int32_t zero, rectype, txn_num;
1011 int is_durable, ret;
1013 COMPQUIET(lr, NULL);
1020 if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
1030 null_lsn.file = null_lsn.offset = 0;
1032 if (TAILQ_FIRST(&txnp->kids) != NULL &&
1033 (ret = __txn_activekids(env, rectype, txnp)) != 0)
1036 * We need to assign begin_lsn while holding region mutex.
1037 * That assignment is done inside the DbEnv->log_put call,
1038 * so pass in the appropriate memory location to be filled
1039 * in by the log_put code.
1041 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
1042 txn_num = txnp->txnid;
1045 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1046 + sizeof(u_int32_t) + (oldname == NULL ? 0 : oldname->size)
1047 + sizeof(u_int32_t) + (newname == NULL ? 0 : newname->size)
1048 + sizeof(u_int32_t) + (dirname == NULL ? 0 : dirname->size)
1049 + sizeof(u_int32_t) + (fileid == NULL ? 0 : fileid->size)
1050 + sizeof(u_int32_t);
1051 if (CRYPTO_ON(env)) {
1052 npad = env->crypto_handle->adj_size(logrec.size);
1053 logrec.size += npad;
1056 if (is_durable || txnp == NULL) {
1058 __os_malloc(env, logrec.size, &logrec.data)) != 0)
1061 if ((ret = __os_malloc(env,
1062 logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
1066 __os_malloc(env, logrec.size, &logrec.data)) != 0) {
1071 logrec.data = lr->data;
1075 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
1079 LOGCOPY_32(env, bp, &rectype);
1080 bp += sizeof(rectype);
1082 LOGCOPY_32(env, bp, &txn_num);
1083 bp += sizeof(txn_num);
1085 LOGCOPY_FROMLSN(env, bp, lsnp);
1086 bp += sizeof(DB_LSN);
1088 if (oldname == NULL) {
1090 LOGCOPY_32(env, bp, &zero);
1091 bp += sizeof(u_int32_t);
1093 LOGCOPY_32(env, bp, &oldname->size);
1094 bp += sizeof(oldname->size);
1095 memcpy(bp, oldname->data, oldname->size);
1096 bp += oldname->size;
1099 if (newname == NULL) {
1101 LOGCOPY_32(env, bp, &zero);
1102 bp += sizeof(u_int32_t);
1104 LOGCOPY_32(env, bp, &newname->size);
1105 bp += sizeof(newname->size);
1106 memcpy(bp, newname->data, newname->size);
1107 bp += newname->size;
1110 if (dirname == NULL) {
1112 LOGCOPY_32(env, bp, &zero);
1113 bp += sizeof(u_int32_t);
1115 LOGCOPY_32(env, bp, &dirname->size);
1116 bp += sizeof(dirname->size);
1117 memcpy(bp, dirname->data, dirname->size);
1118 bp += dirname->size;
1121 if (fileid == NULL) {
1123 LOGCOPY_32(env, bp, &zero);
1124 bp += sizeof(u_int32_t);
1126 LOGCOPY_32(env, bp, &fileid->size);
1127 bp += sizeof(fileid->size);
1128 memcpy(bp, fileid->data, fileid->size);
1132 LOGCOPY_32(env, bp, &appname);
1133 bp += sizeof(appname);
1136 (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
1138 if (is_durable || txnp == NULL) {
1139 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
1140 flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
1142 if (rlsnp != ret_lsnp)
1149 * Set the debug bit if we are going to log non-durable
1150 * transactions so they will be ignored by recovery.
1152 memcpy(lr->data, logrec.data, logrec.size);
1153 rectype |= DB_debug_FLAG;
1154 LOGCOPY_32(env, logrec.data, &rectype);
1156 if (!IS_REP_CLIENT(env))
1157 ret = __log_put(env,
1158 rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
1160 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
1161 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
1162 LSN_NOT_LOGGED(*ret_lsnp);
1165 #ifdef LOG_DIAGNOSTIC
1167 (void)__fop_rename_print(env,
1168 (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
1172 __os_free(env, logrec.data);
1174 if (is_durable || txnp == NULL)
1175 __os_free(env, logrec.data);
1181 * PUBLIC: int __fop_file_remove_read __P((ENV *, void *,
1182 * PUBLIC: __fop_file_remove_args **));
1185 __fop_file_remove_read(env, recbuf, argpp)
1188 __fop_file_remove_args **argpp;
1190 __fop_file_remove_args *argp;
1194 if ((ret = __os_malloc(env,
1195 sizeof(__fop_file_remove_args) + sizeof(DB_TXN), &argp)) != 0)
1198 argp->txnp = (DB_TXN *)&argp[1];
1199 memset(argp->txnp, 0, sizeof(DB_TXN));
1201 LOGCOPY_32(env, &argp->type, bp);
1202 bp += sizeof(argp->type);
1204 LOGCOPY_32(env, &argp->txnp->txnid, bp);
1205 bp += sizeof(argp->txnp->txnid);
1207 LOGCOPY_TOLSN(env, &argp->prev_lsn, bp);
1208 bp += sizeof(DB_LSN);
1210 memset(&argp->real_fid, 0, sizeof(argp->real_fid));
1211 LOGCOPY_32(env,&argp->real_fid.size, bp);
1212 bp += sizeof(u_int32_t);
1213 argp->real_fid.data = bp;
1214 bp += argp->real_fid.size;
1216 memset(&argp->tmp_fid, 0, sizeof(argp->tmp_fid));
1217 LOGCOPY_32(env,&argp->tmp_fid.size, bp);
1218 bp += sizeof(u_int32_t);
1219 argp->tmp_fid.data = bp;
1220 bp += argp->tmp_fid.size;
1222 memset(&argp->name, 0, sizeof(argp->name));
1223 LOGCOPY_32(env,&argp->name.size, bp);
1224 bp += sizeof(u_int32_t);
1225 argp->name.data = bp;
1226 bp += argp->name.size;
1228 LOGCOPY_32(env, &argp->appname, bp);
1229 bp += sizeof(argp->appname);
1231 LOGCOPY_32(env, &argp->child, bp);
1232 bp += sizeof(argp->child);
1239 * PUBLIC: int __fop_file_remove_log __P((ENV *, DB_TXN *, DB_LSN *,
1240 * PUBLIC: u_int32_t, const DBT *, const DBT *, const DBT *, u_int32_t,
1241 * PUBLIC: u_int32_t));
1244 __fop_file_remove_log(env, txnp, ret_lsnp, flags,
1245 real_fid, tmp_fid, name, appname, child)
1250 const DBT *real_fid;
1257 DB_LSN *lsnp, null_lsn, *rlsnp;
1259 u_int32_t zero, rectype, txn_num;
1262 int is_durable, ret;
1264 COMPQUIET(lr, NULL);
1267 rectype = DB___fop_file_remove;
1271 if (LF_ISSET(DB_LOG_NOT_DURABLE)) {
1281 null_lsn.file = null_lsn.offset = 0;
1283 if (TAILQ_FIRST(&txnp->kids) != NULL &&
1284 (ret = __txn_activekids(env, rectype, txnp)) != 0)
1287 * We need to assign begin_lsn while holding region mutex.
1288 * That assignment is done inside the DbEnv->log_put call,
1289 * so pass in the appropriate memory location to be filled
1290 * in by the log_put code.
1292 DB_SET_TXN_LSNP(txnp, &rlsnp, &lsnp);
1293 txn_num = txnp->txnid;
1296 logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
1297 + sizeof(u_int32_t) + (real_fid == NULL ? 0 : real_fid->size)
1298 + sizeof(u_int32_t) + (tmp_fid == NULL ? 0 : tmp_fid->size)
1299 + sizeof(u_int32_t) + (name == NULL ? 0 : name->size)
1301 + sizeof(u_int32_t);
1302 if (CRYPTO_ON(env)) {
1303 npad = env->crypto_handle->adj_size(logrec.size);
1304 logrec.size += npad;
1307 if (is_durable || txnp == NULL) {
1309 __os_malloc(env, logrec.size, &logrec.data)) != 0)
1312 if ((ret = __os_malloc(env,
1313 logrec.size + sizeof(DB_TXNLOGREC), &lr)) != 0)
1317 __os_malloc(env, logrec.size, &logrec.data)) != 0) {
1322 logrec.data = lr->data;
1326 memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
1330 LOGCOPY_32(env, bp, &rectype);
1331 bp += sizeof(rectype);
1333 LOGCOPY_32(env, bp, &txn_num);
1334 bp += sizeof(txn_num);
1336 LOGCOPY_FROMLSN(env, bp, lsnp);
1337 bp += sizeof(DB_LSN);
1339 if (real_fid == NULL) {
1341 LOGCOPY_32(env, bp, &zero);
1342 bp += sizeof(u_int32_t);
1344 LOGCOPY_32(env, bp, &real_fid->size);
1345 bp += sizeof(real_fid->size);
1346 memcpy(bp, real_fid->data, real_fid->size);
1347 bp += real_fid->size;
1350 if (tmp_fid == NULL) {
1352 LOGCOPY_32(env, bp, &zero);
1353 bp += sizeof(u_int32_t);
1355 LOGCOPY_32(env, bp, &tmp_fid->size);
1356 bp += sizeof(tmp_fid->size);
1357 memcpy(bp, tmp_fid->data, tmp_fid->size);
1358 bp += tmp_fid->size;
1363 LOGCOPY_32(env, bp, &zero);
1364 bp += sizeof(u_int32_t);
1366 LOGCOPY_32(env, bp, &name->size);
1367 bp += sizeof(name->size);
1368 memcpy(bp, name->data, name->size);
1372 LOGCOPY_32(env, bp, &appname);
1373 bp += sizeof(appname);
1375 LOGCOPY_32(env, bp, &child);
1376 bp += sizeof(child);
1379 (u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
1381 if (is_durable || txnp == NULL) {
1382 if ((ret = __log_put(env, rlsnp,(DBT *)&logrec,
1383 flags | DB_LOG_NOCOPY)) == 0 && txnp != NULL) {
1385 if (rlsnp != ret_lsnp)
1392 * Set the debug bit if we are going to log non-durable
1393 * transactions so they will be ignored by recovery.
1395 memcpy(lr->data, logrec.data, logrec.size);
1396 rectype |= DB_debug_FLAG;
1397 LOGCOPY_32(env, logrec.data, &rectype);
1399 if (!IS_REP_CLIENT(env))
1400 ret = __log_put(env,
1401 rlsnp, (DBT *)&logrec, flags | DB_LOG_NOCOPY);
1403 STAILQ_INSERT_HEAD(&txnp->logs, lr, links);
1404 F_SET((TXN_DETAIL *)txnp->td, TXN_DTL_INMEMORY);
1405 LSN_NOT_LOGGED(*ret_lsnp);
1408 #ifdef LOG_DIAGNOSTIC
1410 (void)__fop_file_remove_print(env,
1411 (DBT *)&logrec, ret_lsnp, DB_TXN_PRINT, NULL);
1415 __os_free(env, logrec.data);
1417 if (is_durable || txnp == NULL)
1418 __os_free(env, logrec.data);
1424 * PUBLIC: int __fop_init_recover __P((ENV *, DB_DISTAB *));
1427 __fop_init_recover(env, dtabp)
1433 if ((ret = __db_add_recovery_int(env, dtabp,
1434 __fop_create_recover, DB___fop_create)) != 0)
1436 if ((ret = __db_add_recovery_int(env, dtabp,
1437 __fop_remove_recover, DB___fop_remove)) != 0)
1439 if ((ret = __db_add_recovery_int(env, dtabp,
1440 __fop_write_recover, DB___fop_write)) != 0)
1442 if ((ret = __db_add_recovery_int(env, dtabp,
1443 __fop_rename_recover, DB___fop_rename)) != 0)
1445 if ((ret = __db_add_recovery_int(env, dtabp,
1446 __fop_rename_noundo_recover, DB___fop_rename_noundo)) != 0)
1448 if ((ret = __db_add_recovery_int(env, dtabp,
1449 __fop_file_remove_recover, DB___fop_file_remove)) != 0)