Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011 by Delphix. All rights reserved.
  24  */
  25 
  26 /* Portions Copyright 2010 Robert Milkowski */
  27 
  28 #include <sys/zfs_context.h>
  29 #include <sys/spa.h>
  30 #include <sys/dmu.h>
  31 #include <sys/zap.h>
  32 #include <sys/arc.h>
  33 #include <sys/stat.h>
  34 #include <sys/resource.h>
  35 #include <sys/zil.h>
  36 #include <sys/zil_impl.h>
  37 #include <sys/dsl_dataset.h>
  38 #include <sys/vdev_impl.h>
  39 #include <sys/dmu_tx.h>
  40 #include <sys/dsl_pool.h>
  41 
  42 /*
  43  * The zfs intent log (ZIL) saves transaction records of system calls


1045                                 return (lwb);
1046                         }
1047                         if (error) {
1048                                 ASSERT(error == ENOENT || error == EEXIST ||
1049                                     error == EALREADY);
1050                                 return (lwb);
1051                         }
1052                 }
1053         }
1054 
1055         /*
1056          * We're actually making an entry, so update lrc_seq to be the
1057          * log record sequence number.  Note that this is generally not
1058          * equal to the itx sequence number because not all transactions
1059          * are synchronous, and sometimes spa_sync() gets there first.
1060          */
1061         lrc->lrc_seq = ++zilog->zl_lr_seq; /* we are single threaded */
1062         lwb->lwb_nused += reclen + dlen;
1063         lwb->lwb_max_txg = MAX(lwb->lwb_max_txg, txg);
1064         ASSERT3U(lwb->lwb_nused, <=, lwb->lwb_sz);
1065         ASSERT3U(P2PHASE(lwb->lwb_nused, sizeof (uint64_t)), ==, 0);
1066 
1067         return (lwb);
1068 }
1069 
1070 itx_t *
1071 zil_itx_create(uint64_t txtype, size_t lrsize)
1072 {
1073         itx_t *itx;
1074 
1075         lrsize = P2ROUNDUP_TYPED(lrsize, sizeof (uint64_t), size_t);
1076 
1077         itx = kmem_alloc(offsetof(itx_t, itx_lr) + lrsize, KM_SLEEP);
1078         itx->itx_lr.lrc_txtype = txtype;
1079         itx->itx_lr.lrc_reclen = lrsize;
1080         itx->itx_sod = lrsize; /* if write & WR_NEED_COPY will be increased */
1081         itx->itx_lr.lrc_seq = 0;     /* defensive */
1082         itx->itx_sync = B_TRUE;              /* default is synchronous */
1083 
1084         return (itx);
1085 }




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  */
  25 
  26 /* Portions Copyright 2010 Robert Milkowski */
  27 
  28 #include <sys/zfs_context.h>
  29 #include <sys/spa.h>
  30 #include <sys/dmu.h>
  31 #include <sys/zap.h>
  32 #include <sys/arc.h>
  33 #include <sys/stat.h>
  34 #include <sys/resource.h>
  35 #include <sys/zil.h>
  36 #include <sys/zil_impl.h>
  37 #include <sys/dsl_dataset.h>
  38 #include <sys/vdev_impl.h>
  39 #include <sys/dmu_tx.h>
  40 #include <sys/dsl_pool.h>
  41 
  42 /*
  43  * The zfs intent log (ZIL) saves transaction records of system calls


1045                                 return (lwb);
1046                         }
1047                         if (error) {
1048                                 ASSERT(error == ENOENT || error == EEXIST ||
1049                                     error == EALREADY);
1050                                 return (lwb);
1051                         }
1052                 }
1053         }
1054 
1055         /*
1056          * We're actually making an entry, so update lrc_seq to be the
1057          * log record sequence number.  Note that this is generally not
1058          * equal to the itx sequence number because not all transactions
1059          * are synchronous, and sometimes spa_sync() gets there first.
1060          */
1061         lrc->lrc_seq = ++zilog->zl_lr_seq; /* we are single threaded */
1062         lwb->lwb_nused += reclen + dlen;
1063         lwb->lwb_max_txg = MAX(lwb->lwb_max_txg, txg);
1064         ASSERT3U(lwb->lwb_nused, <=, lwb->lwb_sz);
1065         ASSERT0(P2PHASE(lwb->lwb_nused, sizeof (uint64_t)));
1066 
1067         return (lwb);
1068 }
1069 
1070 itx_t *
1071 zil_itx_create(uint64_t txtype, size_t lrsize)
1072 {
1073         itx_t *itx;
1074 
1075         lrsize = P2ROUNDUP_TYPED(lrsize, sizeof (uint64_t), size_t);
1076 
1077         itx = kmem_alloc(offsetof(itx_t, itx_lr) + lrsize, KM_SLEEP);
1078         itx->itx_lr.lrc_txtype = txtype;
1079         itx->itx_lr.lrc_reclen = lrsize;
1080         itx->itx_sod = lrsize; /* if write & WR_NEED_COPY will be increased */
1081         itx->itx_lr.lrc_seq = 0;     /* defensive */
1082         itx->itx_sync = B_TRUE;              /* default is synchronous */
1083 
1084         return (itx);
1085 }