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;
}
/*
- * the function is used to free all pages used for request
- * just to mimic cacheless OSS which don't occupy much memory
- */
-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++) {
- obd_off start;
- obd_off end;
-
- start = rnb->offset >> CFS_PAGE_SHIFT;
- end = (rnb->offset + rnb->len) >> CFS_PAGE_SHIFT;
- invalidate_mapping_pages(inode->i_mapping, start, end);
- /* just to avoid warnings */
- start = 0;
- end = 0;
- }
-}
-
-/*
* 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)
{
- struct niobuf_remote *rnb;
int i;
LASSERT(inode != NULL);
+ for (i = 0; i < obj->ioo_bufcnt; i++, rnb++) {
#ifdef HAVE_TRUNCATE_RANGE
- for (i = 0, rnb = nb; i < obj->ioo_bufcnt; i++, rnb++) {
/* remove pages in which range is fit */
truncate_inode_pages_range(inode->i_mapping,
rnb->offset & CFS_PAGE_MASK,
(rnb->offset + rnb->len - 1) |
~CFS_PAGE_MASK);
- }
-#elif (defined HAVE_TRUNCATE_COMPLETE)
- for (i = 0, lnb = res; i < pages; i++, lnb++)
- truncate_complete_page(inode->i_mapping, lnb->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,
if (res->dentry != NULL)
inode = res->dentry->d_inode;
- for (i = 0, lnb = res; i < npages; i++, lnb++)
- if (lnb->page != NULL)
+ for (i = 0, lnb = res; i < npages; i++, lnb++) {
+ 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, npages, res,
- inode);
-
- for (i = 0, lnb = res; i < npages; i++, lnb++)
- lnb->page = NULL;
+ filter_release_cache(exp->exp_obd, obj, rnb, inode);
if (res->dentry != NULL)
f_dput(res->dentry);