VFS: Implement REQ_BPEEK.
This commit introduces a new request type called REQ_BPEEK. It requests minor device blocks from the FS. Analogously to REQ_PEEK, it requests the filesystem to get the requested blocks into its cache, without actually copying the result anywhere. Change-Id: If1d06645b0e17553a64b3167091e9d12efeb3d6f
This commit is contained in:
@@ -855,3 +855,33 @@ int lmfs_rdwt_err(void)
|
||||
return rdwt_err;
|
||||
}
|
||||
|
||||
int lmfs_do_bpeek(message *m)
|
||||
{
|
||||
block_t startblock, b, limitblock;
|
||||
dev_t dev = m->REQ_DEV2;
|
||||
u64_t extra, pos = make64(m->REQ_SEEK_POS_LO, m->REQ_SEEK_POS_HI);
|
||||
size_t len = m->REQ_NBYTES;
|
||||
struct buf *bp;
|
||||
|
||||
assert(m->m_type == REQ_BPEEK);
|
||||
assert(fs_block_size > 0);
|
||||
assert(dev != NO_DEV);
|
||||
|
||||
if((extra=(pos % fs_block_size))) {
|
||||
pos -= extra;
|
||||
len += extra;
|
||||
}
|
||||
|
||||
len = roundup(len, fs_block_size);
|
||||
|
||||
startblock = pos/fs_block_size;
|
||||
limitblock = startblock + len/fs_block_size;
|
||||
|
||||
for(b = startblock; b < limitblock; b++) {
|
||||
bp = lmfs_get_block(dev, b, NORMAL);
|
||||
assert(bp);
|
||||
lmfs_put_block(bp, FULL_DATA_BLOCK);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -43,4 +43,6 @@ int (*fs_call_vec[])(void) = {
|
||||
fs_rdlink, /* 30 */
|
||||
fs_getdents, /* 31 */
|
||||
fs_statvfs, /* 32 */
|
||||
no_sys, /* 33 peek */
|
||||
no_sys, /* 34 bpeek */
|
||||
};
|
||||
|
||||
@@ -42,6 +42,7 @@ int (*call_vec[])(void) = {
|
||||
do_getdents, /* 31 getdents */
|
||||
do_statvfs, /* 32 statvfs */
|
||||
no_sys, /* 33 peek */
|
||||
no_sys, /* 33 bpeek */
|
||||
};
|
||||
|
||||
/* This should not fail with "array size is negative": */
|
||||
|
||||
@@ -38,6 +38,7 @@ int (*fs_call_vec[])(void) = {
|
||||
fs_getdents, /* 31 getdents */
|
||||
fs_statvfs, /* 32 statvfs */
|
||||
no_sys, /* 33 peek */
|
||||
no_sys, /* 34 bpeek */
|
||||
};
|
||||
|
||||
/* This should not fail with "array size is negative": */
|
||||
|
||||
Reference in New Issue
Block a user