From 124d3d170ef494c7fa3c7da9f660c4bd536e56ee Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 6 Mar 2009 21:27:58 +0000 Subject: [PATCH] - use invalidate_mapping_pages for old kernels in case of disabled ROC for simplicity b:18718 i:adilger,johann --- lustre/obdfilter/filter_internal.h | 4 +-- lustre/obdfilter/filter_io.c | 59 ++++++++++++-------------------------- lustre/obdfilter/filter_io_26.c | 11 +++---- lustre/tests/sanity.sh | 4 +++ 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index 4d3dd30..b3d850e 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -162,8 +162,8 @@ int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount, struct niobuf_local *, struct obd_trans_info *, int rc); int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo, obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *); -void filter_invalidate_cache(struct obd_device *, struct obd_ioobj *, - struct niobuf_remote *, struct inode *); +void filter_release_cache(struct obd_device *, struct obd_ioobj *, + struct niobuf_remote *, struct inode *); /* filter_io_*.c */ struct filter_iobuf; diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 334f64e..8167a0c 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -315,51 +315,32 @@ static int filter_map_remote_to_local(int objcount, struct obd_ioobj *obj, } /* - * the function is used to free all pages used for request - * just to mimic cacheless OSS which don't occupy much memory + * Invalidating the pages to get them out of cache doesn't work because + * LNET pins the pages. Instead (on newer kernels) the pages are truncated + * from the cache, while older kernels (RHEL4 and SLES9) just leave them in + * the cache. b=18718/ */ -void filter_invalidate_cache(struct obd_device *obd, struct obd_ioobj *obj, - struct niobuf_remote *nb, struct inode *inode) -{ - struct niobuf_remote *rnb; - int i; - - LASSERT(inode != NULL); - for (i = 0, rnb = nb; i < obj->ioo_bufcnt; i++, rnb++) { - invalidate_mapping_pages(inode->i_mapping, - rnb->offset >> CFS_PAGE_SHIFT, - (rnb->offset + rnb->len) >> - CFS_PAGE_SHIFT); - } -} - -/* - * the invalidate above doesn't work during read because lnet pins pages. - * The truncate is used here instead to drop pages from cache - */ -void filter_truncate_cache(struct obd_device *obd, struct obd_ioobj *obj, - struct niobuf_remote *nb, int pages, - struct niobuf_local *res, struct inode *inode) +void filter_release_cache(struct obd_device *obd, struct obd_ioobj *obj, + struct niobuf_remote *rnb, struct inode *inode) { int i; LASSERT(inode != NULL); + for (i = 0; i < obj->ioo_bufcnt; i++, rnb++) { #ifdef HAVE_TRUNCATE_RANGE - for (i = 0; i < obj->ioo_bufcnt; i++, nb++) { /* remove pages in which range is fit */ truncate_inode_pages_range(inode->i_mapping, - nb->offset & CFS_PAGE_MASK, - (nb->offset + nb->len - 1) | + rnb->offset & CFS_PAGE_MASK, + (rnb->offset + rnb->len - 1) | ~CFS_PAGE_MASK); - } -#elif (defined HAVE_TRUNCATE_COMPLETE_PAGE) - for (i = 0; i < pages; i++, res++) { - if (res->page != NULL) - truncate_complete_page(inode->i_mapping, res->page); - } #else -#error "Nor truncate_inode_pages_range or truncate_complete_page are supported" + /* use invalidate for old kernels */ + invalidate_mapping_pages(inode->i_mapping, + rnb->offset >> CFS_PAGE_SHIFT, + (rnb->offset + rnb->len) >> + CFS_PAGE_SHIFT); #endif + } } static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa, @@ -901,17 +882,15 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa, inode = res->dentry->d_inode; for (i = 0, lnb = res; i < pages; i++, lnb++) { - if (lnb->page != NULL) + if (lnb->page != NULL) { page_cache_release(lnb->page); + lnb->page = NULL; + } } if (inode && (fo->fo_read_cache == 0 || i_size_read(inode) > fo->fo_readcache_max_filesize)) - filter_truncate_cache(exp->exp_obd, obj, rnb, pages, res, - inode); - - for (i = 0, lnb = res; i < pages; i++, lnb++) - lnb->page = NULL; + filter_release_cache(exp->exp_obd, obj, rnb, inode); if (res->dentry != NULL) f_dput(res->dentry); diff --git a/lustre/obdfilter/filter_io_26.c b/lustre/obdfilter/filter_io_26.c index aad4451..d018fc7 100644 --- a/lustre/obdfilter/filter_io_26.c +++ b/lustre/obdfilter/filter_io_26.c @@ -763,11 +763,12 @@ cleanup: lnb->page = NULL; } - if (inode && (fo->fo_writethrough_cache == 0 || - i_size_read(inode) > fo->fo_readcache_max_filesize)) - filter_invalidate_cache(obd, obj, nb, inode); - - up_read(&inode->i_alloc_sem); + if (inode) { + if (fo->fo_writethrough_cache == 0 || + i_size_read(inode) > fo->fo_readcache_max_filesize) + filter_release_cache(obd, obj, nb, inode); + up_read(&inode->i_alloc_sem); + } RETURN(rc); } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 397f4f0..2bcaed5 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5677,6 +5677,10 @@ function roc_hit() { } test_151() { + if ! grep -q truncate_inode_pages_range /proc/kallsyms; then #b=18718 + skip "old RHEL4/SLES9 kernel" && return + fi + local CPAGES=3 # check whether obdfilter is cache capable at all -- 1.8.3.1