1 struct buf { 2 int flags; 3 uint dev; 4 uint blockno; 5 struct sleeplock lock; 6 uint refcnt; 7 struct buf *prev; // LRU cache list 8 struct buf *next; 9 struct buf *qnext; // disk queue 10 uchar data[BSIZE]; 11 }; 12 #define B_VALID 0x2 // buffer has been read from disk 13 #define B_DIRTY 0x4 // buffer needs to be written to disk 14