More fix

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