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