1 789 ahrens /* 2 789 ahrens * CDDL HEADER START 3 789 ahrens * 4 789 ahrens * The contents of this file are subject to the terms of the 5 1544 eschrock * Common Development and Distribution License (the "License"). 6 1544 eschrock * You may not use this file except in compliance with the License. 7 789 ahrens * 8 789 ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 789 ahrens * or http://www.opensolaris.org/os/licensing. 10 789 ahrens * See the License for the specific language governing permissions 11 789 ahrens * and limitations under the License. 12 789 ahrens * 13 789 ahrens * When distributing Covered Code, include this CDDL HEADER in each 14 789 ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 789 ahrens * If applicable, add the following below this CDDL HEADER, with the 16 789 ahrens * fields enclosed by brackets "[]" replaced with your own identifying 17 789 ahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18 789 ahrens * 19 789 ahrens * CDDL HEADER END 20 789 ahrens */ 21 789 ahrens /* 22 1544 eschrock * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 789 ahrens * Use is subject to license terms. 24 789 ahrens */ 25 789 ahrens 26 789 ahrens #pragma ident "%Z%%M% %I% %E% SMI" 27 789 ahrens 28 789 ahrens #include <sys/zfs_context.h> 29 789 ahrens #include <sys/uberblock_impl.h> 30 789 ahrens #include <sys/vdev_impl.h> 31 789 ahrens 32 789 ahrens int 33 789 ahrens uberblock_verify(uberblock_t *ub) 34 789 ahrens { 35 789 ahrens if (ub->ub_magic == BSWAP_64((uint64_t)UBERBLOCK_MAGIC)) 36 789 ahrens byteswap_uint64_array(ub, sizeof (uberblock_t)); 37 789 ahrens 38 789 ahrens if (ub->ub_magic != UBERBLOCK_MAGIC) 39 789 ahrens return (EINVAL); 40 789 ahrens 41 789 ahrens return (0); 42 789 ahrens } 43 789 ahrens 44 789 ahrens /* 45 789 ahrens * Update the uberblock and return a boolean value indicating whether 46 789 ahrens * anything changed in this transaction group. 47 789 ahrens */ 48 789 ahrens int 49 789 ahrens uberblock_update(uberblock_t *ub, vdev_t *rvd, uint64_t txg) 50 789 ahrens { 51 789 ahrens ASSERT(ub->ub_txg < txg); 52 789 ahrens 53 1760 eschrock /* 54 1760 eschrock * We explicitly do not set ub_version here, so that older versions 55 1760 eschrock * continue to be written with the previous uberblock version. 56 1760 eschrock */ 57 789 ahrens ub->ub_magic = UBERBLOCK_MAGIC; 58 789 ahrens ub->ub_txg = txg; 59 789 ahrens ub->ub_guid_sum = rvd->vdev_guid_sum; 60 789 ahrens ub->ub_timestamp = gethrestime_sec(); 61 789 ahrens 62 789 ahrens return (ub->ub_rootbp.blk_birth == txg); 63 789 ahrens } 64