1139825Simp/*- 261926Smckusick * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. 336201Sjulian * 436206Sjulian * The soft updates code is derived from the appendix of a University 536206Sjulian * of Michigan technical report (Gregory R. Ganger and Yale N. Patt, 636206Sjulian * "Soft Updates: A Solution to the Metadata Update Problem in File 736206Sjulian * Systems", CSE-TR-254-95, August 1995). 836201Sjulian * 961926Smckusick * Further information about soft updates can be obtained from: 1036201Sjulian * 1161926Smckusick * Marshall Kirk McKusick http://www.mckusick.com/softdep/ 1261926Smckusick * 1614 Oxford Street mckusick@mckusick.com 1361926Smckusick * Berkeley, CA 94709-1608 +1-510-843-9542 1436201Sjulian * USA 1536201Sjulian * 1636201Sjulian * Redistribution and use in source and binary forms, with or without 1736201Sjulian * modification, are permitted provided that the following conditions 1836201Sjulian * are met: 1936201Sjulian * 2036201Sjulian * 1. Redistributions of source code must retain the above copyright 2136201Sjulian * notice, this list of conditions and the following disclaimer. 2236201Sjulian * 2. Redistributions in binary form must reproduce the above copyright 2336201Sjulian * notice, this list of conditions and the following disclaimer in the 2436201Sjulian * documentation and/or other materials provided with the distribution. 2536201Sjulian * 2636201Sjulian * THIS SOFTWARE IS PROVIDED BY MARSHALL KIRK MCKUSICK ``AS IS'' AND ANY 2736201Sjulian * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 2836201Sjulian * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2936201Sjulian * DISCLAIMED. IN NO EVENT SHALL MARSHALL KIRK MCKUSICK BE LIABLE FOR 3036201Sjulian * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3136201Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3236201Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3336201Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3436201Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3536201Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3636201Sjulian * SUCH DAMAGE. 3736201Sjulian * 3861926Smckusick * @(#)softdep.h 9.7 (McKusick) 6/21/00 3950480Speter * $FreeBSD: stable/10/sys/ufs/ffs/softdep.h 307534 2016-10-17 21:49:54Z mckusick $ 4036201Sjulian */ 4136201Sjulian 4236201Sjulian#include <sys/queue.h> 4336201Sjulian 4436201Sjulian/* 4536201Sjulian * Allocation dependencies are handled with undo/redo on the in-memory 4636201Sjulian * copy of the data. A particular data dependency is eliminated when 4736201Sjulian * it is ALLCOMPLETE: that is ATTACHED, DEPCOMPLETE, and COMPLETE. 4836201Sjulian * 49208287Sjeff * The ATTACHED flag means that the data is not currently being written 50208287Sjeff * to disk. 51208287Sjeff * 52208287Sjeff * The UNDONE flag means that the data has been rolled back to a safe 5336201Sjulian * state for writing to the disk. When the I/O completes, the data is 5436201Sjulian * restored to its current form and the state reverts to ATTACHED. 5536201Sjulian * The data must be locked throughout the rollback, I/O, and roll 5636201Sjulian * forward so that the rolled back information is never visible to 57208287Sjeff * user processes. 58208287Sjeff * 59208287Sjeff * The COMPLETE flag indicates that the item has been written. For example, 60208287Sjeff * a dependency that requires that an inode be written will be marked 61208287Sjeff * COMPLETE after the inode has been written to disk. 62208287Sjeff * 63208287Sjeff * The DEPCOMPLETE flag indicates the completion of any other 6436201Sjulian * dependencies such as the writing of a cylinder group map has been 6536201Sjulian * completed. A dependency structure may be freed only when both it 6636201Sjulian * and its dependencies have completed and any rollbacks that are in 6736201Sjulian * progress have finished as indicated by the set of ALLCOMPLETE flags 68208287Sjeff * all being set. 69208287Sjeff * 70208287Sjeff * The two MKDIR flags indicate additional dependencies that must be done 71208287Sjeff * when creating a new directory. MKDIR_BODY is cleared when the directory 72208287Sjeff * data block containing the "." and ".." entries has been written. 73208287Sjeff * MKDIR_PARENT is cleared when the parent inode with the increased link 74208287Sjeff * count for ".." has been written. When both MKDIR flags have been 75208287Sjeff * cleared, the DEPCOMPLETE flag is set to indicate that the directory 76208287Sjeff * dependencies have been completed. The writing of the directory inode 77208287Sjeff * itself sets the COMPLETE flag which then allows the directory entry for 78208287Sjeff * the new directory to be written to disk. The RMDIR flag marks a dirrem 79208287Sjeff * structure as representing the removal of a directory rather than a 80208287Sjeff * file. When the removal dependencies are completed, additional work needs 81208287Sjeff * to be done* (an additional decrement of the associated inode, and a 82208287Sjeff * decrement of the parent inode). 83208287Sjeff * 84208287Sjeff * The DIRCHG flag marks a diradd structure as representing the changing 8536201Sjulian * of an existing entry rather than the addition of a new one. When 8636201Sjulian * the update is complete the dirrem associated with the inode for 8736201Sjulian * the old name must be added to the worklist to do the necessary 88208287Sjeff * reference count decrement. 89208287Sjeff * 90208287Sjeff * The GOINGAWAY flag indicates that the data structure is frozen from 91208287Sjeff * further change until its dependencies have been completed and its 92208287Sjeff * resources freed after which it will be discarded. 93208287Sjeff * 94208287Sjeff * The IOSTARTED flag prevents multiple calls to the I/O start routine from 95208287Sjeff * doing multiple rollbacks. 96208287Sjeff * 97208287Sjeff * The NEWBLOCK flag marks pagedep structures that have just been allocated, 98208287Sjeff * so must be claimed by the inode before all dependencies are complete. 99208287Sjeff * 100208287Sjeff * The INPROGRESS flag marks worklist structures that are still on the 101208287Sjeff * worklist, but are being considered for action by some process. 102208287Sjeff * 103208287Sjeff * The UFS1FMT flag indicates that the inode being processed is a ufs1 format. 104208287Sjeff * 105208287Sjeff * The EXTDATA flag indicates that the allocdirect describes an 106208287Sjeff * extended-attributes dependency. 107208287Sjeff * 108100344Smckusick * The ONWORKLIST flag shows whether the structure is currently linked 109100344Smckusick * onto a worklist. 110212617Smckusick * 111212617Smckusick * The UNLINK* flags track the progress of updating the on-disk linked 112212617Smckusick * list of active but unlinked inodes. When an inode is first unlinked 113212617Smckusick * it is marked as UNLINKED. When its on-disk di_freelink has been 114212617Smckusick * written its UNLINKNEXT flags is set. When its predecessor in the 115212617Smckusick * list has its di_freelink pointing at us its UNLINKPREV is set. 116212617Smckusick * When the on-disk list can reach it from the superblock, its 117212617Smckusick * UNLINKONLIST flag is set. Once all of these flags are set, it 118212617Smckusick * is safe to let its last name be removed. 11936201Sjulian */ 120207141Sjeff#define ATTACHED 0x000001 121207141Sjeff#define UNDONE 0x000002 122207141Sjeff#define COMPLETE 0x000004 123207141Sjeff#define DEPCOMPLETE 0x000008 124207141Sjeff#define MKDIR_PARENT 0x000010 /* diradd, mkdir, jaddref, jsegdep only */ 125207141Sjeff#define MKDIR_BODY 0x000020 /* diradd, mkdir, jaddref only */ 126207141Sjeff#define RMDIR 0x000040 /* dirrem only */ 127207141Sjeff#define DIRCHG 0x000080 /* diradd, dirrem only */ 128207141Sjeff#define GOINGAWAY 0x000100 /* indirdep, jremref only */ 129207141Sjeff#define IOSTARTED 0x000200 /* inodedep, pagedep, bmsafemap only */ 130222958Sjeff#define DELAYEDFREE 0x000400 /* allocindirect free delayed. */ 131207141Sjeff#define NEWBLOCK 0x000800 /* pagedep, jaddref only */ 132207141Sjeff#define INPROGRESS 0x001000 /* dirrem, freeblks, freefrag, freefile only */ 133207141Sjeff#define UFS1FMT 0x002000 /* indirdep only */ 134207141Sjeff#define EXTDATA 0x004000 /* allocdirect only */ 135207141Sjeff#define ONWORKLIST 0x008000 136207141Sjeff#define IOWAITING 0x010000 /* Thread is waiting for IO to complete. */ 137207141Sjeff#define ONDEPLIST 0x020000 /* Structure is on a dependency list. */ 138207141Sjeff#define UNLINKED 0x040000 /* inodedep has been unlinked. */ 139207141Sjeff#define UNLINKNEXT 0x080000 /* inodedep has valid di_freelink */ 140207141Sjeff#define UNLINKPREV 0x100000 /* inodedep is pointed at in the unlink list */ 141207141Sjeff#define UNLINKONLIST 0x200000 /* inodedep is in the unlinked list on disk */ 142207141Sjeff#define UNLINKLINKS (UNLINKNEXT | UNLINKPREV) 143307534Smckusick#define WRITESUCCEEDED 0x400000 /* the disk write completed successfully */ 14436201Sjulian 14536201Sjulian#define ALLCOMPLETE (ATTACHED | COMPLETE | DEPCOMPLETE) 14636201Sjulian 14736201Sjulian/* 148260078Smckusick * Values for each of the soft dependency types. 149260078Smckusick */ 150260078Smckusick#define D_PAGEDEP 0 151260078Smckusick#define D_INODEDEP 1 152260078Smckusick#define D_BMSAFEMAP 2 153260078Smckusick#define D_NEWBLK 3 154260078Smckusick#define D_ALLOCDIRECT 4 155260078Smckusick#define D_INDIRDEP 5 156260078Smckusick#define D_ALLOCINDIR 6 157260078Smckusick#define D_FREEFRAG 7 158260078Smckusick#define D_FREEBLKS 8 159260078Smckusick#define D_FREEFILE 9 160260078Smckusick#define D_DIRADD 10 161260078Smckusick#define D_MKDIR 11 162260078Smckusick#define D_DIRREM 12 163260078Smckusick#define D_NEWDIRBLK 13 164260078Smckusick#define D_FREEWORK 14 165260078Smckusick#define D_FREEDEP 15 166260078Smckusick#define D_JADDREF 16 167260078Smckusick#define D_JREMREF 17 168260078Smckusick#define D_JMVREF 18 169260078Smckusick#define D_JNEWBLK 19 170260078Smckusick#define D_JFREEBLK 20 171260078Smckusick#define D_JFREEFRAG 21 172260078Smckusick#define D_JSEG 22 173260078Smckusick#define D_JSEGDEP 23 174260078Smckusick#define D_SBDEP 24 175260078Smckusick#define D_JTRUNC 25 176260078Smckusick#define D_JFSYNC 26 177260078Smckusick#define D_SENTINEL 27 178260078Smckusick#define D_LAST D_SENTINEL 179260078Smckusick 180260078Smckusick/* 18136201Sjulian * The workitem queue. 18236201Sjulian * 18336201Sjulian * It is sometimes useful and/or necessary to clean up certain dependencies 18436201Sjulian * in the background rather than during execution of an application process 18536201Sjulian * or interrupt service routine. To realize this, we append dependency 18636201Sjulian * structures corresponding to such tasks to a "workitem" queue. In a soft 18736201Sjulian * updates implementation, most pending workitems should not wait for more 18836201Sjulian * than a couple of seconds, so the filesystem syncer process awakens once 18936201Sjulian * per second to process the items on the queue. 19036201Sjulian */ 19136201Sjulian 19260938Sjake/* LIST_HEAD(workhead, worklist); -- declared in buf.h */ 19336201Sjulian 19436201Sjulian/* 19536201Sjulian * Each request can be linked onto a work queue through its worklist structure. 19636201Sjulian * To avoid the need for a pointer to the structure itself, this structure 19736201Sjulian * MUST be declared FIRST in each type in which it appears! If more than one 19836201Sjulian * worklist is needed in the structure, then a wk_data field must be added 19936201Sjulian * and the macros below changed to use it. 20036201Sjulian */ 20136201Sjulianstruct worklist { 202207141Sjeff LIST_ENTRY(worklist) wk_list; /* list of work requests */ 203156203Sjeff struct mount *wk_mp; /* Mount we live in */ 204207141Sjeff unsigned int wk_type:8, /* type of request */ 205207141Sjeff wk_state:24; /* state flags */ 20636201Sjulian}; 207262779Spfg#define WK_DATA(wk) ((void *)(wk)) 208262779Spfg#define WK_PAGEDEP(wk) ((struct pagedep *)(wk)) 209262779Spfg#define WK_INODEDEP(wk) ((struct inodedep *)(wk)) 210262779Spfg#define WK_BMSAFEMAP(wk) ((struct bmsafemap *)(wk)) 211207141Sjeff#define WK_NEWBLK(wk) ((struct newblk *)(wk)) 212262779Spfg#define WK_ALLOCDIRECT(wk) ((struct allocdirect *)(wk)) 213262779Spfg#define WK_INDIRDEP(wk) ((struct indirdep *)(wk)) 214262779Spfg#define WK_ALLOCINDIR(wk) ((struct allocindir *)(wk)) 215262779Spfg#define WK_FREEFRAG(wk) ((struct freefrag *)(wk)) 216262779Spfg#define WK_FREEBLKS(wk) ((struct freeblks *)(wk)) 217262779Spfg#define WK_FREEWORK(wk) ((struct freework *)(wk)) 218262779Spfg#define WK_FREEFILE(wk) ((struct freefile *)(wk)) 219262779Spfg#define WK_DIRADD(wk) ((struct diradd *)(wk)) 220262779Spfg#define WK_MKDIR(wk) ((struct mkdir *)(wk)) 221262779Spfg#define WK_DIRREM(wk) ((struct dirrem *)(wk)) 222262779Spfg#define WK_NEWDIRBLK(wk) ((struct newdirblk *)(wk)) 223207141Sjeff#define WK_JADDREF(wk) ((struct jaddref *)(wk)) 224207141Sjeff#define WK_JREMREF(wk) ((struct jremref *)(wk)) 225207141Sjeff#define WK_JMVREF(wk) ((struct jmvref *)(wk)) 226207141Sjeff#define WK_JSEGDEP(wk) ((struct jsegdep *)(wk)) 227207141Sjeff#define WK_JSEG(wk) ((struct jseg *)(wk)) 228207141Sjeff#define WK_JNEWBLK(wk) ((struct jnewblk *)(wk)) 229207141Sjeff#define WK_JFREEBLK(wk) ((struct jfreeblk *)(wk)) 230207141Sjeff#define WK_FREEDEP(wk) ((struct freedep *)(wk)) 231207141Sjeff#define WK_JFREEFRAG(wk) ((struct jfreefrag *)(wk)) 232222958Sjeff#define WK_SBDEP(wk) ((struct sbdep *)(wk)) 233207141Sjeff#define WK_JTRUNC(wk) ((struct jtrunc *)(wk)) 234222958Sjeff#define WK_JFSYNC(wk) ((struct jfsync *)(wk)) 23536201Sjulian 23636201Sjulian/* 23736201Sjulian * Various types of lists 23836201Sjulian */ 23960938SjakeLIST_HEAD(dirremhd, dirrem); 24060938SjakeLIST_HEAD(diraddhd, diradd); 24160938SjakeLIST_HEAD(newblkhd, newblk); 24260938SjakeLIST_HEAD(inodedephd, inodedep); 24360938SjakeLIST_HEAD(allocindirhd, allocindir); 24460938SjakeLIST_HEAD(allocdirecthd, allocdirect); 24560938SjakeTAILQ_HEAD(allocdirectlst, allocdirect); 246207141SjeffLIST_HEAD(indirdephd, indirdep); 247207141SjeffLIST_HEAD(jaddrefhd, jaddref); 248207141SjeffLIST_HEAD(jremrefhd, jremref); 249207141SjeffLIST_HEAD(jmvrefhd, jmvref); 250207141SjeffLIST_HEAD(jnewblkhd, jnewblk); 251222958SjeffLIST_HEAD(jblkdephd, jblkdep); 252207141SjeffLIST_HEAD(freeworkhd, freework); 253222958SjeffTAILQ_HEAD(freeworklst, freework); 254207141SjeffTAILQ_HEAD(jseglst, jseg); 255207141SjeffTAILQ_HEAD(inoreflst, inoref); 256222958SjeffTAILQ_HEAD(freeblklst, freeblks); 25736201Sjulian 25836201Sjulian/* 25936201Sjulian * The "pagedep" structure tracks the various dependencies related to 26036201Sjulian * a particular directory page. If a directory page has any dependencies, 26136201Sjulian * it will have a pagedep linked to its associated buffer. The 26236201Sjulian * pd_dirremhd list holds the list of dirrem requests which decrement 26336201Sjulian * inode reference counts. These requests are processed after the 26436201Sjulian * directory page with the corresponding zero'ed entries has been 26536201Sjulian * written. The pd_diraddhd list maintains the list of diradd requests 26636201Sjulian * which cannot be committed until their corresponding inode has been 26736201Sjulian * written to disk. Because a directory may have many new entries 26836201Sjulian * being created, several lists are maintained hashed on bits of the 26936201Sjulian * offset of the entry into the directory page to keep the lists from 27036201Sjulian * getting too long. Once a new directory entry has been cleared to 27136201Sjulian * be written, it is moved to the pd_pendinghd list. After the new 27236201Sjulian * entry has been written to disk it is removed from the pd_pendinghd 27336201Sjulian * list, any removed operations are done, and the dependency structure 27436201Sjulian * is freed. 27536201Sjulian */ 276262779Spfg#define DAHASHSZ 5 277262779Spfg#define DIRADDHASH(offset) (((offset) >> 2) % DAHASHSZ) 27836201Sjulianstruct pagedep { 27936201Sjulian struct worklist pd_list; /* page buffer */ 28036201Sjulian# define pd_state pd_list.wk_state /* check for multiple I/O starts */ 28160938Sjake LIST_ENTRY(pagedep) pd_hash; /* hashed lookup */ 28236201Sjulian ino_t pd_ino; /* associated file */ 28336201Sjulian ufs_lbn_t pd_lbn; /* block within file */ 284207141Sjeff struct newdirblk *pd_newdirblk; /* associated newdirblk if NEWBLOCK */ 28536201Sjulian struct dirremhd pd_dirremhd; /* dirrem's waiting for page */ 28636201Sjulian struct diraddhd pd_diraddhd[DAHASHSZ]; /* diradd dir entry updates */ 28736201Sjulian struct diraddhd pd_pendinghd; /* directory entries awaiting write */ 288207141Sjeff struct jmvrefhd pd_jmvrefhd; /* Dependent journal writes. */ 28936201Sjulian}; 29036201Sjulian 29136201Sjulian/* 29236201Sjulian * The "inodedep" structure tracks the set of dependencies associated 29336225Sjulian * with an inode. One task that it must manage is delayed operations 29436225Sjulian * (i.e., work requests that must be held until the inodedep's associated 29536225Sjulian * inode has been written to disk). Getting an inode from its incore 29636225Sjulian * state to the disk requires two steps to be taken by the filesystem 29736225Sjulian * in this order: first the inode must be copied to its disk buffer by 29836225Sjulian * the VOP_UPDATE operation; second the inode's buffer must be written 29936225Sjulian * to disk. To ensure that both operations have happened in the required 30036225Sjulian * order, the inodedep maintains two lists. Delayed operations are 30136225Sjulian * placed on the id_inowait list. When the VOP_UPDATE is done, all 30236225Sjulian * operations on the id_inowait list are moved to the id_bufwait list. 30336225Sjulian * When the buffer is written, the items on the id_bufwait list can be 30436225Sjulian * safely moved to the work queue to be processed. A second task of the 30536225Sjulian * inodedep structure is to track the status of block allocation within 30636225Sjulian * the inode. Each block that is allocated is represented by an 30736201Sjulian * "allocdirect" structure (see below). It is linked onto the id_newinoupdt 30836201Sjulian * list until both its contents and its allocation in the cylinder 30936225Sjulian * group map have been written to disk. Once these dependencies have been 31036201Sjulian * satisfied, it is removed from the id_newinoupdt list and any followup 31136201Sjulian * actions such as releasing the previous block or fragment are placed 31236225Sjulian * on the id_inowait list. When an inode is updated (a VOP_UPDATE is 31336225Sjulian * done), the "inodedep" structure is linked onto the buffer through 31436225Sjulian * its worklist. Thus, it will be notified when the buffer is about 31536201Sjulian * to be written and when it is done. At the update time, all the 31636201Sjulian * elements on the id_newinoupdt list are moved to the id_inoupdt list 31736201Sjulian * since those changes are now relevant to the copy of the inode in the 31836225Sjulian * buffer. Also at update time, the tasks on the id_inowait list are 31936225Sjulian * moved to the id_bufwait list so that they will be executed when 32036225Sjulian * the updated inode has been written to disk. When the buffer containing 32136225Sjulian * the inode is written to disk, any updates listed on the id_inoupdt 32236225Sjulian * list are rolled back as they are not yet safe. Following the write, 32336225Sjulian * the changes are once again rolled forward and any actions on the 32436225Sjulian * id_bufwait list are processed (since those actions are now safe). 32536201Sjulian * The entries on the id_inoupdt and id_newinoupdt lists must be kept 32636201Sjulian * sorted by logical block number to speed the calculation of the size 32736201Sjulian * of the rolled back inode (see explanation in initiate_write_inodeblock). 32836206Sjulian * When a directory entry is created, it is represented by a diradd. 32936225Sjulian * The diradd is added to the id_inowait list as it cannot be safely 33036225Sjulian * written to disk until the inode that it represents is on disk. After 33136225Sjulian * the inode is written, the id_bufwait list is processed and the diradd 33236206Sjulian * entries are moved to the id_pendinghd list where they remain until 33336206Sjulian * the directory block containing the name has been written to disk. 33436206Sjulian * The purpose of keeping the entries on the id_pendinghd list is so that 33536206Sjulian * the softdep_fsync function can find and push the inode's directory 33636206Sjulian * name(s) as part of the fsync operation for that file. 33736201Sjulian */ 33836201Sjulianstruct inodedep { 33936201Sjulian struct worklist id_list; /* buffer holding inode block */ 34036201Sjulian# define id_state id_list.wk_state /* inode dependency state */ 34160938Sjake LIST_ENTRY(inodedep) id_hash; /* hashed lookup */ 342207141Sjeff TAILQ_ENTRY(inodedep) id_unlinked; /* Unlinked but ref'd inodes */ 34336201Sjulian struct fs *id_fs; /* associated filesystem */ 34436201Sjulian ino_t id_ino; /* dependent inode */ 34536201Sjulian nlink_t id_nlinkdelta; /* saved effective link count */ 346207141Sjeff nlink_t id_savednlink; /* Link saved during rollback */ 34760938Sjake LIST_ENTRY(inodedep) id_deps; /* bmsafemap's list of inodedep's */ 348207141Sjeff struct bmsafemap *id_bmsafemap; /* related bmsafemap (if pending) */ 349207141Sjeff struct diradd *id_mkdiradd; /* diradd for a mkdir. */ 350207141Sjeff struct inoreflst id_inoreflst; /* Inode reference adjustments. */ 351100344Smckusick long id_savedextsize; /* ext size saved during rollback */ 35236201Sjulian off_t id_savedsize; /* file size saved during rollback */ 353207141Sjeff struct dirremhd id_dirremhd; /* Removals pending. */ 35436201Sjulian struct workhead id_pendinghd; /* entries awaiting directory write */ 35536225Sjulian struct workhead id_bufwait; /* operations after inode written */ 35636225Sjulian struct workhead id_inowait; /* operations waiting inode update */ 35736201Sjulian struct allocdirectlst id_inoupdt; /* updates before inode written */ 35836201Sjulian struct allocdirectlst id_newinoupdt; /* updates when inode written */ 359100344Smckusick struct allocdirectlst id_extupdt; /* extdata updates pre-inode write */ 360100344Smckusick struct allocdirectlst id_newextupdt; /* extdata updates at ino write */ 361222958Sjeff struct freeblklst id_freeblklst; /* List of partial truncates. */ 36298542Smckusick union { 36398542Smckusick struct ufs1_dinode *idu_savedino1; /* saved ufs1_dinode contents */ 36498542Smckusick struct ufs2_dinode *idu_savedino2; /* saved ufs2_dinode contents */ 36598542Smckusick } id_un; 36636201Sjulian}; 367262779Spfg#define id_savedino1 id_un.idu_savedino1 368262779Spfg#define id_savedino2 id_un.idu_savedino2 36936201Sjulian 37036201Sjulian/* 37136201Sjulian * A "bmsafemap" structure maintains a list of dependency structures 37236201Sjulian * that depend on the update of a particular cylinder group map. 37336201Sjulian * It has lists for newblks, allocdirects, allocindirs, and inodedeps. 37436201Sjulian * It is attached to the buffer of a cylinder group block when any of 37536201Sjulian * these things are allocated from the cylinder group. It is freed 37636201Sjulian * after the cylinder group map is written and the state of its 37736201Sjulian * dependencies are updated with DEPCOMPLETE to indicate that it has 37836201Sjulian * been processed. 37936201Sjulian */ 38036201Sjulianstruct bmsafemap { 38136201Sjulian struct worklist sm_list; /* cylgrp buffer */ 382207141Sjeff# define sm_state sm_list.wk_state 383222958Sjeff LIST_ENTRY(bmsafemap) sm_hash; /* Hash links. */ 384222958Sjeff LIST_ENTRY(bmsafemap) sm_next; /* Mount list. */ 385207141Sjeff int sm_cg; 38636201Sjulian struct buf *sm_buf; /* associated buffer */ 38736201Sjulian struct allocdirecthd sm_allocdirecthd; /* allocdirect deps */ 388207141Sjeff struct allocdirecthd sm_allocdirectwr; /* writing allocdirect deps */ 38936201Sjulian struct allocindirhd sm_allocindirhd; /* allocindir deps */ 390207141Sjeff struct allocindirhd sm_allocindirwr; /* writing allocindir deps */ 39136201Sjulian struct inodedephd sm_inodedephd; /* inodedep deps */ 392207141Sjeff struct inodedephd sm_inodedepwr; /* writing inodedep deps */ 39336201Sjulian struct newblkhd sm_newblkhd; /* newblk deps */ 394207141Sjeff struct newblkhd sm_newblkwr; /* writing newblk deps */ 395207141Sjeff struct jaddrefhd sm_jaddrefhd; /* Pending inode allocations. */ 396207141Sjeff struct jnewblkhd sm_jnewblkhd; /* Pending block allocations. */ 397222958Sjeff struct workhead sm_freehd; /* Freedep deps. */ 398222958Sjeff struct workhead sm_freewr; /* Written freedeps. */ 39936201Sjulian}; 40036201Sjulian 40136201Sjulian/* 402207141Sjeff * A "newblk" structure is attached to a bmsafemap structure when a block 403207141Sjeff * or fragment is allocated from a cylinder group. Its state is set to 404207141Sjeff * DEPCOMPLETE when its cylinder group map is written. It is converted to 405207141Sjeff * an allocdirect or allocindir allocation once the allocator calls the 406212617Smckusick * appropriate setup function. It will initially be linked onto a bmsafemap 407212617Smckusick * list. Once converted it can be linked onto the lists described for 408212617Smckusick * allocdirect or allocindir as described below. 409207141Sjeff */ 410207141Sjeffstruct newblk { 411212617Smckusick struct worklist nb_list; /* See comment above. */ 412207141Sjeff# define nb_state nb_list.wk_state 413212617Smckusick LIST_ENTRY(newblk) nb_hash; /* Hashed lookup. */ 414212617Smckusick LIST_ENTRY(newblk) nb_deps; /* Bmsafemap's list of newblks. */ 415207141Sjeff struct jnewblk *nb_jnewblk; /* New block journal entry. */ 416212617Smckusick struct bmsafemap *nb_bmsafemap;/* Cylgrp dep (if pending). */ 417212617Smckusick struct freefrag *nb_freefrag; /* Fragment to be freed (if any). */ 418207141Sjeff struct indirdephd nb_indirdeps; /* Children indirect blocks. */ 419212617Smckusick struct workhead nb_newdirblk; /* Dir block to notify when written. */ 420207141Sjeff struct workhead nb_jwork; /* Journal work pending. */ 421212617Smckusick ufs2_daddr_t nb_newblkno; /* New value of block pointer. */ 422207141Sjeff}; 423207141Sjeff 424207141Sjeff/* 42536201Sjulian * An "allocdirect" structure is attached to an "inodedep" when a new block 42636201Sjulian * or fragment is allocated and pointed to by the inode described by 42736201Sjulian * "inodedep". The worklist is linked to the buffer that holds the block. 42836201Sjulian * When the block is first allocated, it is linked to the bmsafemap 42936201Sjulian * structure associated with the buffer holding the cylinder group map 43036201Sjulian * from which it was allocated. When the cylinder group map is written 43136201Sjulian * to disk, ad_state has the DEPCOMPLETE flag set. When the block itself 43236201Sjulian * is written, the COMPLETE flag is set. Once both the cylinder group map 43336201Sjulian * and the data itself have been written, it is safe to write the inode 43436201Sjulian * that claims the block. If there was a previous fragment that had been 43536201Sjulian * allocated before the file was increased in size, the old fragment may 43636201Sjulian * be freed once the inode claiming the new block is written to disk. 43736201Sjulian * This ad_fragfree request is attached to the id_inowait list of the 43836201Sjulian * associated inodedep (pointed to by ad_inodedep) for processing after 43976724Smckusick * the inode is written. When a block is allocated to a directory, an 44076724Smckusick * fsync of a file whose name is within that block must ensure not only 44176724Smckusick * that the block containing the file name has been written, but also 44276724Smckusick * that the on-disk inode references that block. When a new directory 44376724Smckusick * block is created, we allocate a newdirblk structure which is linked 44476724Smckusick * to the associated allocdirect (on its ad_newdirblk list). When the 44576724Smckusick * allocdirect has been satisfied, the newdirblk structure is moved to 44676724Smckusick * the inodedep id_bufwait list of its directory to await the inode 44776724Smckusick * being written. When the inode is written, the directory entries are 44876724Smckusick * fully committed and can be deleted from their pagedep->id_pendinghd 44976724Smckusick * and inodedep->id_pendinghd lists. 45036201Sjulian */ 45136201Sjulianstruct allocdirect { 452207141Sjeff struct newblk ad_block; /* Common block logic */ 453260078Smckusick# define ad_list ad_block.nb_list /* block pointer worklist */ 454260078Smckusick# define ad_state ad_list.wk_state /* block pointer state */ 45560938Sjake TAILQ_ENTRY(allocdirect) ad_next; /* inodedep's list of allocdirect's */ 45636201Sjulian struct inodedep *ad_inodedep; /* associated inodedep */ 457207141Sjeff ufs2_daddr_t ad_oldblkno; /* old value of block pointer */ 458207141Sjeff int ad_offset; /* Pointer offset in parent. */ 459207141Sjeff long ad_newsize; /* size of new block */ 460207141Sjeff long ad_oldsize; /* size of old block */ 46136201Sjulian}; 462207141Sjeff#define ad_newblkno ad_block.nb_newblkno 463207141Sjeff#define ad_freefrag ad_block.nb_freefrag 464207141Sjeff#define ad_newdirblk ad_block.nb_newdirblk 46536201Sjulian 46636201Sjulian/* 46736201Sjulian * A single "indirdep" structure manages all allocation dependencies for 46836201Sjulian * pointers in an indirect block. The up-to-date state of the indirect 46936201Sjulian * block is stored in ir_savedata. The set of pointers that may be safely 47036201Sjulian * written to the disk is stored in ir_safecopy. The state field is used 47136201Sjulian * only to track whether the buffer is currently being written (in which 47236201Sjulian * case it is not safe to update ir_safecopy). Ir_deplisthd contains the 47336201Sjulian * list of allocindir structures, one for each block that needs to be 47436201Sjulian * written to disk. Once the block and its bitmap allocation have been 47536201Sjulian * written the safecopy can be updated to reflect the allocation and the 47636201Sjulian * allocindir structure freed. If ir_state indicates that an I/O on the 47736201Sjulian * indirect block is in progress when ir_safecopy is to be updated, the 47836201Sjulian * update is deferred by placing the allocindir on the ir_donehd list. 47936201Sjulian * When the I/O on the indirect block completes, the entries on the 48036201Sjulian * ir_donehd list are processed by updating their corresponding ir_safecopy 48136201Sjulian * pointers and then freeing the allocindir structure. 48236201Sjulian */ 48336201Sjulianstruct indirdep { 48436201Sjulian struct worklist ir_list; /* buffer holding indirect block */ 48536201Sjulian# define ir_state ir_list.wk_state /* indirect block pointer state */ 486207141Sjeff LIST_ENTRY(indirdep) ir_next; /* alloc{direct,indir} list */ 487222958Sjeff TAILQ_HEAD(, freework) ir_trunc; /* List of truncations. */ 488207141Sjeff caddr_t ir_saveddata; /* buffer cache contents */ 48936201Sjulian struct buf *ir_savebp; /* buffer holding safe copy */ 490222958Sjeff struct buf *ir_bp; /* buffer holding live copy */ 491207141Sjeff struct allocindirhd ir_completehd; /* waiting for indirdep complete */ 492207141Sjeff struct allocindirhd ir_writehd; /* Waiting for the pointer write. */ 49336201Sjulian struct allocindirhd ir_donehd; /* done waiting to update safecopy */ 49436201Sjulian struct allocindirhd ir_deplisthd; /* allocindir deps for this block */ 495222958Sjeff struct freeblks *ir_freeblks; /* Freeblks that frees this indir. */ 49636201Sjulian}; 49736201Sjulian 49836201Sjulian/* 49936201Sjulian * An "allocindir" structure is attached to an "indirdep" when a new block 50036201Sjulian * is allocated and pointed to by the indirect block described by the 50136201Sjulian * "indirdep". The worklist is linked to the buffer that holds the new block. 50236201Sjulian * When the block is first allocated, it is linked to the bmsafemap 50336201Sjulian * structure associated with the buffer holding the cylinder group map 50436201Sjulian * from which it was allocated. When the cylinder group map is written 50536201Sjulian * to disk, ai_state has the DEPCOMPLETE flag set. When the block itself 50636201Sjulian * is written, the COMPLETE flag is set. Once both the cylinder group map 50736201Sjulian * and the data itself have been written, it is safe to write the entry in 50836201Sjulian * the indirect block that claims the block; the "allocindir" dependency 50936201Sjulian * can then be freed as it is no longer applicable. 51036201Sjulian */ 51136201Sjulianstruct allocindir { 512207141Sjeff struct newblk ai_block; /* Common block area */ 513207141Sjeff# define ai_state ai_block.nb_list.wk_state /* indirect pointer state */ 51460938Sjake LIST_ENTRY(allocindir) ai_next; /* indirdep's list of allocindir's */ 51536201Sjulian struct indirdep *ai_indirdep; /* address of associated indirdep */ 516207141Sjeff ufs2_daddr_t ai_oldblkno; /* old value of block pointer */ 517222958Sjeff ufs_lbn_t ai_lbn; /* Logical block number. */ 518207141Sjeff int ai_offset; /* Pointer offset in parent. */ 51936201Sjulian}; 520207141Sjeff#define ai_newblkno ai_block.nb_newblkno 521207141Sjeff#define ai_freefrag ai_block.nb_freefrag 522207141Sjeff#define ai_newdirblk ai_block.nb_newdirblk 52336201Sjulian 52436201Sjulian/* 525207141Sjeff * The allblk union is used to size the newblk structure on allocation so 526207141Sjeff * that it may be any one of three types. 527207141Sjeff */ 528207141Sjeffunion allblk { 529207141Sjeff struct allocindir ab_allocindir; 530207141Sjeff struct allocdirect ab_allocdirect; 531207141Sjeff struct newblk ab_newblk; 532207141Sjeff}; 533207141Sjeff 534207141Sjeff/* 53536201Sjulian * A "freefrag" structure is attached to an "inodedep" when a previously 53636201Sjulian * allocated fragment is replaced with a larger fragment, rather than extended. 53736201Sjulian * The "freefrag" structure is constructed and attached when the replacement 53836201Sjulian * block is first allocated. It is processed after the inode claiming the 539207141Sjeff * bigger block that replaces it has been written to disk. 54036201Sjulian */ 54136201Sjulianstruct freefrag { 54236201Sjulian struct worklist ff_list; /* id_inowait or delayed worklist */ 543207141Sjeff# define ff_state ff_list.wk_state 544220406Sjeff struct worklist *ff_jdep; /* Associated journal entry. */ 545207141Sjeff struct workhead ff_jwork; /* Journal work pending. */ 54698542Smckusick ufs2_daddr_t ff_blkno; /* fragment physical block number */ 54736201Sjulian long ff_fragsize; /* size of fragment being deleted */ 54836201Sjulian ino_t ff_inum; /* owning inode number */ 549223127Smckusick enum vtype ff_vtype; /* owning inode's file type */ 55036201Sjulian}; 55136201Sjulian 55236201Sjulian/* 55336201Sjulian * A "freeblks" structure is attached to an "inodedep" when the 55436201Sjulian * corresponding file's length is reduced to zero. It records all 55536201Sjulian * the information needed to free the blocks of a file after its 556207141Sjeff * zero'ed inode has been written to disk. The actual work is done 557207141Sjeff * by child freework structures which are responsible for individual 558207141Sjeff * inode pointers while freeblks is responsible for retiring the 559207141Sjeff * entire operation when it is complete and holding common members. 56036201Sjulian */ 56136201Sjulianstruct freeblks { 56236201Sjulian struct worklist fb_list; /* id_inowait or delayed worklist */ 563148608Sups# define fb_state fb_list.wk_state /* inode and dirty block state */ 564222958Sjeff TAILQ_ENTRY(freeblks) fb_next; /* List of inode truncates. */ 565222958Sjeff struct jblkdephd fb_jblkdephd; /* Journal entries pending */ 566207141Sjeff struct workhead fb_freeworkhd; /* Work items pending */ 567207141Sjeff struct workhead fb_jwork; /* Journal work pending */ 568222958Sjeff struct vnode *fb_devvp; /* filesystem device vnode */ 569222958Sjeff#ifdef QUOTA 570222958Sjeff struct dquot *fb_quota[MAXQUOTAS]; /* quotas to be adjusted */ 571222958Sjeff#endif 572222958Sjeff uint64_t fb_modrev; /* Inode revision at start of trunc. */ 573222958Sjeff off_t fb_len; /* Length we're truncating to. */ 574223772Sjeff ufs2_daddr_t fb_chkcnt; /* Blocks released. */ 575222958Sjeff ino_t fb_inum; /* inode owner of blocks */ 576223127Smckusick enum vtype fb_vtype; /* inode owner's file type */ 57798542Smckusick uid_t fb_uid; /* uid of previous owner of blocks */ 578207141Sjeff int fb_ref; /* Children outstanding. */ 579222958Sjeff int fb_cgwait; /* cg writes outstanding. */ 58036201Sjulian}; 58136201Sjulian 58236201Sjulian/* 583207141Sjeff * A "freework" structure handles the release of a tree of blocks or a single 584207141Sjeff * block. Each indirect block in a tree is allocated its own freework 585212617Smckusick * structure so that the indirect block may be freed only when all of its 586207141Sjeff * children are freed. In this way we enforce the rule that an allocated 587207141Sjeff * block must have a valid path to a root that is journaled. Each child 588207141Sjeff * block acquires a reference and when the ref hits zero the parent ref 589207141Sjeff * is decremented. If there is no parent the freeblks ref is decremented. 590207141Sjeff */ 591207141Sjeffstruct freework { 592212617Smckusick struct worklist fw_list; /* Delayed worklist. */ 593207141Sjeff# define fw_state fw_list.wk_state 594222958Sjeff LIST_ENTRY(freework) fw_segs; /* Seg list. */ 595222958Sjeff TAILQ_ENTRY(freework) fw_next; /* Hash/Trunc list. */ 596222958Sjeff struct jnewblk *fw_jnewblk; /* Journal entry to cancel. */ 597207141Sjeff struct freeblks *fw_freeblks; /* Root of operation. */ 598207141Sjeff struct freework *fw_parent; /* Parent indirect. */ 599222958Sjeff struct indirdep *fw_indir; /* indirect block. */ 600207141Sjeff ufs2_daddr_t fw_blkno; /* Our block #. */ 601207141Sjeff ufs_lbn_t fw_lbn; /* Original lbn before free. */ 602222958Sjeff uint16_t fw_frags; /* Number of frags. */ 603222958Sjeff uint16_t fw_ref; /* Number of children out. */ 604222958Sjeff uint16_t fw_off; /* Current working position. */ 605222958Sjeff uint16_t fw_start; /* Start of partial truncate. */ 606207141Sjeff}; 607207141Sjeff 608207141Sjeff/* 609207141Sjeff * A "freedep" structure is allocated to track the completion of a bitmap 610207141Sjeff * write for a freework. One freedep may cover many freed blocks so long 611207141Sjeff * as they reside in the same cylinder group. When the cg is written 612207141Sjeff * the freedep decrements the ref on the freework which may permit it 613207141Sjeff * to be freed as well. 614207141Sjeff */ 615207141Sjeffstruct freedep { 616212617Smckusick struct worklist fd_list; /* Delayed worklist. */ 617207141Sjeff struct freework *fd_freework; /* Parent freework. */ 618207141Sjeff}; 619207141Sjeff 620207141Sjeff/* 62136201Sjulian * A "freefile" structure is attached to an inode when its 62236201Sjulian * link count is reduced to zero. It marks the inode as free in 62336201Sjulian * the cylinder group map after the zero'ed inode has been written 62436201Sjulian * to disk and any associated blocks and fragments have been freed. 62536201Sjulian */ 62636201Sjulianstruct freefile { 62736201Sjulian struct worklist fx_list; /* id_inowait or delayed worklist */ 62836201Sjulian mode_t fx_mode; /* mode of inode */ 62936201Sjulian ino_t fx_oldinum; /* inum of the unlinked file */ 63036201Sjulian struct vnode *fx_devvp; /* filesystem device vnode */ 631207141Sjeff struct workhead fx_jwork; /* journal work pending. */ 63236201Sjulian}; 63336201Sjulian 63436201Sjulian/* 63536201Sjulian * A "diradd" structure is linked to an "inodedep" id_inowait list when a 63636201Sjulian * new directory entry is allocated that references the inode described 63736201Sjulian * by "inodedep". When the inode itself is written (either the initial 63836201Sjulian * allocation for new inodes or with the increased link count for 63936201Sjulian * existing inodes), the COMPLETE flag is set in da_state. If the entry 64036201Sjulian * is for a newly allocated inode, the "inodedep" structure is associated 64136201Sjulian * with a bmsafemap which prevents the inode from being written to disk 64236201Sjulian * until the cylinder group has been updated. Thus the da_state COMPLETE 64336201Sjulian * flag cannot be set until the inode bitmap dependency has been removed. 64436201Sjulian * When creating a new file, it is safe to write the directory entry that 64536201Sjulian * claims the inode once the referenced inode has been written. Since 64636201Sjulian * writing the inode clears the bitmap dependencies, the DEPCOMPLETE flag 64736201Sjulian * in the diradd can be set unconditionally when creating a file. When 64836201Sjulian * creating a directory, there are two additional dependencies described by 64936201Sjulian * mkdir structures (see their description below). When these dependencies 65036201Sjulian * are resolved the DEPCOMPLETE flag is set in the diradd structure. 65136201Sjulian * If there are multiple links created to the same inode, there will be 65236201Sjulian * a separate diradd structure created for each link. The diradd is 65336201Sjulian * linked onto the pg_diraddhd list of the pagedep for the directory 65436201Sjulian * page that contains the entry. When a directory page is written, 65536201Sjulian * the pg_diraddhd list is traversed to rollback any entries that are 65636201Sjulian * not yet ready to be written to disk. If a directory entry is being 65736201Sjulian * changed (by rename) rather than added, the DIRCHG flag is set and 65836201Sjulian * the da_previous entry points to the entry that will be "removed" 65936201Sjulian * once the new entry has been committed. During rollback, entries 66036201Sjulian * with da_previous are replaced with the previous inode number rather 66136201Sjulian * than zero. 66236201Sjulian * 66336201Sjulian * The overlaying of da_pagedep and da_previous is done to keep the 664207141Sjeff * structure down. If a da_previous entry is present, the pointer to its 665207141Sjeff * pagedep is available in the associated dirrem entry. If the DIRCHG flag 666207141Sjeff * is set, the da_previous entry is valid; if not set the da_pagedep entry 667207141Sjeff * is valid. The DIRCHG flag never changes; it is set when the structure 668207141Sjeff * is created if appropriate and is never cleared. 66936201Sjulian */ 67036201Sjulianstruct diradd { 67136225Sjulian struct worklist da_list; /* id_inowait or id_pendinghd list */ 67236201Sjulian# define da_state da_list.wk_state /* state of the new directory entry */ 67360938Sjake LIST_ENTRY(diradd) da_pdlist; /* pagedep holding directory block */ 67436201Sjulian doff_t da_offset; /* offset of new dir entry in dir blk */ 67536201Sjulian ino_t da_newinum; /* inode number for the new dir entry */ 67636201Sjulian union { 67736201Sjulian struct dirrem *dau_previous; /* entry being replaced in dir change */ 67836201Sjulian struct pagedep *dau_pagedep; /* pagedep dependency for addition */ 67936201Sjulian } da_un; 680207141Sjeff struct workhead da_jwork; /* Journal work awaiting completion. */ 68136201Sjulian}; 682262779Spfg#define da_previous da_un.dau_previous 683262779Spfg#define da_pagedep da_un.dau_pagedep 68436201Sjulian 68536201Sjulian/* 68636201Sjulian * Two "mkdir" structures are needed to track the additional dependencies 68736201Sjulian * associated with creating a new directory entry. Normally a directory 68836201Sjulian * addition can be committed as soon as the newly referenced inode has been 68936201Sjulian * written to disk with its increased link count. When a directory is 69036201Sjulian * created there are two additional dependencies: writing the directory 69136201Sjulian * data block containing the "." and ".." entries (MKDIR_BODY) and writing 69236201Sjulian * the parent inode with the increased link count for ".." (MKDIR_PARENT). 69336201Sjulian * These additional dependencies are tracked by two mkdir structures that 69436201Sjulian * reference the associated "diradd" structure. When they have completed, 69536201Sjulian * they set the DEPCOMPLETE flag on the diradd so that it knows that its 69636201Sjulian * extra dependencies have been completed. The md_state field is used only 69736201Sjulian * to identify which type of dependency the mkdir structure is tracking. 69836201Sjulian * It is not used in the mainline code for any purpose other than consistency 69936201Sjulian * checking. All the mkdir structures in the system are linked together on 70036201Sjulian * a list. This list is needed so that a diradd can find its associated 70136201Sjulian * mkdir structures and deallocate them if it is prematurely freed (as for 70236201Sjulian * example if a mkdir is immediately followed by a rmdir of the same directory). 70336201Sjulian * Here, the free of the diradd must traverse the list to find the associated 70436201Sjulian * mkdir structures that reference it. The deletion would be faster if the 70536201Sjulian * diradd structure were simply augmented to have two pointers that referenced 70636201Sjulian * the associated mkdir's. However, this would increase the size of the diradd 707207141Sjeff * structure to speed a very infrequent operation. 70836201Sjulian */ 70936201Sjulianstruct mkdir { 71036201Sjulian struct worklist md_list; /* id_inowait or buffer holding dir */ 71136201Sjulian# define md_state md_list.wk_state /* type: MKDIR_PARENT or MKDIR_BODY */ 71236201Sjulian struct diradd *md_diradd; /* associated diradd */ 713207141Sjeff struct jaddref *md_jaddref; /* dependent jaddref. */ 71446618Smckusick struct buf *md_buf; /* MKDIR_BODY: buffer holding dir */ 71560938Sjake LIST_ENTRY(mkdir) md_mkdirs; /* list of all mkdirs */ 71636201Sjulian}; 71736201Sjulian 71836201Sjulian/* 71936201Sjulian * A "dirrem" structure describes an operation to decrement the link 72036201Sjulian * count on an inode. The dirrem structure is attached to the pg_dirremhd 72136201Sjulian * list of the pagedep for the directory page that contains the entry. 72236201Sjulian * It is processed after the directory page with the deleted entry has 72336201Sjulian * been written to disk. 72436201Sjulian */ 72536201Sjulianstruct dirrem { 72636201Sjulian struct worklist dm_list; /* delayed worklist */ 72736201Sjulian# define dm_state dm_list.wk_state /* state of the old directory entry */ 72860938Sjake LIST_ENTRY(dirrem) dm_next; /* pagedep's list of dirrem's */ 729207141Sjeff LIST_ENTRY(dirrem) dm_inonext; /* inodedep's list of dirrem's */ 730207141Sjeff struct jremrefhd dm_jremrefhd; /* Pending remove reference deps. */ 73136201Sjulian ino_t dm_oldinum; /* inum of the removed dir entry */ 732222958Sjeff doff_t dm_offset; /* offset of removed dir entry in blk */ 73336201Sjulian union { 73436201Sjulian struct pagedep *dmu_pagedep; /* pagedep dependency for remove */ 73536201Sjulian ino_t dmu_dirinum; /* parent inode number (for rmdir) */ 73636201Sjulian } dm_un; 737207141Sjeff struct workhead dm_jwork; /* Journal work awaiting completion. */ 73836201Sjulian}; 739262779Spfg#define dm_pagedep dm_un.dmu_pagedep 740262779Spfg#define dm_dirinum dm_un.dmu_dirinum 74176724Smckusick 74276724Smckusick/* 74376724Smckusick * A "newdirblk" structure tracks the progress of a newly allocated 74476724Smckusick * directory block from its creation until it is claimed by its on-disk 74576724Smckusick * inode. When a block is allocated to a directory, an fsync of a file 74676724Smckusick * whose name is within that block must ensure not only that the block 74776724Smckusick * containing the file name has been written, but also that the on-disk 74876724Smckusick * inode references that block. When a new directory block is created, 74976724Smckusick * we allocate a newdirblk structure which is linked to the associated 75076724Smckusick * allocdirect (on its ad_newdirblk list). When the allocdirect has been 75176724Smckusick * satisfied, the newdirblk structure is moved to the inodedep id_bufwait 75276724Smckusick * list of its directory to await the inode being written. When the inode 75376724Smckusick * is written, the directory entries are fully committed and can be 75476724Smckusick * deleted from their pagedep->id_pendinghd and inodedep->id_pendinghd 75576724Smckusick * lists. Note that we could track directory blocks allocated to indirect 75676724Smckusick * blocks using a similar scheme with the allocindir structures. Rather 75776724Smckusick * than adding this level of complexity, we simply write those newly 75876724Smckusick * allocated indirect blocks synchronously as such allocations are rare. 759207141Sjeff * In the case of a new directory the . and .. links are tracked with 760207141Sjeff * a mkdir rather than a pagedep. In this case we track the mkdir 761207141Sjeff * so it can be released when it is written. A workhead is used 762207141Sjeff * to simplify canceling a mkdir that is removed by a subsequent dirrem. 76376724Smckusick */ 76476724Smckusickstruct newdirblk { 76576724Smckusick struct worklist db_list; /* id_inowait or pg_newdirblk */ 766222958Sjeff# define db_state db_list.wk_state 76776724Smckusick struct pagedep *db_pagedep; /* associated pagedep */ 768207141Sjeff struct workhead db_mkdir; 76976724Smckusick}; 770207141Sjeff 771207141Sjeff/* 772207141Sjeff * The inoref structure holds the elements common to jaddref and jremref 773207141Sjeff * so they may easily be queued in-order on the inodedep. 774207141Sjeff */ 775207141Sjeffstruct inoref { 776212617Smckusick struct worklist if_list; /* Journal pending or jseg entries. */ 777207141Sjeff# define if_state if_list.wk_state 778207141Sjeff TAILQ_ENTRY(inoref) if_deps; /* Links for inodedep. */ 779212617Smckusick struct jsegdep *if_jsegdep; /* Will track our journal record. */ 780207141Sjeff off_t if_diroff; /* Directory offset. */ 781207141Sjeff ino_t if_ino; /* Inode number. */ 782207141Sjeff ino_t if_parent; /* Parent inode number. */ 783207141Sjeff nlink_t if_nlink; /* nlink before addition. */ 784207141Sjeff uint16_t if_mode; /* File mode, needed for IFMT. */ 785207141Sjeff}; 786207141Sjeff 787207141Sjeff/* 788207141Sjeff * A "jaddref" structure tracks a new reference (link count) on an inode 789207141Sjeff * and prevents the link count increase and bitmap allocation until a 790207141Sjeff * journal entry can be written. Once the journal entry is written, 791207141Sjeff * the inode is put on the pendinghd of the bmsafemap and a diradd or 792207141Sjeff * mkdir entry is placed on the bufwait list of the inode. The DEPCOMPLETE 793207141Sjeff * flag is used to indicate that all of the required information for writing 794207141Sjeff * the journal entry is present. MKDIR_BODY and MKDIR_PARENT are used to 795207141Sjeff * differentiate . and .. links from regular file names. NEWBLOCK indicates 796207141Sjeff * a bitmap is still pending. If a new reference is canceled by a delete 797207141Sjeff * prior to writing the journal the jaddref write is canceled and the 798207141Sjeff * structure persists to prevent any disk-visible changes until it is 799207141Sjeff * ultimately released when the file is freed or the link is dropped again. 800207141Sjeff */ 801207141Sjeffstruct jaddref { 802212617Smckusick struct inoref ja_ref; /* see inoref above. */ 803212617Smckusick# define ja_list ja_ref.if_list /* Jrnl pending, id_inowait, dm_jwork.*/ 804207141Sjeff# define ja_state ja_ref.if_list.wk_state 805207141Sjeff LIST_ENTRY(jaddref) ja_bmdeps; /* Links for bmsafemap. */ 806207141Sjeff union { 807207141Sjeff struct diradd *jau_diradd; /* Pending diradd. */ 808207141Sjeff struct mkdir *jau_mkdir; /* MKDIR_{PARENT,BODY} */ 809207141Sjeff } ja_un; 810207141Sjeff}; 811207141Sjeff#define ja_diradd ja_un.jau_diradd 812207141Sjeff#define ja_mkdir ja_un.jau_mkdir 813207141Sjeff#define ja_diroff ja_ref.if_diroff 814207141Sjeff#define ja_ino ja_ref.if_ino 815207141Sjeff#define ja_parent ja_ref.if_parent 816207141Sjeff#define ja_mode ja_ref.if_mode 817207141Sjeff 818207141Sjeff/* 819207141Sjeff * A "jremref" structure tracks a removed reference (unlink) on an 820207141Sjeff * inode and prevents the directory remove from proceeding until the 821207141Sjeff * journal entry is written. Once the journal has been written the remove 822207141Sjeff * may proceed as normal. 823207141Sjeff */ 824207141Sjeffstruct jremref { 825212617Smckusick struct inoref jr_ref; /* see inoref above. */ 826212617Smckusick# define jr_list jr_ref.if_list /* Linked to softdep_journal_pending. */ 827207141Sjeff# define jr_state jr_ref.if_list.wk_state 828212617Smckusick LIST_ENTRY(jremref) jr_deps; /* Links for dirrem. */ 829207141Sjeff struct dirrem *jr_dirrem; /* Back pointer to dirrem. */ 830207141Sjeff}; 831207141Sjeff 832212617Smckusick/* 833212617Smckusick * A "jmvref" structure tracks a name relocations within the same 834212617Smckusick * directory block that occur as a result of directory compaction. 835212617Smckusick * It prevents the updated directory entry from being written to disk 836212617Smckusick * until the journal entry is written. Once the journal has been 837212617Smckusick * written the compacted directory may be written to disk. 838212617Smckusick */ 839207141Sjeffstruct jmvref { 840212617Smckusick struct worklist jm_list; /* Linked to softdep_journal_pending. */ 841212617Smckusick LIST_ENTRY(jmvref) jm_deps; /* Jmvref on pagedep. */ 842212617Smckusick struct pagedep *jm_pagedep; /* Back pointer to pagedep. */ 843212617Smckusick ino_t jm_parent; /* Containing directory inode number. */ 844212617Smckusick ino_t jm_ino; /* Inode number of our entry. */ 845212617Smckusick off_t jm_oldoff; /* Our old offset in directory. */ 846212617Smckusick off_t jm_newoff; /* Our new offset in directory. */ 847207141Sjeff}; 848207141Sjeff 849207141Sjeff/* 850207141Sjeff * A "jnewblk" structure tracks a newly allocated block or fragment and 851207141Sjeff * prevents the direct or indirect block pointer as well as the cg bitmap 852207141Sjeff * from being written until it is logged. After it is logged the jsegdep 853207141Sjeff * is attached to the allocdirect or allocindir until the operation is 854207141Sjeff * completed or reverted. If the operation is reverted prior to the journal 855207141Sjeff * write the jnewblk structure is maintained to prevent the bitmaps from 856207141Sjeff * reaching the disk. Ultimately the jnewblk structure will be passed 857207141Sjeff * to the free routine as the in memory cg is modified back to the free 858212617Smckusick * state at which time it can be released. It may be held on any of the 859212617Smckusick * fx_jwork, fw_jwork, fb_jwork, ff_jwork, nb_jwork, or ir_jwork lists. 860207141Sjeff */ 861207141Sjeffstruct jnewblk { 862212617Smckusick struct worklist jn_list; /* See lists above. */ 863207141Sjeff# define jn_state jn_list.wk_state 864212617Smckusick struct jsegdep *jn_jsegdep; /* Will track our journal record. */ 865212617Smckusick LIST_ENTRY(jnewblk) jn_deps; /* Jnewblks on sm_jnewblkhd. */ 866220406Sjeff struct worklist *jn_dep; /* Dependency to ref completed seg. */ 867212617Smckusick ufs_lbn_t jn_lbn; /* Lbn to which allocated. */ 868212617Smckusick ufs2_daddr_t jn_blkno; /* Blkno allocated */ 869222958Sjeff ino_t jn_ino; /* Ino to which allocated. */ 870212617Smckusick int jn_oldfrags; /* Previous fragments when extended. */ 871212617Smckusick int jn_frags; /* Number of fragments. */ 872207141Sjeff}; 873207141Sjeff 874207141Sjeff/* 875222958Sjeff * A "jblkdep" structure tracks jfreeblk and jtrunc records attached to a 876222958Sjeff * freeblks structure. 877222958Sjeff */ 878222958Sjeffstruct jblkdep { 879222958Sjeff struct worklist jb_list; /* For softdep journal pending. */ 880222958Sjeff struct jsegdep *jb_jsegdep; /* Reference to the jseg. */ 881222958Sjeff struct freeblks *jb_freeblks; /* Back pointer to freeblks. */ 882222958Sjeff LIST_ENTRY(jblkdep) jb_deps; /* Dep list on freeblks. */ 883222958Sjeff 884222958Sjeff}; 885222958Sjeff 886222958Sjeff/* 887207141Sjeff * A "jfreeblk" structure tracks the journal write for freeing a block 888207141Sjeff * or tree of blocks. The block pointer must not be cleared in the inode 889212617Smckusick * or indirect prior to the jfreeblk being written to the journal. 890207141Sjeff */ 891207141Sjeffstruct jfreeblk { 892222958Sjeff struct jblkdep jf_dep; /* freeblks linkage. */ 893212617Smckusick ufs_lbn_t jf_lbn; /* Lbn from which blocks freed. */ 894212617Smckusick ufs2_daddr_t jf_blkno; /* Blkno being freed. */ 895222958Sjeff ino_t jf_ino; /* Ino from which blocks freed. */ 896212617Smckusick int jf_frags; /* Number of frags being freed. */ 897207141Sjeff}; 898207141Sjeff 899207141Sjeff/* 900207141Sjeff * A "jfreefrag" tracks the freeing of a single block when a fragment is 901207141Sjeff * extended or an indirect page is replaced. It is not part of a larger 902207141Sjeff * freeblks operation. 903207141Sjeff */ 904207141Sjeffstruct jfreefrag { 905212617Smckusick struct worklist fr_list; /* Linked to softdep_journal_pending. */ 906207141Sjeff# define fr_state fr_list.wk_state 907212617Smckusick struct jsegdep *fr_jsegdep; /* Will track our journal record. */ 908212617Smckusick struct freefrag *fr_freefrag; /* Back pointer to freefrag. */ 909212617Smckusick ufs_lbn_t fr_lbn; /* Lbn from which frag freed. */ 910212617Smckusick ufs2_daddr_t fr_blkno; /* Blkno being freed. */ 911222958Sjeff ino_t fr_ino; /* Ino from which frag freed. */ 912212617Smckusick int fr_frags; /* Size of frag being freed. */ 913207141Sjeff}; 914207141Sjeff 915207141Sjeff/* 916222958Sjeff * A "jtrunc" journals the intent to truncate an inode's data or extent area. 917207141Sjeff */ 918207141Sjeffstruct jtrunc { 919222958Sjeff struct jblkdep jt_dep; /* freeblks linkage. */ 920222958Sjeff off_t jt_size; /* Final file size. */ 921222958Sjeff int jt_extsize; /* Final extent size. */ 922222958Sjeff ino_t jt_ino; /* Ino being truncated. */ 923207141Sjeff}; 924207141Sjeff 925207141Sjeff/* 926222958Sjeff * A "jfsync" journals the completion of an fsync which invalidates earlier 927222958Sjeff * jtrunc records in the journal. 928222958Sjeff */ 929222958Sjeffstruct jfsync { 930222958Sjeff struct worklist jfs_list; /* For softdep journal pending. */ 931222958Sjeff off_t jfs_size; /* Sync file size. */ 932222958Sjeff int jfs_extsize; /* Sync extent size. */ 933222958Sjeff ino_t jfs_ino; /* ino being synced. */ 934222958Sjeff}; 935222958Sjeff 936222958Sjeff/* 937207141Sjeff * A "jsegdep" structure tracks a single reference to a written journal 938207141Sjeff * segment so the journal space can be reclaimed when all dependencies 939212617Smckusick * have been written. It can hang off of id_inowait, dm_jwork, da_jwork, 940212617Smckusick * nb_jwork, ff_jwork, or fb_jwork lists. 941207141Sjeff */ 942207141Sjeffstruct jsegdep { 943212617Smckusick struct worklist jd_list; /* See above for lists. */ 944207141Sjeff# define jd_state jd_list.wk_state 945212617Smckusick struct jseg *jd_seg; /* Our journal record. */ 946207141Sjeff}; 947207141Sjeff 948207141Sjeff/* 949207141Sjeff * A "jseg" structure contains all of the journal records written in a 950212617Smckusick * single disk write. The jaddref and jremref structures are linked into 951207141Sjeff * js_entries so thay may be completed when the write completes. The 952212617Smckusick * js_entries also include the write dependency structures: jmvref, 953212617Smckusick * jnewblk, jfreeblk, jfreefrag, and jtrunc. The js_refs field counts 954212617Smckusick * the number of entries on the js_entries list. Thus there is a single 955212617Smckusick * jseg entry to describe each journal write. 956207141Sjeff */ 957207141Sjeffstruct jseg { 958207141Sjeff struct worklist js_list; /* b_deps link for journal */ 959207141Sjeff# define js_state js_list.wk_state 960207141Sjeff struct workhead js_entries; /* Entries awaiting write */ 961220511Sjeff LIST_HEAD(, freework) js_indirs;/* List of indirects in this seg. */ 962212617Smckusick TAILQ_ENTRY(jseg) js_next; /* List of all unfinished segments. */ 963207141Sjeff struct jblocks *js_jblocks; /* Back pointer to block/seg list */ 964207141Sjeff struct buf *js_buf; /* Buffer while unwritten */ 965212617Smckusick uint64_t js_seq; /* Journal record sequence number. */ 966220511Sjeff uint64_t js_oldseq; /* Oldest valid sequence number. */ 967212617Smckusick int js_size; /* Size of journal record in bytes. */ 968212617Smckusick int js_cnt; /* Total items allocated. */ 969212617Smckusick int js_refs; /* Count of js_entries items. */ 970207141Sjeff}; 971207141Sjeff 972207141Sjeff/* 973207141Sjeff * A 'sbdep' structure tracks the head of the free inode list and 974207141Sjeff * superblock writes. This makes sure the superblock is always pointing at 975207141Sjeff * the first possible unlinked inode for the suj recovery process. If a 976207141Sjeff * block write completes and we discover a new head is available the buf 977212617Smckusick * is dirtied and the dep is kept. See the description of the UNLINK* 978212617Smckusick * flags above for more details. 979207141Sjeff */ 980207141Sjeffstruct sbdep { 981207141Sjeff struct worklist sb_list; /* b_dep linkage */ 982207141Sjeff struct fs *sb_fs; /* Filesystem pointer within buf. */ 983212617Smckusick struct ufsmount *sb_ump; /* Our mount structure */ 984207141Sjeff}; 985260078Smckusick 986260078Smckusick/* 987260078Smckusick * Private journaling structures. 988260078Smckusick */ 989260078Smckusickstruct jblocks { 990260078Smckusick struct jseglst jb_segs; /* TAILQ of current segments. */ 991260078Smckusick struct jseg *jb_writeseg; /* Next write to complete. */ 992260078Smckusick struct jseg *jb_oldestseg; /* Oldest segment with valid entries. */ 993260078Smckusick struct jextent *jb_extent; /* Extent array. */ 994260078Smckusick uint64_t jb_nextseq; /* Next sequence number. */ 995260078Smckusick uint64_t jb_oldestwrseq; /* Oldest written sequence number. */ 996260078Smckusick uint8_t jb_needseg; /* Need a forced segment. */ 997260078Smckusick uint8_t jb_suspended; /* Did journal suspend writes? */ 998260078Smckusick int jb_avail; /* Available extents. */ 999260078Smckusick int jb_used; /* Last used extent. */ 1000260078Smckusick int jb_head; /* Allocator head. */ 1001260078Smckusick int jb_off; /* Allocator extent offset. */ 1002260078Smckusick int jb_blocks; /* Total disk blocks covered. */ 1003260078Smckusick int jb_free; /* Total disk blocks free. */ 1004260078Smckusick int jb_min; /* Minimum free space. */ 1005260078Smckusick int jb_low; /* Low on space. */ 1006260078Smckusick int jb_age; /* Insertion time of oldest rec. */ 1007260078Smckusick}; 1008260078Smckusick 1009260078Smckusickstruct jextent { 1010260078Smckusick ufs2_daddr_t je_daddr; /* Disk block address. */ 1011260078Smckusick int je_blocks; /* Disk block count. */ 1012260078Smckusick}; 1013260078Smckusick 1014260078Smckusick/* 1015260078Smckusick * Hash table declarations. 1016260078Smckusick */ 1017260078SmckusickLIST_HEAD(mkdirlist, mkdir); 1018260078SmckusickLIST_HEAD(pagedep_hashhead, pagedep); 1019260078SmckusickLIST_HEAD(inodedep_hashhead, inodedep); 1020260078SmckusickLIST_HEAD(newblk_hashhead, newblk); 1021260078SmckusickLIST_HEAD(bmsafemap_hashhead, bmsafemap); 1022260078SmckusickTAILQ_HEAD(indir_hashhead, freework); 1023260078Smckusick 1024260078Smckusick/* 1025260078Smckusick * Per-filesystem soft dependency data. 1026260078Smckusick * Allocated at mount and freed at unmount. 1027260078Smckusick */ 1028260078Smckusickstruct mount_softdeps { 1029270157Smckusick struct rwlock sd_fslock; /* softdep lock */ 1030260078Smckusick struct workhead sd_workitem_pending; /* softdep work queue */ 1031260078Smckusick struct worklist *sd_worklist_tail; /* Tail pointer for above */ 1032260078Smckusick struct workhead sd_journal_pending; /* journal work queue */ 1033260078Smckusick struct worklist *sd_journal_tail; /* Tail pointer for above */ 1034260078Smckusick struct jblocks *sd_jblocks; /* Journal block information */ 1035260078Smckusick struct inodedeplst sd_unlinked; /* Unlinked inodes */ 1036260078Smckusick struct bmsafemaphd sd_dirtycg; /* Dirty CGs */ 1037260078Smckusick struct mkdirlist sd_mkdirlisthd; /* Track mkdirs */ 1038260078Smckusick struct pagedep_hashhead *sd_pdhash; /* pagedep hash table */ 1039260078Smckusick u_long sd_pdhashsize; /* pagedep hash table size-1 */ 1040260078Smckusick long sd_pdnextclean; /* next hash bucket to clean */ 1041260078Smckusick struct inodedep_hashhead *sd_idhash; /* inodedep hash table */ 1042260078Smckusick u_long sd_idhashsize; /* inodedep hash table size-1 */ 1043260078Smckusick long sd_idnextclean; /* next hash bucket to clean */ 1044260078Smckusick struct newblk_hashhead *sd_newblkhash; /* newblk hash table */ 1045260078Smckusick u_long sd_newblkhashsize; /* newblk hash table size-1 */ 1046260078Smckusick struct bmsafemap_hashhead *sd_bmhash; /* bmsafemap hash table */ 1047260078Smckusick u_long sd_bmhashsize; /* bmsafemap hash table size-1*/ 1048260078Smckusick struct indir_hashhead *sd_indirhash; /* indir hash table */ 1049260078Smckusick u_long sd_indirhashsize; /* indir hash table size-1 */ 1050260078Smckusick int sd_on_journal; /* Items on the journal list */ 1051260078Smckusick int sd_on_worklist; /* Items on the worklist */ 1052260078Smckusick int sd_deps; /* Total dependency count */ 1053260078Smckusick int sd_accdeps; /* accumulated dep count */ 1054260078Smckusick int sd_req; /* Wakeup when deps hits 0. */ 1055270157Smckusick int sd_flags; /* comm with flushing thread */ 1056270157Smckusick int sd_cleanups; /* Calls to cleanup */ 1057270157Smckusick struct thread *sd_flushtd; /* thread handling flushing */ 1058270157Smckusick TAILQ_ENTRY(mount_softdeps) sd_next; /* List of softdep filesystem */ 1059270157Smckusick struct ufsmount *sd_ump; /* our ufsmount structure */ 1060260078Smckusick u_long sd_curdeps[D_LAST + 1]; /* count of current deps */ 1061260078Smckusick}; 1062260078Smckusick/* 1063270157Smckusick * Flags for communicating with the syncer thread. 1064270157Smckusick */ 1065270157Smckusick#define FLUSH_EXIT 0x0001 /* time to exit */ 1066270157Smckusick#define FLUSH_CLEANUP 0x0002 /* need to clear out softdep structures */ 1067278667Skib#define FLUSH_STARTING 0x0004 /* flush thread not yet started */ 1068278667Skib 1069270157Smckusick/* 1070260078Smckusick * Keep the old names from when these were in the ufsmount structure. 1071260078Smckusick */ 1072262779Spfg#define softdep_workitem_pending um_softdep->sd_workitem_pending 1073262779Spfg#define softdep_worklist_tail um_softdep->sd_worklist_tail 1074262779Spfg#define softdep_journal_pending um_softdep->sd_journal_pending 1075262779Spfg#define softdep_journal_tail um_softdep->sd_journal_tail 1076262779Spfg#define softdep_jblocks um_softdep->sd_jblocks 1077262779Spfg#define softdep_unlinked um_softdep->sd_unlinked 1078262779Spfg#define softdep_dirtycg um_softdep->sd_dirtycg 1079262779Spfg#define softdep_mkdirlisthd um_softdep->sd_mkdirlisthd 1080262779Spfg#define pagedep_hashtbl um_softdep->sd_pdhash 1081262779Spfg#define pagedep_hash_size um_softdep->sd_pdhashsize 1082262779Spfg#define pagedep_nextclean um_softdep->sd_pdnextclean 1083262779Spfg#define inodedep_hashtbl um_softdep->sd_idhash 1084262779Spfg#define inodedep_hash_size um_softdep->sd_idhashsize 1085262779Spfg#define inodedep_nextclean um_softdep->sd_idnextclean 1086262779Spfg#define newblk_hashtbl um_softdep->sd_newblkhash 1087262779Spfg#define newblk_hash_size um_softdep->sd_newblkhashsize 1088262779Spfg#define bmsafemap_hashtbl um_softdep->sd_bmhash 1089262779Spfg#define bmsafemap_hash_size um_softdep->sd_bmhashsize 1090262779Spfg#define indir_hashtbl um_softdep->sd_indirhash 1091262779Spfg#define indir_hash_size um_softdep->sd_indirhashsize 1092262779Spfg#define softdep_on_journal um_softdep->sd_on_journal 1093262779Spfg#define softdep_on_worklist um_softdep->sd_on_worklist 1094262779Spfg#define softdep_deps um_softdep->sd_deps 1095262779Spfg#define softdep_accdeps um_softdep->sd_accdeps 1096262779Spfg#define softdep_req um_softdep->sd_req 1097270157Smckusick#define softdep_flags um_softdep->sd_flags 1098270157Smckusick#define softdep_flushtd um_softdep->sd_flushtd 1099262779Spfg#define softdep_curdeps um_softdep->sd_curdeps 1100