summaryrefslogtreecommitdiffstats
path: root/sys/contrib/softupdates
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1998-05-19 22:54:53 +0000
committerjulian <julian@FreeBSD.org>1998-05-19 22:54:53 +0000
commit988e3e4a342a4c2530586875d9aebf700b1b4354 (patch)
tree298a2013d9e7d6e9d33a788ae11192a6103b2ed9 /sys/contrib/softupdates
parenta3d6984f734f5eb36f7c3913947b77d09dfd325f (diff)
downloadFreeBSD-src-988e3e4a342a4c2530586875d9aebf700b1b4354.zip
FreeBSD-src-988e3e4a342a4c2530586875d9aebf700b1b4354.tar.gz
Merge with Kirk's version as of Feb 20
His version 9.23 == our version 1.5 of ffs_softdep.c His version 9.5 == our version 1.4 of softdep.c
Diffstat (limited to 'sys/contrib/softupdates')
-rw-r--r--sys/contrib/softupdates/ffs_softdep.c174
1 files changed, 86 insertions, 88 deletions
diff --git a/sys/contrib/softupdates/ffs_softdep.c b/sys/contrib/softupdates/ffs_softdep.c
index b86bb2a..25acbd2 100644
--- a/sys/contrib/softupdates/ffs_softdep.c
+++ b/sys/contrib/softupdates/ffs_softdep.c
@@ -53,7 +53,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)ffs_softdep.c 9.21 (McKusick) 2/15/98
+ * @(#)ffs_softdep.c 9.23 (McKusick) 2/20/98
*/
/*
@@ -75,7 +75,6 @@
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/vnode.h>
-/*#include <machine/pcpu.h>*/
#include <miscfs/specfs/specdev.h>
#include <ufs/ufs/dir.h>
#include <ufs/ufs/quota.h>
@@ -87,63 +86,9 @@
#include <ufs/ufs/ufs_extern.h>
/*
- * Internal function prototypes.
- */
-static void softdep_error __P((char *, int));
-static int getdirtybuf __P((struct buf **, int));
-static int flush_pagedep_deps __P((struct vnode *, struct mount *,
- struct diraddhd *));
-static int flush_inodedep_deps __P((struct fs *, ino_t));
-static int handle_written_filepage __P((struct pagedep *, struct buf *));
-static void diradd_inode_written __P((struct diradd *, struct inodedep *));
-static int handle_written_inodeblock __P((struct inodedep *, struct buf *));
-static void handle_allocdirect_partdone __P((struct allocdirect *));
-static void handle_allocindir_partdone __P((struct allocindir *));
-static void initiate_write_filepage __P((struct pagedep *, struct buf *));
-static void handle_written_mkdir __P((struct mkdir *, int));
-static void initiate_write_inodeblock __P((struct inodedep *, struct buf *));
-static void handle_workitem_freefile __P((struct freefile *));
-static void handle_workitem_remove __P((struct dirrem *));
-static struct dirrem *newdirrem __P((struct buf *, struct inode *,
- struct inode *, int));
-static void free_diradd __P((struct diradd *));
-static void free_allocindir __P((struct allocindir *, struct inodedep *));
-static int indir_trunc __P((struct inode *, ufs_daddr_t, int, ufs_lbn_t,
- long *));
-static void deallocate_dependencies __P((struct buf *, struct inodedep *));
-static void free_allocdirect __P((struct allocdirectlst *,
- struct allocdirect *, int));
-static int free_inodedep __P((struct inodedep *));
-static void handle_workitem_freeblocks __P((struct freeblks *));
-static void merge_inode_lists __P((struct inodedep *));
-static void setup_allocindir_phase2 __P((struct buf *, struct inode *,
- struct allocindir *));
-static struct allocindir *newallocindir __P((struct inode *, int, ufs_daddr_t,
- ufs_daddr_t));
-static void handle_workitem_freefrag __P((struct freefrag *));
-static struct freefrag *newfreefrag __P((struct inode *, ufs_daddr_t, long));
-static void allocdirect_merge __P((struct allocdirectlst *,
- struct allocdirect *, struct allocdirect *));
-static struct bmsafemap *bmsafemap_lookup __P((struct buf *));
-static int newblk_lookup __P((struct fs *, ufs_daddr_t, int,
- struct newblk **));
-static int inodedep_lookup __P((struct fs *, ino_t, int, struct inodedep **));
-static int pagedep_lookup __P((struct inode *, ufs_lbn_t, int,
- struct pagedep **));
-static void pause_timer __P((void *));
-static int checklimit __P((long *, int));
-static void add_to_worklist __P((struct worklist *));
-
-/*
- * Exported softdep operations.
+ * These definitions need to be adapted to the system to which
+ * this file is being ported.
*/
-struct bio_ops bioops = {
- softdep_disk_io_initiation, /* io_start */
- softdep_disk_write_complete, /* io_complete */
- softdep_deallocate_dependencies, /* io_deallocate */
- softdep_process_worklist, /* io_sync */
-};
-
/*
* malloc types defined for the softdep system.
*/
@@ -201,7 +146,70 @@ static struct malloc_type *memtype[] = {
/*
* Names of malloc types.
*/
-#define TYPENAME(type) ((unsigned)(type) < D_LAST ? memtype[type]->ks_shortdesc : "???")
+#define TYPENAME(type) \
+ ((unsigned)(type) < D_LAST ? memtype[type]->ks_shortdesc : "???")
+#define CURPROC curproc
+/*
+ * End system adaptaion definitions.
+ */
+
+/*
+ * Internal function prototypes.
+ */
+static void softdep_error __P((char *, int));
+static int getdirtybuf __P((struct buf **, int));
+static int flush_pagedep_deps __P((struct vnode *, struct mount *,
+ struct diraddhd *));
+static int flush_inodedep_deps __P((struct fs *, ino_t));
+static int handle_written_filepage __P((struct pagedep *, struct buf *));
+static void diradd_inode_written __P((struct diradd *, struct inodedep *));
+static int handle_written_inodeblock __P((struct inodedep *, struct buf *));
+static void handle_allocdirect_partdone __P((struct allocdirect *));
+static void handle_allocindir_partdone __P((struct allocindir *));
+static void initiate_write_filepage __P((struct pagedep *, struct buf *));
+static void handle_written_mkdir __P((struct mkdir *, int));
+static void initiate_write_inodeblock __P((struct inodedep *, struct buf *));
+static void handle_workitem_freefile __P((struct freefile *));
+static void handle_workitem_remove __P((struct dirrem *));
+static struct dirrem *newdirrem __P((struct buf *, struct inode *,
+ struct inode *, int));
+static void free_diradd __P((struct diradd *));
+static void free_allocindir __P((struct allocindir *, struct inodedep *));
+static int indir_trunc __P((struct inode *, ufs_daddr_t, int, ufs_lbn_t,
+ long *));
+static void deallocate_dependencies __P((struct buf *, struct inodedep *));
+static void free_allocdirect __P((struct allocdirectlst *,
+ struct allocdirect *, int));
+static int free_inodedep __P((struct inodedep *));
+static void handle_workitem_freeblocks __P((struct freeblks *));
+static void merge_inode_lists __P((struct inodedep *));
+static void setup_allocindir_phase2 __P((struct buf *, struct inode *,
+ struct allocindir *));
+static struct allocindir *newallocindir __P((struct inode *, int, ufs_daddr_t,
+ ufs_daddr_t));
+static void handle_workitem_freefrag __P((struct freefrag *));
+static struct freefrag *newfreefrag __P((struct inode *, ufs_daddr_t, long));
+static void allocdirect_merge __P((struct allocdirectlst *,
+ struct allocdirect *, struct allocdirect *));
+static struct bmsafemap *bmsafemap_lookup __P((struct buf *));
+static int newblk_lookup __P((struct fs *, ufs_daddr_t, int,
+ struct newblk **));
+static int inodedep_lookup __P((struct fs *, ino_t, int, struct inodedep **));
+static int pagedep_lookup __P((struct inode *, ufs_lbn_t, int,
+ struct pagedep **));
+static void pause_timer __P((void *));
+static int checklimit __P((long *, int));
+static void add_to_worklist __P((struct worklist *));
+
+/*
+ * Exported softdep operations.
+ */
+struct bio_ops bioops = {
+ softdep_disk_io_initiation, /* io_start */
+ softdep_disk_write_complete, /* io_complete */
+ softdep_deallocate_dependencies, /* io_deallocate */
+ softdep_process_worklist, /* io_sync */
+};
/*
* Locking primitives.
@@ -250,12 +258,12 @@ acquire_lock(lk)
{
if (lk->lkt_held != -1)
- if (lk->lkt_held == curproc->p_pid)
+ if (lk->lkt_held == CURPROC->p_pid)
panic("softdep_lock: locking against myself");
else
panic("softdep_lock: lock held by %d", lk->lkt_held);
lk->lkt_spl = splbio();
- lk->lkt_held = curproc->p_pid;
+ lk->lkt_held = CURPROC->p_pid;
lockcnt++;
}
@@ -276,12 +284,12 @@ acquire_lock_interlocked(lk)
{
if (lk->lkt_held != -1)
- if (lk->lkt_held == curproc->p_pid)
+ if (lk->lkt_held == CURPROC->p_pid)
panic("softdep_lock_interlocked: locking against self");
else
panic("softdep_lock_interlocked: lock held by %d",
lk->lkt_held);
- lk->lkt_held = curproc->p_pid;
+ lk->lkt_held = CURPROC->p_pid;
lockcnt++;
}
@@ -340,7 +348,7 @@ sema_get(semap, interlock)
}
return (0);
}
- semap->holder = curproc->p_pid;
+ semap->holder = CURPROC->p_pid;
if (interlock != NULL)
FREE_LOCK(interlock);
return (1);
@@ -351,7 +359,7 @@ sema_release(semap)
struct sema *semap;
{
- if (semap->value <= 0 || semap->holder != curproc->p_pid)
+ if (semap->value <= 0 || semap->holder != CURPROC->p_pid)
panic("sema_release: not held");
if (--semap->value > 0) {
semap->value = 0;
@@ -445,10 +453,10 @@ SYSCTL_INT(_debug, OID_AUTO, tickdelay, CTLFLAG_RW, &tickdelay, 0, "");
SYSCTL_INT(_debug, OID_AUTO, max_limit_hit, CTLFLAG_RW, &max_limit_hit, 0, "");
SYSCTL_INT(_debug, OID_AUTO, rush_requests, CTLFLAG_RW, &rush_requests, 0, "");
#else /* !__FreeBSD__ */
-struct ctldebug debug4 = { "max_softdeps", &max_softdeps };
-struct ctldebug debug5 = { "tickdelay", &tickdelay };
-struct ctldebug debug6 = { "max_limit_hit", &max_limit_hit };
-struct ctldebug debug7 = { "rush_requests", &rush_requests };
+struct ctldebug debug8 = { "max_softdeps", &max_softdeps };
+struct ctldebug debug9 = { "tickdelay", &tickdelay };
+struct ctldebug debug10 = { "max_limit_hit", &max_limit_hit };
+struct ctldebug debug11 = { "rush_requests", &rush_requests };
#endif /* !__FreeBSD__ */
#endif /* DEBUG */
@@ -490,7 +498,7 @@ int
softdep_process_worklist(matchmnt)
struct mount *matchmnt;
{
- struct proc *p = curproc;
+ struct proc *p = CURPROC;
struct worklist *wk;
struct fs *matchfs;
int matchcnt;
@@ -575,7 +583,7 @@ softdep_flushfiles(oldmnt, flags, p)
* Await our turn to clear out the queue.
*/
while (softdep_worklist_busy)
- tsleep(&lbolt, PRIBIO, "sdflsh", 0);
+ tsleep(&lbolt, PRIBIO, "softflush", 0);
softdep_worklist_busy = 1;
if ((error = ffs_flushfiles(oldmnt, flags, p)) != 0) {
softdep_worklist_busy = 0;
@@ -633,7 +641,7 @@ checklimit(resource, islocked)
long *resource;
int islocked;
{
- struct proc *p = curproc;
+ struct proc *p = CURPROC;
/*
* If we are under our limit, just proceed.
@@ -1677,8 +1685,6 @@ deallocate_dependencies(bp, inodedep)
struct pagedep *pagedep;
struct dirrem *dirrem;
struct diradd *dap;
- long tmpsize;
- caddr_t tmp;
int i;
while ((wk = LIST_FIRST(&bp->b_dep)) != NULL) {
@@ -2132,13 +2138,9 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp)
mkdir2->md_list.wk_type = D_MKDIR;
mkdir2->md_state = MKDIR_PARENT;
mkdir2->md_diradd = dap;
-
ACQUIRE_LOCK(&lk);
/*
- * If this directory entry references a new directory, create
- * its two additional dependencies: its "." and ".." being
- * written to disk and the link count increase for its
- * parent directory.
+ * Dependency on "." and ".." being written to disk.
*/
LIST_INSERT_HEAD(&mkdirlisthd, mkdir1, md_mkdirs);
WORKLIST_INSERT(&newdirbp->b_dep, &mkdir1->md_list);
@@ -2468,7 +2470,7 @@ static void
handle_workitem_remove(dirrem)
struct dirrem *dirrem;
{
- struct proc *p = curproc; /* XXX */
+ struct proc *p = CURPROC; /* XXX */
struct inodedep *inodedep;
struct vnode *vp;
struct inode *ip;
@@ -3499,7 +3501,7 @@ softdep_fsync(vp)
struct inode *ip;
struct buf *bp;
struct fs *fs;
- struct proc *p = curproc; /* XXX */
+ struct proc *p = CURPROC; /* XXX */
int error, ret, flushparent;
struct timeval tv;
ino_t parentino;
@@ -3670,13 +3672,8 @@ loop:
if (adp->ad_state & DEPCOMPLETE)
break;
nbp = adp->ad_buf;
- if (getdirtybuf(&nbp, waitfor) == 0) {
-#if 0 /* [JRE] I suspect this should be here XXX */
- if (waitfor == MNT_NOWAIT)
- continue;
-#endif
+ if (getdirtybuf(&nbp, waitfor) == 0)
break;
- }
FREE_LOCK(&lk);
if (waitfor == MNT_NOWAIT) {
bawrite(nbp);
@@ -3917,7 +3914,7 @@ flush_pagedep_deps(pvp, mp, diraddhdp)
struct mount *mp;
struct diraddhd *diraddhdp;
{
- struct proc *p = curproc; /* XXX */
+ struct proc *p = CURPROC; /* XXX */
struct inodedep *inodedep;
struct ufsmount *ump;
struct diradd *dap;
@@ -4128,3 +4125,4 @@ softdep_error(func, error)
log(LOG_ERR, "%s: got error %d while accessing filesystem\n",
func, error);
}
+
OpenPOWER on IntegriCloud