mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Convert the vnode clean/dirty attached buffer lists from LISTs to TAILQs.
Add a new flags field (we get this for free because of struct packing) for cleaner management of tailq membership. We had two spare b_flags slots, but they are a precious resource and may be needed for other things that are related to other b_flags bits. The two new flags are convenient to use in a seperate location. Reviewed (in principle) by: dg Obtained from: John Dyson's old work-in-progress
This commit is contained in:
parent
3ab1f0562c
commit
630ff66320
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40786
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)buf.h 8.9 (Berkeley) 3/30/95
|
||||
* $Id: buf.h,v 1.58 1998/09/25 17:34:49 peter Exp $
|
||||
* $Id: buf.h,v 1.59 1998/10/03 16:19:27 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_BUF_H_
|
||||
@ -44,8 +44,6 @@
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define NOLIST ((struct buf *)0x87654321)
|
||||
|
||||
struct buf;
|
||||
struct mount;
|
||||
struct vnode;
|
||||
@ -83,13 +81,14 @@ struct iodone_chain {
|
||||
*/
|
||||
struct buf {
|
||||
LIST_ENTRY(buf) b_hash; /* Hash chain. */
|
||||
LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
|
||||
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
|
||||
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
|
||||
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
|
||||
struct proc *b_proc; /* Associated proc; NULL if kernel. */
|
||||
long b_flags; /* B_* flags. */
|
||||
unsigned short b_qindex; /* buffer queue index */
|
||||
unsigned char b_usecount; /* buffer use count */
|
||||
unsigned char b_xflags; /* extra flags */
|
||||
int b_error; /* Errno value. */
|
||||
long b_bufsize; /* Allocated buffer size. */
|
||||
long b_bcount; /* Valid bytes in buffer. */
|
||||
@ -170,6 +169,12 @@ struct buf {
|
||||
"\17locked\16inval\15avail2\14error\13eintr\12done\11freebuf" \
|
||||
"\10delwri\7call\6cache\5busy\4bad\3async\2needcommit\1age"
|
||||
|
||||
/*
|
||||
* These flags are kept in b_xflags.
|
||||
*/
|
||||
#define B_VNDIRTY 0x01 /* On vnode dirty list */
|
||||
#define B_VNCLEAN 0x02 /* On vnode clean list */
|
||||
|
||||
#define NOOFFSET (-1LL) /* No buffer offset calculated yet */
|
||||
|
||||
struct buf_queue_head {
|
||||
@ -217,9 +222,8 @@ bufq_remove(struct buf_queue_head *head, struct buf *bp)
|
||||
head->insert_point = TAILQ_PREV(bp, buf_queue, b_act);
|
||||
if (head->insert_point == NULL)
|
||||
head->last_pblkno = 0;
|
||||
} else if (bp == TAILQ_FIRST(&head->queue)) {
|
||||
} else if (bp == TAILQ_FIRST(&head->queue))
|
||||
head->last_pblkno = bp->b_pblkno;
|
||||
}
|
||||
TAILQ_REMOVE(&head->queue, bp, b_act);
|
||||
if (TAILQ_FIRST(&head->queue) == head->switch_point)
|
||||
head->switch_point = NULL;
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)buf.h 8.9 (Berkeley) 3/30/95
|
||||
* $Id: buf.h,v 1.58 1998/09/25 17:34:49 peter Exp $
|
||||
* $Id: buf.h,v 1.59 1998/10/03 16:19:27 bde Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_BUF_H_
|
||||
@ -44,8 +44,6 @@
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#define NOLIST ((struct buf *)0x87654321)
|
||||
|
||||
struct buf;
|
||||
struct mount;
|
||||
struct vnode;
|
||||
@ -83,13 +81,14 @@ struct iodone_chain {
|
||||
*/
|
||||
struct buf {
|
||||
LIST_ENTRY(buf) b_hash; /* Hash chain. */
|
||||
LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
|
||||
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
|
||||
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
|
||||
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
|
||||
struct proc *b_proc; /* Associated proc; NULL if kernel. */
|
||||
long b_flags; /* B_* flags. */
|
||||
unsigned short b_qindex; /* buffer queue index */
|
||||
unsigned char b_usecount; /* buffer use count */
|
||||
unsigned char b_xflags; /* extra flags */
|
||||
int b_error; /* Errno value. */
|
||||
long b_bufsize; /* Allocated buffer size. */
|
||||
long b_bcount; /* Valid bytes in buffer. */
|
||||
@ -170,6 +169,12 @@ struct buf {
|
||||
"\17locked\16inval\15avail2\14error\13eintr\12done\11freebuf" \
|
||||
"\10delwri\7call\6cache\5busy\4bad\3async\2needcommit\1age"
|
||||
|
||||
/*
|
||||
* These flags are kept in b_xflags.
|
||||
*/
|
||||
#define B_VNDIRTY 0x01 /* On vnode dirty list */
|
||||
#define B_VNCLEAN 0x02 /* On vnode clean list */
|
||||
|
||||
#define NOOFFSET (-1LL) /* No buffer offset calculated yet */
|
||||
|
||||
struct buf_queue_head {
|
||||
@ -217,9 +222,8 @@ bufq_remove(struct buf_queue_head *head, struct buf *bp)
|
||||
head->insert_point = TAILQ_PREV(bp, buf_queue, b_act);
|
||||
if (head->insert_point == NULL)
|
||||
head->last_pblkno = 0;
|
||||
} else if (bp == TAILQ_FIRST(&head->queue)) {
|
||||
} else if (bp == TAILQ_FIRST(&head->queue))
|
||||
head->last_pblkno = bp->b_pblkno;
|
||||
}
|
||||
TAILQ_REMOVE(&head->queue, bp, b_act);
|
||||
if (TAILQ_FIRST(&head->queue) == head->switch_point)
|
||||
head->switch_point = NULL;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)vnode.h 8.7 (Berkeley) 2/4/94
|
||||
* $Id: vnode.h,v 1.75 1998/10/16 03:55:01 peter Exp $
|
||||
* $Id: vnode.h,v 1.76 1998/10/29 09:51:28 peter Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_VNODE_H_
|
||||
@ -69,7 +69,7 @@ enum vtagtype {
|
||||
* Each underlying filesystem allocates its own private area and hangs
|
||||
* it from v_data. If non-null, this area is freed in getnewvnode().
|
||||
*/
|
||||
LIST_HEAD(buflists, buf);
|
||||
TAILQ_HEAD(buflists, buf);
|
||||
|
||||
typedef int vop_t __P((void *));
|
||||
struct namecache;
|
||||
|
Loading…
Reference in New Issue
Block a user