Whamcloud - gitweb
b=5383
authorjacob <jacob>
Wed, 2 Feb 2005 23:29:07 +0000 (23:29 +0000)
committerjacob <jacob>
Wed, 2 Feb 2005 23:29:07 +0000 (23:29 +0000)
r=phil

allow readahead to fail when low on memory.

lustre/ChangeLog
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-2.6-suse.patch [new file with mode: 0644]
lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-rh-2.4.patch [new file with mode: 0644]
lustre/kernel_patches/series/2.6-suse-lnxi.series
lustre/kernel_patches/series/rh-2.4.20
lustre/kernel_patches/series/rhel-2.4.21
lustre/llite/rw.c

index a1bb7cb..54a64e7 100644 (file)
@@ -28,6 +28,7 @@ tbd         Cluster File Systems, Inc. <info@clusterfs.com>
        - fix ppc64/x86_64 spec to use %{_libdir} instead of /usr/lib (5389)
        - remove ancient LOV_MAGIC_V0 EA support (5047)
        - add "disk I/Os in flight" and "I/O req time" stats in obdfilter
+       - allow readahead allocations to fail when low on memory (5383)
 
 2004-11-23  Cluster File Systems, Inc. <info@clusterfs.com>
        * version 1.4.0
index 506bac5..f09a05b 100644 (file)
@@ -244,6 +244,25 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
+#
+# check for our patched grab_cache_page_nowait_gfp() function
+#
+AC_DEFUN([LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP],
+[
+LB_LINUX_TRY_COMPILE([
+       #include <linux/pagemap.h>
+],[
+       grab_cache_page_nowait_gfp(NULL, 0, 0);
+],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP, 1,
+               [kernel has grab_cache_page_nowait_gfp()])
+],[
+       AC_MSG_RESULT([no])
+])])
+
+#
 # LC_CONFIG_BACKINGFS
 #
 # whether to use extN or ldiskfs instead of ext3
@@ -363,6 +382,7 @@ LC_FUNC_DIRECT_IO
 LC_HEADER_MM_INLINE
 LC_STRUCT_INODE
 LC_FUNC_REGISTER_CACHE
+LC_FUNC_GRAB_CACHE_PAGE_NOWAIT_GFP
 ])
 
 #
index 2b97e36..d6f039f 100644 (file)
@@ -294,5 +294,9 @@ static inline int mapping_has_pages(struct address_space *mapping)
 #define MDS_PACK_MD_LOCK 0
 #endif
 
+#ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
+#define grab_cache_page_nowait_gfp(x, y, z) (grab_cache_page_nowait((x), (y)))
+#endif
+
 #endif /* __KERNEL__ */
 #endif /* _COMPAT25_H */
