Index: configure =================================================================== RCS file: /projects/cvsroot/pvfs2/configure,v retrieving revision 1.367 diff -u -a -p -r1.367 configure --- configure 9 Nov 2007 00:10:20 -0000 1.367 +++ configure 15 Nov 2007 18:26:41 -0000 @@ -11440,6 +11440,62 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #define __KERNEL__ + #include + +int +main () +{ + + struct address_space as; + spin_lock(&as.page_lock); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define HAVE_SPIN_LOCK_ADDR_SPACE_STRUCT 1 +_ACEOF + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$oldcflags Index: pvfs2-config.h.in =================================================================== RCS file: /projects/cvsroot/pvfs2/pvfs2-config.h.in,v retrieving revision 1.111 diff -u -a -p -r1.111 pvfs2-config.h.in --- pvfs2-config.h.in 5 Nov 2007 21:07:54 -0000 1.111 +++ pvfs2-config.h.in 15 Nov 2007 18:26:41 -0000 @@ -273,6 +273,9 @@ /* Define if SLAB_KERNEL is defined in kernel */ #undef HAVE_SLAB_KERNEL +/* Define if kernel address_space struct has a spin_lock instead of rw_lock */ +#undef HAVE_SPIN_LOCK_ADDR_SPACE_STRUCT + /* Define if struct super_operations in kernel has statfs_lite callback */ #undef HAVE_STATFS_LITE_SUPER_OPERATIONS Index: maint/config/kernel.m4 =================================================================== RCS file: /projects/cvsroot/pvfs2/maint/config/kernel.m4,v retrieving revision 1.46 diff -u -a -p -r1.46 kernel.m4 --- maint/config/kernel.m4 6 Nov 2007 16:29:52 -0000 1.46 +++ maint/config/kernel.m4 15 Nov 2007 18:26:41 -0000 @@ -849,5 +849,17 @@ AC_DEFUN([AX_KERNEL_FEATURES], AC_MSG_RESULT(no) ) + AC_TRY_COMPILE([ + #define __KERNEL__ + #include + ], [ + struct address_space as; + spin_lock(&as.page_lock); + ], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SPIN_LOCK_ADDR_SPACE_STRUCT, 1, [Define if kernel address_space struct has a spin_lock instead of rw_lock]), + AC_MSG_RESULT(no) + ) + CFLAGS=$oldcflags ]) Index: src/kernel/linux-2.6/file.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/file.c,v retrieving revision 1.141 diff -u -a -p -r1.141 file.c --- src/kernel/linux-2.6/file.c 31 Aug 2007 22:20:49 -0000 1.141 +++ src/kernel/linux-2.6/file.c 15 Nov 2007 18:26:42 -0000 @@ -772,6 +772,14 @@ static int pvfs2_readpages_fill_cb(void return 0; } +#ifdef HAVE_SPIN_LOCK_ADDR_SPACE_STRUCT +#define lock_page_tree(mapping) spin_lock(&mapping->page_lock) +#define unlock_page_tree(mapping) spin_unlock(&mapping->page_lock) +#else +#define lock_page_tree(mapping) read_lock_irq(&mapping->tree_lock) +#define unlock_page_tree(mapping) read_unlock_irq(&mapping->tree_lock) +#endif + /* A debugging function to check the contents of a * mapping's address space/radix tree */ @@ -785,7 +793,7 @@ static int check_mapping_tree(struct add begin_index = 0; end_index = (file_size - 1) >> PAGE_CACHE_SHIFT; nr_to_read = end_index - begin_index + 1; - read_lock_irq(&mapping->tree_lock); + lock_mapping_tree(mapping); for (page_idx = 0; page_idx < nr_to_read; page_idx++) { struct page *page; pgoff_t page_offset = begin_index + page_idx; @@ -805,7 +813,7 @@ static int check_mapping_tree(struct add page_idx, page_offset); } } - read_unlock_irq(&mapping->tree_lock); + unlock_mapping_tree(mapping); return 0; } @@ -877,7 +885,7 @@ static int locate_file_pages(struct rw_o gossip_debug(GOSSIP_FILE_DEBUG, "read %ld pages\n", nr_to_read); - read_lock_irq(&mapping->tree_lock); + lock_mapping_tree(mapping); /* Preallocate all pages, increase their ref counts if they are in cache */ for (page_idx = 0; page_idx < nr_to_read; page_idx++) { pgoff_t page_offset = begin_index + page_idx; @@ -898,10 +906,10 @@ static int locate_file_pages(struct rw_o continue; } g_pvfs2_stats.cache_misses++; - read_unlock_irq(&mapping->tree_lock); + unlock_mapping_tree(mapping); /* Allocate, but don't add it to the LRU list yet */ page = page_cache_alloc_cold(mapping); - read_lock_irq(&mapping->tree_lock); + lock_mapping_tree(mapping); if (!page) { ret = -ENOMEM; gossip_err("could not allocate page cache\n"); @@ -921,7 +929,7 @@ static int locate_file_pages(struct rw_o rw->dest.pages.pg_byte_map[page_idx] = 1; ret++; } - read_unlock_irq(&mapping->tree_lock); + unlock_mapping_tree(mapping); /* cleanup in case of error */ if (ret < 0) { gossip_err("could not page_cache_alloc_cold\n");