On Wed, Jan 22 2014, Robert Baldyga wrote: > This patch adds asynchronous I/O support for FunctionFS endpoint files. > It adds ffs_epfile_aio_write() and ffs_epfile_aio_read() functions responsible > for preparing AIO operations. > > It also modifies ffs_epfile_io() function, adding aio handling code. Instead > of extending list of parameters of this function, there is new struct > ffs_io_data which contains all information needed to perform I/O operation. > Pointer to this struct replaces "buf" and "len" parameters of ffs_epfile_io() > function. Allocated buffer is freed immediately only after sync operation, > because in async IO it's freed in complete funcion. For each async operation > an USB request is allocated, because it allows to have more than one request > queued on single endpoint. > > According to changes in ffs_epfile_io() function, functions ffs_epfile_write() > and ffs_epfile_read() are updated to use new API. > > For asynchronous I/O operations there is new request complete function named > ffs_epfile_async_io_complete(), which completes AIO operation, and frees > used memory. > > Signed-off-by: Robert Baldyga <r.baldyga@xxxxxxxxxxx> Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx> Just minor nit picks related to use of sizeof operator: > +static ssize_t ffs_epfile_aio_write(struct kiocb *kiocb, > + const struct iovec *iovec, > + unsigned long nr_segs, loff_t loff) > +{ > + struct ffs_io_data *io_data; > + > + ENTER(); > + > + io_data = kmalloc(sizeof(struct ffs_io_data), GFP_KERNEL); io_data = kmalloc(sizeof(*io_data), GFP_KERNEL); > + if (unlikely(!io_data)) > + return -ENOMEM; > + > + io_data->aio = true; > + io_data->read = false; > + io_data->kiocb = kiocb; > + io_data->iovec = iovec; > + io_data->nr_segs = nr_segs; > + io_data->len = kiocb->ki_nbytes; > + io_data->mm = current->mm; > + > + kiocb->private = io_data; > + > + kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > + > + return ffs_epfile_io(kiocb->ki_filp, io_data); > +} > + > +static ssize_t ffs_epfile_aio_read(struct kiocb *kiocb, > + const struct iovec *iovec, > + unsigned long nr_segs, loff_t loff) > +{ > + struct ffs_io_data *io_data; > + struct iovec *iovec_copy; > + > + ENTER(); > + > + iovec_copy = kmalloc(sizeof(struct iovec)*nr_segs, GFP_KERNEL); iovec_copy = kmalloc_array(nr_segs, sizeof(*iovec_copy), GFP_KERNEL); > + if (unlikely(!iovec_copy)) > + return -ENOMEM; > + > + memcpy(iovec_copy, iovec, sizeof(struct iovec)*nr_segs); > + > + io_data = kmalloc(sizeof(struct ffs_io_data), GFP_KERNEL); io_data = kmalloc(sizeof(*io_data), GFP_KERNEL); > + if (unlikely(!io_data)) { > + kfree(iovec_copy); > + return -ENOMEM; > + } > + > + io_data->aio = true; > + io_data->read = true; > + io_data->kiocb = kiocb; > + io_data->iovec = iovec_copy; > + io_data->nr_segs = nr_segs; > + io_data->len = kiocb->ki_nbytes; > + io_data->mm = current->mm; > + > + kiocb->private = io_data; > + > + kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > + > + return ffs_epfile_io(kiocb->ki_filp, io_data); > +} > + -- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--
Attachment:
signature.asc
Description: PGP signature