| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: lfs_vfsops.c,v 1.346 2015/10/10 22:33:57 dholland Exp $ */ | | 1 | /* $NetBSD: lfs_vfsops.c,v 1.347 2015/10/15 06:15:48 dholland Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 | | 4 | * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 |
5 | * The NetBSD Foundation, Inc. | | 5 | * The NetBSD Foundation, Inc. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to The NetBSD Foundation | | 8 | * This code is derived from software contributed to The NetBSD Foundation |
9 | * by Konrad E. Schroder <perseant@hhhh.org>. | | 9 | * by Konrad E. Schroder <perseant@hhhh.org>. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -51,27 +51,27 @@ | | | @@ -51,27 +51,27 @@ |
51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
58 | * SUCH DAMAGE. | | 58 | * SUCH DAMAGE. |
59 | * | | 59 | * |
60 | * @(#)lfs_vfsops.c 8.20 (Berkeley) 6/10/95 | | 60 | * @(#)lfs_vfsops.c 8.20 (Berkeley) 6/10/95 |
61 | */ | | 61 | */ |
62 | | | 62 | |
63 | #include <sys/cdefs.h> | | 63 | #include <sys/cdefs.h> |
64 | __KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.346 2015/10/10 22:33:57 dholland Exp $"); | | 64 | __KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.347 2015/10/15 06:15:48 dholland Exp $"); |
65 | | | 65 | |
66 | #if defined(_KERNEL_OPT) | | 66 | #if defined(_KERNEL_OPT) |
67 | #include "opt_lfs.h" | | 67 | #include "opt_lfs.h" |
68 | #include "opt_quota.h" | | 68 | #include "opt_quota.h" |
69 | #endif | | 69 | #endif |
70 | | | 70 | |
71 | #include <sys/param.h> | | 71 | #include <sys/param.h> |
72 | #include <sys/systm.h> | | 72 | #include <sys/systm.h> |
73 | #include <sys/namei.h> | | 73 | #include <sys/namei.h> |
74 | #include <sys/proc.h> | | 74 | #include <sys/proc.h> |
75 | #include <sys/kernel.h> | | 75 | #include <sys/kernel.h> |
76 | #include <sys/vnode.h> | | 76 | #include <sys/vnode.h> |
77 | #include <sys/mount.h> | | 77 | #include <sys/mount.h> |
| @@ -662,46 +662,54 @@ lfs_mount(struct mount *mp, const char * | | | @@ -662,46 +662,54 @@ lfs_mount(struct mount *mp, const char * |
662 | | | 662 | |
663 | if (!update) { | | 663 | if (!update) { |
664 | /* | | 664 | /* |
665 | * Be sure this is a valid block device | | 665 | * Be sure this is a valid block device |
666 | */ | | 666 | */ |
667 | if (devvp->v_type != VBLK) | | 667 | if (devvp->v_type != VBLK) |
668 | error = ENOTBLK; | | 668 | error = ENOTBLK; |
669 | else if (bdevsw_lookup(devvp->v_rdev) == NULL) | | 669 | else if (bdevsw_lookup(devvp->v_rdev) == NULL) |
670 | error = ENXIO; | | 670 | error = ENXIO; |
671 | } else { | | 671 | } else { |
672 | /* | | 672 | /* |
673 | * Be sure we're still naming the same device | | 673 | * Be sure we're still naming the same device |
674 | * used for our initial mount | | 674 | * used for our initial mount |
| | | 675 | * |
| | | 676 | * XXX dholland 20151010: if namei gives us a |
| | | 677 | * different vnode for the same device, |
| | | 678 | * wouldn't it be better to use it going |
| | | 679 | * forward rather than ignore it in favor of |
| | | 680 | * the old one? |
675 | */ | | 681 | */ |
676 | ump = VFSTOULFS(mp); | | 682 | ump = VFSTOULFS(mp); |
677 | if (devvp != ump->um_devvp) { | | 683 | fs = ump->um_lfs; |
678 | if (devvp->v_rdev != ump->um_devvp->v_rdev) | | 684 | if (devvp != fs->lfs_devvp) { |
| | | 685 | if (devvp->v_rdev != fs->lfs_devvp->v_rdev) |
679 | error = EINVAL; | | 686 | error = EINVAL; |
680 | else { | | 687 | else { |
681 | vrele(devvp); | | 688 | vrele(devvp); |
682 | devvp = ump->um_devvp; | | 689 | devvp = fs->lfs_devvp; |
683 | vref(devvp); | | 690 | vref(devvp); |
684 | } | | 691 | } |
685 | } | | 692 | } |
686 | } | | 693 | } |
687 | } else { | | 694 | } else { |
688 | if (!update) { | | 695 | if (!update) { |
689 | /* New mounts must have a filename for the device */ | | 696 | /* New mounts must have a filename for the device */ |
690 | return (EINVAL); | | 697 | return (EINVAL); |
691 | } else { | | 698 | } else { |
692 | /* Use the extant mount */ | | 699 | /* Use the extant mount */ |
693 | ump = VFSTOULFS(mp); | | 700 | ump = VFSTOULFS(mp); |
694 | devvp = ump->um_devvp; | | 701 | fs = ump->um_lfs; |
| | | 702 | devvp = fs->lfs_devvp; |
695 | vref(devvp); | | 703 | vref(devvp); |
696 | } | | 704 | } |
697 | } | | 705 | } |
698 | | | 706 | |
699 | | | 707 | |
700 | /* | | 708 | /* |
701 | * If mount by non-root, then verify that user has necessary | | 709 | * If mount by non-root, then verify that user has necessary |
702 | * permissions on the device. | | 710 | * permissions on the device. |
703 | */ | | 711 | */ |
704 | if (error == 0) { | | 712 | if (error == 0) { |
705 | accessmode = VREAD; | | 713 | accessmode = VREAD; |
706 | if (update ? | | 714 | if (update ? |
707 | (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : | | 715 | (mp->mnt_iflag & IMNT_WANTRDWR) != 0 : |
| @@ -1026,62 +1034,64 @@ lfs_mountfs(struct vnode *devvp, struct | | | @@ -1026,62 +1034,64 @@ lfs_mountfs(struct vnode *devvp, struct |
1026 | fs->lfs_seglock = 0; | | 1034 | fs->lfs_seglock = 0; |
1027 | fs->lfs_pdflush = 0; | | 1035 | fs->lfs_pdflush = 0; |
1028 | fs->lfs_sleepers = 0; | | 1036 | fs->lfs_sleepers = 0; |
1029 | fs->lfs_pages = 0; | | 1037 | fs->lfs_pages = 0; |
1030 | rw_init(&fs->lfs_fraglock); | | 1038 | rw_init(&fs->lfs_fraglock); |
1031 | rw_init(&fs->lfs_iflock); | | 1039 | rw_init(&fs->lfs_iflock); |
1032 | cv_init(&fs->lfs_stopcv, "lfsstop"); | | 1040 | cv_init(&fs->lfs_stopcv, "lfsstop"); |
1033 | | | 1041 | |
1034 | /* Set the file system readonly/modify bits. */ | | 1042 | /* Set the file system readonly/modify bits. */ |
1035 | fs->lfs_ronly = ronly; | | 1043 | fs->lfs_ronly = ronly; |
1036 | if (ronly == 0) | | 1044 | if (ronly == 0) |
1037 | fs->lfs_fmod = 1; | | 1045 | fs->lfs_fmod = 1; |
1038 | | | 1046 | |
| | | 1047 | /* Device we're using */ |
| | | 1048 | dev = devvp->v_rdev; |
| | | 1049 | fs->lfs_dev = dev; |
| | | 1050 | fs->lfs_devvp = devvp; |
| | | 1051 | |
1039 | /* ulfs-level information */ | | 1052 | /* ulfs-level information */ |
1040 | fs->um_flags = 0; | | 1053 | fs->um_flags = 0; |
1041 | fs->um_bptrtodb = lfs_sb_getffshift(fs) - DEV_BSHIFT; | | 1054 | fs->um_bptrtodb = lfs_sb_getffshift(fs) - DEV_BSHIFT; |
1042 | fs->um_seqinc = lfs_sb_getfrag(fs); | | 1055 | fs->um_seqinc = lfs_sb_getfrag(fs); |
1043 | fs->um_nindir = lfs_sb_getnindir(fs); | | 1056 | fs->um_nindir = lfs_sb_getnindir(fs); |
1044 | fs->um_lognindir = ffs(lfs_sb_getnindir(fs)) - 1; | | 1057 | fs->um_lognindir = ffs(lfs_sb_getnindir(fs)) - 1; |
1045 | fs->um_maxsymlinklen = lfs_sb_getmaxsymlinklen(fs); | | 1058 | fs->um_maxsymlinklen = lfs_sb_getmaxsymlinklen(fs); |
1046 | fs->um_dirblksiz = LFS_DIRBLKSIZ; | | 1059 | fs->um_dirblksiz = LFS_DIRBLKSIZ; |
1047 | fs->um_maxfilesize = lfs_sb_getmaxfilesize(fs); | | 1060 | fs->um_maxfilesize = lfs_sb_getmaxfilesize(fs); |
1048 | | | 1061 | |
1049 | /* quota stuff */ | | 1062 | /* quota stuff */ |
1050 | /* XXX: these need to come from the on-disk superblock to be used */ | | 1063 | /* XXX: these need to come from the on-disk superblock to be used */ |
1051 | fs->lfs_use_quota2 = 0; | | 1064 | fs->lfs_use_quota2 = 0; |
1052 | fs->lfs_quota_magic = 0; | | 1065 | fs->lfs_quota_magic = 0; |
1053 | fs->lfs_quota_flags = 0; | | 1066 | fs->lfs_quota_flags = 0; |
1054 | fs->lfs_quotaino[0] = 0; | | 1067 | fs->lfs_quotaino[0] = 0; |
1055 | fs->lfs_quotaino[1] = 0; | | 1068 | fs->lfs_quotaino[1] = 0; |
1056 | | | 1069 | |
1057 | /* Initialize the mount structure. */ | | 1070 | /* Initialize the mount structure. */ |
1058 | dev = devvp->v_rdev; | | | |
1059 | mp->mnt_data = ump; | | 1071 | mp->mnt_data = ump; |
1060 | mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev; | | 1072 | mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev; |
1061 | mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_LFS); | | 1073 | mp->mnt_stat.f_fsidx.__fsid_val[1] = makefstype(MOUNT_LFS); |
1062 | mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0]; | | 1074 | mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0]; |
1063 | mp->mnt_stat.f_namemax = LFS_MAXNAMLEN; | | 1075 | mp->mnt_stat.f_namemax = LFS_MAXNAMLEN; |
1064 | mp->mnt_stat.f_iosize = lfs_sb_getbsize(fs); | | 1076 | mp->mnt_stat.f_iosize = lfs_sb_getbsize(fs); |
1065 | mp->mnt_flag |= MNT_LOCAL; | | 1077 | mp->mnt_flag |= MNT_LOCAL; |
1066 | mp->mnt_fs_bshift = lfs_sb_getbshift(fs); | | 1078 | mp->mnt_fs_bshift = lfs_sb_getbshift(fs); |
1067 | if (fs->um_maxsymlinklen > 0) | | 1079 | if (fs->um_maxsymlinklen > 0) |
1068 | mp->mnt_iflag |= IMNT_DTYPE; | | 1080 | mp->mnt_iflag |= IMNT_DTYPE; |
1069 | else | | 1081 | else |
1070 | fs->lfs_hasolddirfmt = true; | | 1082 | fs->lfs_hasolddirfmt = true; |
1071 | | | 1083 | |
1072 | ump->um_mountp = mp; | | 1084 | ump->um_mountp = mp; |
1073 | ump->um_dev = dev; | | | |
1074 | ump->um_devvp = devvp; | | | |
1075 | for (i = 0; i < ULFS_MAXQUOTAS; i++) | | 1085 | for (i = 0; i < ULFS_MAXQUOTAS; i++) |
1076 | ump->um_quotas[i] = NULLVP; | | 1086 | ump->um_quotas[i] = NULLVP; |
1077 | spec_node_setmountedfs(devvp, mp); | | 1087 | spec_node_setmountedfs(devvp, mp); |
1078 | | | 1088 | |
1079 | /* Set up reserved memory for pageout */ | | 1089 | /* Set up reserved memory for pageout */ |
1080 | lfs_setup_resblks(fs); | | 1090 | lfs_setup_resblks(fs); |
1081 | /* Set up vdirop tailq */ | | 1091 | /* Set up vdirop tailq */ |
1082 | TAILQ_INIT(&fs->lfs_dchainhd); | | 1092 | TAILQ_INIT(&fs->lfs_dchainhd); |
1083 | /* and paging tailq */ | | 1093 | /* and paging tailq */ |
1084 | TAILQ_INIT(&fs->lfs_pchainhd); | | 1094 | TAILQ_INIT(&fs->lfs_pchainhd); |
1085 | /* and delayed segment accounting for truncation list */ | | 1095 | /* and delayed segment accounting for truncation list */ |
1086 | LIST_INIT(&fs->lfs_segdhd); | | 1096 | LIST_INIT(&fs->lfs_segdhd); |
1087 | | | 1097 | |
| @@ -1318,32 +1328,32 @@ lfs_unmount(struct mount *mp, int mntfla | | | @@ -1318,32 +1328,32 @@ lfs_unmount(struct mount *mp, int mntfla |
1318 | lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) | LFS_PF_CLEAN); | | 1328 | lfs_sb_setpflags(fs, lfs_sb_getpflags(fs) | LFS_PF_CLEAN); |
1319 | lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); | | 1329 | lfs_writesuper(fs, lfs_sb_getsboff(fs, 0)); |
1320 | lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); | | 1330 | lfs_writesuper(fs, lfs_sb_getsboff(fs, 1)); |
1321 | mutex_enter(&lfs_lock); | | 1331 | mutex_enter(&lfs_lock); |
1322 | while (fs->lfs_iocount) | | 1332 | while (fs->lfs_iocount) |
1323 | mtsleep(&fs->lfs_iocount, PRIBIO + 1, "lfs_umount", 0, | | 1333 | mtsleep(&fs->lfs_iocount, PRIBIO + 1, "lfs_umount", 0, |
1324 | &lfs_lock); | | 1334 | &lfs_lock); |
1325 | mutex_exit(&lfs_lock); | | 1335 | mutex_exit(&lfs_lock); |
1326 | | | 1336 | |
1327 | /* Finish with the Ifile, now that we're done with it */ | | 1337 | /* Finish with the Ifile, now that we're done with it */ |
1328 | vgone(fs->lfs_ivnode); | | 1338 | vgone(fs->lfs_ivnode); |
1329 | | | 1339 | |
1330 | ronly = !fs->lfs_ronly; | | 1340 | ronly = !fs->lfs_ronly; |
1331 | if (ump->um_devvp->v_type != VBAD) | | 1341 | if (fs->lfs_devvp->v_type != VBAD) |
1332 | spec_node_setmountedfs(ump->um_devvp, NULL); | | 1342 | spec_node_setmountedfs(fs->lfs_devvp, NULL); |
1333 | vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY); | | 1343 | vn_lock(fs->lfs_devvp, LK_EXCLUSIVE | LK_RETRY); |
1334 | error = VOP_CLOSE(ump->um_devvp, | | 1344 | error = VOP_CLOSE(fs->lfs_devvp, |
1335 | ronly ? FREAD : FREAD|FWRITE, NOCRED); | | 1345 | ronly ? FREAD : FREAD|FWRITE, NOCRED); |
1336 | vput(ump->um_devvp); | | 1346 | vput(fs->lfs_devvp); |
1337 | | | 1347 | |
1338 | /* Complain about page leakage */ | | 1348 | /* Complain about page leakage */ |
1339 | if (fs->lfs_pages > 0) | | 1349 | if (fs->lfs_pages > 0) |
1340 | printf("lfs_unmount: still claim %d pages (%d in subsystem)\n", | | 1350 | printf("lfs_unmount: still claim %d pages (%d in subsystem)\n", |
1341 | fs->lfs_pages, lfs_subsys_pages); | | 1351 | fs->lfs_pages, lfs_subsys_pages); |
1342 | | | 1352 | |
1343 | /* Free per-mount data structures */ | | 1353 | /* Free per-mount data structures */ |
1344 | free(fs->lfs_ino_bitmap, M_SEGMENT); | | 1354 | free(fs->lfs_ino_bitmap, M_SEGMENT); |
1345 | free(fs->lfs_suflags[0], M_SEGMENT); | | 1355 | free(fs->lfs_suflags[0], M_SEGMENT); |
1346 | free(fs->lfs_suflags[1], M_SEGMENT); | | 1356 | free(fs->lfs_suflags[1], M_SEGMENT); |
1347 | free(fs->lfs_suflags, M_SEGMENT); | | 1357 | free(fs->lfs_suflags, M_SEGMENT); |
1348 | lfs_free_resblks(fs); | | 1358 | lfs_free_resblks(fs); |
1349 | cv_destroy(&fs->lfs_stopcv); | | 1359 | cv_destroy(&fs->lfs_stopcv); |
| @@ -1476,42 +1486,42 @@ lfs_vget(struct mount *mp, ino_t ino, st | | | @@ -1476,42 +1486,42 @@ lfs_vget(struct mount *mp, ino_t ino, st |
1476 | return 0; | | 1486 | return 0; |
1477 | } | | 1487 | } |
1478 | | | 1488 | |
1479 | /* | | 1489 | /* |
1480 | * Create a new vnode/inode pair and initialize what fields we can. | | 1490 | * Create a new vnode/inode pair and initialize what fields we can. |
1481 | */ | | 1491 | */ |
1482 | static void | | 1492 | static void |
1483 | lfs_init_vnode(struct ulfsmount *ump, ino_t ino, struct vnode *vp) | | 1493 | lfs_init_vnode(struct ulfsmount *ump, ino_t ino, struct vnode *vp) |
1484 | { | | 1494 | { |
1485 | struct lfs *fs = ump->um_lfs; | | 1495 | struct lfs *fs = ump->um_lfs; |
1486 | struct inode *ip; | | 1496 | struct inode *ip; |
1487 | union lfs_dinode *dp; | | 1497 | union lfs_dinode *dp; |
1488 | | | 1498 | |
1489 | ASSERT_NO_SEGLOCK(ump->um_lfs); | | 1499 | ASSERT_NO_SEGLOCK(fs); |
1490 | | | 1500 | |
1491 | /* Initialize the inode. */ | | 1501 | /* Initialize the inode. */ |
1492 | ip = pool_get(&lfs_inode_pool, PR_WAITOK); | | 1502 | ip = pool_get(&lfs_inode_pool, PR_WAITOK); |
1493 | memset(ip, 0, sizeof(*ip)); | | 1503 | memset(ip, 0, sizeof(*ip)); |
1494 | dp = pool_get(&lfs_dinode_pool, PR_WAITOK); | | 1504 | dp = pool_get(&lfs_dinode_pool, PR_WAITOK); |
1495 | memset(dp, 0, sizeof(*dp)); | | 1505 | memset(dp, 0, sizeof(*dp)); |
1496 | ip->inode_ext.lfs = pool_get(&lfs_inoext_pool, PR_WAITOK); | | 1506 | ip->inode_ext.lfs = pool_get(&lfs_inoext_pool, PR_WAITOK); |
1497 | memset(ip->inode_ext.lfs, 0, sizeof(*ip->inode_ext.lfs)); | | 1507 | memset(ip->inode_ext.lfs, 0, sizeof(*ip->inode_ext.lfs)); |
1498 | ip->i_din = dp; | | 1508 | ip->i_din = dp; |
1499 | ip->i_ump = ump; | | 1509 | ip->i_ump = ump; |
1500 | ip->i_vnode = vp; | | 1510 | ip->i_vnode = vp; |
1501 | ip->i_dev = ump->um_dev; | | 1511 | ip->i_dev = fs->lfs_dev; |
1502 | lfs_dino_setinumber(fs, dp, ino); | | 1512 | lfs_dino_setinumber(fs, dp, ino); |
1503 | ip->i_number = ino; | | 1513 | ip->i_number = ino; |
1504 | ip->i_lfs = ump->um_lfs; | | 1514 | ip->i_lfs = fs; |
1505 | ip->i_lfs_effnblks = 0; | | 1515 | ip->i_lfs_effnblks = 0; |
1506 | SPLAY_INIT(&ip->i_lfs_lbtree); | | 1516 | SPLAY_INIT(&ip->i_lfs_lbtree); |
1507 | ip->i_lfs_nbtree = 0; | | 1517 | ip->i_lfs_nbtree = 0; |
1508 | LIST_INIT(&ip->i_lfs_segdhd); | | 1518 | LIST_INIT(&ip->i_lfs_segdhd); |
1509 | | | 1519 | |
1510 | vp->v_tag = VT_LFS; | | 1520 | vp->v_tag = VT_LFS; |
1511 | vp->v_op = lfs_vnodeop_p; | | 1521 | vp->v_op = lfs_vnodeop_p; |
1512 | vp->v_data = ip; | | 1522 | vp->v_data = ip; |
1513 | } | | 1523 | } |
1514 | | | 1524 | |
1515 | /* | | 1525 | /* |
1516 | * Undo lfs_init_vnode(). | | 1526 | * Undo lfs_init_vnode(). |
1517 | */ | | 1527 | */ |
| @@ -1575,48 +1585,48 @@ lfs_loadvnode(struct mount *mp, struct v | | | @@ -1575,48 +1585,48 @@ lfs_loadvnode(struct mount *mp, struct v |
1575 | ts.tv_nsec = lfs_if_getatime_nsec(fs, ifp); | | 1585 | ts.tv_nsec = lfs_if_getatime_nsec(fs, ifp); |
1576 | } | | 1586 | } |
1577 | | | 1587 | |
1578 | brelse(bp, 0); | | 1588 | brelse(bp, 0); |
1579 | if (daddr == LFS_UNUSED_DADDR) | | 1589 | if (daddr == LFS_UNUSED_DADDR) |
1580 | return (ENOENT); | | 1590 | return (ENOENT); |
1581 | } | | 1591 | } |
1582 | | | 1592 | |
1583 | /* Allocate/init new vnode/inode. */ | | 1593 | /* Allocate/init new vnode/inode. */ |
1584 | lfs_init_vnode(ump, ino, vp); | | 1594 | lfs_init_vnode(ump, ino, vp); |
1585 | ip = VTOI(vp); | | 1595 | ip = VTOI(vp); |
1586 | | | 1596 | |
1587 | /* If the cleaner supplied the inode, use it. */ | | 1597 | /* If the cleaner supplied the inode, use it. */ |
1588 | if (curlwp == ump->um_cleaner_thread && ump->um_cleaner_hint != NULL && | | 1598 | if (curlwp == fs->lfs_cleaner_thread && fs->lfs_cleaner_hint != NULL && |
1589 | ump->um_cleaner_hint->bi_lbn == LFS_UNUSED_LBN) { | | 1599 | fs->lfs_cleaner_hint->bi_lbn == LFS_UNUSED_LBN) { |
1590 | dip = ump->um_cleaner_hint->bi_bp; | | 1600 | dip = fs->lfs_cleaner_hint->bi_bp; |
1591 | if (fs->lfs_is64) { | | 1601 | if (fs->lfs_is64) { |
1592 | error = copyin(dip, &ip->i_din->u_64, | | 1602 | error = copyin(dip, &ip->i_din->u_64, |
1593 | sizeof(struct lfs64_dinode)); | | 1603 | sizeof(struct lfs64_dinode)); |
1594 | } else { | | 1604 | } else { |
1595 | error = copyin(dip, &ip->i_din->u_32, | | 1605 | error = copyin(dip, &ip->i_din->u_32, |
1596 | sizeof(struct lfs32_dinode)); | | 1606 | sizeof(struct lfs32_dinode)); |
1597 | } | | 1607 | } |
1598 | if (error) { | | 1608 | if (error) { |
1599 | lfs_deinit_vnode(ump, vp); | | 1609 | lfs_deinit_vnode(ump, vp); |
1600 | return error; | | 1610 | return error; |
1601 | } | | 1611 | } |
1602 | KASSERT(ip->i_number == ino); | | 1612 | KASSERT(ip->i_number == ino); |
1603 | goto out; | | 1613 | goto out; |
1604 | } | | 1614 | } |
1605 | | | 1615 | |
1606 | /* Read in the disk contents for the inode, copy into the inode. */ | | 1616 | /* Read in the disk contents for the inode, copy into the inode. */ |
1607 | retries = 0; | | 1617 | retries = 0; |
1608 | again: | | 1618 | again: |
1609 | error = bread(ump->um_devvp, LFS_FSBTODB(fs, daddr), | | 1619 | error = bread(fs->lfs_devvp, LFS_FSBTODB(fs, daddr), |
1610 | (lfs_sb_getversion(fs) == 1 ? lfs_sb_getbsize(fs) : lfs_sb_getibsize(fs)), | | 1620 | (lfs_sb_getversion(fs) == 1 ? lfs_sb_getbsize(fs) : lfs_sb_getibsize(fs)), |
1611 | 0, &bp); | | 1621 | 0, &bp); |
1612 | if (error) { | | 1622 | if (error) { |
1613 | lfs_deinit_vnode(ump, vp); | | 1623 | lfs_deinit_vnode(ump, vp); |
1614 | return error; | | 1624 | return error; |
1615 | } | | 1625 | } |
1616 | | | 1626 | |
1617 | dip = lfs_ifind(fs, ino, bp); | | 1627 | dip = lfs_ifind(fs, ino, bp); |
1618 | if (dip == NULL) { | | 1628 | if (dip == NULL) { |
1619 | /* Assume write has not completed yet; try again */ | | 1629 | /* Assume write has not completed yet; try again */ |
1620 | brelse(bp, BC_INVAL); | | 1630 | brelse(bp, BC_INVAL); |
1621 | ++retries; | | 1631 | ++retries; |
1622 | if (retries <= LFS_IFIND_RETRIES) { | | 1632 | if (retries <= LFS_IFIND_RETRIES) { |
| @@ -2256,27 +2266,27 @@ lfs_vinit(struct mount *mp, struct vnode | | | @@ -2256,27 +2266,27 @@ lfs_vinit(struct mount *mp, struct vnode |
2256 | # ifdef DEBUG | | 2266 | # ifdef DEBUG |
2257 | lfs_dump_dinode(fs, ip->i_din); | | 2267 | lfs_dump_dinode(fs, ip->i_din); |
2258 | # endif | | 2268 | # endif |
2259 | panic("lfs_vinit: ino %llu is type VNON! (ifmt=%o)\n", | | 2269 | panic("lfs_vinit: ino %llu is type VNON! (ifmt=%o)\n", |
2260 | (unsigned long long)ip->i_number, | | 2270 | (unsigned long long)ip->i_number, |
2261 | (ip->i_mode & LFS_IFMT) >> 12); | | 2271 | (ip->i_mode & LFS_IFMT) >> 12); |
2262 | } | | 2272 | } |
2263 | #endif /* DIAGNOSTIC */ | | 2273 | #endif /* DIAGNOSTIC */ |
2264 | | | 2274 | |
2265 | /* | | 2275 | /* |
2266 | * Finish inode initialization now that aliasing has been resolved. | | 2276 | * Finish inode initialization now that aliasing has been resolved. |
2267 | */ | | 2277 | */ |
2268 | | | 2278 | |
2269 | ip->i_devvp = ump->um_devvp; | | 2279 | ip->i_devvp = fs->lfs_devvp; |
2270 | vref(ip->i_devvp); | | 2280 | vref(ip->i_devvp); |
2271 | #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) | | 2281 | #if defined(LFS_QUOTA) || defined(LFS_QUOTA2) |
2272 | ulfsquota_init(ip); | | 2282 | ulfsquota_init(ip); |
2273 | #endif | | 2283 | #endif |
2274 | genfs_node_init(vp, &lfs_genfsops); | | 2284 | genfs_node_init(vp, &lfs_genfsops); |
2275 | uvm_vnp_setsize(vp, ip->i_size); | | 2285 | uvm_vnp_setsize(vp, ip->i_size); |
2276 | | | 2286 | |
2277 | /* Initialize hiblk from file size */ | | 2287 | /* Initialize hiblk from file size */ |
2278 | ip->i_lfs_hiblk = lfs_lblkno(ip->i_lfs, ip->i_size + lfs_sb_getbsize(ip->i_lfs) - 1) - 1; | | 2288 | ip->i_lfs_hiblk = lfs_lblkno(ip->i_lfs, ip->i_size + lfs_sb_getbsize(ip->i_lfs) - 1) - 1; |
2279 | | | 2289 | |
2280 | *vpp = vp; | | 2290 | *vpp = vp; |
2281 | } | | 2291 | } |
2282 | | | 2292 | |