summaryrefslogtreecommitdiffstats
path: root/sculld/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sculld/main.c')
-rw-r--r--sculld/main.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/sculld/main.c b/sculld/main.c
index 8a990e1..24d321c 100644
--- a/sculld/main.c
+++ b/sculld/main.c
@@ -408,31 +408,40 @@ loff_t sculld_llseek (struct file *filp, loff_t off, int whence)
struct async_work {
struct kiocb *iocb;
int result;
- struct work_struct work;
+ struct delayed_work work;
};
/*
* "Complete" an asynchronous operation.
*/
-static void sculld_do_deferred_op(void *p)
+static void sculld_do_deferred_op(struct work_struct *work)
{
- struct async_work *stuff = (struct async_work *) p;
+ struct async_work *stuff = container_of(work, struct async_work, work.work);
aio_complete(stuff->iocb, stuff->result, 0);
kfree(stuff);
}
-static int sculld_defer_op(int write, struct kiocb *iocb, char __user *buf,
- size_t count, loff_t pos)
+static int sculld_defer_op(int write, struct kiocb *iocb, const struct iovec *iovec,
+ unsigned long nr_segs, loff_t pos)
{
struct async_work *stuff;
- int result;
+ size_t result = 0;
+ size_t len = 0;
+ unsigned long seg = 0;
/* Copy now while we can access the buffer */
- if (write)
- result = sculld_write(iocb->ki_filp, buf, count, &pos);
- else
- result = sculld_read(iocb->ki_filp, buf, count, &pos);
+ for (seg = 0; seg < nr_segs; seg++){
+ if (write)
+ len = sculld_write(iocb->ki_filp, iovec[seg].iov_base, iovec[seg].iov_len, &pos);
+ else
+ len = sculld_read(iocb->ki_filp, iovec[seg].iov_base, iovec[seg].iov_len, &pos);
+
+ if (len < 0)
+ return len;
+
+ result += len;
+ }
/* If this is a synchronous IOCB, we return our status now. */
if (is_sync_kiocb(iocb))
@@ -444,22 +453,22 @@ static int sculld_defer_op(int write, struct kiocb *iocb, char __user *buf,
return result; /* No memory, just complete now */
stuff->iocb = iocb;
stuff->result = result;
- INIT_WORK(&stuff->work, sculld_do_deferred_op, stuff);
+ INIT_DELAYED_WORK(&stuff->work, sculld_do_deferred_op);
schedule_delayed_work(&stuff->work, HZ/100);
return -EIOCBQUEUED;
}
-static ssize_t sculld_aio_read(struct kiocb *iocb, char __user *buf, size_t count,
- loff_t pos)
+static ssize_t sculld_aio_read(struct kiocb *iocb, const struct iovec *iovec,
+ unsigned long nr_segs, loff_t pos)
{
- return sculld_defer_op(0, iocb, buf, count, pos);
+ return sculld_defer_op(0, iocb, iovec, nr_segs, pos);
}
-static ssize_t sculld_aio_write(struct kiocb *iocb, const char __user *buf,
- size_t count, loff_t pos)
+static ssize_t sculld_aio_write(struct kiocb *iocb, const struct iovec *iovec,
+ unsigned long nr_segs, loff_t pos)
{
- return sculld_defer_op(1, iocb, (char __user *) buf, count, pos);
+ return sculld_defer_op(1, iocb, iovec, nr_segs, pos);
}