@@ -154,6 +154,15 @@ bfree(int dev, uint b)
154
154
// Many internal file system functions expect the caller to
155
155
// have locked the inodes involved; this lets callers create
156
156
// multi-step atomic operations.
157
+ //
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.
162
+ //
163
+ // An ip->lock sleep-lock defends all ip-> fields other than ref,
164
+ // dev, and inum. One must hold ip->lock in order to
165
+ // read or write that inode's ip->valid, ip->size, ip->type, &c.
157
166
158
167
struct {
159
168
struct spinlock lock ;
@@ -205,6 +214,7 @@ ialloc(uint dev, short type)
205
214
}
206
215
207
216
// Copy a modified in-memory inode to disk.
217
+ // Caller must hold ip->lock.
208
218
void
209
219
iupdate (struct inode * ip )
210
220
{
@@ -421,6 +431,7 @@ itrunc(struct inode *ip)
421
431
}
422
432
423
433
// Copy stat information from inode.
434
+ // Caller must hold ip->lock.
424
435
void
425
436
stati (struct inode * ip , struct stat * st )
426
437
{
@@ -433,6 +444,7 @@ stati(struct inode *ip, struct stat *st)
433
444
434
445
//PAGEBREAK!
435
446
// Read data from inode.
447
+ // Caller must hold ip->lock.
436
448
int
437
449
readi (struct inode * ip , char * dst , uint off , uint n )
438
450
{
@@ -461,6 +473,7 @@ readi(struct inode *ip, char *dst, uint off, uint n)
461
473
462
474
// PAGEBREAK!
463
475
// Write data to inode.
476
+ // Caller must hold ip->lock.
464
477
int
465
478
writei (struct inode * ip , char * src , uint off , uint n )
466
479
{
0 commit comments