Whamcloud - gitweb
r=adilger
[fs/lustre-release.git] / lustre / obdfilter / filter_io_26.c
index 5fc41e3..848025d 100644 (file)
@@ -36,8 +36,6 @@
 #include <linux/lustre_fsfilt.h>
 #include "filter_internal.h"
 
-#warning "implement writeback mode -bzzz"
-
 /* 512byte block min */
 #define MAX_BLOCKS_PER_PAGE (PAGE_SIZE / 512)
 struct dio_request {
@@ -297,7 +295,7 @@ int filter_do_bio(struct obd_device *obd, struct inode *inode,
                 rc = dreq->dr_error;
         RETURN(rc);
 }
-  
 /* These are our hacks to keep our directio/bh IO coherent with ext3's
  * page cache use.  Most notably ext3 reads file data into the page
  * cache when it is zeroing the tail of partial-block truncates and
@@ -394,9 +392,11 @@ int filter_direct_io(int rw, struct dentry *dchild, void *iobuf,
                 rc2 = filter_finish_transno(exp, oti, 0);
                 if (rc2 != 0)
                         CERROR("can't close transaction: %d\n", rc);
+                rc = (rc == 0) ? rc2 : rc;
+
+                rc2 = fsfilt_commit_async(obd,inode,oti->oti_handle,wait_handle);
+                rc = (rc == 0) ? rc2 : rc;
 
-                if (rc == 0)
-                        rc = rc2;
                 if (rc != 0)
                         RETURN(rc);
         }
@@ -443,7 +443,9 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         unsigned long now = jiffies;
         int i, err, cleanup_phase = 0;
         struct obd_device *obd = exp->exp_obd;
+        void *wait_handle = NULL;
         int   total_size = 0;
+        loff_t old_size;
         ENTRY;
 
         LASSERT(oti != NULL);
@@ -496,6 +498,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         cleanup_phase = 2;
 
         down(&inode->i_sem);
+        old_size = inode->i_size;
         oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, res,
                                            oti);
         if (IS_ERR(oti->oti_handle)) {
@@ -513,22 +516,25 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa,
         iattr_from_obdo(&iattr,oa,OBD_MD_FLATIME|OBD_MD_FLMTIME|OBD_MD_FLCTIME);
         /* filter_direct_io drops i_sem */
         rc = filter_direct_io(OBD_BRW_WRITE, res->dentry, dreq, exp, &iattr,
-                              oti, NULL);
+                              oti, &wait_handle);
+
+#if 0
+        if (inode->i_size != old_size) {
+                struct llog_cookie *cookie = obdo_logcookie(oa);
+                struct lustre_id *id = obdo_id(oa);
+                filter_log_sz_change(obd, id, oa->o_easize, cookie, inode);
+        }
+#endif
+
         if (rc == 0)
                 obdo_from_inode(oa, inode, FILTER_VALID_FLAGS);
 
         fsfilt_check_slow(now, obd_timeout, "direct_io");
 
-        err = fsfilt_commit(obd, obd->u.filter.fo_sb, inode, oti->oti_handle,
-                            obd_sync_filter);
-        if (err)
+        err = fsfilt_commit_wait(obd, inode, wait_handle);
+        if (rc == 0)
                 rc = err;
-
-        if (obd_sync_filter && !err)
-                LASSERTF(oti->oti_transno <= obd->obd_last_committed,
-                         "oti_transno "LPU64" last_committed "LPU64"\n",
-                         oti->oti_transno, obd->obd_last_committed);
-
+   
         fsfilt_check_slow(now, obd_timeout, "commitrw commit");
 
 cleanup: