Whamcloud - gitweb
Branch: HEAD
authorwangdi <wangdi>
Wed, 24 Aug 2005 09:45:12 +0000 (09:45 +0000)
committerwangdi <wangdi>
Wed, 24 Aug 2005 09:45:12 +0000 (09:45 +0000)
b7375
when decrypt page, should decrypt the whole page array, not only the first
page

lustre/llite/llite_gs.c
lustre/osc/osc_request.c

index 4f7a9d3..16a2f32 100644 (file)
@@ -499,7 +499,7 @@ static int ll_crypt_cb(struct page *page, __u64 offset, __u64 count,
         unsigned char *ptr;
         char *key_ptr;
         int index = page->index;
-        __u64 data_key = 0; 
+        __u8 data_key = 0; 
         int i, rc = 0;
         ENTRY;
 
@@ -518,7 +518,12 @@ static int ll_crypt_cb(struct page *page, __u64 offset, __u64 count,
         spin_unlock(&lli->lli_lock);
         data_key += index;
 
-        CDEBUG(D_INFO, "data_key is "LPU64" \n", data_key);
+        CDEBUG(D_INFO, "data_key is %d \n", data_key);
+        if (data_key == 0) {
+                CDEBUG(D_INFO, "data_key is 0, inc 1 \n");
+                data_key ++; 
+        }
+        LASSERT((__u8)data_key != 0);
         /*encrypt the data*/
         ptr = (char *)kmap(page);
         key_ptr = ptr;
index 8ef35b0..0f0cbe1 100644 (file)
@@ -751,7 +751,6 @@ static obd_count cksum_pages(int nob, obd_count page_count,
         osc_crypt_page(page, off, count, ENCRYPT_DATA)
 #define osc_decrypt_page(page, off, count)  \
         osc_crypt_page(page, off, count, DECRYPT_DATA)
-
 /*Put a global call back var here is Ugly, but put it to client_obd
  *also seems not a good idea, WangDi*/
 crypt_cb_t  osc_crypt_cb = NULL;
@@ -769,6 +768,18 @@ static int osc_crypt_page(struct page *page, obd_off page_off, obd_off count,
         RETURN(rc);
 }
 
+static int osc_decrypt_pages(struct brw_page *pga, int page_count)
+{
+        int i =0;
+        ENTRY;
+
+        for (i = 0; i < page_count; i++) {
+                struct brw_page *pg = &pga[i];
+                osc_decrypt_page(pg->pg, pg->page_offset, pg->count);
+        }
+        RETURN(0);
+}
+
 static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa,
                                 struct lov_stripe_md *lsm, obd_count page_count,
                                 struct brw_page *pga, int *requested_nobp,
@@ -944,8 +955,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, struct obdo *oa,
                         RETURN(-EPROTO);
                 }
                 LASSERT (req->rq_bulk->bd_nob == requested_nob);
-                osc_decrypt_page(pga->pg, pga->page_offset,
-                                 pga->count);
+                osc_decrypt_pages(pga, page_count);
                 RETURN(check_write_rcs(req, requested_nob, niocount,
                                        page_count, pga));
         }
@@ -996,7 +1006,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, struct obdo *oa,
                                req->rq_import->imp_connection->c_peer.peer_id.nid);
         }
 #endif
-        osc_decrypt_page(pga->pg, pga->page_offset, pga->count);
+        osc_decrypt_pages(pga, page_count);
         RETURN(0);
 }