Whamcloud - gitweb
LU-10810 clio: SEEK_HOLE/SEEK_DATA on client side
[fs/lustre-release.git] / lustre / obdclass / cl_io.c
index 4afe3d0..21fa939 100644 (file)
@@ -45,6 +45,7 @@
 #include <lustre_fid.h>
 #include <cl_object.h>
 #include "cl_internal.h"
+#include <libcfs/crypto/llcrypt.h>
 
 /*****************************************************************************
  *
@@ -125,6 +126,7 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io)
        case CIT_GLIMPSE:
                break;
        case CIT_LADVISE:
+       case CIT_LSEEK:
                break;
        default:
                LBUG();
@@ -704,7 +706,8 @@ EXPORT_SYMBOL(cl_io_submit_sync);
  */
 int cl_io_loop(const struct lu_env *env, struct cl_io *io)
 {
-       int result   = 0;
+       int result = 0;
+       int rc = 0;
 
        LINVRNT(cl_io_is_loopable(io));
        ENTRY;
@@ -738,7 +741,13 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io)
                        }
                }
                cl_io_iter_fini(env, io);
-       } while (result == 0 && io->ci_continue);
+               if (result)
+                       rc = result;
+       } while ((result == 0 || result == -EIOCBQUEUED) &&
+                io->ci_continue);
+
+       if (rc && !result)
+               result = rc;
 
        if (result == -EWOULDBLOCK && io->ci_ndelay) {
                io->ci_need_restart = 1;
@@ -1159,14 +1168,25 @@ static void cl_aio_end(const struct lu_env *env, struct cl_sync_io *anchor)
        /* release pages */
        while (aio->cda_pages.pl_nr > 0) {
                struct cl_page *page = cl_page_list_first(&aio->cda_pages);
+               struct page *vmpage = cl_page_vmpage(page);
+               struct inode *inode = vmpage ? page2inode(vmpage) : NULL;
 
                cl_page_get(page);
+               /* We end up here in case of Direct IO only. For encrypted file,
+                * mapping was set on pages in ll_direct_rw_pages(), so it has
+                * to be cleared now before page cleanup.
+                * PageChecked flag was also set there, so we clean up here.
+                */
+               if (inode && IS_ENCRYPTED(inode)) {
+                       vmpage->mapping = NULL;
+                       ClearPageChecked(vmpage);
+               }
                cl_page_list_del(env, &aio->cda_pages, page);
                cl_page_delete(env, page);
                cl_page_put(env, page);
        }
 
-       if (!is_sync_kiocb(aio->cda_iocb))
+       if (!is_sync_kiocb(aio->cda_iocb) && !aio->cda_no_aio_complete)
                aio_complete(aio->cda_iocb, ret ?: aio->cda_bytes, 0);
 
        EXIT;
@@ -1186,6 +1206,7 @@ struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
                                       NULL : aio, cl_aio_end);
                cl_page_list_init(&aio->cda_pages);
                aio->cda_iocb = iocb;
+               aio->cda_no_aio_complete = 0;
        }
        return aio;
 }