Subject: afs/include/linux cachefs.h,1.18,1.19

From: [email-masked]
Date: Tue, 19 Aug 2003 14:37:39 +0100

Update of /home/cvs/afs/include/linux
In directory phoenix.infradead.org:/tmp/cvs-serv1024/include/linux

Modified Files:
	cachefs.h 
Log Message:
made the CacheFS interface functions always present in cachefs.h, even if
CONFIG_CACHEFS is not set

Index: cachefs.h
===================================================================
RCS file: /home/cvs/afs/include/linux/cachefs.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- cachefs.h	13 Aug 2003 10:05:28 -0000	1.18
+++ cachefs.h	19 Aug 2003 13:37:05 -0000	1.19
@@ -16,6 +16,8 @@
 #include <linux/list.h>
 #include <linux/pagemap.h>
 
+#define CONFIG_CACHEFS
+
 struct cachefs_cookie;
 struct cachefs_netfs;
 struct cachefs_netfs_operations;
@@ -84,13 +86,38 @@
 	void (*update)(void *source_netfs_data, void *entry);
 };
 
-extern void cachefs_acquire_cookie(struct cachefs_cookie *iparent,
-				   struct cachefs_index_def *idef,
-				   void *netfs_data,
-				   struct cachefs_cookie **_cookie);
+#ifdef CONFIG_CACHEFS
+extern void __cachefs_acquire_cookie(struct cachefs_cookie *iparent,
+				     struct cachefs_index_def *idef,
+				     void *netfs_data,
+				     struct cachefs_cookie **_cookie);
+
+extern void __cachefs_relinquish_cookie(struct cachefs_cookie *cookie,
+					int retire);
+#endif
 
-extern void cachefs_relinquish_cookie(struct cachefs_cookie *cookie,
-				      int retire);
+static inline
+void cachefs_acquire_cookie(struct cachefs_cookie *iparent,
+			    struct cachefs_index_def *idef,
+			    void *netfs_data,
+			    struct cachefs_cookie **_cookie)
+{
+#ifdef CONFIG_CACHEFS
+	if (iparent)
+		return __cachefs_acquire_cookie(iparent, idef, netfs_data,
+						_cookie);
+#endif
+}
+
+static inline
+void cachefs_relinquish_cookie(struct cachefs_cookie *cookie,
+			       int retire)
+{
+#ifdef CONFIG_CACHEFS
+	if (cookie)
+		return __cachefs_relinquish_cookie(cookie, retire);
+#endif
+}
 
 /*****************************************************************************/
 /*
@@ -107,10 +134,6 @@
 	struct list_head		link;		/* internal link */
 };
 
-extern int cachefs_register_netfs(struct cachefs_netfs *netfs,
-				  struct cachefs_index_def *primary_idef);
-extern void cachefs_unregister_netfs(struct cachefs_netfs *netfs);
-
 struct cachefs_netfs_operations
 {
 	/* get page-to-block mapping cookie for a page
@@ -122,6 +145,31 @@
 			       struct cachefs_page **_page_cookie);
 };
 
+#ifdef CONFIG_CACHEFS
+extern int __cachefs_register_netfs(struct cachefs_netfs *netfs,
+				    struct cachefs_index_def *primary_idef);
+extern void __cachefs_unregister_netfs(struct cachefs_netfs *netfs);
+#endif
+
+static inline
+int cachefs_register_netfs(struct cachefs_netfs *netfs,
+			   struct cachefs_index_def *primary_idef)
+{
+#ifdef CONFIG_CACHEFS
+	return __cachefs_register_netfs(netfs, primary_idef);
+#else
+	return 0;
+#endif
+}
+
+static inline
+void cachefs_unregister_netfs(struct cachefs_netfs *netfs)
+{
+#ifdef CONFIG_CACHEFS
+	__cachefs_unregister_netfs(netfs);
+#endif
+}
+
 /*****************************************************************************/
 /*
  * page mapping cookie
@@ -156,11 +204,28 @@
  *     contain valid data
  *   - -ENODATA will be returned
  */
+#ifdef CONFIG_CACHEFS
+extern int __cachefs_read_or_alloc_page(struct cachefs_cookie *cookie,
+					struct page *page,
+					cachefs_rw_complete_t end_io_func,
+					void *end_io_data,
+					unsigned long gfp);
+#endif
+
+static inline
 int cachefs_read_or_alloc_page(struct cachefs_cookie *cookie,
 			       struct page *page,
 			       cachefs_rw_complete_t end_io_func,
 			       void *end_io_data,
-			       unsigned long gfp);
+			       unsigned long gfp)
+{
+#ifdef CONFIG_CACHEFS
+	if (cookie)
+		return __cachefs_read_or_alloc_page(cookie, page, end_io_func,
+						    end_io_data, gfp);
+#endif
+	return -ENOBUFS;
+}
 
 /*
  * request a page be stored in the cache
@@ -176,18 +241,46 @@
  *   - any associated validity journal entry will be cleared
  *   - returns 0
  */
-extern int cachefs_write_page(struct cachefs_cookie *cookie,
-			      struct page *page,
-			      cachefs_rw_complete_t end_io_func,
-			      void *end_io_data,
-			      unsigned long gfp);
+#ifdef CONFIG_CACHEFS
+extern int __cachefs_write_page(struct cachefs_cookie *cookie,
+				struct page *page,
+				cachefs_rw_complete_t end_io_func,
+				void *end_io_data,
+				unsigned long gfp);
+#endif
+
+static inline
+int cachefs_write_page(struct cachefs_cookie *cookie,
+		       struct page *page,
+		       cachefs_rw_complete_t end_io_func,
+		       void *end_io_data,
+		       unsigned long gfp)
+{
+#ifdef CONFIG_CACHEFS
+	if (cookie)
+		return __cachefs_write_page(cookie, page, end_io_func,
+					    end_io_data, gfp);
+#endif
+	return -ENOBUFS;
+}
 
 /*
  * indicate that caching is no longer required on a page
  * - note: cannot cancel any outstanding BIOs between this page and the cache
  */
-extern void cachefs_uncache_page(struct cachefs_cookie *cookie,
-				 struct page *page);
+#ifdef CONFIG_CACHEFS
+extern void __cachefs_uncache_page(struct cachefs_cookie *cookie,
+				   struct page *page);
+#endif
+
+static inline
+void cachefs_uncache_page(struct cachefs_cookie *cookie,
+			  struct page *page)
+{
+#ifdef CONFIG_CACHEFS
+	__cachefs_uncache_page(cookie, page);
+#endif
+}
 
 /*
  * keep track of pages changed locally but not yet committed
@@ -214,14 +307,29 @@
  * cachefs_page
  */
 static inline
-struct cachefs_page *__cachefs_page_get_private(struct page *page)
+struct cachefs_page *cachefs_page_grab_private(struct page *page)
 {
 	BUG_ON(!PagePrivate(page));
 	return (struct cachefs_page *) page->private;
 }
 
-extern int cachefs_page_get_private(struct page *page,
-				    struct cachefs_page **_page,
-				    unsigned gfp);
+#ifdef CONFIG_CACHEFS
+extern int __cachefs_page_get_private(struct page *page,
+				      struct cachefs_page **_page,
+				      unsigned gfp);
+#endif
+
+static inline
+int cachefs_page_get_private(struct page *page,
+			     struct cachefs_page **_page,
+			     unsigned gfp)
+{
+#ifdef CONFIG_CACHEFS
+	return __cachefs_page_get_private(page, _page, gfp);
+#else
+	*_page = NULL;
+	return -EIO;
+#endif
+}
 
 #endif /* _LINUX_CACHEFS_H */