io->ci_ndelay = 0;
io->ci_designated_mirror = fd->fd_designated_mirror;
io->ci_layout_version = fd->fd_layout_version;
- io->ci_pio = 0; /* doesn't have a mechanism to pass mirror
- * io to ptasks */
}
CDEBUG(D_VFSTRACE, "%s: desiginated mirror: %d\n",
return false;
}
-static int ll_file_io_ptask(struct cfs_ptask *ptask);
-
static void ll_io_init(struct cl_io *io, struct file *file, enum cl_io_type iot)
{
struct inode *inode = file_inode(file);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
- memset(&io->u.ci_rw.rw_iter, 0, sizeof(io->u.ci_rw.rw_iter));
- init_sync_kiocb(&io->u.ci_rw.rw_iocb, file);
- io->u.ci_rw.rw_file = file;
- io->u.ci_rw.rw_ptask = ll_file_io_ptask;
- io->u.ci_rw.rw_nonblock = !!(file->f_flags & O_NONBLOCK);
+ io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
io->ci_lock_no_expand = fd->ll_lock_no_expand;
if (iot == CIT_WRITE) {
- io->u.ci_rw.rw_append = !!(file->f_flags & O_APPEND);
- io->u.ci_rw.rw_sync = !!(file->f_flags & O_SYNC ||
+ io->u.ci_wr.wr_append = !!(file->f_flags & O_APPEND);
+ io->u.ci_wr.wr_sync = !!(file->f_flags & O_SYNC ||
file->f_flags & O_DIRECT ||
IS_SYNC(inode));
}
io->ci_lockreq = CILR_MANDATORY;
}
io->ci_noatime = file_is_noatime(file);
- if (ll_i2sbi(inode)->ll_flags & LL_SBI_PIO)
- io->ci_pio = !io->u.ci_rw.rw_append;
- else
- io->ci_pio = 0;
/* FLR: only use non-delay I/O for read as there is only one
* avaliable mirror for write. */
ll_io_set_mirror(io, file);
}
-static int ll_file_io_ptask(struct cfs_ptask *ptask)
-{
- struct cl_io_pt *pt = ptask->pt_cbdata;
- struct file *file = pt->cip_file;
- struct lu_env *env;
- struct cl_io *io;
- loff_t pos = pt->cip_pos;
- int rc;
- __u16 refcheck;
- ENTRY;
-
- CDEBUG(D_VFSTRACE, "%s: %s range: [%llu, %llu)\n",
- file_dentry(file)->d_name.name,
- pt->cip_iot == CIT_READ ? "read" : "write",
- pos, pos + pt->cip_count);
-
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
-
- io = vvp_env_thread_io(env);
- ll_io_init(io, file, pt->cip_iot);
- io->u.ci_rw.rw_iter = pt->cip_iter;
- io->u.ci_rw.rw_iocb = pt->cip_iocb;
- io->ci_pio = 0; /* It's already in parallel task */
-
- rc = cl_io_rw_init(env, io, pt->cip_iot, pos,
- pt->cip_count - pt->cip_result);
- if (!rc) {
- struct vvp_io *vio = vvp_env_io(env);
-
- vio->vui_io_subtype = IO_NORMAL;
- vio->vui_fd = LUSTRE_FPRIVATE(file);
-
- ll_cl_add(file, env, io, LCC_RW);
- rc = cl_io_loop(env, io);
- ll_cl_remove(file, env);
- } else {
- /* cl_io_rw_init() handled IO */
- rc = io->ci_result;
- }
-
- if (OBD_FAIL_CHECK_RESET(OBD_FAIL_LLITE_PTASK_IO_FAIL, 0)) {
- if (io->ci_nob > 0)
- io->ci_nob /= 2;
- rc = -EIO;
- }
-
- if (io->ci_nob > 0) {
- pt->cip_result += io->ci_nob;
- iov_iter_advance(&pt->cip_iter, io->ci_nob);
- pos += io->ci_nob;
- pt->cip_iocb.ki_pos = pos;
-#ifdef HAVE_KIOCB_KI_LEFT
- pt->cip_iocb.ki_left = pt->cip_count - pt->cip_result;
-#elif defined(HAVE_KI_NBYTES)
- pt->cip_iocb.ki_nbytes = pt->cip_count - pt->cip_result;
-#endif
- }
-
- cl_io_fini(env, io);
- cl_env_put(env, &refcheck);
-
- pt->cip_need_restart = io->ci_need_restart;
-
- CDEBUG(D_VFSTRACE, "%s: %s ret: %zd, rc: %d\n",
- file_dentry(file)->d_name.name,
- pt->cip_iot == CIT_READ ? "read" : "write",
- pt->cip_result, rc);
-
- RETURN(pt->cip_result > 0 ? 0 : rc);
-}
-
static ssize_t
ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
struct file *file, enum cl_io_type iot,
loff_t *ppos, size_t count)
{
- struct range_lock range;
struct vvp_io *vio = vvp_env_io(env);
struct inode *inode = file_inode(file);
struct ll_inode_info *lli = ll_i2info(inode);
struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ struct range_lock range;
struct cl_io *io;
- loff_t pos = *ppos;
ssize_t result = 0;
int rc = 0;
unsigned retried = 0;
ENTRY;
- CDEBUG(D_VFSTRACE, "%s: %s range: [%llu, %llu)\n",
+ CDEBUG(D_VFSTRACE, "%s: %s ppos: %llu, count: %zu\n",
file_dentry(file)->d_name.name,
- iot == CIT_READ ? "read" : "write", pos, pos + count);
+ iot == CIT_READ ? "read" : "write", *ppos, count);
restart:
io = vvp_env_thread_io(env);
ll_io_init(io, file, iot);
- if (args->via_io_subtype == IO_NORMAL) {
- io->u.ci_rw.rw_iter = *args->u.normal.via_iter;
- io->u.ci_rw.rw_iocb = *args->u.normal.via_iocb;
- }
- if (args->via_io_subtype != IO_NORMAL || restarted)
- io->ci_pio = 0;
io->ci_ndelay_tried = retried;
- if (cl_io_rw_init(env, io, iot, pos, count) == 0) {
+ if (cl_io_rw_init(env, io, iot, *ppos, count) == 0) {
bool range_locked = false;
if (file->f_flags & O_APPEND)
range_lock_init(&range, 0, LUSTRE_EOF);
else
- range_lock_init(&range, pos, pos + count - 1);
+ range_lock_init(&range, *ppos, *ppos + count - 1);
vio->vui_fd = LUSTRE_FPRIVATE(file);
vio->vui_io_subtype = args->via_io_subtype;
switch (vio->vui_io_subtype) {
case IO_NORMAL:
+ vio->vui_iter = args->u.normal.via_iter;
+ vio->vui_iocb = args->u.normal.via_iocb;
/* Direct IO reads must also take range lock,
* or multiple reads will try to work on the same pages
* See LU-6227 for details. */
}
ll_cl_add(file, env, io, LCC_RW);
- if (io->ci_pio && iot == CIT_WRITE && !IS_NOSEC(inode) &&
- !lli->lli_inode_locked) {
- inode_lock(inode);
- lli->lli_inode_locked = 1;
- }
rc = cl_io_loop(env, io);
- if (lli->lli_inode_locked) {
- lli->lli_inode_locked = 0;
- inode_unlock(inode);
- }
ll_cl_remove(file, env);
if (range_locked) {
if (io->ci_nob > 0) {
result += io->ci_nob;
count -= io->ci_nob;
+ *ppos = io->u.ci_wr.wr.crw_pos; /* for splice */
- if (args->via_io_subtype == IO_NORMAL) {
- iov_iter_advance(args->u.normal.via_iter, io->ci_nob);
-
- /* CLIO is too complicated. See LU-11069. */
- if (cl_io_is_append(io))
- pos = io->u.ci_rw.rw_iocb.ki_pos;
- else
- pos += io->ci_nob;
-
- args->u.normal.via_iocb->ki_pos = pos;
-#ifdef HAVE_KIOCB_KI_LEFT
- args->u.normal.via_iocb->ki_left = count;
-#elif defined(HAVE_KI_NBYTES)
- args->u.normal.via_iocb->ki_nbytes = count;
-#endif
- } else {
- /* for splice */
- pos = io->u.ci_rw.rw_range.cir_pos;
- }
+ /* prepare IO restart */
+ if (count > 0 && args->via_io_subtype == IO_NORMAL)
+ args->u.normal.via_iter = vio->vui_iter;
}
out:
cl_io_fini(env, io);
if ((rc == 0 || rc == -ENODATA) && count > 0 && io->ci_need_restart) {
CDEBUG(D_VFSTRACE,
- "%s: restart %s range: [%llu, %llu) ret: %zd, rc: %d\n",
- file_dentry(file)->d_name.name,
- iot == CIT_READ ? "read" : "write",
- pos, pos + count, result, rc);
+ "%s: restart %s from %lld, count: %zu, ret: %zd, rc: %d\n",
+ file_dentry(file)->d_name.name,
+ iot == CIT_READ ? "read" : "write",
+ *ppos, count, result, rc);
/* preserve the tried count for FLR */
retried = io->ci_ndelay_tried;
restarted = true;
}
}
- CDEBUG(D_VFSTRACE, "%s: %s *ppos: %llu, pos: %llu, ret: %zd, rc: %d\n",
- file_dentry(file)->d_name.name,
- iot == CIT_READ ? "read" : "write", *ppos, pos, result, rc);
-
- *ppos = pos;
+ CDEBUG(D_VFSTRACE, "iot: %d, result: %zd\n", iot, result);
RETURN(result > 0 ? result : rc);
}
int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
{
struct dentry *dentry = file_dentry(file);
- bool lock_inode;
#elif defined(HAVE_FILE_FSYNC_2ARGS)
int ll_fsync(struct file *file, int datasync)
{
#ifdef HAVE_FILE_FSYNC_4ARGS
rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
- lock_inode = !lli->lli_inode_locked;
- if (lock_inode)
- inode_lock(inode);
+ inode_lock(inode);
#else
/* fsync's caller has already called _fdata{sync,write}, we want
* that IO to finish before calling the osc and mdc sync methods */
}
#ifdef HAVE_FILE_FSYNC_4ARGS
- if (lock_inode)
- inode_unlock(inode);
+ inode_unlock(inode);
#endif
RETURN(rc);
}