More fix

上级 b421af8e
...@@ -137,21 +137,21 @@ vmnode::loadpg(off_t off) ...@@ -137,21 +137,21 @@ vmnode::loadpg(off_t off)
mtreadavar("inode:%x.%x", ip->dev, ip->inum); mtreadavar("inode:%x.%x", ip->dev, ip->inum);
mtwriteavar("vmnode:%016x", this); mtwriteavar("vmnode:%016x", this);
#endif #endif
char *p = page[off/PGSIZE];
s64 n = sz-off < PGSIZE ? sz-off : PGSIZE; char *p = page[off/PGSIZE];
off += offset; s64 filen = off > sz ? 0 : MIN(PGSIZE, sz-off);
s64 filen = off > ip->size ? 0 : MIN(n, ip->size-off); off_t fileo = offset+off;
// //
// Possible race condition with concurrent loadpg() calls, // Possible race condition with concurrent loadpg() calls,
// if the underlying inode's contents change.. // if the underlying inode's contents change..
// //
if (readi(ip, p, off, filen) != filen) if (readi(ip, p, fileo, filen) != filen)
return -1; return -1;
// XXX(sbw) if we call vmnode::loadpg once for each page, // XXX(sbw), we should memset the remainder, but sometimes
// then we should memset(&p[filen], 0, n-filen) // we loadpg on a pg that already has content.
//memset(&p[filen], 0, PGSIZE-filen);
return 0; return 0;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论