Whamcloud - gitweb
LU-15189 osc: don't have extra nvidia call
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 68da594..b239a91 100644 (file)
@@ -763,6 +763,7 @@ void osc_update_next_shrink(struct client_obd *cli)
        CDEBUG(D_CACHE, "next time %lld to shrink grant\n",
               cli->cl_next_shrink_grant);
 }
+EXPORT_SYMBOL(osc_update_next_shrink);
 
 static void __osc_update_grant(struct client_obd *cli, u64 grant)
 {
@@ -971,6 +972,7 @@ void osc_schedule_grant_work(void)
        cancel_delayed_work_sync(&work);
        schedule_work(&work.work);
 }
+EXPORT_SYMBOL(osc_schedule_grant_work);
 
 /**
  * Start grant thread for returing grant to server for idle clients.
@@ -1439,7 +1441,8 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa,
         if (req == NULL)
                 RETURN(-ENOMEM);
 
-       if (opc == OST_WRITE && inode && IS_ENCRYPTED(inode)) {
+       if (opc == OST_WRITE && inode && IS_ENCRYPTED(inode) &&
+           llcrypt_has_encryption_key(inode)) {
                for (i = 0; i < page_count; i++) {
                        struct brw_page *pg = pga[i];
                        struct page *data_page = NULL;
@@ -1450,9 +1453,7 @@ osc_brw_prep_request(int cmd, struct client_obd *cli, struct obdo *oa,
                        pgoff_t index_orig;
 
 retry_encrypt:
-                       if (nunits & ~LUSTRE_ENCRYPTION_MASK)
-                               nunits = (nunits & LUSTRE_ENCRYPTION_MASK) +
-                                       LUSTRE_ENCRYPTION_UNIT_SIZE;
+                       nunits = round_up(nunits, LUSTRE_ENCRYPTION_UNIT_SIZE);
                        /* The page can already be locked when we arrive here.
                         * This is possible when cl_page_assume/vvp_page_assume
                         * is stuck on wait_on_page_writeback with page lock
@@ -1509,14 +1510,38 @@ retry_encrypt:
                        pg->bp_off_diff = pg->off & ~PAGE_MASK;
                        pg->off = pg->off & PAGE_MASK;
                }
-       } else if (opc == OST_READ && inode && IS_ENCRYPTED(inode)) {
+       } else if (opc == OST_WRITE && inode && IS_ENCRYPTED(inode)) {
+               struct osc_async_page *oap = brw_page2oap(pga[0]);
+               struct cl_page *clpage = oap2cl_page(oap);
+               struct cl_object *clobj = clpage->cp_obj;
+               struct cl_attr attr = { 0 };
+               struct lu_env *env;
+               __u16 refcheck;
+
+               env = cl_env_get(&refcheck);
+               if (IS_ERR(env)) {
+                       rc = PTR_ERR(env);
+                       ptlrpc_request_free(req);
+                       RETURN(rc);
+               }
+
+               cl_object_attr_lock(clobj);
+               rc = cl_object_attr_get(env, clobj, &attr);
+               cl_object_attr_unlock(clobj);
+               cl_env_put(env, &refcheck);
+               if (rc != 0) {
+                       ptlrpc_request_free(req);
+                       RETURN(rc);
+               }
+               if (attr.cat_size)
+                       oa->o_size = attr.cat_size;
+       } else if (opc == OST_READ && inode && IS_ENCRYPTED(inode) &&
+                  llcrypt_has_encryption_key(inode)) {
                for (i = 0; i < page_count; i++) {
                        struct brw_page *pg = pga[i];
                        u32 nunits = (pg->off & ~PAGE_MASK) + pg->count;
 
-                       if (nunits & ~LUSTRE_ENCRYPTION_MASK)
-                               nunits = (nunits & LUSTRE_ENCRYPTION_MASK) +
-                                       LUSTRE_ENCRYPTION_UNIT_SIZE;
+                       nunits = round_up(nunits, LUSTRE_ENCRYPTION_UNIT_SIZE);
                        /* count/off are forced to cover the whole encryption
                         * unit size so that all encrypted data is stored on the
                         * OST, so adjust bp_{count,off}_diff for the size of
@@ -1542,13 +1567,14 @@ retry_encrypt:
 
        for (i = 0; i < page_count; i++) {
                short_io_size += pga[i]->count;
-               if (!inode || !IS_ENCRYPTED(inode)) {
+               if (!inode || !IS_ENCRYPTED(inode) ||
+                   !llcrypt_has_encryption_key(inode)) {
                        pga[i]->bp_count_diff = 0;
                        pga[i]->bp_off_diff = 0;
                }
        }
 
-       if (lnet_is_rdma_only_page(pga[0]->pg)) {
+       if (brw_page2oap(pga[0])->oap_brw_flags & OBD_BRW_RDMA_ONLY) {
                enable_checksum = false;
                short_io_size = 0;
        }
@@ -2802,7 +2828,7 @@ int osc_enqueue_interpret(const struct lu_env *env, struct ptlrpc_request *req,
 
        /* Complete obtaining the lock procedure. */
        rc = ldlm_cli_enqueue_fini(aa->oa_exp, req, &einfo, 1, aa->oa_flags,
-                                  lvb, lvb_len, lockh, rc);
+                                  lvb, lvb_len, lockh, rc, false);
        /* Complete osc stuff. */
        rc = osc_enqueue_fini(req, aa->oa_upcall, aa->oa_cookie, lockh, mode,
                              aa->oa_flags, aa->oa_speculative, rc);