diff options
author | Frans Kaashoek <[email protected]> | 2011-08-26 10:08:29 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2011-08-26 10:08:29 -0400 |
commit | 3a5fa7ed9020eaf8ab843a16d26db7393b2ec072 (patch) | |
tree | bfa4ad4ae03d7d21796bacaa7eab8e3d3e4ab365 /file.c | |
parent | 8a9b6dbd4468f6312f1d07226a623879f970bd4b (diff) | |
download | xv6-labs-3a5fa7ed9020eaf8ab843a16d26db7393b2ec072.tar.gz xv6-labs-3a5fa7ed9020eaf8ab843a16d26db7393b2ec072.tar.bz2 xv6-labs-3a5fa7ed9020eaf8ab843a16d26db7393b2ec072.zip |
Introduce and use sleeplocks instead of BUSY flags
Remove I_BUSY, B_BUSY, and intrans defs and usages
One spinlock per buf to avoid ugly loop in bget
fix race in filewrite (don't update f->off after releasing lock)
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -2,8 +2,8 @@ #include "defs.h" #include "param.h" #include "fs.h" -#include "file.h" #include "spinlock.h" +#include "file.h" struct devsw devsw[NDEV]; struct { @@ -133,7 +133,8 @@ filewrite(struct file *f, char *addr, int n) begin_trans(); ilock(f->ip); - r = writei(f->ip, addr + i, f->off, n1); + if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) + f->off += r; iunlock(f->ip); commit_trans(); @@ -141,7 +142,6 @@ filewrite(struct file *f, char *addr, int n) break; if(r != n1) panic("short filewrite"); - f->off += r; i += r; } return i == n ? n : -1; |