Skip to content

Commit 7070596

Browse files
author
Robert Morris
committed
comment fixes
1 parent da3b931 commit 7070596

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

bio.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ bget(uint dev, uint blockno)
7575
}
7676
}
7777

78-
// Not cached; recycle some unused buffer and clean buffer
79-
// "clean" because B_DIRTY and not locked means log.c
80-
// hasn't yet committed the changes to the buffer.
78+
// Not cached; recycle an unused buffer.
79+
// Even if refcnt==0, B_DIRTY indicates a buffer is in use
80+
// because log.c has modified it but not yet committed it.
8181
for(b = bcache.head.prev; b != &bcache.head; b = b->prev){
8282
if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) {
8383
b->dev = dev;

fs.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ bfree(int dev, uint b)
155155
// have locked the inodes involved; this lets callers create
156156
// multi-step atomic operations.
157157
//
158-
// The icache.lock spin-lock defends ip->ref, ip->dev, and ip->inum.
159-
// Since ip->ref indicates whether an icache entry is free, the
160-
// icache.lock defends icache allocation. icache.lock also defends
161-
// all fields of an unallocated icache entry, during allocation.
158+
// The icache.lock spin-lock defends the allocation of icache
159+
// entries. Since ip->ref indicates whether an entry is free,
160+
// and ip->dev and ip->inum indicate which i-node an entry
161+
// holds, one must hold icache.lock while using any of those fields.
162162
//
163163
// An ip->lock sleep-lock defends all ip-> fields other than ref,
164164
// dev, and inum. One must hold ip->lock in order to
@@ -189,8 +189,9 @@ iinit(int dev)
189189
static struct inode* iget(uint dev, uint inum);
190190

191191
//PAGEBREAK!
192-
// Allocate a new inode with the given type on device dev.
193-
// A free inode has a type of zero.
192+
// Allocate an inode on device dev.
193+
// Give it type type.
194+
// Returns an unlocked but allocated and referenced inode.
194195
struct inode*
195196
ialloc(uint dev, short type)
196197
{
@@ -214,6 +215,8 @@ ialloc(uint dev, short type)
214215
}
215216

216217
// Copy a modified in-memory inode to disk.
218+
// Must be called after every change to an ip->xxx field
219+
// that lives on disk, since i-node cache is write-through.
217220
// Caller must hold ip->lock.
218221
void
219222
iupdate(struct inode *ip)

0 commit comments

Comments
 (0)