[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tyndur-devel] [PATCH 4/6] cdi/fs: Readahead implementiert
+ cdi/fs: Für Dateien (nicht für Verzeichnisse) wird das Readahead-Flag
gesetzt. read ist jetzt ein Wrapper um readahead.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
src/modules/cdi/lib/fs/fs.c | 3 +++
src/modules/cdi/lib/fs/lostio_if.c | 22 +++++++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/modules/cdi/lib/fs/fs.c b/src/modules/cdi/lib/fs/fs.c
index 11777eb..dddf9ee 100644
--- a/src/modules/cdi/lib/fs/fs.c
+++ b/src/modules/cdi/lib/fs/fs.c
@@ -49,6 +49,8 @@ bool lostio_not_found_handler(char** path, uint8_t args, pid_t pid,
FILE* source);
bool lostio_pre_open_handler(char** path, uint8_t args, pid_t pid,
FILE* source);
+size_t lostio_readahead_handler(lostio_filehandle_t* fh, void* buf,
+ size_t bs, size_t bc);
size_t lostio_read_handler(lostio_filehandle_t* fh, void* buf,
size_t bs, size_t bc);
size_t lostio_write_handler(lostio_filehandle_t* fh, size_t bs, size_t bc,
@@ -66,6 +68,7 @@ typehandle_t cdi_typehandle = {
.pre_open = &lostio_pre_open_handler,
.post_open = NULL,
.read = &lostio_read_handler,
+ .readahead = &lostio_readahead_handler,
.write = &lostio_write_handler,
.seek = &lostio_seek_handler,
.unlink = &lostio_unlink_handler,
diff --git a/src/modules/cdi/lib/fs/lostio_if.c b/src/modules/cdi/lib/fs/lostio_if.c
index 4f3271e..e3375dd 100644
--- a/src/modules/cdi/lib/fs/lostio_if.c
+++ b/src/modules/cdi/lib/fs/lostio_if.c
@@ -131,6 +131,7 @@ static int handle_dirent(struct cdi_fs_res* res, vfstree_node_t* node)
if (res->file) {
size = res->res->meta_read(s, CDI_FS_META_SIZE);
+ flags |= LOSTIO_FLAG_READAHEAD;
}
}
@@ -378,7 +379,7 @@ bool lostio_pre_open_handler(char** path, uint8_t args, pid_t pid,
return true;
}
-size_t lostio_read_handler(lostio_filehandle_t* fh, void* buf,
+size_t lostio_readahead_handler(lostio_filehandle_t* fh, void* buf,
size_t bs, size_t bc)
{
size_t size = 0;
@@ -404,16 +405,27 @@ size_t lostio_read_handler(lostio_filehandle_t* fh, void* buf,
size = dh->res->file->read(dh, fh->pos, size, buf);
- fh->pos += size;
+out:
+ v();
+ return size;
+}
+
+size_t lostio_read_handler(lostio_filehandle_t* fh, void* buf,
+ size_t bs, size_t bc)
+{
+ size_t ret;
+
+ p();
+ ret = lostio_readahead_handler(fh, buf, bs, bc);
+ fh->pos += ret;
if(fh->pos >= fh->node->size) {
fh->flags |= LOSTIO_FLAG_EOF;
} else {
fh->flags &= ~LOSTIO_FLAG_EOF;
}
-
-out:
v();
- return size;
+
+ return ret;
}
size_t lostio_write_handler(lostio_filehandle_t* fh, size_t bs, size_t bc,
--
1.7.7