can't get_block(NO_DEV) any more

. 'anonymous' cache blocks (retrieved with NO_DEV as dev
	  parameter) were used to implement read()s from holes in
	  inodes that should return zeroes
	. this is an awkward special case in the cache code though
	  and there's a more direct way to implement the same functionality:
	  instead of copying from a new, anonymous, zero block, to
	  the user target buffer, simply sys_safememset the user target
	  buffer directly. as this was the only use of this feature,
	  this is all that's needed to simplify the cache code a little.
This commit is contained in:
Ben Gras
2012-11-12 19:15:10 +01:00
parent 2d43bf5807
commit a89ec8bc3b
3 changed files with 49 additions and 47 deletions

View File

@@ -237,8 +237,12 @@ int *completed; /* number of bytes copied */
if (!block_spec && b == NO_BLOCK) {
if (rw_flag == READING) {
/* Reading from a nonexistent block. Must read as all zeros.*/
bp = get_block(NO_DEV, NO_BLOCK, NORMAL); /* get a buffer */
zero_block(bp);
r = sys_safememset(VFS_PROC_NR, gid, (vir_bytes) buf_off,
0, (size_t) chunk);
if(r != OK) {
printf("ext2fs: sys_safememset failed\n");
}
return r;
} else {
/* Writing to a nonexistent block. Create and enter in inode.*/
if ((bp = new_block(rip, (off_t) ex64lo(position))) == NULL)

View File

@@ -246,8 +246,12 @@ int *completed; /* number of bytes copied */
if (!block_spec && b == NO_BLOCK) {
if (rw_flag == READING) {
/* Reading from a nonexistent block. Must read as all zeros.*/
bp = get_block(NO_DEV, NO_BLOCK, NORMAL); /* get a buffer */
zero_block(bp);
r = sys_safememset(VFS_PROC_NR, gid, (vir_bytes) buf_off,
0, (size_t) chunk);
if(r != OK) {
printf("MFS: sys_safememset failed\n");
}
return r;
} else {
/* Writing to a nonexistent block. Create and enter in inode.*/
if ((bp = new_block(rip, (off_t) ex64lo(position))) == NULL)