Lines Matching refs:ip

253 	struct inode *ip = buf;
256 vp = ip->i_vnode = vn_alloc(kmflags);
261 vp->v_data = ip;
263 rw_init(&ip->i_rwlock, NULL, RW_DEFAULT, NULL);
264 rw_init(&ip->i_contents, NULL, RW_DEFAULT, NULL);
265 mutex_init(&ip->i_tlock, NULL, MUTEX_DEFAULT, NULL);
266 dnlc_dir_init(&ip->i_danchor);
268 cv_init(&ip->i_wrcv, NULL, CV_DRIVER, NULL);
277 struct inode *ip = buf;
280 vp = ITOV(ip);
282 rw_destroy(&ip->i_rwlock);
283 rw_destroy(&ip->i_contents);
284 mutex_destroy(&ip->i_tlock);
286 dnlc_dir_fini(&ip->i_danchor);
289 cv_destroy(&ip->i_wrcv);
325 ufs_free_inode(struct inode *ip)
327 vn_invalid(ITOV(ip));
328 kmem_cache_free(inode_cache, ip);
337 struct inode *ip;
340 ip = kmem_cache_alloc(inode_cache, KM_SLEEP);
344 ip->i_freef = ip;
345 ip->i_freeb = ip;
346 ip->i_flag = IREF;
347 ip->i_seq = 0xFF; /* Unique initial value */
348 ip->i_dev = ufsvfsp->vfs_dev;
349 ip->i_ufsvfs = ufsvfsp;
350 ip->i_devvp = ufsvfsp->vfs_devvp;
351 ip->i_number = ino;
352 ip->i_diroff = 0;
353 ip->i_nextr = 0;
354 ip->i_map = NULL;
355 ip->i_rdev = 0;
356 ip->i_writes = 0;
357 ip->i_mode = 0;
358 ip->i_delaylen = 0;
359 ip->i_delayoff = 0;
360 ip->i_nextrio = 0;
361 ip->i_ufs_acl = NULL;
362 ip->i_cflags = 0;
363 ip->i_mapcnt = 0;
364 ip->i_dquot = NULL;
365 ip->i_cachedir = CD_ENABLED;
366 ip->i_writer = NULL;
371 vp = ITOV(ip);
377 return (ip);
447 struct inode *ip, *sp;
475 for (ip = ih->ih_chain[0]; ip != (struct inode *)ih; ip = ip->i_forw) {
476 if (ino != ip->i_number || vfs_dev != ip->i_dev ||
477 (ip->i_flag & ISTALE))
483 vp = ITOV(ip); /* for locknest */
486 rw_enter(&ip->i_contents, RW_READER);
491 if ((ip->i_flag & IREF) == 0) {
492 if (ufs_rmidle(ip))
499 if (ip->i_flag & ISTALE) {
500 rw_exit(&ip->i_contents);
506 *ipp = ip;
515 rw_exit(&ip->i_contents);
529 ip = ufs_alloc_inode(ufsvfsp, ino);
530 vp = ITOV(ip);
534 ip->i_doff = (offset_t)ioff + ldbtob(bno);
544 ufs_free_inode(ip);
555 rw_enter(&ip->i_contents, RW_WRITER);
556 insque(ip, ih);
561 bp = UFS_BREAD(ufsvfsp, ip->i_dev, bno, (int)fs->fs_bsize);
569 ip->i_flag |= ISTALE; /* in case someone is looking it up */
570 rw_exit(&ip->i_contents);
579 ip->i_ic = dp->di_ic; /* structure assignment */
585 if (ip->i_suid != UID_LONG)
586 ip->i_uid = ip->i_suid;
587 if (ip->i_sgid != GID_LONG)
588 ip->i_gid = ip->i_sgid;
590 ftype = ip->i_mode & IFMT;
593 uint_t top16 = ip->i_ordev & 0xffff0000u;
596 dv = expdev(ip->i_ordev);
598 dv = expldev(ip->i_ordev);
599 vp->v_rdev = ip->i_rdev = dv;
607 if ((ftype == 0) || (ip->i_nlink <= 0)) {
608 ip->i_flag |= ISTALE;
609 rw_exit(&ip->i_contents);
628 vp->v_type = IFTOVT((mode_t)ip->i_mode);
636 if (ftype != 0 && ip->i_shadow != 0) {
637 if ((error = ufs_si_load(ip, cr)) != 0) {
638 ip->i_flag |= ISTALE;
639 ip->i_ufs_acl = NULL;
640 rw_exit(&ip->i_contents);
651 if (ip->i_mode && ((ip->i_mode & IFMT) != IFSHAD) &&
652 ((ip->i_mode & IFMT) != IFATTRDIR)) {
653 ip->i_dquot = getinoquota(ip);
655 TRANS_MATA_IGET(ufsvfsp, ip);
656 *ipp = ip;
657 rw_exit(&ip->i_contents);
667 ufs_iinactive(struct inode *ip)
673 struct vnode *vp = ITOV(ip);
674 struct ufsvfs *ufsvfsp = ip->i_ufsvfs;
681 dnlc_dir_purge(&ip->i_danchor);
686 rw_enter(&ip->i_contents, RW_WRITER);
687 ASSERT(ip->i_flag & IREF);
706 rw_exit(&ip->i_contents);
715 if (ip->i_ufsvfs == NULL) {
716 rw_exit(&ip->i_contents);
717 ufs_si_del(ip);
719 ufs_free_inode(ip);
730 if ((ip->i_flag & ISTALE) == 0 && ip->i_fs->fs_ronly == 0 &&
731 ip->i_mode && ip->i_nlink <= 0) {
738 ip->i_flag |= IDEL;
745 if (ULOCKFS_IS_NOIDEL(ITOUL(ip))) {
749 rw_exit(&ip->i_contents);
752 if (!TRANS_ISTRANS(ip->i_ufsvfs)) {
753 rw_exit(&ip->i_contents);
754 ufs_delete(ip->i_ufsvfs, ip, 0);
760 uq = &ip->i_ufsvfs->vfs_delete;
766 ip->i_freef = iq;
767 ip->i_freeb = iq->i_freeb;
768 iq->i_freeb->i_freef = ip;
769 iq->i_freeb = ip;
771 uq->uq_ihead = ip;
773 uq->uq_ihead = ip;
774 ip->i_freef = ip;
775 ip->i_freeb = ip;
779 delq_info->delq_unreclaimed_blocks += ip->i_blocks;
790 rw_exit(&ip->i_contents);
802 ip->i_flag &= ~(IREF | IDIRECTIO);
804 if (vn_has_cached_data(vp) || ip->i_flag & IFASTSYMLNK) {
806 hip = (inode_t *)&ufs_useful_iq[IQHASH(ip)];
810 hip = (inode_t *)&ufs_junk_iq[IQHASH(ip)];
811 ip->i_flag |= IJUNKIQ;
814 ip->i_freef = hip;
815 ip->i_freeb = hip->i_freeb;
816 hip->i_freeb->i_freef = ip;
817 hip->i_freeb = ip;
826 rw_exit(&ip->i_contents);
835 ufs_iupdat(struct inode *ip, int waitfor)
840 struct ufsvfs *ufsvfsp = ip->i_ufsvfs;
851 ASSERT(RW_LOCK_HELD(&ip->i_contents));
859 flag = ip->i_flag; /* Atomic read */
866 fp = ip->i_fs;
870 mutex_enter(&ip->i_tlock);
871 ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD|IMODACC|IATTCHG);
872 mutex_exit(&ip->i_tlock);
883 bp = UFS_BREAD(ufsvfsp, ip->i_dev,
884 (daddr_t)fsbtodb(fp, itod(fp, ip->i_number)),
887 mutex_enter(&ip->i_tlock);
888 ip->i_flag &=
890 mutex_exit(&ip->i_tlock);
897 mutex_enter(&ip->i_tlock);
898 ITIMES_NOLOCK(ip);
899 do_trans_times = ((ip->i_flag & (IMOD|IMODACC)) == IMODACC);
900 ip->i_flag &= ~(IUPD|IACC|ICHG|IMOD|IMODACC|IATTCHG);
901 mutex_exit(&ip->i_tlock);
908 TRANS_INODE_TIMES(ufsvfsp, ip);
914 * suid = (ip->i_uid > MAXUID) ? UID_LONG : ip->i_uid;
915 * sgid = (ip->i_gid > MAXUID) ? GID_LONG : ip->i_gid;
928 suid = (ulong_t)ip->i_uid > (ulong_t)USHRT_MAX ?
929 UID_LONG : ip->i_uid;
930 sgid = (ulong_t)ip->i_gid > (ulong_t)USHRT_MAX ?
931 GID_LONG : ip->i_gid;
933 if ((ip->i_suid != suid) || (ip->i_sgid != sgid)) {
934 ip->i_suid = suid;
935 ip->i_sgid = sgid;
936 TRANS_INODE(ufsvfsp, ip);
939 if ((ip->i_mode & IFMT) == IFBLK ||
940 (ip->i_mode & IFMT) == IFCHR) {
941 dev_t d = ip->i_rdev;
954 panic("ip %p: i_rdev too big", (void *)ip);
958 ip->i_ordev = dev32; /* can't use old fmt. */
960 ip->i_ordev = cmpdev(d);
967 dp = (struct dinode *)bp->b_un.b_addr + itoo(fp, ip->i_number);
968 dp->di_ic = ip->i_ic; /* structure assignment */
982 TRANS_LOG(ufsvfsp, (caddr_t)dp, ip->i_doff,
988 } else if (waitfor && (ip->i_ufsvfs->vfs_dio == 0)) {
995 mutex_enter(&ip->i_tlock);
996 ip->i_flag &= ~IBDWRITE;
997 mutex_exit(&ip->i_tlock);
1009 mutex_enter(&ip->i_tlock);
1010 ip->i_flag |= IBDWRITE;
1011 mutex_exit(&ip->i_tlock);
1020 blkflush(ip->i_dev,
1021 (daddr_t)fsbtodb(fp, itod(fp, ip->i_number)));
1022 mutex_enter(&ip->i_tlock);
1023 ip->i_flag &= ~IBDWRITE;
1024 mutex_exit(&ip->i_tlock);
1034 * Release blocks associated with the inode ip and
1044 indirtrunc(struct inode *ip, daddr_t bn, daddr_t lastbn, int level, int flags)
1049 struct ufsvfs *ufsvfsp = ip->i_ufsvfs;
1055 ASSERT(RW_WRITE_HELD(&ip->i_contents));
1078 ip->i_dev, (daddr_t)fsbtodb(fs, bn), (int)fs->fs_bsize);
1125 indirtrunc(ip, nb, (daddr_t)-1, level - 1, flags);
1126 free(ip, nb, (off_t)fs->fs_bsize, flags | I_IBLK);
1128 free(ip, nb, (off_t)fs->fs_bsize, flags);
1141 indirtrunc(ip, nb, last, level - 1, flags);
1148 * Truncate the inode ip to at most length size.
1160 struct inode *ip;
1187 * ip->i_ordev is actually being stored in ip->i_db[0]!
1401 ip = &tip;
1422 bn = ip->i_ib[level];
1425 indirtrunc(ip, bn, lastiblock[level], level, flags);
1427 ip->i_ib[level] = 0;
1428 free(ip, bn, (off_t)fs->fs_bsize,
1441 bn = ip->i_db[i];
1444 ip->i_db[i] = 0;
1445 bsize = (off_t)blksize(fs, ip, i);
1446 free(ip, bn, bsize, flags);
1456 bn = ip->i_db[lastblock];
1464 oldspace = blksize(fs, ip, lastblock);
1465 UFS_SET_ISIZE(length, ip);
1466 newspace = blksize(fs, ip, lastblock);
1468 err = ufs_fault(ITOV(ip), "ufs_itrunc: newspace == 0");
1478 free(ip, bn, oldspace - newspace, flags);
1485 if (ip->i_ib[level] != oip->i_ib[level]) {
1486 err = ufs_fault(ITOV(ip), "ufs_itrunc: indirect block");
1491 if (ip->i_db[i] != oip->i_db[i]) {
1492 err = ufs_fault(ITOV(ip), "ufs_itrunc: direct block");
1525 ufs_iaccess(struct inode *ip, int mode, struct cred *cr, int dolock)
1531 rw_enter(&ip->i_contents, RW_READER);
1532 ASSERT(RW_LOCK_HELD(&ip->i_contents));
1540 if (ip->i_fs->fs_ronly != 0) {
1541 if ((ip->i_mode & IFMT) != IFCHR &&
1542 (ip->i_mode & IFMT) != IFBLK &&
1543 (ip->i_mode & IFMT) != IFIFO) {
1552 if (ip->i_ufs_acl && ip->i_ufs_acl->aowner) {
1553 ret = ufs_acl_access(ip, mode, cr);
1562 if (crgetuid(cr) != ip->i_uid) {
1564 if (!groupmember((uid_t)ip->i_gid, cr))
1569 ret = secpolicy_vnode_access2(cr, ITOV(ip), ip->i_uid,
1570 ip->i_mode << shift, mode);
1573 rw_exit(&ip->i_contents);
1587 ufs_rmidle(struct inode *ip)
1591 mutex_enter(&ip->i_tlock);
1592 if ((ip->i_flag & IREF) == 0) {
1594 ip->i_freef->i_freeb = ip->i_freeb;
1595 ip->i_freeb->i_freef = ip->i_freef;
1596 ip->i_freef = ip;
1597 ip->i_freeb = ip;
1598 ip->i_flag |= IREF;
1600 if (ip->i_flag & IJUNKIQ) {
1602 ip->i_flag &= ~IJUNKIQ;
1609 mutex_exit(&ip->i_tlock);
1620 struct inode *ip; /* current inode */
1635 * We know that ip is a valid inode in the hash chain (and thus
1654 for (ip = ih->ih_chain[0], lip_held = 0;
1655 ip != (struct inode *)ih;
1656 ip = lip->i_forw) {
1667 lip = ip;
1668 if (ufsvfsp != NULL && ip->i_ufsvfs != ufsvfsp) {
1680 VN_HOLD(ITOV(ip));
1695 if (!rw_tryenter(&ip->i_contents, RW_WRITER)) {
1700 rw_enter(&ip->i_contents, RW_WRITER);
1703 rw_exit(&ip->i_contents);
1719 if ((ip->i_flag & ISTALE) == 0) {
1720 if ((error = (*func)(ip, arg)) != 0)
1743 ufs_imark(struct inode *ip)
1752 if (ip->i_flag & ISEQ) {
1753 ASSERT(ip->i_flag & (IUPD|ICHG));
1754 ip->i_seq++;
1755 ip->i_flag &= ~ISEQ;
1795 if ((ip->i_flag & IACC) && !(ip->i_ufsvfs->vfs_noatime)) {
1796 ip->i_atime = iuniqtime;
1798 if (ip->i_flag & IUPD) {
1799 ip->i_mtime = iuniqtime;
1800 ip->i_flag |= IMODTIME;
1802 if (ip->i_flag & ICHG) {
1803 ip->i_diroff = 0;
1804 ip->i_ctime = iuniqtime;
1813 ufs_itimes_nolock(struct inode *ip)
1820 if (((ip->i_flag & (IUPD|IACC|ICHG)) == IACC) &&
1821 (ip->i_ufsvfs->vfs_noatime)) {
1825 if (ip->i_flag & (IUPD|IACC|ICHG)) {
1826 if (ip->i_flag & ICHG)
1827 ip->i_flag |= IMOD;
1829 ip->i_flag |= IMODACC;
1830 ufs_imark(ip);
1831 ip->i_flag &= ~(IACC|IUPD|ICHG);