diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c
index 74d5aa8a91485457ed4495e3ce5d080f67fe9350..526828c2237f0be8c8554cb00f06e9408d3b350f 100644
--- a/lustre/obdfilter/filter_io.c
+++ b/lustre/obdfilter/filter_io.c
@@ -345,7 +345,6 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                               struct lustre_capa *capa)
 {
         struct obd_device *obd = exp->exp_obd;
-        struct filter_obd *fo = &obd->u.filter;
         struct timeval start, end;
         struct lvfs_run_ctxt saved;
         struct niobuf_local *lnb;
@@ -467,10 +466,6 @@ static int filter_preprw_read(int cmd, struct obd_export *exp, struct obdo *oa,
                 }
         }
 
-        if (inode && (fo->fo_read_cache == 0 ||
-                        i_size_read(inode) > fo->fo_readcache_max_filesize))
-                filter_invalidate_cache(obd, obj, nb, inode);
-
         if (rc != 0) {
                 if (dentry != NULL)
                         f_dput(dentry);
@@ -830,6 +825,7 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
                                 int npages, struct niobuf_local *res,
                                 struct obd_trans_info *oti, int rc)
 {
+        struct filter_obd *fo = &exp->exp_obd->u.filter;
         struct inode *inode = NULL;
         struct ldlm_res_id res_id;
         struct ldlm_resource *resource = NULL;
@@ -861,6 +857,10 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
                 }
         }
 
+        if (inode && (fo->fo_read_cache == 0 ||
+                        i_size_read(inode) > fo->fo_readcache_max_filesize))
+                filter_invalidate_cache(exp->exp_obd, obj, rnb, inode);
+
         if (res->dentry != NULL)
                 f_dput(res->dentry);
         RETURN(rc);