1/* 2 * Copyright (c) 1994,1997 John S. Dyson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * Author: John S. Dyson 22 * Significant help during the development and debugging phases 23 * had been provided by David Greenman, also of the FreeBSD core team. 24 * 25 * see man buf(9) for more info. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/kern/vfs_bio.c 130640 2004-06-17 17:16:53Z phk $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/bio.h> 34#include <sys/conf.h> 35#include <sys/buf.h> 36#include <sys/devicestat.h> 37#include <sys/eventhandler.h> --- 474 unchanged lines hidden (view full) --- 512 for (i = 0; i < BUFFER_QUEUES; i++) 513 TAILQ_INIT(&bufqueues[i]); 514 515 /* finally, initialize each buffer header and stick on empty q */ 516 for (i = 0; i < nbuf; i++) { 517 bp = &buf[i]; 518 bzero(bp, sizeof *bp); 519 bp->b_flags = B_INVAL; /* we're just an empty header */ |
520 bp->b_dev = NULL; |
521 bp->b_rcred = NOCRED; 522 bp->b_wcred = NOCRED; 523 bp->b_qindex = QUEUE_EMPTY; 524 bp->b_vflags = 0; 525 bp->b_xflags = 0; 526 LIST_INIT(&bp->b_dep); 527 BUF_LOCKINIT(bp); 528 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_EMPTY], bp, b_freelist); --- 879 unchanged lines hidden (view full) --- 1408 if (bp->b_vflags & BV_BKGRDINPROG) 1409 panic("losing buffer 1"); 1410 if (bp->b_kvasize) { 1411 bp->b_qindex = QUEUE_EMPTYKVA; 1412 } else { 1413 bp->b_qindex = QUEUE_EMPTY; 1414 } 1415 TAILQ_INSERT_HEAD(&bufqueues[bp->b_qindex], bp, b_freelist); |
1416 bp->b_dev = NULL; |
1417 /* buffers with junk contents */ 1418 } else if (bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF) || 1419 (bp->b_ioflags & BIO_ERROR)) { 1420 bp->b_flags |= B_INVAL; 1421 bp->b_xflags &= ~(BX_BKGRDWRITE | BX_ALTDATA); 1422 if (bp->b_vflags & BV_BKGRDINPROG) 1423 panic("losing buffer 2"); 1424 bp->b_qindex = QUEUE_CLEAN; 1425 TAILQ_INSERT_HEAD(&bufqueues[QUEUE_CLEAN], bp, b_freelist); |
1426 bp->b_dev = NULL; |
1427 /* remaining buffers */ 1428 } else { 1429 if (bp->b_flags & B_DELWRI) 1430 bp->b_qindex = QUEUE_DIRTY; 1431 else 1432 bp->b_qindex = QUEUE_CLEAN; 1433 if (bp->b_flags & B_AGE) 1434 TAILQ_INSERT_HEAD(&bufqueues[bp->b_qindex], bp, b_freelist); --- 477 unchanged lines hidden (view full) --- 1912 1913 if (bp->b_bufsize) 1914 allocbuf(bp, 0); 1915 1916 bp->b_flags = 0; 1917 bp->b_ioflags = 0; 1918 bp->b_xflags = 0; 1919 bp->b_vflags = 0; |
1920 bp->b_dev = NULL; |
1921 bp->b_vp = NULL; 1922 bp->b_blkno = bp->b_lblkno = 0; 1923 bp->b_offset = NOOFFSET; 1924 bp->b_iodone = 0; 1925 bp->b_error = 0; 1926 bp->b_resid = 0; 1927 bp->b_bcount = 0; 1928 bp->b_npages = 0; --- 1878 unchanged lines hidden --- |