diff --git a/lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-2.6-suse.patch b/lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-2.6-suse.patch
new file mode 100644 (file)
index 0000000..6f781b4
--- /dev/null
@@ -0,0 +1,57 @@
+Index: linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891/mm/filemap.c
+===================================================================
+--- linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891.orig/mm/filemap.c    2004-11-11 10:28:45.000000000 -0500
++++ linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891/mm/filemap.c 2005-02-01 01:36:08.000000000 -0500
+@@ -773,8 +773,19 @@
+ struct page *
+ grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
+ {
++      return grab_cache_page_nowait_gfp(mapping, index,
++                                        mapping_gfp_mask(mapping) & 
++                                        ~__GFP_FS);
++}
++
++EXPORT_SYMBOL(grab_cache_page_nowait);
++
++struct page *
++grab_cache_page_nowait_gfp(struct address_space *mapping,
++                         unsigned long index,
++                         unsigned int gfp_mask)
++{
+       struct page *page = find_get_page(mapping, index);
+-      int gfp_mask;
+       if (page) {
+               if (!TestSetPageLocked(page))
+@@ -782,7 +793,7 @@
+               page_cache_release(page);
+               return NULL;
+       }
+-      gfp_mask = mapping_gfp_mask(mapping) & ~__GFP_FS;
++
+       page = alloc_pages(gfp_mask, 0);
+       if (page && add_to_page_cache_lru(page, mapping, index, gfp_mask)) {
+               page_cache_release(page);
+@@ -791,7 +802,7 @@
+       return page;
+ }
+-EXPORT_SYMBOL(grab_cache_page_nowait);
++EXPORT_SYMBOL(grab_cache_page_nowait_gfp);
+ /*
+  * This is a generic file read routine, and uses the
+Index: linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891/include/linux/pagemap.h
+===================================================================
+--- linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891.orig/include/linux/pagemap.h 2004-11-11 10:28:43.000000000 -0500
++++ linux-2.6.5-SLES9_SP1_BRANCH_2004111114454891/include/linux/pagemap.h      2005-02-01 01:29:06.000000000 -0500
+@@ -92,6 +92,9 @@
+ extern struct page * grab_cache_page_nowait(struct address_space *mapping,
+                               unsigned long index);
++extern struct page * grab_cache_page_nowait_gfp(struct address_space *mapping,
++                                              unsigned long index,
++                                              unsigned int gfp_mask);
+ extern struct page * read_cache_page(struct address_space *mapping,
+                               unsigned long index, filler_t *filler,
+                               void *data);
diff --git a/lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-rh-2.4.patch b/lustre/kernel_patches/patches/grab_cache_page_nowait_gfp-rh-2.4.patch
new file mode 100644 (file)
index 0000000..c7b00f7
--- /dev/null
@@ -0,0 +1,65 @@
+Index: linux-2.4.20/mm/filemap.c
+===================================================================
+--- linux-2.4.20.orig/mm/filemap.c     2004-12-17 17:51:44.000000000 -0500
++++ linux-2.4.20/mm/filemap.c  2004-12-17 17:56:54.000000000 -0500
+@@ -1153,6 +1153,14 @@
+  */
+ struct page *grab_cache_page_nowait(struct address_space *mapping, unsigned long index)
+ {
++      return grab_cache_page_nowait_gfp(mapping, index, mapping->gfp_mask);
++}
++
++
++struct page *grab_cache_page_nowait_gfp(struct address_space *mapping,
++                                      unsigned long index, 
++                                      unsigned int gfp_mask)
++{
+       struct page *page, **hash;
+       hash = page_hash(mapping, index);
+@@ -1177,7 +1185,7 @@
+               }
+       }
+-      page = page_cache_alloc(mapping);
++      page = alloc_pages(gfp_mask, 0);
+       if ( unlikely(!page) )
+               return NULL;    /* Failed to allocate a page */
+Index: linux-2.4.20/mm/page_alloc.c
+===================================================================
+--- linux-2.4.20.orig/mm/page_alloc.c  2004-12-17 17:51:30.000000000 -0500
++++ linux-2.4.20/mm/page_alloc.c       2004-12-17 18:26:45.000000000 -0500
+@@ -547,6 +547,8 @@
+                                */
+                               return NULL;
+                       }
++              } else if (!(gfp_mask & __GFP_HIGH)) {
++                      return NULL;
+               }
+       }
+Index: linux-2.4.20/kernel/ksyms.c
+===================================================================
+--- linux-2.4.20.orig/kernel/ksyms.c   2004-12-17 17:51:46.000000000 -0500
++++ linux-2.4.20/kernel/ksyms.c        2004-12-17 17:52:59.000000000 -0500
+@@ -300,6 +300,7 @@
+ EXPORT_SYMBOL(__find_lock_page);
+ EXPORT_SYMBOL(find_or_create_page);
+ EXPORT_SYMBOL(grab_cache_page_nowait);
++EXPORT_SYMBOL(grab_cache_page_nowait_gfp);
+ EXPORT_SYMBOL(read_cache_page);
+ EXPORT_SYMBOL(set_page_dirty);
+ EXPORT_SYMBOL(vfs_readlink);
+Index: linux-2.4.20/include/linux/pagemap.h
+===================================================================
+--- linux-2.4.20.orig/include/linux/pagemap.h  2004-05-27 14:25:05.000000000 -0400
++++ linux-2.4.20/include/linux/pagemap.h       2004-12-17 18:11:09.000000000 -0500
+@@ -110,6 +110,7 @@
+ extern struct page * grab_cache_page_nowait (struct address_space *, unsigned long);
++extern struct page * grab_cache_page_nowait_gfp (struct address_space *, unsigned long, unsigned int);
+ typedef int filler_t(void *, struct page*);
index 1604238..4ed864c 100644 (file)
@@ -5,3 +5,4 @@ mtd-2.6-suse-lnxi.patch
 perfctr-2.6-suse-lnxi.patch 
 kexec-2.6-suse-lnxi.patch
 brk-locked-2.6-suse-lnxi.patch
+grab_cache_page_nowait_gfp-2.6-suse.patch 
index ebe8f74..02481d0 100644 (file)
@@ -50,3 +50,4 @@ ext3-mballoc-2.4.24.patch
 x86-fpu-crash.patch
 export-show_task-2.4-rh.patch 
 export-zap-page-range.patch
+grab_cache_page_nowait_gfp-rh-2.4.patch 
index cf623d5..c8cc479 100644 (file)
@@ -45,3 +45,4 @@ llnl-frame-pointer-walk-2.4.21-rhel.patch
 llnl-frame-pointer-walk-fix-2.4.21-rhel.patch
 export-show_task-2.4-rhel.patch 
 compile-fixes-2.4.21-rhel.patch 
+grab_cache_page_nowait_gfp-rh-2.4.patch 
index e332559..490b0b1 100644 (file)
@@ -891,6 +891,7 @@ static int ll_readahead(struct ll_readahead_state *ras,
         struct page *page;
         int rc, ret = 0, match_failed = 0;
         __u64 kms;
+        unsigned int gfp_mask;
         ENTRY;
 
         kms = lov_merge_size(ll_i2info(mapping->host)->lli_smd, 1);
@@ -920,9 +921,14 @@ static int ll_readahead(struct ll_readahead_state *ras,
         if (reserved < end - start + 1)
                 ll_ra_stats_inc(mapping, RA_STAT_MAX_IN_FLIGHT);
 
+        gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT;
+#ifdef __GFP_NOWARN
+        gfp_mask |= __GFP_NOWARN;
+#endif
+
         for (i = start; reserved > 0 && !match_failed && i <= end; i++) {
                 /* skip locked pages from previous readpage calls */
-                page = grab_cache_page_nowait(mapping, i);
+                page = grab_cache_page_nowait_gfp(mapping, i, gfp_mask);
                 if (page == NULL) {
                         CDEBUG(D_READA, "g_c_p_n failed\n");
                         continue;