Lines Matching refs:inodedep

650 SOFTDEP_TYPE(INODEDEP, inodedep, "Inode dependencies");
746 static int check_inodedep_free(struct inodedep *);
749 static void unlinked_inodedep(struct mount *, struct inodedep *);
750 static void clear_unlinked_inodedep(struct inodedep *);
751 static struct inodedep *first_unlinked_inodedep(struct ufsmount *);
762 static void diradd_inode_written(struct diradd *, struct inodedep *);
765 static int handle_written_inodeblock(struct inodedep *, struct buf *, int);
803 static void initiate_write_inodeblock_ufs1(struct inodedep *, struct buf *);
804 static void initiate_write_inodeblock_ufs2(struct inodedep *, struct buf *);
815 static void merge_diradd(struct inodedep *, struct diradd *);
846 struct inodedep *);
848 static int cancel_jaddref(struct jaddref *, struct inodedep *,
870 static int check_inode_unwritten(struct inodedep *);
871 static int free_inodedep(struct inodedep *);
882 struct inodedep *, struct allocindir *, ufs_lbn_t);
900 struct inodedep **);
901 static int inodedep_lookup(struct mount *, ino_t, int, struct inodedep **);
947 static void move_newblock_dep(struct jaddref *, struct inodedep *);
954 static struct inodedep *inodedep_lookup_ip(struct inode *);
956 static struct freefile *handle_bufwait(struct inodedep *, struct workhead *);
1638 struct inodedep *inodedep;
1650 if (inodedep_lookup(mp, inum, 0, &inodedep) == 0)
1652 LIST_FOREACH(dirrem, &inodedep->id_dirremhd, dm_inonext) {
1688 struct inodedep *inodedep;
1700 if (inodedep_lookup(mp, inum, 0, &inodedep) == 0)
1703 TAILQ_FOREACH(freeblks, &inodedep->id_freeblklst, fb_next) {
2050 * 2) inodedep structures identified by mount point and inode number.
2056 * The "pagedep" and "inodedep" dependency structures are hashed
2162 * Structures and routines associated with inodedep caching.
2171 struct inodedep **inodedeppp;
2173 struct inodedep *inodedep;
2175 LIST_FOREACH(inodedep, inodedephd, id_hash)
2176 if (inum == inodedep->id_ino)
2178 if (inodedep) {
2179 *inodedeppp = inodedep;
2187 * Look up an inodedep. Return 1 if found, 0 if not found.
2196 struct inodedep **inodedeppp;
2198 struct inodedep *inodedep;
2215 * we are not in a rush, request some inodedep cleanup.
2221 inodedep = malloc(sizeof(struct inodedep),
2223 workitem_alloc(&inodedep->id_list, D_INODEDEP, mp);
2226 WORKITEM_FREE(inodedep, D_INODEDEP);
2229 inodedep->id_fs = fs;
2230 inodedep->id_ino = inum;
2231 inodedep->id_state = ALLCOMPLETE;
2232 inodedep->id_nlinkdelta = 0;
2233 inodedep->id_savedino1 = NULL;
2234 inodedep->id_savedsize = -1;
2235 inodedep->id_savedextsize = -1;
2236 inodedep->id_savednlink = -1;
2237 inodedep->id_bmsafemap = NULL;
2238 inodedep->id_mkdiradd = NULL;
2239 LIST_INIT(&inodedep->id_dirremhd);
2240 LIST_INIT(&inodedep->id_pendinghd);
2241 LIST_INIT(&inodedep->id_inowait);
2242 LIST_INIT(&inodedep->id_bufwait);
2243 TAILQ_INIT(&inodedep->id_inoreflst);
2244 TAILQ_INIT(&inodedep->id_inoupdt);
2245 TAILQ_INIT(&inodedep->id_newinoupdt);
2246 TAILQ_INIT(&inodedep->id_extupdt);
2247 TAILQ_INIT(&inodedep->id_newextupdt);
2248 TAILQ_INIT(&inodedep->id_freeblklst);
2249 LIST_INSERT_HEAD(inodedephd, inodedep, id_hash);
2250 *inodedeppp = inodedep;
3728 struct inodedep *inodedep;
3738 0, &inodedep) == 0)
3739 panic("handle_written_jremref: Lost inodedep");
3740 TAILQ_REMOVE(&inodedep->id_inoreflst, &jremref->jr_ref, if_deps);
3767 struct inodedep *inodedep;
3776 0, &inodedep) == 0)
3777 panic("handle_written_jaddref: Lost inodedep.");
3782 WORKLIST_INSERT(&inodedep->id_bufwait, &diradd->da_list);
3785 WORKLIST_INSERT(&inodedep->id_bufwait, &mkdir->md_list);
3795 TAILQ_REMOVE(&inodedep->id_inoreflst, &jaddref->ja_ref, if_deps);
3810 inodedep->id_state |= ONDEPLIST;
3811 LIST_INSERT_HEAD(&inodedep->id_bmsafemap->sm_inodedephd,
3812 inodedep, id_deps);
4260 move_newblock_dep(jaddref, inodedep)
4262 struct inodedep *inodedep;
4284 LIST_INSERT_HEAD(&inodedep->id_bmsafemap->sm_jaddrefhd, jaddrefn,
4300 cancel_jaddref(jaddref, inodedep, wkhd)
4302 struct inodedep *inodedep;
4315 if (inodedep == NULL)
4317 0, &inodedep) == 0)
4318 panic("cancel_jaddref: Lost inodedep");
4334 move_newblock_dep(jaddref, inodedep);
4348 * Leave NEWBLOCK jaddrefs on the inodedep so handle_workitem_remove
4354 TAILQ_REMOVE(&inodedep->id_inoreflst, &jaddref->ja_ref,
4638 * Lookup an inodedep based on an inode pointer and set the nlinkdelta as
4642 static struct inodedep *
4646 struct inodedep *inodedep;
4651 &inodedep);
4652 inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink;
4653 KASSERT((inodedep->id_state & UNLINKED) == 0, ("inode unlinked"));
4655 return (inodedep);
4669 struct inodedep *inodedep;
4679 inodedep = inodedep_lookup_ip(ip);
4681 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4701 struct inodedep *inodedep;
4717 inodedep = inodedep_lookup_ip(dp);
4719 TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jaddref->ja_ref,
4736 struct inodedep *inodedep;
4748 inodedep = inodedep_lookup_ip(ip);
4750 TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jaddref->ja_ref,
4767 struct inodedep *inodedep;
4786 inodedep = inodedep_lookup_ip(ip);
4788 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4798 inodedep = inodedep_lookup_ip(dp);
4800 TAILQ_INSERT_TAIL(&inodedep->id_inoreflst,
4857 struct inodedep *inodedep;
4865 inodedep = inodedep_lookup_ip(ip);
4867 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4871 cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait);
4885 struct inodedep *inodedep;
4893 inodedep = inodedep_lookup_ip(ip);
4895 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4899 cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait);
4913 struct inodedep *inodedep;
4923 inodedep = inodedep_lookup_ip(dp);
4925 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4929 cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait);
4931 inodedep = inodedep_lookup_ip(ip);
4933 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
4939 cancel_jaddref(jaddref, inodedep, &inodedep->id_inowait);
4942 cancel_jaddref(dotaddref, inodedep, &inodedep->id_inowait);
4976 * inode is allocated. When an inode is allocated an "inodedep" is created
4978 * Each "inodedep" is also inserted into the hash indexing structure so
5006 struct inodedep *inodedep;
5034 * in bmsafemap_lookup since once we allocate the inodedep, we
5038 * creating the inodedep as it can be freed during the time
5039 * that we FREE_LOCK() while allocating the inodedep. We must
5048 if ((inodedep_lookup(mp, newinum, DEPALLOC, &inodedep)))
5050 "inode already exists", inodedep);
5054 TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jaddref->ja_ref,
5057 inodedep->id_state |= ONDEPLIST;
5058 LIST_INSERT_HEAD(&bmsafemap->sm_inodedephd, inodedep, id_deps);
5060 inodedep->id_bmsafemap = bmsafemap;
5061 inodedep->id_state &= ~DEPCOMPLETE;
5276 struct inodedep *inodedep;
5360 inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
5361 adp->ad_inodedep = inodedep;
5376 adphead = &inodedep->id_newinoupdt;
5676 struct inodedep *inodedep;
5739 inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
5740 adp->ad_inodedep = inodedep;
5755 adphead = &inodedep->id_newextupdt;
5860 struct inodedep *inodedep;
5879 (void) inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
5888 freefrag = setup_allocindir_phase2(bp, ip, inodedep, aip, lbn);
5906 struct inodedep *inodedep;
5920 inodedep_lookup(UFSTOVFS(ump), ip->i_number, DEPALLOC, &inodedep);
5922 if (setup_allocindir_phase2(bp, ip, inodedep, aip, lbn))
6029 setup_allocindir_phase2(bp, ip, inodedep, aip, lbn)
6032 struct inodedep *inodedep; /* Inodedep for ip */
6541 struct inodedep *inodedep;
6572 inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
6573 if ((inodedep->id_state & (UNLINKED | DEPCOMPLETE)) == UNLINKED &&
6705 (void) inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
6706 if ((inodedep->id_state & IOSTARTED) != 0)
6720 TAILQ_FOREACH_SAFE(adp, &inodedep->id_inoupdt, ad_next, adpn) {
6722 cancel_allocdirect(&inodedep->id_inoupdt, adp,
6733 while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != NULL)
6734 cancel_allocdirect(&inodedep->id_extupdt, adp,
6740 LIST_FOREACH_SAFE(wk, &inodedep->id_bufwait, wk_list, wkn) {
6798 inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
6799 TAILQ_INSERT_TAIL(&inodedep->id_freeblklst, freeblks, fb_next);
6806 TAILQ_FOREACH(fbn, &inodedep->id_freeblklst, fb_next)
6884 struct inodedep *inodedep;
6964 (void) inodedep_lookup(mp, ip->i_number, DEPALLOC, &inodedep);
6965 if ((inodedep->id_state & IOSTARTED) != 0)
6974 delay = (inodedep->id_state & DEPCOMPLETE);
6989 merge_inode_lists(&inodedep->id_newinoupdt,
6990 &inodedep->id_inoupdt);
6991 while ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != NULL)
6992 cancel_allocdirect(&inodedep->id_inoupdt, adp,
6996 merge_inode_lists(&inodedep->id_newextupdt,
6997 &inodedep->id_extupdt);
6998 while ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != NULL)
6999 cancel_allocdirect(&inodedep->id_extupdt, adp,
7006 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) != 0)
7007 (void) free_inodedep(inodedep);
7573 struct inodedep *inodedep;
7596 * If the inodedep does not exist, then the zero'ed inode has
7607 inodedep_lookup(pvp->v_mount, ino, 0, &inodedep);
7608 if (inodedep) {
7614 TAILQ_FIRST(&inodedep->id_freeblklst)) != NULL) {
7615 TAILQ_REMOVE(&inodedep->id_freeblklst, freeblks,
7622 if (inodedep->id_state & UNLINKED) {
7628 handle_bufwait(inodedep, &freefile->fx_jwork);
7629 clear_unlinked_inodedep(inodedep);
7631 * Re-acquire inodedep as we've dropped the
7634 inodedep_lookup(pvp->v_mount, ino, 0, &inodedep);
7637 if (inodedep == NULL || check_inode_unwritten(inodedep)) {
7642 if ((inodedep->id_state & DEPCOMPLETE) == 0)
7643 inodedep->id_state |= GOINGAWAY;
7644 WORKLIST_INSERT(&inodedep->id_inowait, &freefile->fx_list);
7652 * so free the inodedep and return success, otherwise return failure.
7665 check_inode_unwritten(inodedep)
7666 struct inodedep *inodedep;
7669 LOCK_OWNED(VFSTOUFS(inodedep->id_list.wk_mp));
7671 if ((inodedep->id_state & (DEPCOMPLETE | UNLINKED)) != 0 ||
7672 !LIST_EMPTY(&inodedep->id_dirremhd) ||
7673 !LIST_EMPTY(&inodedep->id_pendinghd) ||
7674 !LIST_EMPTY(&inodedep->id_bufwait) ||
7675 !LIST_EMPTY(&inodedep->id_inowait) ||
7676 !TAILQ_EMPTY(&inodedep->id_inoreflst) ||
7677 !TAILQ_EMPTY(&inodedep->id_inoupdt) ||
7678 !TAILQ_EMPTY(&inodedep->id_newinoupdt) ||
7679 !TAILQ_EMPTY(&inodedep->id_extupdt) ||
7680 !TAILQ_EMPTY(&inodedep->id_newextupdt) ||
7681 !TAILQ_EMPTY(&inodedep->id_freeblklst) ||
7682 inodedep->id_mkdiradd != NULL ||
7683 inodedep->id_nlinkdelta != 0)
7689 if ((inodedep->id_state & IOSTARTED) != 0 &&
7690 inodedep->id_savedino1 == NULL)
7693 if (inodedep->id_state & ONDEPLIST)
7694 LIST_REMOVE(inodedep, id_deps);
7695 inodedep->id_state &= ~ONDEPLIST;
7696 inodedep->id_state |= ALLCOMPLETE;
7697 inodedep->id_bmsafemap = NULL;
7698 if (inodedep->id_state & ONWORKLIST)
7699 WORKLIST_REMOVE(&inodedep->id_list);
7700 if (inodedep->id_savedino1 != NULL) {
7701 free(inodedep->id_savedino1, M_SAVEDINO);
7702 inodedep->id_savedino1 = NULL;
7704 if (free_inodedep(inodedep) == 0)
7710 check_inodedep_free(inodedep)
7711 struct inodedep *inodedep;
7714 LOCK_OWNED(VFSTOUFS(inodedep->id_list.wk_mp));
7715 if ((inodedep->id_state & ALLCOMPLETE) != ALLCOMPLETE ||
7716 !LIST_EMPTY(&inodedep->id_dirremhd) ||
7717 !LIST_EMPTY(&inodedep->id_pendinghd) ||
7718 !LIST_EMPTY(&inodedep->id_bufwait) ||
7719 !LIST_EMPTY(&inodedep->id_inowait) ||
7720 !TAILQ_EMPTY(&inodedep->id_inoreflst) ||
7721 !TAILQ_EMPTY(&inodedep->id_inoupdt) ||
7722 !TAILQ_EMPTY(&inodedep->id_newinoupdt) ||
7723 !TAILQ_EMPTY(&inodedep->id_extupdt) ||
7724 !TAILQ_EMPTY(&inodedep->id_newextupdt) ||
7725 !TAILQ_EMPTY(&inodedep->id_freeblklst) ||
7726 inodedep->id_mkdiradd != NULL ||
7727 inodedep->id_nlinkdelta != 0 ||
7728 inodedep->id_savedino1 != NULL)
7734 * Try to free an inodedep structure. Return 1 if it could be freed.
7737 free_inodedep(inodedep)
7738 struct inodedep *inodedep;
7741 LOCK_OWNED(VFSTOUFS(inodedep->id_list.wk_mp));
7742 if ((inodedep->id_state & (ONWORKLIST | UNLINKED)) != 0 ||
7743 !check_inodedep_free(inodedep))
7745 if (inodedep->id_state & ONDEPLIST)
7746 LIST_REMOVE(inodedep, id_deps);
7747 LIST_REMOVE(inodedep, id_hash);
7748 WORKITEM_FREE(inodedep, D_INODEDEP);
8030 struct inodedep *inodedep;
8079 0, &inodedep);
8080 TAILQ_REMOVE(&inodedep->id_freeblklst, freeblks, fb_next);
8082 if (TAILQ_EMPTY(&inodedep->id_freeblklst))
8083 free_inodedep(inodedep);
8385 struct inodedep *inodedep;
8442 * Look up the inodedep for the parent directory so that we
8448 inodedep_lookup(mp, dinum, 0, &inodedep);
8450 if (inodedep == NULL)
8452 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
8460 } else if (inodedep == NULL ||
8461 (inodedep->id_state & ALLCOMPLETE) == ALLCOMPLETE) {
8467 WORKLIST_INSERT(&inodedep->id_bufwait, &mkdir2->md_list);
8512 struct inodedep *inodedep;
8578 inodedep_lookup(mp, newinum, DEPALLOC, &inodedep);
8582 * link the diradd into its inodedep. If the inode is not yet
8587 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
8594 } else if ((inodedep->id_state & ALLCOMPLETE) == ALLCOMPLETE)
8595 diradd_inode_written(dap, inodedep);
8597 WORKLIST_INSERT(&inodedep->id_bufwait, &dap->da_list);
8631 if (inodedep->id_mkdiradd != NULL)
8633 inodedep->id_mkdiradd = dap;
8634 } else if (inodedep->id_mkdiradd)
8635 merge_diradd(inodedep, dap);
8746 merge_diradd(inodedep, newdap)
8747 struct inodedep *inodedep;
8755 olddap = inodedep->id_mkdiradd;
8756 inodedep->id_mkdiradd = newdap;
8759 ump = VFSTOUFS(inodedep->id_list.wk_mp);
8817 struct inodedep *inodedep;
8836 0, &inodedep) != 0) {
8838 TAILQ_FOREACH(inoref, &inodedep->id_inoreflst, if_deps) {
8844 if (cancel_jaddref(jaddref, inodedep,
8871 if (cancel_jaddref(jaddref, inodedep,
8881 journal_jremref(dirrem, jremref, inodedep);
8883 journal_jremref(dirrem, dotremref, inodedep);
8900 struct inodedep *inodedep;
8920 0, &inodedep) != 0)
8921 if (inodedep->id_mkdiradd == dap)
8922 inodedep->id_mkdiradd = NULL;
8943 if (inodedep)
8944 free_inodedep(inodedep);
8977 struct inodedep *inodedep;
8991 * Add the dirrem to the inodedep's pending remove list for quick
8994 if (inodedep_lookup(UFSTOVFS(ump), ip->i_number, 0, &inodedep) == 0)
8995 panic("softdep_setup_remove: Lost inodedep.");
8996 KASSERT((inodedep->id_state & UNLINKED) == 0, ("inode unlinked"));
8998 LIST_INSERT_HEAD(&inodedep->id_dirremhd, dirrem, dm_inonext);
9090 struct inodedep *inodedep;
9098 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0)
9100 dap = inodedep->id_mkdiradd;
9103 ump = VFSTOUFS(inodedep->id_list.wk_mp);
9113 if (inodedep_lookup(mp, jaddref->ja_ino, 0, &inodedep) == 0)
9114 panic("cancel_mkdir_dotdot: Lost parent inodedep");
9115 if (cancel_jaddref(jaddref, inodedep, &dirrem->dm_jwork)) {
9116 journal_jremref(dirrem, jremref, inodedep);
9128 journal_jremref(dirrem, jremref, inodedep)
9131 struct inodedep *inodedep;
9134 if (inodedep == NULL)
9136 jremref->jr_ref.if_ino, 0, &inodedep) == 0)
9137 panic("journal_jremref: Lost inodedep");
9139 TAILQ_INSERT_TAIL(&inodedep->id_inoreflst, &jremref->jr_ref, if_deps);
9150 struct inodedep *inodedep;
9154 &inodedep) == 0)
9155 panic("dirrem_journal: Lost inodedep");
9156 journal_jremref(dirrem, jremref, inodedep);
9158 journal_jremref(dirrem, dotremref, inodedep);
9197 * we are not a snapshot, request some inodedep cleanup.
9342 struct inodedep *inodedep;
9403 * Add the dirrem to the inodedep's pending remove list for quick
9407 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0)
9408 panic("softdep_setup_directory_change: Lost inodedep.");
9410 LIST_INSERT_HEAD(&inodedep->id_dirremhd, dirrem, dm_inonext);
9445 inodedep_lookup(mp, newinum, DEPALLOC, &inodedep);
9447 jaddref = (struct jaddref *)TAILQ_LAST(&inodedep->id_inoreflst,
9457 } else if ((inodedep->id_state & ALLCOMPLETE) == ALLCOMPLETE) {
9460 WORKLIST_INSERT(&inodedep->id_pendinghd, &dap->da_list);
9464 WORKLIST_INSERT(&inodedep->id_bufwait, &dap->da_list);
9471 if (inodedep->id_mkdiradd && dp->i_offset != DOTDOT_OFFSET)
9472 merge_diradd(inodedep, dap);
9486 struct inodedep *inodedep;
9493 inodedep_lookup(UFSTOVFS(ump), ip->i_number, DEPALLOC, &inodedep);
9496 inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink;
9530 * Return the first unlinked inodedep which is ready to be the head of the
9531 * list. The inodedep and all those after it must have valid next pointers.
9533 static struct inodedep *
9537 struct inodedep *inodedep;
9538 struct inodedep *idp;
9541 for (inodedep = TAILQ_LAST(&ump->softdep_unlinked, inodedeplst);
9542 inodedep; inodedep = idp) {
9543 if ((inodedep->id_state & UNLINKNEXT) == 0)
9545 idp = TAILQ_PREV(inodedep, inodedeplst, id_unlinked);
9548 if ((inodedep->id_state & UNLINKPREV) == 0)
9551 return (inodedep);
9561 struct inodedep *inodedep;
9567 inodedep = first_unlinked_inodedep(sbdep->sb_ump);
9568 if (inodedep) {
9569 fs->fs_sujfree = inodedep->id_ino;
9570 inodedep->id_state |= UNLINKPREV;
9585 struct inodedep *inodedep;
9593 inodedep = first_unlinked_inodedep(sbdep->sb_ump);
9594 if ((inodedep && fs->fs_sujfree != inodedep->id_ino) ||
9595 (inodedep == NULL && fs->fs_sujfree != 0)) {
9607 for (; inodedep != NULL; inodedep = TAILQ_NEXT(inodedep, id_unlinked)) {
9608 if ((inodedep->id_state & UNLINKLINKS) != UNLINKLINKS)
9609 panic("handle_written_sbdep: Bad inodedep %p (0x%X)",
9610 inodedep, inodedep->id_state);
9611 if (inodedep->id_state & UNLINKONLIST)
9613 inodedep->id_state |= DEPCOMPLETE | UNLINKONLIST;
9620 * Mark an inodedep as unlinked and insert it into the in-memory unlinked list.
9623 unlinked_inodedep(mp, inodedep)
9625 struct inodedep *inodedep;
9634 if (inodedep->id_state & UNLINKED)
9635 panic("unlinked_inodedep: %p already unlinked\n", inodedep);
9636 inodedep->id_state |= UNLINKED;
9637 TAILQ_INSERT_HEAD(&ump->softdep_unlinked, inodedep, id_unlinked);
9641 * Remove an inodedep from the unlinked inodedep list. This may require
9645 clear_unlinked_inodedep(inodedep)
9646 struct inodedep *inodedep;
9649 struct inodedep *idp;
9650 struct inodedep *idn;
9658 ump = VFSTOUFS(inodedep->id_list.wk_mp);
9660 ino = inodedep->id_ino;
9664 KASSERT((inodedep->id_state & UNLINKED) != 0,
9665 ("clear_unlinked_inodedep: inodedep %p not unlinked",
9666 inodedep));
9673 if ((inodedep->id_state & UNLINKLINKS) == 0)
9681 idn = TAILQ_NEXT(inodedep, id_unlinked);
9682 if ((inodedep->id_state & UNLINKLINKS) == UNLINKNEXT) {
9688 * Here we have an inodedep which is actually linked into
9697 idp = TAILQ_PREV(inodedep, inodedeplst, id_unlinked);
9716 idp = TAILQ_PREV(inodedep, inodedeplst, id_unlinked);
9721 (inodedep->id_state & UNLINKPREV) != UNLINKPREV) {
9728 idn = TAILQ_NEXT(inodedep, id_unlinked);
9733 * access the inodedep.
9735 KASSERT((inodedep->id_state & UNLINKED) != 0,
9736 ("clear_unlinked_inodedep: inodedep %p not unlinked",
9737 inodedep));
9738 inodedep->id_state &= ~(UNLINKED | UNLINKLINKS | UNLINKONLIST);
9739 TAILQ_REMOVE(&ump->softdep_unlinked, inodedep, id_unlinked);
9783 if (inodedep->id_ino == fs->fs_sujfree)
9785 inodedep->id_state &= ~(UNLINKED | UNLINKLINKS | UNLINKONLIST);
9786 TAILQ_REMOVE(&ump->softdep_unlinked, inodedep, id_unlinked);
9799 struct inodedep *inodedep;
9820 if ((inodedep_lookup(mp, oldinum, 0, &inodedep)) == 0)
9821 panic("handle_workitem_remove: lost inodedep");
9848 WORKLIST_INSERT(&inodedep->id_inowait, wk);
9861 unlinked_inodedep(mp, inodedep);
9862 inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink;
9882 unlinked_inodedep(mp, inodedep);
9883 inodedep->id_nlinkdelta = ip->i_nlink - ip->i_effnlink;
9901 if (inodedep_lookup(mp, dirrem->dm_oldinum, 0, &inodedep) == 0)
9902 panic("handle_workitem_remove: lost dir inodedep");
9903 LIST_INSERT_HEAD(&inodedep->id_dirremhd, dirrem, dm_inonext);
9910 inodedep_lookup(mp, oldinum, 0, &inodedep);
9911 if (inodedep == NULL ||
9912 (inodedep->id_state & (DEPCOMPLETE | UNLINKED)) == UNLINKED ||
9913 check_inode_unwritten(inodedep)) {
9918 WORKLIST_INSERT(&inodedep->id_inowait, &dirrem->dm_list);
9947 struct inodedep *idp;
9958 panic("handle_workitem_freefile: inodedep %p survived", idp);
10002 * in-memory inode block and indexing them separately (via "inodedep"s), we
10016 struct inodedep *inodedep;
10053 inodedep = WK_INODEDEP(wk);
10054 if (inodedep->id_fs->fs_magic == FS_UFS1_MAGIC)
10055 initiate_write_inodeblock_ufs1(inodedep, bp);
10057 initiate_write_inodeblock_ufs2(inodedep, bp);
10197 initiate_write_inodeblock_ufs1(inodedep, bp)
10198 struct inodedep *inodedep;
10213 if (inodedep->id_state & IOSTARTED)
10215 inodedep->id_state |= IOSTARTED;
10216 fs = inodedep->id_fs;
10217 ump = VFSTOUFS(inodedep->id_list.wk_mp);
10220 ino_to_fsbo(fs, inodedep->id_ino);
10226 if ((inodedep->id_state & (UNLINKED | UNLINKNEXT)) == UNLINKED) {
10227 struct inodedep *inon;
10229 inon = TAILQ_NEXT(inodedep, id_unlinked);
10236 if ((inodedep->id_state & DEPCOMPLETE) == 0) {
10237 if (inodedep->id_savedino1 != NULL)
10243 inodedep->id_savedino1 = sip;
10244 *inodedep->id_savedino1 = *dp;
10246 dp->di_gen = inodedep->id_savedino1->di_gen;
10247 dp->di_freelink = inodedep->id_savedino1->di_freelink;
10253 inodedep->id_savedsize = dp->di_size;
10254 inodedep->id_savedextsize = 0;
10255 inodedep->id_savednlink = dp->di_nlink;
10256 if (TAILQ_EMPTY(&inodedep->id_inoupdt) &&
10257 TAILQ_EMPTY(&inodedep->id_inoreflst))
10262 inoref = TAILQ_FIRST(&inodedep->id_inoreflst);
10268 for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
10302 for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
10369 initiate_write_inodeblock_ufs2(inodedep, bp)
10370 struct inodedep *inodedep;
10385 if (inodedep->id_state & IOSTARTED)
10387 inodedep->id_state |= IOSTARTED;
10388 fs = inodedep->id_fs;
10389 ump = VFSTOUFS(inodedep->id_list.wk_mp);
10392 ino_to_fsbo(fs, inodedep->id_ino);
10398 if ((inodedep->id_state & (UNLINKED | UNLINKNEXT)) == UNLINKED) {
10399 struct inodedep *inon;
10401 inon = TAILQ_NEXT(inodedep, id_unlinked);
10408 if ((inodedep->id_state & DEPCOMPLETE) == 0) {
10409 if (inodedep->id_savedino2 != NULL)
10415 inodedep->id_savedino2 = sip;
10416 *inodedep->id_savedino2 = *dp;
10418 dp->di_gen = inodedep->id_savedino2->di_gen;
10419 dp->di_freelink = inodedep->id_savedino2->di_freelink;
10425 inodedep->id_savedsize = dp->di_size;
10426 inodedep->id_savedextsize = dp->di_extsize;
10427 inodedep->id_savednlink = dp->di_nlink;
10428 if (TAILQ_EMPTY(&inodedep->id_inoupdt) &&
10429 TAILQ_EMPTY(&inodedep->id_extupdt) &&
10430 TAILQ_EMPTY(&inodedep->id_inoreflst))
10435 inoref = TAILQ_FIRST(&inodedep->id_inoreflst);
10442 for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_extupdt); adp;
10468 for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_extupdt); adp;
10502 for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
10508 panic("inodedep %p and adp %p not attached", inodedep, adp);
10538 for (lastadp = NULL, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
10735 struct inodedep *inodedep;
10751 if (inodedep_lookup(mp, ino, 0, &inodedep))
10752 panic("softdep_setup_inofree: ino %ju has existing inodedep %p",
10753 (uintmax_t)ino, inodedep);
11013 inodedep, id_deps);
11192 struct inodedep *inodedep;
11208 inodedep = adp->ad_inodedep;
11209 bsize = inodedep->id_fs->fs_bsize;
11211 listhead = &inodedep->id_extupdt;
11213 listhead = &inodedep->id_inoupdt;
11234 listhead = &inodedep->id_newextupdt;
11236 listhead = &inodedep->id_newinoupdt;
11255 wkhd = &inodedep->id_bufwait;
11338 handle_bufwait(inodedep, refhd)
11339 struct inodedep *inodedep;
11347 while ((wk = LIST_FIRST(&inodedep->id_bufwait)) != NULL) {
11367 diradd_inode_written(WK_DIRADD(wk), inodedep);
11405 TAILQ_REMOVE(&inodedep->id_inoreflst, &jaddref->ja_ref,
11437 handle_written_inodeblock(inodedep, bp, flags)
11438 struct inodedep *inodedep;
11453 if ((inodedep->id_state & IOSTARTED) == 0)
11455 inodedep->id_state &= ~IOSTARTED;
11456 if (inodedep->id_fs->fs_magic == FS_UFS1_MAGIC) {
11459 ino_to_fsbo(inodedep->id_fs, inodedep->id_ino);
11464 ino_to_fsbo(inodedep->id_fs, inodedep->id_ino);
11470 if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) == UNLINKED &&
11472 struct inodedep *inon;
11474 inon = TAILQ_NEXT(inodedep, id_unlinked);
11479 inodedep->id_state |= UNLINKNEXT;
11490 if (inodedep->id_savedino1 != NULL) {
11493 *dp1 = *inodedep->id_savedino1;
11495 *dp2 = *inodedep->id_savedino2;
11496 free(inodedep->id_savedino1, M_SAVEDINO);
11497 inodedep->id_savedino1 = NULL;
11506 if (inodedep->id_state & GOINGAWAY)
11511 inodedep->id_state |= COMPLETE;
11516 for (adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp; adp = nextadp) {
11572 for (adp = TAILQ_FIRST(&inodedep->id_extupdt); adp; adp = nextadp) {
11592 if (inodedep->id_savedsize == -1 || inodedep->id_savedextsize == -1)
11594 if (inodedep->id_savednlink > UFS_LINK_MAX)
11596 "%jd for inodedep %p", (uintmax_t)inodedep->id_savednlink,
11597 inodedep);
11599 if (dp1->di_nlink != inodedep->id_savednlink) {
11600 dp1->di_nlink = inodedep->id_savednlink;
11603 if (dp1->di_size != inodedep->id_savedsize) {
11604 dp1->di_size = inodedep->id_savedsize;
11608 if (dp2->di_nlink != inodedep->id_savednlink) {
11609 dp2->di_nlink = inodedep->id_savednlink;
11612 if (dp2->di_size != inodedep->id_savedsize) {
11613 dp2->di_size = inodedep->id_savedsize;
11616 if (dp2->di_extsize != inodedep->id_savedextsize) {
11617 dp2->di_extsize = inodedep->id_savedextsize;
11621 inodedep->id_savedsize = -1;
11622 inodedep->id_savedextsize = -1;
11623 inodedep->id_savednlink = -1;
11642 if ((adp = TAILQ_FIRST(&inodedep->id_inoupdt)) != NULL)
11644 if ((adp = TAILQ_FIRST(&inodedep->id_extupdt)) != NULL)
11655 if ((inodedep->id_state & (UNLINKED | UNLINKONLIST)) != UNLINKED) {
11656 freefile = handle_bufwait(inodedep, NULL);
11668 jwork_move(&inodedep->id_bufwait, &wkhd);
11675 if (inodedep->id_state & GOINGAWAY)
11676 inodedep->id_state |= COMPLETE | DEPCOMPLETE;
11677 if (free_inodedep(inodedep) == 0)
11678 panic("handle_written_inodeblock: live inodedep %p",
11679 inodedep);
11687 if (free_inodedep(inodedep) ||
11688 (TAILQ_FIRST(&inodedep->id_inoreflst) == 0 &&
11689 TAILQ_FIRST(&inodedep->id_inoupdt) == 0 &&
11690 TAILQ_FIRST(&inodedep->id_extupdt) == 0 &&
11691 LIST_FIRST(&inodedep->id_bufwait) == 0))
11804 diradd_inode_written(dap, inodedep)
11806 struct inodedep *inodedep;
11812 WORKLIST_INSERT(&inodedep->id_pendinghd, &dap->da_list);
11909 struct inodedep *inodedep;
12014 while ((inodedep = LIST_FIRST(&bmsafemap->sm_inodedepwr)) != NULL) {
12015 inodedep->id_state |= DEPCOMPLETE;
12016 inodedep->id_state &= ~ONDEPLIST;
12017 LIST_REMOVE(inodedep, id_deps);
12018 inodedep->id_bmsafemap = NULL;
12213 struct inodedep *inodedep;
12224 if (inodedep_lookup(UFSTOVFS(ump), ip->i_number, 0, &inodedep) == 0) {
12228 ip->i_effnlink -= inodedep->id_nlinkdelta;
12248 struct inodedep *inodedep;
12275 * count, then we must track the difference in an inodedep while
12277 * if there is no existing inodedep, then there are no dependencies
12282 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0) {
12288 if (inodedep->id_nlinkdelta != ip->i_nlink - ip->i_effnlink)
12295 TAILQ_FOREACH(inoref, &inodedep->id_inoreflst, if_deps) {
12307 inodedep->id_state &= ~COMPLETE;
12308 if ((inodedep->id_state & ONWORKLIST) == 0)
12309 WORKLIST_INSERT(&bp->b_dep, &inodedep->id_list);
12316 merge_inode_lists(&inodedep->id_newinoupdt, &inodedep->id_inoupdt);
12317 if (!TAILQ_EMPTY(&inodedep->id_inoupdt))
12318 handle_allocdirect_partdone(TAILQ_FIRST(&inodedep->id_inoupdt),
12320 merge_inode_lists(&inodedep->id_newextupdt, &inodedep->id_extupdt);
12321 if (!TAILQ_EMPTY(&inodedep->id_extupdt))
12322 handle_allocdirect_partdone(TAILQ_FIRST(&inodedep->id_extupdt),
12330 while ((wk = LIST_FIRST(&inodedep->id_inowait)) != NULL) {
12332 WORKLIST_INSERT(&inodedep->id_bufwait, wk);
12346 if ((inodedep->id_state & (DEPCOMPLETE | GOINGAWAY)) != 0) {
12350 ibp = inodedep->id_bmsafemap->sm_buf;
12358 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) != 0)
12410 struct inodedep *inodedep;
12434 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0) {
12438 TAILQ_FOREACH(inoref, &inodedep->id_inoreflst, if_deps) {
12445 if (!LIST_EMPTY(&inodedep->id_inowait) ||
12446 !TAILQ_EMPTY(&inodedep->id_extupdt) ||
12447 !TAILQ_EMPTY(&inodedep->id_newextupdt) ||
12448 !TAILQ_EMPTY(&inodedep->id_inoupdt) ||
12449 !TAILQ_EMPTY(&inodedep->id_newinoupdt))
12450 panic("softdep_fsync: pending ops %p", inodedep);
12452 if ((wk = LIST_FIRST(&inodedep->id_pendinghd)) == NULL)
12530 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) != 0) {
12531 if ((wk = LIST_FIRST(&inodedep->id_pendinghd)) != NULL) {
12566 if (inodedep_lookup(mp, ip->i_number, 0, &inodedep) == 0)
12865 * Flush the dependencies associated with an inodedep.
12873 struct inodedep *inodedep;
12899 if (inodedep_lookup(mp, ino, 0, &inodedep) == 0)
12901 TAILQ_FOREACH(inoref, &inodedep->id_inoreflst, if_deps) {
12908 if (flush_deplist(&inodedep->id_inoupdt, waitfor, &error) ||
12909 flush_deplist(&inodedep->id_newinoupdt, waitfor, &error) ||
12910 flush_deplist(&inodedep->id_extupdt, waitfor, &error) ||
12911 flush_deplist(&inodedep->id_newextupdt, waitfor, &error))
12921 * Try freeing inodedep in case all dependencies have been removed.
12923 if (inodedep_lookup(mp, ino, 0, &inodedep) != 0)
12924 (void) free_inodedep(inodedep);
13078 struct inodedep *inodedep;
13128 if (inodedep_lookup(UFSTOVFS(ump), inum, 0, &inodedep) == 0)
13134 TAILQ_FOREACH(inoref, &inodedep->id_inoreflst, if_deps) {
13166 &inodedep);
13168 "inodedep %p dap %p vp %p",
13169 inodedep, dap, vp);
13183 if (inodedep_lookup(UFSTOVFS(ump), inum, 0, &inodedep) == 0)
13189 if ((inodedep->id_state & (DEPCOMPLETE | GOINGAWAY)) == 0) {
13190 bp = inodedep->id_bmsafemap->sm_buf;
13223 inodedep_lookup(UFSTOVFS(ump), inum, 0, &inodedep);
13225 "inodedep %p ino %ju dap %p",
13226 inodedep, (uintmax_t)inum, dap);
13804 * the number of inodedep dependency structures.
13811 struct inodedep *inodedep;
13830 if ((inodedep = LIST_FIRST(inodedephd)) != NULL)
13833 if (inodedep == NULL)
13838 firstino = rounddown2(inodedep->id_ino, INOPB(fs));
13840 if (inodedep_lookup(mp, lastino, 0, &inodedep) != 0)
13848 if (inodedep_lookup(mp, ino, 0, &inodedep) == 0)
14017 struct inodedep *inodedep;
14037 inodedep = WK_INODEDEP(wk);
14038 if ((inodedep->id_state & DEPCOMPLETE) == 0) {
14044 if (TAILQ_FIRST(&inodedep->id_inoupdt)) {
14050 if (TAILQ_FIRST(&inodedep->id_extupdt)) {
14056 if (TAILQ_FIRST(&inodedep->id_inoreflst)) {
14248 struct inodedep *inodedep;
14312 for (inodedep = TAILQ_FIRST(&ump->softdep_unlinked);
14313 inodedep != NULL;
14314 inodedep = TAILQ_NEXT(inodedep, id_unlinked)) {
14315 if ((inodedep->id_state & (UNLINKED | UNLINKLINKS |
14318 !check_inodedep_free(inodedep))
14419 inodedep_print(struct inodedep *inodedep, int verbose)
14423 inodedep, inodedep->id_fs, inodedep->id_state,
14424 (intmax_t)inodedep->id_ino,
14425 (intmax_t)fsbtodb(inodedep->id_fs,
14426 ino_to_fsba(inodedep->id_fs, inodedep->id_ino)),
14427 (intmax_t)inodedep->id_nlinkdelta,
14428 (intmax_t)inodedep->id_savednlink,
14429 inodedep->id_savedino1);
14436 LIST_FIRST(&inodedep->id_pendinghd),
14437 LIST_FIRST(&inodedep->id_bufwait),
14438 LIST_FIRST(&inodedep->id_inowait),
14439 TAILQ_FIRST(&inodedep->id_inoreflst),
14440 inodedep->id_mkdiradd);
14442 TAILQ_FIRST(&inodedep->id_inoupdt),
14443 TAILQ_FIRST(&inodedep->id_newinoupdt),
14444 TAILQ_FIRST(&inodedep->id_extupdt),
14445 TAILQ_FIRST(&inodedep->id_newextupdt));
14448 DB_SHOW_COMMAND(inodedep, db_show_inodedep)
14455 inodedep_print((struct inodedep*)addr, 1);
14461 struct inodedep *inodedep;
14472 LIST_FOREACH(inodedep, inodedephd, id_hash) {
14473 inodedep_print(inodedep, 0);