Print this page
OS-2366 ddi_periodic_add(9F) is entirely rubbish (MORE)


   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2011 Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 #include <sys/param.h>
  29 #include <sys/types.h>
  30 #include <sys/sysmacros.h>
  31 #include <sys/systm.h>
  32 #include <sys/errno.h>
  33 #include <sys/vfs.h>
  34 #include <sys/vnode.h>
  35 #include <sys/swap.h>
  36 #include <sys/file.h>
  37 #include <sys/proc.h>
  38 #include <sys/var.h>
  39 #include <sys/uadmin.h>
  40 #include <sys/signal.h>
  41 #include <sys/time.h>
  42 #include <vm/seg_kmem.h>
  43 #include <sys/modctl.h>
  44 #include <sys/callb.h>
  45 #include <sys/dumphdr.h>
  46 #include <sys/debug.h>
  47 #include <sys/ftrace.h>
  48 #include <sys/cmn_err.h>
  49 #include <sys/panic.h>
  50 #include <sys/ddi.h>

  51 #include <sys/sunddi.h>
  52 #include <sys/policy.h>
  53 #include <sys/zone.h>
  54 #include <sys/condvar.h>
  55 #include <sys/thread.h>
  56 #include <sys/sdt.h>
  57 
  58 /*
  59  * Administrivia system call.  We provide this in two flavors: one for calling
  60  * from the system call path (uadmin), and the other for calling from elsewhere
  61  * within the kernel (kadmin).  Callers must beware that certain uadmin cmd
  62  * values (specifically A_SWAPCTL) are only supported by uadmin and not kadmin.
  63  */
  64 
  65 extern ksema_t fsflush_sema;
  66 kmutex_t ualock;
  67 kcondvar_t uacond;
  68 kthread_t *ua_shutdown_thread = NULL;
  69 
  70 int sys_shutdown = 0;


 268                  * performing the actual poweroff.
 269                  */
 270                 if ((mdep != NULL) && (*(char *)mdep == '/')) {
 271                         buf = i_convert_boot_device_name(mdep, NULL, &buflen);
 272                         mdpreboot(cmd, fcn, buf);
 273                 } else
 274                         mdpreboot(cmd, fcn, mdep);
 275 
 276                 /*
 277                  * Allow fsflush to finish running and then prevent it
 278                  * from ever running again so that vfs_unmountall() and
 279                  * vfs_syncall() can acquire the vfs locks they need.
 280                  */
 281                 sema_p(&fsflush_sema);
 282                 (void) callb_execute_class(CB_CL_UADMIN_PRE_VFS, NULL);
 283 
 284                 vfs_unmountall();
 285                 (void) VFS_MOUNTROOT(rootvfs, ROOT_UNMOUNT);
 286                 vfs_syncall();
 287 






 288                 dump_ereports();
 289                 dump_messages();
 290 
 291                 invoke_cb = B_TRUE;
 292 
 293                 /* FALLTHROUGH */
 294         }
 295 
 296         case A_REBOOT:
 297                 if ((mdep != NULL) && (*(char *)mdep == '/')) {
 298                         buf = i_convert_boot_device_name(mdep, NULL, &buflen);
 299                         mdboot(cmd, fcn, buf, invoke_cb);
 300                 } else
 301                         mdboot(cmd, fcn, mdep, invoke_cb);
 302                 /* no return expected */
 303                 break;
 304 
 305         case A_CONFIG:
 306                 switch (fcn) {
 307                 case AD_UPDATE_BOOT_CONFIG:




   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 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2013 Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 #include <sys/param.h>
  29 #include <sys/types.h>
  30 #include <sys/sysmacros.h>
  31 #include <sys/systm.h>
  32 #include <sys/errno.h>
  33 #include <sys/vfs.h>
  34 #include <sys/vnode.h>
  35 #include <sys/swap.h>
  36 #include <sys/file.h>
  37 #include <sys/proc.h>
  38 #include <sys/var.h>
  39 #include <sys/uadmin.h>
  40 #include <sys/signal.h>
  41 #include <sys/time.h>
  42 #include <vm/seg_kmem.h>
  43 #include <sys/modctl.h>
  44 #include <sys/callb.h>
  45 #include <sys/dumphdr.h>
  46 #include <sys/debug.h>
  47 #include <sys/ftrace.h>
  48 #include <sys/cmn_err.h>
  49 #include <sys/panic.h>
  50 #include <sys/ddi.h>
  51 #include <sys/ddi_periodic.h>
  52 #include <sys/sunddi.h>
  53 #include <sys/policy.h>
  54 #include <sys/zone.h>
  55 #include <sys/condvar.h>
  56 #include <sys/thread.h>
  57 #include <sys/sdt.h>
  58 
  59 /*
  60  * Administrivia system call.  We provide this in two flavors: one for calling
  61  * from the system call path (uadmin), and the other for calling from elsewhere
  62  * within the kernel (kadmin).  Callers must beware that certain uadmin cmd
  63  * values (specifically A_SWAPCTL) are only supported by uadmin and not kadmin.
  64  */
  65 
  66 extern ksema_t fsflush_sema;
  67 kmutex_t ualock;
  68 kcondvar_t uacond;
  69 kthread_t *ua_shutdown_thread = NULL;
  70 
  71 int sys_shutdown = 0;


 269                  * performing the actual poweroff.
 270                  */
 271                 if ((mdep != NULL) && (*(char *)mdep == '/')) {
 272                         buf = i_convert_boot_device_name(mdep, NULL, &buflen);
 273                         mdpreboot(cmd, fcn, buf);
 274                 } else
 275                         mdpreboot(cmd, fcn, mdep);
 276 
 277                 /*
 278                  * Allow fsflush to finish running and then prevent it
 279                  * from ever running again so that vfs_unmountall() and
 280                  * vfs_syncall() can acquire the vfs locks they need.
 281                  */
 282                 sema_p(&fsflush_sema);
 283                 (void) callb_execute_class(CB_CL_UADMIN_PRE_VFS, NULL);
 284 
 285                 vfs_unmountall();
 286                 (void) VFS_MOUNTROOT(rootvfs, ROOT_UNMOUNT);
 287                 vfs_syncall();
 288 
 289                 /*
 290                  * Check for (and unregister) any DDI periodic handlers that
 291                  * still exist, as they most likely constitute resource leaks:
 292                  */
 293                 ddi_periodic_fini();
 294 
 295                 dump_ereports();
 296                 dump_messages();
 297 
 298                 invoke_cb = B_TRUE;
 299 
 300                 /* FALLTHROUGH */
 301         }
 302 
 303         case A_REBOOT:
 304                 if ((mdep != NULL) && (*(char *)mdep == '/')) {
 305                         buf = i_convert_boot_device_name(mdep, NULL, &buflen);
 306                         mdboot(cmd, fcn, buf, invoke_cb);
 307                 } else
 308                         mdboot(cmd, fcn, mdep, invoke_cb);
 309                 /* no return expected */
 310                 break;
 311 
 312         case A_CONFIG:
 313                 switch (fcn) {
 314                 case AD_UPDATE_BOOT_CONFIG: