From 353d73e7cf04552ffdf927aa2bfbc1a6dd097243 Mon Sep 17 00:00:00 2001
From: mattwu <mattwu>
Date: Tue, 7 Oct 2008 06:43:05 +0000
Subject: [PATCH] b=16150 i=nikita i=robert winnt libcfs/lnetcleanup

---
 lustre/llite/llite_internal.h |  7 +++++++
 lustre/llite/rw.c             | 12 ++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h
index 8631e1e1fc..18addb31f6 100644
--- a/lustre/llite/llite_internal.h
+++ b/lustre/llite/llite_internal.h
@@ -639,6 +639,13 @@ struct ll_async_page {
         __u32            llap_checksum;
 };
 
+static inline struct ll_async_page *llap_from_cookie(void *ptr)
+{
+        struct ll_async_page *ap = ptr;
+        LASSERT(ap->llap_magic == LLAP_MAGIC);
+        return ap;
+}
+
 /*
  * enumeration of llap_from_page() call-sites. Used to export statistics in
  * /proc/fs/lustre/llite/fsN/dump_page_cache.
diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c
index 06ebe17a9d..f6813408a9 100644
--- a/lustre/llite/rw.c
+++ b/lustre/llite/rw.c
@@ -348,7 +348,7 @@ static int ll_ap_make_ready(void *data, int cmd)
         struct page *page;
         ENTRY;
 
-        llap = LLAP_FROM_COOKIE(data);
+        llap = llap_from_cookie(data);
         page = llap->llap_page;
 
         /* we're trying to write, but the page is locked.. come back later */
@@ -411,7 +411,7 @@ static int ll_ap_refresh_count(void *data, int cmd)
         /* readpage queues with _COUNT_STABLE, shouldn't get here. */
         LASSERT(cmd != OBD_BRW_READ);
 
-        llap = LLAP_FROM_COOKIE(data);
+        llap = llap_from_cookie(data);
         page = llap->llap_page;
         inode = page->mapping->host;
         lli = ll_i2info(inode);
@@ -462,7 +462,7 @@ static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
         struct ll_async_page *llap;
         ENTRY;
 
-        llap = LLAP_FROM_COOKIE(data);
+        llap = llap_from_cookie(data);
         ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
 
         EXIT;
@@ -474,7 +474,7 @@ static void ll_ap_update_obdo(void *data, int cmd, struct obdo *oa,
         struct ll_async_page *llap;
         ENTRY;
 
-        llap = LLAP_FROM_COOKIE(data);
+        llap = llap_from_cookie(data);
         obdo_from_inode(oa, llap->llap_page->mapping->host, valid);
 
         EXIT;
@@ -482,8 +482,8 @@ static void ll_ap_update_obdo(void *data, int cmd, struct obdo *oa,
 
 static struct obd_capa *ll_ap_lookup_capa(void *data, int cmd)
 {
-        struct ll_async_page *llap = LLAP_FROM_COOKIE(data);
         int opc = cmd & OBD_BRW_WRITE ? CAPA_OPC_OSS_WRITE : CAPA_OPC_OSS_RW;
+        struct ll_async_page *llap = llap_from_cookie(data);
 
         return ll_osscapa_get(llap->llap_page->mapping->host, opc);
 }
@@ -1130,7 +1130,7 @@ int ll_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
         int ret = 0;
         ENTRY;
 
-        llap = LLAP_FROM_COOKIE(data);
+        llap = llap_from_cookie(data);
         page = llap->llap_page;
         LASSERT(PageLocked(page));
         LASSERT(CheckWriteback(page,cmd));
-- 
GitLab