> + if ((ret > 0) && No need for the braces here. > + if (dio->is_async && iov_iter_rw(iter) == WRITE) { > + retval = 0; > + if ((iocb->ki_filp->f_flags & O_DSYNC) || > + IS_SYNC(iocb->ki_filp->f_mapping->host)) > + retval = dio_set_defer_completion(dio); > + else if (!dio->inode->i_sb->s_dio_done_wq) > + /* > + * In case of AIO write racing with buffered read we > + * need to defer completion. We can't decide this now, > + * however the workqueue needs to be initialized here. > + */ > + retval = sb_init_dio_done_wq(dio->inode->i_sb); So now we initialize the workqueue on the first aio write. Maybe we should just always initialize it? Especially given that the cost of a workqueue is rather cheap. I also don't really understand why we even need the workqueue per-superblock instead of global. > index 1732228..2f8dbf9 100644 > --- a/fs/iomap.c > +++ b/fs/iomap.c > @@ -713,8 +713,16 @@ struct iomap_dio { > static ssize_t iomap_dio_complete(struct iomap_dio *dio) > { > struct kiocb *iocb = dio->iocb; > + loff_t offset = iocb->ki_pos; If you introduce this variable please also use it later in the function instead of iocb->ki_pos. OR remove the variable, which would be fine with me as well. > + struct inode *inode = file_inode(iocb->ki_filp); > ssize_t ret; > > + if ((!dio->error) && no need for the inner braces.