Whamcloud - gitweb
Land b_orphan on HEAD (20040130_1601)
[fs/lustre-release.git] / lustre / obdfilter / filter_io.c
index 1ce8825..afb49db 100644 (file)
@@ -213,6 +213,8 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                 CDEBUG(D_INFO, "finish_page_read: %lu jiffies\n",
                        (jiffies - now));
 
+        filter_tally_read(&exp->exp_obd->u.filter, res, niocount);
+
         EXIT;
 
  cleanup:
@@ -358,13 +360,24 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
 {
         struct obd_ioobj *o;
         struct niobuf_local *lnb;
-        int i, j;
+        int i, j, drop = 0;
         ENTRY;
 
+        if (res->dentry != NULL)
+                drop = (res->dentry->d_inode->i_size >
+                        exp->exp_obd->u.filter.fo_readcache_max_filesize);
+
         for (i = 0, o = obj, lnb = res; i < objcount; i++, o++) {
                 for (j = 0 ; j < o->ioo_bufcnt ; j++, lnb++) {
-                        if (lnb->page != NULL)
-                                page_cache_release(lnb->page);
+                        if (lnb->page == NULL)
+                                continue;
+                        /* drop from cache like truncate_list_pages() */
+                        if (drop && !TryLockPage(lnb->page)) {
+                                if (lnb->page->mapping)
+                                        truncate_complete_page(lnb->page);
+                                unlock_page(lnb->page);
+                        }
+                        page_cache_release(lnb->page);
                 }
         }
         if (res->dentry != NULL)