Print this page
Revert "Revert "6602 lofi should support labeled devices""
This reverts commit 21386c8bd8477810b291eee22e08f1382e70cdf3.
Revert "6602 lofi should support labeled devices"
This reverts commit 406fc5100dac8d225a315a6def6be8d628f34e24.
Adding AoE support to nza-kernel


4469 vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype)
4470 {
4471         vfs_list_lock();
4472 
4473         vfs_hash_remove(vfsp);
4474 
4475         vfsp->vfs_dev = ndev;
4476         vfs_make_fsid(&vfsp->vfs_fsid, ndev, fstype);
4477 
4478         vfs_hash_add(vfsp, 1);
4479 
4480         vfs_list_unlock();
4481 }
4482 
4483 #else /* x86 NEWBOOT */
4484 
4485 #if defined(__x86)
4486 extern int hvmboot_rootconf();
4487 #endif /* __x86 */
4488 

4489 extern ib_boot_prop_t *iscsiboot_prop;
4490 
4491 int
4492 rootconf()
4493 {
4494         int error;
4495         struct vfssw *vsw;
4496         extern void pm_init();
4497         char *fstyp, *fsmod;
4498         int ret = -1;
4499 
4500         getrootfs(&fstyp, &fsmod);
4501 
4502 #if defined(__x86)
4503         /*
4504          * hvmboot_rootconf() is defined in the hvm_bootstrap misc module,
4505          * which lives in /platform/i86hvm, and hence is only available when
4506          * booted in an x86 hvm environment.  If the hvm_bootstrap misc module
4507          * is not available then the modstub for this function will return 0.
4508          * If the hvm_bootstrap misc module is available it will be loaded


4511         if (error = hvmboot_rootconf())
4512                 return (error);
4513 #endif /* __x86 */
4514 
4515         if (error = clboot_rootconf())
4516                 return (error);
4517 
4518         if (modload("fs", fsmod) == -1)
4519                 panic("Cannot _init %s module", fsmod);
4520 
4521         RLOCK_VFSSW();
4522         vsw = vfs_getvfsswbyname(fstyp);
4523         RUNLOCK_VFSSW();
4524         if (vsw == NULL) {
4525                 cmn_err(CE_CONT, "Cannot find %s filesystem\n", fstyp);
4526                 return (ENXIO);
4527         }
4528         VFS_INIT(rootvfs, &vsw->vsw_vfsops, 0);
4529         VFS_HOLD(rootvfs);
4530 
4531         /* always mount readonly first */
4532         rootvfs->vfs_flag |= VFS_RDONLY;
4533 
4534         pm_init();
4535 
4536         if (netboot && iscsiboot_prop) {
4537                 cmn_err(CE_WARN, "NFS boot and iSCSI boot"
4538                     " shouldn't happen in the same time");


4539                 return (EINVAL);
4540         }
4541 
4542         if (netboot || iscsiboot_prop) {
4543                 ret = strplumb();
4544                 if (ret != 0) {
4545                         cmn_err(CE_WARN, "Cannot plumb network device %d", ret);
4546                         return (EFAULT);
4547                 }
4548         }
4549 
4550         if ((ret == 0) && iscsiboot_prop) {
4551                 ret = modload("drv", "iscsi");
4552                 /* -1 indicates fail */
4553                 if (ret == -1) {










4554                         cmn_err(CE_WARN, "Failed to load iscsi module");
4555                         iscsi_boot_prop_free();
4556                         return (EINVAL);
4557                 } else {
4558                         if (!i_ddi_attach_pseudo_node("iscsi")) {
4559                                 cmn_err(CE_WARN,
4560                                     "Failed to attach iscsi driver");
4561                                 iscsi_boot_prop_free();
4562                                 return (ENODEV);
4563                         }
4564                 }
4565         }
4566 
4567         error = VFS_MOUNTROOT(rootvfs, ROOT_INIT);
4568         vfs_unrefvfssw(vsw);
4569         rootdev = rootvfs->vfs_dev;
4570 
4571         if (error)
4572                 cmn_err(CE_CONT, "Cannot mount root on %s fstype %s\n",
4573                     rootfs.bo_name, fstyp);
4574         else
4575                 cmn_err(CE_CONT, "?root on %s fstype %s\n",
4576                     rootfs.bo_name, fstyp);
4577         return (error);
4578 }
4579 
4580 /*
4581  * XXX this is called by nfs only and should probably be removed
4582  * If booted with ASKNAME, prompt on the console for a filesystem
4583  * name and return it.
4584  */
4585 void
4586 getfsname(char *askfor, char *name, size_t namelen)
4587 {
4588         if (boothowto & RB_ASKNAME) {
4589                 printf("%s name: ", askfor);
4590                 console_gets(name, namelen);
4591         }




4469 vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype)
4470 {
4471         vfs_list_lock();
4472 
4473         vfs_hash_remove(vfsp);
4474 
4475         vfsp->vfs_dev = ndev;
4476         vfs_make_fsid(&vfsp->vfs_fsid, ndev, fstype);
4477 
4478         vfs_hash_add(vfsp, 1);
4479 
4480         vfs_list_unlock();
4481 }
4482 
4483 #else /* x86 NEWBOOT */
4484 
4485 #if defined(__x86)
4486 extern int hvmboot_rootconf();
4487 #endif /* __x86 */
4488 
4489 extern char *aoepath_prop;
4490 extern ib_boot_prop_t *iscsiboot_prop;
4491 
4492 int
4493 rootconf()
4494 {
4495         int error;
4496         struct vfssw *vsw;
4497         extern void pm_init();
4498         char *fstyp, *fsmod;
4499         int ret = -1;
4500 
4501         getrootfs(&fstyp, &fsmod);
4502 
4503 #if defined(__x86)
4504         /*
4505          * hvmboot_rootconf() is defined in the hvm_bootstrap misc module,
4506          * which lives in /platform/i86hvm, and hence is only available when
4507          * booted in an x86 hvm environment.  If the hvm_bootstrap misc module
4508          * is not available then the modstub for this function will return 0.
4509          * If the hvm_bootstrap misc module is available it will be loaded


4512         if (error = hvmboot_rootconf())
4513                 return (error);
4514 #endif /* __x86 */
4515 
4516         if (error = clboot_rootconf())
4517                 return (error);
4518 
4519         if (modload("fs", fsmod) == -1)
4520                 panic("Cannot _init %s module", fsmod);
4521 
4522         RLOCK_VFSSW();
4523         vsw = vfs_getvfsswbyname(fstyp);
4524         RUNLOCK_VFSSW();
4525         if (vsw == NULL) {
4526                 cmn_err(CE_CONT, "Cannot find %s filesystem\n", fstyp);
4527                 return (ENXIO);
4528         }
4529         VFS_INIT(rootvfs, &vsw->vsw_vfsops, 0);
4530         VFS_HOLD(rootvfs);
4531 
4532         /* Always mount readonly first */
4533         rootvfs->vfs_flag |= VFS_RDONLY;
4534 
4535         pm_init();
4536 
4537         if ((aoepath_prop != NULL && (iscsiboot_prop != NULL || netboot)) ||
4538             (iscsiboot_prop != NULL && (aoepath_prop != NULL || netboot)) ||
4539             (netboot && (aoepath_prop != NULL || iscsiboot_prop != NULL))) {
4540                 cmn_err(CE_WARN, "Only one of AoE, iSCSI or NFS boot "
4541                     "can be specified at time");
4542                 return (EINVAL);
4543         }
4544 
4545         if (aoepath_prop != NULL || iscsiboot_prop != NULL || netboot) {
4546                 ret = strplumb();
4547                 if (ret != 0) {
4548                         cmn_err(CE_WARN, "Cannot plumb network device %d", ret);
4549                         return (EFAULT);
4550                 }
4551         }
4552 
4553         if (aoepath_prop != NULL) {
4554                 if (modload("drv", "aoe") == -1 ||
4555                     modload("drv", "aoeblk") == -1) {
4556                         cmn_err(CE_WARN, "Failed to load aoe modules");
4557                         return (EINVAL);
4558                 }
4559                 if (i_ddi_attach_pseudo_node("aoe") == 0) {
4560                         cmn_err(CE_WARN, "Failed to attach aoe driver");
4561                         return (ENODEV);
4562                 }
4563         }
4564 
4565         if (iscsiboot_prop != NULL) {
4566                 if (modload("drv", "iscsi") == -1) {
4567                         cmn_err(CE_WARN, "Failed to load iscsi module");
4568                         iscsi_boot_prop_free();
4569                         return (EINVAL);
4570                 }
4571                 if (i_ddi_attach_pseudo_node("iscsi") == 0) {
4572                         cmn_err(CE_WARN, "Failed to attach iscsi driver");

4573                         iscsi_boot_prop_free();
4574                         return (ENODEV);
4575                 }
4576         }

4577 
4578         error = VFS_MOUNTROOT(rootvfs, ROOT_INIT);
4579         vfs_unrefvfssw(vsw);
4580         rootdev = rootvfs->vfs_dev;
4581 
4582         if (error != 0)
4583                 cmn_err(CE_CONT, "Cannot mount root on %s fstype %s\n",
4584                     rootfs.bo_name, fstyp);
4585         else
4586                 cmn_err(CE_CONT, "?root on %s fstype %s\n",
4587                     rootfs.bo_name, fstyp);
4588         return (error);
4589 }
4590 
4591 /*
4592  * XXX this is called by nfs only and should probably be removed
4593  * If booted with ASKNAME, prompt on the console for a filesystem
4594  * name and return it.
4595  */
4596 void
4597 getfsname(char *askfor, char *name, size_t namelen)
4598 {
4599         if (boothowto & RB_ASKNAME) {
4600                 printf("%s name: ", askfor);
4601                 console_gets(name, namelen);
4602         }