FreeBSD ZFS
The Zettabyte File System
|
00001 /* 00002 * CDDL HEADER START 00003 * 00004 * The contents of this file are subject to the terms of the 00005 * Common Development and Distribution License (the "License"). 00006 * You may not use this file except in compliance with the License. 00007 * 00008 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 00009 * or http://www.opensolaris.org/os/licensing. 00010 * See the License for the specific language governing permissions 00011 * and limitations under the License. 00012 * 00013 * When distributing Covered Code, include this CDDL HEADER in each 00014 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 00015 * If applicable, add the following below this CDDL HEADER, with the 00016 * fields enclosed by brackets "[]" replaced with your own identifying 00017 * information: Portions Copyright [yyyy] [name of copyright owner] 00018 * 00019 * CDDL HEADER END 00020 */ 00021 /* 00022 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 00023 */ 00024 00025 #include <sys/zfs_context.h> 00026 #include <sys/uberblock_impl.h> 00027 #include <sys/vdev_impl.h> 00028 00029 int 00030 uberblock_verify(uberblock_t *ub) 00031 { 00032 if (ub->ub_magic == BSWAP_64((uint64_t)UBERBLOCK_MAGIC)) 00033 byteswap_uint64_array(ub, sizeof (uberblock_t)); 00034 00035 if (ub->ub_magic != UBERBLOCK_MAGIC) 00036 return (EINVAL); 00037 00038 return (0); 00039 } 00040 00041 /* 00042 * Update the uberblock and return a boolean value indicating whether 00043 * anything changed in this transaction group. 00044 */ 00045 int 00046 uberblock_update(uberblock_t *ub, vdev_t *rvd, uint64_t txg) 00047 { 00048 ASSERT(ub->ub_txg < txg); 00049 00050 /* 00051 * We explicitly do not set ub_version here, so that older versions 00052 * continue to be written with the previous uberblock version. 00053 */ 00054 ub->ub_magic = UBERBLOCK_MAGIC; 00055 ub->ub_txg = txg; 00056 ub->ub_guid_sum = rvd->vdev_guid_sum; 00057 ub->ub_timestamp = gethrestime_sec(); 00058 ub->ub_software_version = SPA_VERSION; 00059 00060 return (ub->ub_rootbp.blk_birth == txg); 00061 }