From: James Simmons Date: Thu, 8 Sep 2016 16:39:14 +0000 (-0400) Subject: LU-8560 libcfs: handle page_cache_*() removal in newer kernels X-Git-Tag: 2.8.58~9 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3792aa13dab69c1a8de50ea23c5a4352f9bd0f45 LU-8560 libcfs: handle page_cache_*() removal in newer kernels Since page cache handling never was handled differently than normal pages the page_cache_*() macros have been removed starting with linux kernel 4.6. Now put_page() and get_page() need to be used instead. Second change is that get_user_page dropped the first two arguments in linux kernel version 4.6. We handle this change as well in libcfs. Signed-off-by: James Simmons Change-Id: I84c347a55c45e0794b913134f1abdd45926c24e8 Reviewed-on: http://review.whamcloud.com/22385 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: Andreas Dilger --- diff --git a/contrib/scripts/checkpatch.pl b/contrib/scripts/checkpatch.pl index 20db5d5..d4250e9 100755 --- a/contrib/scripts/checkpatch.pl +++ b/contrib/scripts/checkpatch.pl @@ -438,6 +438,9 @@ my %dep_functions = ( 'PAGE_CACHE_SIZE', 'PAGE_SIZE', 'PAGE_CACHE_SHIFT', 'PAGE_SHIFT', + 'page_cache_release', 'put_page', + 'page_cache_get', 'get_page', + 'cfs_proc_dir_entry_t', 'struct proc_dir_entry', 'cfs_rcu_head_t', 'struct rcu_head', diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index b559798..238396a 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -358,6 +358,24 @@ stacktrace_ops_address_return_int, [ ]) # LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT # +# Kernel version 4.6 removed both struct task_struct and struct mm_struct +# arguments to get_user_pages +# +AC_DEFUN([LIBCFS_GET_USER_PAGES_6ARG], [ +LB_CHECK_COMPILE([if 'get_user_pages()' takes 6 arguments], +get_user_pages_6arg, [ + #include +],[ + int rc; + + rc = get_user_pages(0, 0, 0, 0, NULL, NULL); +],[ + AC_DEFINE(HAVE_GET_USER_PAGES_6ARG, 1, + [get_user_pages takes 6 arguments]) +]) +]) # LIBCFS_GET_USER_PAGES_6ARG + +# # LIBCFS_PROG_LINUX # # LibCFS linux kernel checks @@ -401,6 +419,7 @@ LIBCFS_FPU_API LIBCFS_CRYPTO_HASH_HELPERS # 4.6 LIBCFS_STACKTRACE_OPS_ADDRESS_RETURN_INT +LIBCFS_GET_USER_PAGES_6ARG ]) # LIBCFS_PROG_LINUX # diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index d9c06ac..91c1ef1 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -153,8 +153,11 @@ static int cfs_access_process_vm(struct task_struct *tsk, int bytes, rc, offset; void *maddr; - rc = get_user_pages(tsk, mm, addr, 1, - write, 1, &page, &vma); +#ifdef HAVE_GET_USER_PAGES_6ARG + rc = get_user_pages(addr, 1, write, 1, &page, &vma); +#else + rc = get_user_pages(tsk, mm, addr, 1, write, 1, &page, &vma); +#endif if (rc <= 0) break; @@ -173,7 +176,7 @@ static int cfs_access_process_vm(struct task_struct *tsk, buf, maddr + offset, bytes); } kunmap(page); - page_cache_release(page); + put_page(page); len -= bytes; buf += bytes; addr += bytes; diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 99e4237..a2e5126 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2166,7 +2166,7 @@ static inline void ptlrpc_release_bulk_page_pin(struct ptlrpc_bulk_desc *desc) int i; for (i = 0; i < desc->bd_iov_count ; i++) - page_cache_release(BD_GET_KIOV(desc, i).kiov_page); + put_page(BD_GET_KIOV(desc, i).kiov_page); } static inline void ptlrpc_release_bulk_noop(struct ptlrpc_bulk_desc *desc) diff --git a/lustre/include/lustre_patchless_compat.h b/lustre/include/lustre_patchless_compat.h index 644ab78..7bcdaf4 100644 --- a/lustre/include/lustre_patchless_compat.h +++ b/lustre/include/lustre_patchless_compat.h @@ -68,7 +68,7 @@ static inline void ll_remove_from_page_cache(struct page *page) static inline void ll_delete_from_page_cache(struct page *page) { ll_remove_from_page_cache(page); - page_cache_release(page); + put_page(page); } #else /* HAVE_DELETE_FROM_PAGE_CACHE */ #define ll_delete_from_page_cache(page) delete_from_page_cache(page) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 03c0866..5939468 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -180,7 +180,7 @@ void ll_release_page(struct inode *inode, struct page *page, truncate_complete_page(page->mapping, page); unlock_page(page); } - page_cache_release(page); + put_page(page); } /** diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index d03e92f..3950724 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -329,7 +329,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) vmpage = vio->u.fault.ft_vmpage; if (result != 0 && vmpage != NULL) { - page_cache_release(vmpage); + put_page(vmpage); vmf->page = NULL; } } @@ -370,7 +370,7 @@ restart: lock_page(vmpage); if (unlikely(vmpage->mapping == NULL)) { /* unlucky */ unlock_page(vmpage); - page_cache_release(vmpage); + put_page(vmpage); vmf->page = NULL; if (!printed && ++count > 16) { diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 15b0c3f..00ae698 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -231,7 +231,7 @@ out: if (vmpage != NULL) { if (rc != 0) unlock_page(vmpage); - page_cache_release(vmpage); + put_page(vmpage); } if (msg != NULL) { ll_ra_stats_inc(inode, which); diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 7830a83..1369c09 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -315,7 +315,7 @@ static void ll_free_user_pages(struct page **pages, int npages, int do_dirty) break; if (do_dirty) set_page_dirty_lock(pages[i]); - page_cache_release(pages[i]); + put_page(pages[i]); } #if defined(HAVE_DIRECTIO_ITER) || defined(HAVE_IOV_ITER_RW) @@ -670,7 +670,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, * one in commit page list, though. */ if (vmpage != NULL && plist->pl_nr > 0) { unlock_page(vmpage); - page_cache_release(vmpage); + put_page(vmpage); vmpage = NULL; } @@ -719,7 +719,7 @@ out: if (result < 0) { if (vmpage != NULL) { unlock_page(vmpage); - page_cache_release(vmpage); + put_page(vmpage); } if (io) io->ci_result = result; @@ -744,7 +744,7 @@ static int ll_write_end(struct file *file, struct address_space *mapping, int result = 0; ENTRY; - page_cache_release(vmpage); + put_page(vmpage); LASSERT(lcc != NULL); env = lcc->lcc_env; diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index 61b8bb9..591b249 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -481,7 +481,7 @@ static loff_t vvp_pgcache_find(const struct lu_env *env, id.vpi_index = vmpage->index; /* Cant support over 16T file */ nr = !(vmpage->index > 0xffffffff); - page_cache_release(vmpage); + put_page(vmpage); } lu_object_ref_del(&clob->co_lu, "dump", current); @@ -562,7 +562,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) page = cl_vmpage_page(vmpage, clob); unlock_page(vmpage); - page_cache_release(vmpage); + put_page(vmpage); } seq_printf(f, "%8x@"DFID": ", id.vpi_index, diff --git a/lustre/llite/vvp_page.c b/lustre/llite/vvp_page.c index e2afea4..ec050f5 100644 --- a/lustre/llite/vvp_page.c +++ b/lustre/llite/vvp_page.c @@ -63,7 +63,7 @@ static void vvp_page_fini_common(struct vvp_page *vpg) struct page *vmpage = vpg->vpg_page; LASSERT(vmpage != NULL); - page_cache_release(vmpage); + put_page(vmpage); } static void vvp_page_fini(const struct lu_env *env, @@ -523,7 +523,7 @@ int vvp_page_init(const struct lu_env *env, struct cl_object *obj, CLOBINVRNT(env, obj, vvp_object_invariant(obj)); vpg->vpg_page = vmpage; - page_cache_get(vmpage); + get_page(vmpage); if (page->cp_type == CPT_CACHEABLE) { /* in cache, decref in vvp_page_delete */ diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 74a29be..010fef7 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -2183,7 +2183,7 @@ next: stripe_hash = le64_to_cpu(dp->ldp_hash_end); kunmap(page); - page_cache_release(page); + put_page(page); page = NULL; /* reach the end of current stripe, go to next stripe */ @@ -2198,12 +2198,12 @@ next: le64_to_cpu(ent->lde_hash)) { min_ent = ent; kunmap(min_page); - page_cache_release(min_page); + put_page(min_page); min_idx = i; min_page = page; } else { kunmap(page); - page_cache_release(page); + put_page(page); page = NULL; } } else { @@ -2216,7 +2216,7 @@ next: out: if (*ppage != NULL) { kunmap(*ppage); - page_cache_release(*ppage); + put_page(*ppage); } *stripe_offset = min_idx; *entp = min_ent; @@ -2342,7 +2342,7 @@ static int lmv_read_striped_page(struct obd_export *exp, out: if (min_ent_page != NULL) { kunmap(min_ent_page); - page_cache_release(min_ent_page); + put_page(min_ent_page); } if (unlikely(rc != 0)) { diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 7c3fb96..7912100 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -960,7 +960,7 @@ static void mdc_release_page(struct page *page, int remove) truncate_complete_page(page->mapping, page); unlock_page(page); } - page_cache_release(page); + put_page(page); } static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, @@ -981,7 +981,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, if (found > 0 && !radix_tree_exceptional_entry(page)) { struct lu_dirpage *dp; - page_cache_get(page); + get_page(page); spin_unlock_irq(&mapping->tree_lock); /* * In contrast to find_lock_page() we are sure that directory @@ -1027,7 +1027,7 @@ static struct page *mdc_page_locate(struct address_space *mapping, __u64 *hash, page = NULL; } } else { - page_cache_release(page); + put_page(page); page = ERR_PTR(-EIO); } } else { @@ -1153,7 +1153,7 @@ struct readpage_param { static inline void delete_from_page_cache(struct page *page) { remove_from_page_cache(page); - page_cache_release(page); + put_page(page); } #endif @@ -1235,7 +1235,7 @@ static int mdc_read_page_remote(void *data, struct page *page0) page = page_pool[i]; if (rc < 0 || i >= rd_pgs) { - page_cache_release(page); + put_page(page); continue; } @@ -1255,7 +1255,7 @@ static int mdc_read_page_remote(void *data, struct page *page0) else CDEBUG(D_VFSTRACE, "page %lu add to page cache failed:" " rc = %d\n", offset, ret); - page_cache_release(page); + put_page(page); } if (page_pool != &page0) diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 3f5dfce..8d11e05 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -336,7 +336,7 @@ static void echo_page_fini(const struct lu_env *env, ENTRY; atomic_dec(&eco->eo_npages); - page_cache_release(slice->cpl_page->cp_vmpage); + put_page(slice->cpl_page->cp_vmpage); EXIT; } @@ -413,7 +413,7 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, struct echo_object *eco = cl2echo_obj(obj); ENTRY; - page_cache_get(page->cp_vmpage); + get_page(page->cp_vmpage); mutex_init(&ep->ep_lock); cl_page_slice_add(page, &ep->ep_cl, obj, index, &echo_page_ops); atomic_inc(&eco->eo_npages); diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 734e048..91034d2 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -471,7 +471,7 @@ static int osd_bufs_put(const struct lu_env *env, struct dt_object *dt, continue; LASSERT(PageLocked(lnb[i].lnb_page)); unlock_page(lnb[i].lnb_page); - page_cache_release(lnb[i].lnb_page); + put_page(lnb[i].lnb_page); lu_object_put(env, &dt->do_lu); lnb[i].lnb_page = NULL; } diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 59f4cc5..df2aa13 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -220,7 +220,7 @@ void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc, desc->bd_nob += len; if (pin) - page_cache_get(page); + get_page(page); kiov->kiov_page = page; kiov->kiov_offset = pageoffset; diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index 3e45abf..e32e558 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -421,7 +421,7 @@ int tgt_mod_init(void) void tgt_mod_exit(void) { if (tgt_page_to_corrupt != NULL) - page_cache_release(tgt_page_to_corrupt); + put_page(tgt_page_to_corrupt); lu_context_key_degister(&tgt_thread_key); lu_context_key_degister(&tgt_session_key);