Lines Matching refs:image

110  * image, then, once the inactive image has completed the hash chain
112 * atomically switched, making the formerly-inactive image authoritative.
113 * After the image switch, the update code then updates the formerly-active
114 * image's hash chains to match the active image's hash chains.
118 * inactive image's hash chains with the active image's chains. Note that
119 * the atomic image switch serves as the "commit point" for the operation:
329 uchar_t image;
341 * our active image's hash chains correct and only swap to the
342 * alternate image when the other image is completely safe to use.
357 image = header.dnh_image;
384 if (read_hashhead(fd, &recid, hash, image)
389 if (recid == rec.rec_next[image])
391 recid = rec.rec_next[image];
403 recid = header.dnh_cidhash[hash][image];
406 if (recid == rec.rec_next[image])
408 recid = rec.rec_next[image];
412 recid = header.dnh_cidhash[hash][image];
437 if (rec.rec_prev[image] == DN_NOREC)
573 uchar_t image;
588 * Get the active image.
590 retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image);
601 if (rec.rec_prev[image] != DN_NOREC)
607 * image's hash record id pointers so that the record will
608 * atomically become in-use when we switch to the alternate image.
610 if (read_hashhead(fd, &recid_head, hash, image) == -1)
615 rec.rec_prev[!image] = DN_HASHHEAD;
616 rec.rec_next[!image] = recid_head;
622 if (rec.rec_next[!image] != DN_NOREC) {
623 if (read_rec(fd, &rec_next, rec.rec_next[!image]) == -1)
644 * Update the alternate image's on-disk hash pointers. We need to
645 * do this before we switch to the alternate image so we cannot
646 * abort with an inconsistent active image.
648 if (rec.rec_next[!image] != DN_NOREC) {
649 rec_next.rec_prev[!image] = recid;
650 if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1)
653 if (write_hashhead(fd, recid, hash, !image) == -1)
657 * Activate the alternate image. This is our commit point -- if we
660 image = !image;
661 retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image);
668 rec.rec_prev[!image] = rec.rec_prev[image];
669 rec.rec_next[!image] = rec.rec_next[image];
673 if (rec.rec_next[!image] != DN_NOREC) {
674 rec_next.rec_prev[!image] = recid;
675 if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1)
678 if (write_hashhead(fd, recid, hash, !image) == -1)
698 uchar_t image;
711 * Get the active image.
713 retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image);
726 if (rec.rec_prev[image] == DN_NOREC)
742 if (rec.rec_next[image] != DN_NOREC) {
743 if (read_rec(fd, &rec_next, rec.rec_next[image]) == -1)
747 if (rec.rec_prev[image] != DN_HASHHEAD) {
748 if (read_rec(fd, &rec_prev, rec.rec_prev[image]) == -1)
753 * Before we update the alternate image's on-disk hash pointers,
762 * Update the alternate image's on-disk hash pointers. We need to
763 * do this before we switch to the alternate image so we do not
764 * abort with an inconsistent active image. Also reset the
765 * record's alternate image record id pointers, so that the old
766 * record will not be in-use when we switch to the alternate image.
768 if (rec.rec_next[image] != DN_NOREC) {
769 rec_next.rec_prev[!image] = rec.rec_prev[image];
770 if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1)
774 if (rec.rec_prev[image] != DN_HASHHEAD) {
775 rec_prev.rec_next[!image] = rec.rec_next[image];
776 if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1)
779 if (write_hashhead(fd, rec.rec_next[image], hash, !image) == -1)
783 rec.rec_next[!image] = DN_NOREC;
784 rec.rec_prev[!image] = DN_NOREC;
789 * Activate the alternate image. This is our commit point -- if we
792 image = !image;
793 retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image);
800 if (rec.rec_next[!image] != DN_NOREC) {
801 rec_next.rec_prev[!image] = rec.rec_prev[!image];
802 if (write_rec(fd, &rec_next, rec.rec_next[!image]) == -1)
806 if (rec.rec_prev[!image] != DN_HASHHEAD) {
807 rec_prev.rec_next[!image] = rec.rec_next[!image];
808 if (write_rec(fd, &rec_prev, rec.rec_prev[!image]) == -1)
811 if (write_hashhead(fd, rec.rec_next[!image], hash, !image)
816 rec.rec_next[!image] = DN_NOREC;
817 rec.rec_prev[!image] = DN_NOREC;
833 uchar_t image;
846 * Get the active image
848 retval = getabyte(fd, offsetof(dn_header_t, dnh_image), &image);
861 if (rec.rec_prev[image] == DN_NOREC)
876 if (new_rec.rec_prev[image] != DN_NOREC)
890 * in either case, only update the alternate image pointers, so
892 * alternate image.
898 new_rec.rec_prev[!image] = rec.rec_prev[image];
899 new_rec.rec_next[!image] = rec.rec_next[image];
901 if (read_hashhead(fd, &recid_head, new_hash, image) == -1)
904 new_rec.rec_prev[!image] = DN_HASHHEAD;
905 new_rec.rec_next[!image] = recid_head;
931 * alternate image for now so that we can recover upon failure.
934 if (rec.rec_next[image] != DN_NOREC) {
935 if (read_rec(fd, &rec_next, rec.rec_next[image]) == -1)
938 if (rec.rec_prev[image] != DN_HASHHEAD) {
939 if (read_rec(fd, &rec_prev, rec.rec_prev[image]) == -1)
944 rec_next.rec_prev[!image] = rec.rec_prev[!image];
945 rec_prev.rec_next[!image] = rec.rec_next[!image];
947 rec_next.rec_prev[!image] = new_recid;
948 rec_prev.rec_next[!image] = new_recid;
951 if (rec.rec_next[image] != DN_NOREC) {
952 if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1)
955 if (rec.rec_prev[image] != DN_HASHHEAD) {
956 if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1)
959 if (write_hashhead(fd, rec_prev.rec_next[!image], hash,
960 !image) == -1)
965 * If our hash is changing, update the alternate image
972 rec_head.rec_prev[!image] = new_recid;
976 if (write_hashhead(fd, new_recid, new_hash, !image)
983 * alternate image record id pointers, so that the old
985 * alternate image.
988 rec.rec_prev[!image] = DN_NOREC;
989 rec.rec_next[!image] = DN_NOREC;
997 * the image that will be active when we're done. This piece of
1000 * failed before or after activating the alternate image (below).
1001 * If we failed before activating the alternate image, then the
1004 * after making the alternate image active but before we completed
1011 !image);
1017 * Activate the alternate image. This is our commit point -- if we
1020 image = !image;
1021 retval = setabyte(fd, offsetof(dn_header_t, dnh_image), image);
1043 new_rec.rec_prev[!image] = new_rec.rec_prev[image];
1044 new_rec.rec_next[!image] = new_rec.rec_next[image];
1049 if (rec.rec_next[image] != DN_NOREC) {
1050 rec_next.rec_prev[!image] = rec.rec_prev[image];
1051 if (write_rec(fd, &rec_next, rec.rec_next[image]) == -1)
1054 if (rec.rec_prev[image] != DN_HASHHEAD) {
1055 rec_prev.rec_next[!image] = rec.rec_next[image];
1056 if (write_rec(fd, &rec_prev, rec.rec_prev[image]) == -1)
1059 if (write_hashhead(fd, rec.rec_next[image], hash,
1060 !image) == -1)
1065 * If our hash changed, update the alternate image record
1070 rec_head.rec_prev[!image] =
1071 rec_head.rec_prev[image];
1075 if (write_hashhead(fd, new_recid, new_hash, !image)
1085 rec.rec_prev[!image] = DN_NOREC;
1086 rec.rec_next[!image] = DN_NOREC;
1189 uchar_t image, dirty;
1212 * If `dnh_tempimage' matches the current working image, then we
1231 image = header.dnh_image;
1233 header.dnh_cidhash[hash][!image] =
1234 header.dnh_cidhash[hash][image];
1252 if (rec.rec_next[image] != rec.rec_next[!image] ||
1253 rec.rec_prev[image] != rec.rec_prev[!image]) {
1256 rec.rec_prev[!image] = rec.rec_prev[image];
1257 rec.rec_next[!image] = rec.rec_next[image];
1426 * into `recid_headp', using image `image'. Returns 0 on success, -1 on
1430 read_hashhead(int fd, dn_recid_t *recid_headp, uint16_t cidhash, uchar_t image)
1433 offsetof(dn_header_t, dnh_cidhash[cidhash][image])) == -1)
1442 * from `recid_head', using image `image'. Returns 0 on success, -1 on
1446 write_hashhead(int fd, dn_recid_t recid_head, uint16_t cidhash, uchar_t image)
1450 offsetof(dn_header_t, dnh_cidhash[cidhash][image])));