Whamcloud - gitweb
Land b_smallfix onto HEAD (20040414_1359)
[fs/lustre-release.git] / lustre / obdfilter / filter_io_26.c
index fb43702..3794bba 100644 (file)
@@ -97,7 +97,8 @@ static int filter_range_is_mapped(struct inode *inode, obd_size offset, int len)
 
 int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
                           struct obd_ioobj *obj, int niocount,
-                          struct niobuf_local *res, struct obd_trans_info *oti)
+                          struct niobuf_local *res, struct obd_trans_info *oti,
+                          int rc)
 {
         struct obd_device *obd = exp->exp_obd;
         struct obd_run_ctxt saved;
@@ -105,16 +106,19 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
         struct fsfilt_objinfo fso;
         struct iattr iattr = { .ia_valid = ATTR_SIZE, .ia_size = 0, };
         struct inode *inode = NULL;
-        int rc = 0, i, k, cleanup_phase = 0, err;
+        int i, k, cleanup_phase = 0, err;
         unsigned long now = jiffies; /* DEBUGGING OST TIMEOUTS */
         int blocks_per_page;
-        struct dio_request *dreq;
+        struct dio_request *dreq = NULL;
         struct bio *bio = NULL;
         ENTRY;
         LASSERT(oti != NULL);
         LASSERT(objcount == 1);
         LASSERT(current->journal_info == NULL);
 
+        if (rc != 0)
+                GOTO(cleanup, rc);
+
         inode = res->dentry->d_inode;
         blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
         LASSERT(blocks_per_page <= MAX_BLOCKS_PER_PAGE);
@@ -134,7 +138,7 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
         push_ctxt(&saved, &obd->obd_ctxt, NULL);
         cleanup_phase = 2;
 
-        oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, oti);
+        oti->oti_handle = fsfilt_brw_start(obd, objcount, &fso, niocount, res, oti);
         if (IS_ERR(oti->oti_handle)) {
                 rc = PTR_ERR(oti->oti_handle);
                 CDEBUG(rc == -ENOSPC ? D_INODE : D_ERROR,
@@ -202,8 +206,6 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
                 submit_bio(WRITE, bio);
         }
 
-        filter_grant_commit(exp, niocount, res);
-
         /* time to wait for I/O completion */
         wait_event(dreq->wait, atomic_read(&dreq->numreqs) == 0);
 
@@ -238,6 +240,8 @@ int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount,
                 CERROR("slow commitrw commit %lus\n", (jiffies - now) / HZ);
 
 cleanup:
+        filter_grant_commit(exp, niocount, res);
+
         switch (cleanup_phase) {
         case 2:
                 pop_ctxt(&saved, &obd->obd_ctxt, NULL);