Whamcloud - gitweb
b=20762
authormanoj <manoj>
Thu, 24 Sep 2009 18:50:29 +0000 (18:50 +0000)
committermanoj <manoj>
Thu, 24 Sep 2009 18:50:29 +0000 (18:50 +0000)
o=tappro
r=alex.zhuravlev
r=tappro

Do truncate only for new kernels

lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/obdfilter/filter_io_26.c

index c93f44f..01e4ea2 100644 (file)
@@ -168,8 +168,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;
index 5ed6c98..925e5dc 100644 (file)
@@ -341,56 +341,30 @@ 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
- */
-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,
@@ -933,17 +907,15 @@ static int filter_commitrw_read(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);
index 964f4f1..56547b3 100644 (file)
@@ -790,11 +790,12 @@ cleanup:
         }
         f_dput(res->dentry);
 
-        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);
 }