1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Move the P_COWINPROGRESS flag from being a per-process p_flag to being a

per-thread td_pflag which doesn't require any locks to read or write as it
is only read or written by curthread on itself.

Glanced at by:	mckusick
This commit is contained in:
John Baldwin 2003-10-23 21:14:08 +00:00
parent 06cb76bde3
commit 787f162df6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=121443
4 changed files with 17 additions and 18 deletions

View File

@ -981,7 +981,7 @@ bdwrite(struct buf * bp)
*/
vp = bp->b_vp;
VI_LOCK(vp);
if (td->td_proc->p_flag & P_COWINPROGRESS) {
if (td->td_pflags & TDP_COWINPROGRESS) {
recursiveflushes++;
} else if (vp != NULL && vp->v_dirtybufcnt > dirtybufthresh + 10) {
VI_UNLOCK(vp);

View File

@ -358,6 +358,7 @@ struct thread {
#define TDP_INKTR 0x0002 /* Thread is currently in KTR code. */
#define TDP_INKTRACE 0x0004 /* Thread is currently in KTRACE code. */
#define TDP_UPCALLING 0x0008 /* This thread is doing an upcall. */
#define TDP_COWINPROGRESS 0x0010 /* Snapshot copy-on-write in progress. */
#define TDI_SUSPENDED 0x0001 /* On suspension queue. */
#define TDI_SLEEPING 0x0002 /* Actually asleep! (tricky). */
@ -641,8 +642,6 @@ struct proc {
/* (not to user) */
#define P_PROTECTED 0x100000 /* Do not kill on memory overcommit. */
#define P_SIGEVENT 0x200000 /* Process pending signals changed */
/* Should be moved to machine-dependent areas. */
#define P_COWINPROGRESS 0x400000 /* Snapshot copy-on-write in progress. */
#define P_JAILED 0x1000000 /* Process is in jail. */
#define P_ALTSTACK 0x2000000 /* Have alternate signal stack. */

View File

@ -822,10 +822,10 @@ expunge_ufs1(snapvp, cancelip, fs, acctfunc, expungetype)
if (lbn < NDADDR) {
blkno = VTOI(snapvp)->i_din1->di_db[lbn];
} else {
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(snapvp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, BA_METAONLY, &bp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
return (error);
indiroff = (lbn - NDADDR) % NINDIR(fs);
@ -1102,10 +1102,10 @@ expunge_ufs2(snapvp, cancelip, fs, acctfunc, expungetype)
if (lbn < NDADDR) {
blkno = VTOI(snapvp)->i_din2->di_db[lbn];
} else {
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(snapvp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, BA_METAONLY, &bp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
return (error);
indiroff = (lbn - NDADDR) % NINDIR(fs);
@ -1552,10 +1552,10 @@ ffs_snapblkfree(fs, devvp, bno, size, inum)
VI_MTX(devvp), td) != 0)
goto retry;
snapshot_locked = 1;
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
indiroff = (lbn - NDADDR) % NINDIR(fs);
@ -1659,10 +1659,10 @@ ffs_snapblkfree(fs, devvp, bno, size, inum)
* allocation will never require any additional allocations for
* the snapshot inode.
*/
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, 0, &cbp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
#ifdef DEBUG
@ -1930,7 +1930,7 @@ ffs_copyonwrite(devvp, bp)
ufs2_daddr_t lbn, blkno, *snapblklist;
int lower, upper, mid, indiroff, snapshot_locked = 0, error = 0;
if (td->td_proc->p_flag & P_COWINPROGRESS)
if (td->td_pflags & TDP_COWINPROGRESS)
panic("ffs_copyonwrite: recursive call");
/*
* First check to see if it is in the preallocated list.
@ -1988,10 +1988,10 @@ ffs_copyonwrite(devvp, bp)
goto retry;
}
snapshot_locked = 1;
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, BA_METAONLY, &ibp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
indiroff = (lbn - NDADDR) % NINDIR(fs);
@ -2025,10 +2025,10 @@ ffs_copyonwrite(devvp, bp)
goto retry;
}
snapshot_locked = 1;
td->td_proc->p_flag |= P_COWINPROGRESS;
td->td_pflags |= TDP_COWINPROGRESS;
error = UFS_BALLOC(vp, lblktosize(fs, (off_t)lbn),
fs->fs_bsize, KERNCRED, 0, &cbp);
td->td_proc->p_flag &= ~P_COWINPROGRESS;
td->td_pflags &= ~TDP_COWINPROGRESS;
if (error)
break;
#ifdef DEBUG

View File

@ -688,7 +688,7 @@ process_worklist_item(matchmnt, flags)
* copy-on-write, then it is not safe to write as we may
* recurse into the copy-on-write routine.
*/
if (curthread->td_proc->p_flag & P_COWINPROGRESS)
if (curthread->td_pflags & TDP_COWINPROGRESS)
return (-1);
ACQUIRE_LOCK(&lk);
/*
@ -5479,7 +5479,7 @@ softdep_request_cleanup(fs, vp)
* copy-on-write, then it is not safe to update the vnode
* as we may recurse into the copy-on-write routine.
*/
if ((curthread->td_proc->p_flag & P_COWINPROGRESS) == 0 &&
if (!(curthread->td_pflags & TDP_COWINPROGRESS) &&
UFS_UPDATE(vp, 1) != 0)
return (0);
while (fs->fs_pendingblocks > 0 && fs->fs_cstotal.cs_nbfree <= needed) {