From 014e2c56ba8ffb30cc50a724a402f72e38418e05 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 25 Aug 2015 18:12:10 -0400 Subject: [PATCH] LU-6215 client: cancel_dirty_page revival For linux kernel version 4.2 we see the return of the function cancel_dirty_page() except it does not take the second argument anymore. This happened in linux commit 11f81becca04bb7d2826a9b65bb8d27b0a1bb543. Change-Id: If3156dddcc2f104f128ce5b76ed9839d97054448 Signed-off-by: James Simmons Reviewed-on: http://review.whamcloud.com/16069 Reviewed-by: frank zago Reviewed-by: Bob Glossman Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 22 +++++++++++++++++++++- lustre/include/lustre_patchless_compat.h | 21 +++++++++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index e1a2a2c..6c18234 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1827,7 +1827,7 @@ bdi_cap_map_copy, [ # # LC_CANCEL_DIRTY_PAGE # -# 4.0.0 kernel removed cancle_dirty_page +# 4.0.0 kernel removed cancel_dirty_page # AC_DEFUN([LC_CANCEL_DIRTY_PAGE], [ LB_CHECK_COMPILE([if cancel_dirty_page still exist], @@ -1873,6 +1873,23 @@ LB_CHECK_EXPORT([new_sync_read], [fs/read_write.c], ]) # LC_HAVE_SYNC_READ_WRITE # +# LC_NEW_CANCEL_DIRTY_PAGE +# +# 4.2 kernel has new cancel_dirty_page +# +AC_DEFUN([LC_NEW_CANCEL_DIRTY_PAGE], [ +LB_CHECK_COMPILE([if cancel_dirty_page with one argument exist], +new_cancel_dirty_page, [ + #include +],[ + cancel_dirty_page(NULL); +],[ + AC_DEFINE(HAVE_NEW_CANCEL_DIRTY_PAGE, 1, + [cancel_dirty_page with one arguement is available]) +]) +]) # LC_NEW_CANCEL_DIRTY_PAGE + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -2027,6 +2044,9 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_IOV_ITER_RW LC_HAVE_SYNC_READ_WRITE + # 4.2 + LC_NEW_CANCEL_DIRTY_PAGE + # AS_IF([test "x$enable_server" != xno], [ LC_FUNC_DEV_SET_RDONLY diff --git a/lustre/include/lustre_patchless_compat.h b/lustre/include/lustre_patchless_compat.h index c62e4d5..cefa869 100644 --- a/lustre/include/lustre_patchless_compat.h +++ b/lustre/include/lustre_patchless_compat.h @@ -75,6 +75,19 @@ static inline void ll_delete_from_page_cache(struct page *page) #endif /* !HAVE_DELETE_FROM_PAGE_CACHE */ static inline void +ll_cancel_dirty_page(struct address_space *mapping, struct page *page) +{ +#ifdef HAVE_NEW_CANCEL_DIRTY_PAGE + cancel_dirty_page(page); +#elif defined(HAVE_CANCEL_DIRTY_PAGE) + cancel_dirty_page(page, PAGE_SIZE); +#else + if (TestClearPageDirty(page)) + account_page_cleaned(page, mapping); +#endif /* HAVE_NEW_CANCEL_DIRTY_PAGE */ +} + +static inline void truncate_complete_page(struct address_space *mapping, struct page *page) { if (page->mapping != mapping) @@ -86,12 +99,8 @@ truncate_complete_page(struct address_space *mapping, struct page *page) #else page->mapping->a_ops->invalidatepage(page, 0); #endif -#ifdef HAVE_CANCEL_DIRTY_PAGE - cancel_dirty_page(page, PAGE_SIZE); -#else - if (TestClearPageDirty(page)) - account_page_cleaned(page, mapping); -#endif /* HAVE_CANCEL_DIRTY_PAGE */ + + ll_cancel_dirty_page(mapping, page); ClearPageMappedToDisk(page); ll_delete_from_page_cache(page); } -- 1.8.3.1