summaryrefslogtreecommitdiff
path: root/src/kernel/vfs/request.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/vfs/request.c')
-rw-r--r--src/kernel/vfs/request.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c
index 4489f5a..d4ea16c 100644
--- a/src/kernel/vfs/request.c
+++ b/src/kernel/vfs/request.c
@@ -33,19 +33,7 @@ vfsreq_dispatchcopy(VfsReq tmpl)
VfsBackend *backend;
/* allocate memory for the request and move it there */
- if (tmpl.caller) {
- // TODO: ensure we aren't overriding an existing request
- // TODO: wouldn't it be better to just optimize malloc?
- // see commit afa28cfc7069f7649632f7b33daac47ee56d3819
- proc_setstate(tmpl.caller, PS_WAITS4FS);
- if (!tmpl.caller->reqslot)
- tmpl.caller->reqslot = kmalloc(sizeof *req, "reqslot");
- req = tmpl.caller->reqslot;
- /* (re)using a single allocation for all request a process makes */
- } else {
- req = kmalloc(sizeof *req, "reqanon");
- }
-
+ req = kmalloc(sizeof *req, "VfsReq");
memcpy(req, &tmpl, sizeof *req);
backend = req->backend;
if (backend) {
@@ -53,6 +41,11 @@ vfsreq_dispatchcopy(VfsReq tmpl)
backend->usehcnt++;
}
+ if (req->caller) {
+ proc_setstate(req->caller, PS_WAITS4FS);
+ req->caller->reqslot = req;
+ }
+
/* Check request validity. Doing this after the memcpy means that it
* doesn't need to be special cased in vfsreq_finish. */
if (!vfsreq_isvalid(req)) {
@@ -125,9 +118,8 @@ vfsreq_finish(VfsReq *req, char __user *stored, long ret, int flags, Proc *handl
assert(req->caller->state == PS_WAITS4FS);
regs_savereturn(&req->caller->regs, ret);
proc_setstate(req->caller, PS_RUNNING);
- } else {
- kfree(req);
}
+ kfree(req);
}
void