if (obj == NULL)
return 1;
- /* 1 for caller, 1 for cl_page and 1 for page cache */
- if (page_count(vmpage) > 3)
- return 0;
-
page = cl_vmpage_page(vmpage, obj);
if (page == NULL)
return 1;
int result = 0;
ENTRY;
- CDEBUG(D_PAGE, "Writing %lu of %d to %d bytes\n", index, from, len);
+ CDEBUG(D_VFSTRACE, "Writing %lu of %d to %d bytes\n", index, from, len);
lcc = ll_cl_find(file);
if (lcc == NULL) {
env = lcc->lcc_env;
io = lcc->lcc_io;
- if (file->f_flags & O_DIRECT && io->ci_designated_mirror > 0) {
+ if (file->f_flags & O_DIRECT) {
/* direct IO failed because it couldn't clean up cached pages,
* this causes a problem for mirror write because the cached
* page may belong to another mirror, which will result in
* problem submitting the I/O. */
- GOTO(out, result = -EBUSY);
- }
+ if (io->ci_designated_mirror > 0)
+ GOTO(out, result = -EBUSY);
+ /**
+ * Direct read can fall back to buffered read, but DIO is done
+ * with lockless i/o, and buffered requires LDLM locking, so
+ * in this case we must restart without lockless.
+ */
+ if (!io->ci_ignore_lockless) {
+ io->ci_ignore_lockless = 1;
+ io->ci_need_restart = 1;
+ GOTO(out, result = -ENOLCK);
+ }
+ }
again:
/* To avoid deadlock, try to lock page first. */
vmpage = grab_cache_page_nowait(mapping, index);
if (plist->pl_nr >= PTLRPC_MAX_BRW_PAGES)
unplug = true;
- CL_PAGE_DEBUG(D_PAGE, env, page,
+ CL_PAGE_DEBUG(D_VFSTRACE, env, page,
"queued page: %d.\n", plist->pl_nr);
} else {
cl_page_disown(env, io, page);
/* page list is not contiguous now, commit it now */
unplug = true;
}
- if (unplug || io->u.ci_rw.rw_sync)
+ if (unplug || io->u.ci_wr.wr_sync)
result = vvp_io_write_commit(env, io);
if (result < 0)