mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-28 11:57:28 +00:00
buf: Add a runningbufclaim() helper
No functional change intended. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D47696
This commit is contained in:
parent
0289db3259
commit
4efe531c9d
@ -206,7 +206,7 @@ static int sysctl_bufspace(SYSCTL_HANDLER_ARGS);
|
|||||||
int vmiodirenable = TRUE;
|
int vmiodirenable = TRUE;
|
||||||
SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0,
|
SYSCTL_INT(_vfs, OID_AUTO, vmiodirenable, CTLFLAG_RW, &vmiodirenable, 0,
|
||||||
"Use the VM system for directory writes");
|
"Use the VM system for directory writes");
|
||||||
long runningbufspace;
|
static long runningbufspace;
|
||||||
SYSCTL_LONG(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0,
|
SYSCTL_LONG(_vfs, OID_AUTO, runningbufspace, CTLFLAG_RD, &runningbufspace, 0,
|
||||||
"Amount of presently outstanding async buffer io");
|
"Amount of presently outstanding async buffer io");
|
||||||
SYSCTL_PROC(_vfs, OID_AUTO, bufspace, CTLTYPE_LONG|CTLFLAG_MPSAFE|CTLFLAG_RD,
|
SYSCTL_PROC(_vfs, OID_AUTO, bufspace, CTLTYPE_LONG|CTLFLAG_MPSAFE|CTLFLAG_RD,
|
||||||
@ -941,6 +941,16 @@ runningbufwakeup(struct buf *bp)
|
|||||||
runningwakeup();
|
runningwakeup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
runningbufclaim(struct buf *bp, int space)
|
||||||
|
{
|
||||||
|
long old;
|
||||||
|
|
||||||
|
old = atomic_fetchadd_long(&runningbufspace, space);
|
||||||
|
bp->b_runningbufspace = space;
|
||||||
|
return (old);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* waitrunningbufspace()
|
* waitrunningbufspace()
|
||||||
*
|
*
|
||||||
@ -2352,8 +2362,7 @@ bufwrite(struct buf *bp)
|
|||||||
/*
|
/*
|
||||||
* Normal bwrites pipeline writes
|
* Normal bwrites pipeline writes
|
||||||
*/
|
*/
|
||||||
bp->b_runningbufspace = bp->b_bufsize;
|
space = runningbufclaim(bp, bp->b_bufsize);
|
||||||
space = atomic_fetchadd_long(&runningbufspace, bp->b_runningbufspace);
|
|
||||||
|
|
||||||
#ifdef RACCT
|
#ifdef RACCT
|
||||||
if (racct_enable) {
|
if (racct_enable) {
|
||||||
|
@ -519,7 +519,6 @@ extern int nbuf; /* The number of buffer headers */
|
|||||||
extern u_long maxswzone; /* Max KVA for swap structures */
|
extern u_long maxswzone; /* Max KVA for swap structures */
|
||||||
extern u_long maxbcache; /* Max KVA for buffer cache */
|
extern u_long maxbcache; /* Max KVA for buffer cache */
|
||||||
extern int maxbcachebuf; /* Max buffer cache block size */
|
extern int maxbcachebuf; /* Max buffer cache block size */
|
||||||
extern long runningbufspace;
|
|
||||||
extern long hibufspace;
|
extern long hibufspace;
|
||||||
extern int dirtybufthresh;
|
extern int dirtybufthresh;
|
||||||
extern int bdwriteskip;
|
extern int bdwriteskip;
|
||||||
@ -536,6 +535,7 @@ buf_mapped(struct buf *bp)
|
|||||||
return (bp->b_data != unmapped_buf);
|
return (bp->b_data != unmapped_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long runningbufclaim(struct buf *, int);
|
||||||
void runningbufwakeup(struct buf *);
|
void runningbufwakeup(struct buf *);
|
||||||
void waitrunningbufspace(void);
|
void waitrunningbufspace(void);
|
||||||
caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);
|
caddr_t kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est);
|
||||||
|
@ -2343,9 +2343,8 @@ ffs_copyonwrite(struct vnode *devvp, struct buf *bp)
|
|||||||
TAILQ_EMPTY(&sn->sn_head)) {
|
TAILQ_EMPTY(&sn->sn_head)) {
|
||||||
VI_UNLOCK(devvp);
|
VI_UNLOCK(devvp);
|
||||||
if (saved_runningbufspace != 0) {
|
if (saved_runningbufspace != 0) {
|
||||||
bp->b_runningbufspace = saved_runningbufspace;
|
(void)runningbufclaim(bp,
|
||||||
atomic_add_long(&runningbufspace,
|
saved_runningbufspace);
|
||||||
bp->b_runningbufspace);
|
|
||||||
}
|
}
|
||||||
return (0); /* Snapshot gone */
|
return (0); /* Snapshot gone */
|
||||||
}
|
}
|
||||||
@ -2479,10 +2478,8 @@ ffs_copyonwrite(struct vnode *devvp, struct buf *bp)
|
|||||||
/*
|
/*
|
||||||
* I/O on bp will now be started, so count it in runningbufspace.
|
* I/O on bp will now be started, so count it in runningbufspace.
|
||||||
*/
|
*/
|
||||||
if (saved_runningbufspace != 0) {
|
if (saved_runningbufspace != 0)
|
||||||
bp->b_runningbufspace = saved_runningbufspace;
|
(void)runningbufclaim(bp, saved_runningbufspace);
|
||||||
atomic_add_long(&runningbufspace, bp->b_runningbufspace);
|
|
||||||
}
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2517,9 +2517,7 @@ ffs_geom_strategy(struct bufobj *bo, struct buf *bp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bp->b_runningbufspace = bp->b_bufsize;
|
(void)runningbufclaim(bp, bp->b_bufsize);
|
||||||
atomic_add_long(&runningbufspace,
|
|
||||||
bp->b_runningbufspace);
|
|
||||||
} else {
|
} else {
|
||||||
error = ffs_copyonwrite(vp, bp);
|
error = ffs_copyonwrite(vp, bp);
|
||||||
if (error != 0 && error != EOPNOTSUPP) {
|
if (error != 0 && error != EOPNOTSUPP) {
|
||||||
|
@ -717,8 +717,7 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m)
|
|||||||
bp->b_vp = vp;
|
bp->b_vp = vp;
|
||||||
bp->b_bcount = bsize;
|
bp->b_bcount = bsize;
|
||||||
bp->b_bufsize = bsize;
|
bp->b_bufsize = bsize;
|
||||||
bp->b_runningbufspace = bp->b_bufsize;
|
(void)runningbufclaim(bp, bp->b_bufsize);
|
||||||
atomic_add_long(&runningbufspace, bp->b_runningbufspace);
|
|
||||||
|
|
||||||
/* do the input */
|
/* do the input */
|
||||||
bp->b_iooffset = dbtob(bp->b_blkno);
|
bp->b_iooffset = dbtob(bp->b_blkno);
|
||||||
@ -1160,7 +1159,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int count,
|
|||||||
bp->b_wcred = crhold(curthread->td_ucred);
|
bp->b_wcred = crhold(curthread->td_ucred);
|
||||||
pbgetbo(bo, bp);
|
pbgetbo(bo, bp);
|
||||||
bp->b_vp = vp;
|
bp->b_vp = vp;
|
||||||
bp->b_bcount = bp->b_bufsize = bp->b_runningbufspace = bytecount;
|
bp->b_bcount = bp->b_bufsize = bytecount;
|
||||||
bp->b_iooffset = dbtob(bp->b_blkno);
|
bp->b_iooffset = dbtob(bp->b_blkno);
|
||||||
KASSERT(IDX_TO_OFF(m[0]->pindex - bp->b_pages[0]->pindex) ==
|
KASSERT(IDX_TO_OFF(m[0]->pindex - bp->b_pages[0]->pindex) ==
|
||||||
(blkno0 - bp->b_blkno) * DEV_BSIZE +
|
(blkno0 - bp->b_blkno) * DEV_BSIZE +
|
||||||
@ -1170,7 +1169,8 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int count,
|
|||||||
(uintmax_t)m[0]->pindex, (uintmax_t)bp->b_pages[0]->pindex,
|
(uintmax_t)m[0]->pindex, (uintmax_t)bp->b_pages[0]->pindex,
|
||||||
(uintmax_t)blkno0, (uintmax_t)bp->b_blkno));
|
(uintmax_t)blkno0, (uintmax_t)bp->b_blkno));
|
||||||
|
|
||||||
atomic_add_long(&runningbufspace, bp->b_runningbufspace);
|
(void)runningbufclaim(bp, bp->b_bufsize);
|
||||||
|
|
||||||
VM_CNT_INC(v_vnodein);
|
VM_CNT_INC(v_vnodein);
|
||||||
VM_CNT_ADD(v_vnodepgsin, bp->b_npages);
|
VM_CNT_ADD(v_vnodepgsin, bp->b_npages);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user