Whamcloud - gitweb
LU-4198 clio: turn on lockless for some kind of IO
[fs/lustre-release.git] / lustre / llite / rw26.c
index b8deb17..ab6bec9 100644 (file)
@@ -136,10 +136,6 @@ static int ll_releasepage(struct page *vmpage, RELEASEPAGE_ARG_TYPE gfp_mask)
        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;
@@ -664,7 +660,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
        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) {
@@ -676,14 +672,25 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
        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);
@@ -864,7 +871,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
                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);
@@ -876,7 +883,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
                /* 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)