Whamcloud - gitweb
LU-14205 osd-ldiskfs: fix return of osd_extend_restart_trans()
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_io.c
index 15392bb..7631d61 100644 (file)
@@ -159,7 +159,7 @@ void osd_fini_iobuf(struct osd_device *d, struct osd_iobuf *iobuf)
 #ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
 static void dio_complete_routine(struct bio *bio)
 {
-       int error = bio->bi_status;
+       int error = blk_status_to_errno(bio->bi_status);
 #else
 static void dio_complete_routine(struct bio *bio, int error)
 {
@@ -931,7 +931,30 @@ static int osd_chunk_trans_blocks(struct inode *inode, int nrblocks)
        return ret;
 }
 
-static int osd_extend_trans(handle_t *handle, int needed)
+#ifdef HAVE_LDISKFS_JOURNAL_ENSURE_CREDITS
+static int osd_extend_trans(handle_t *handle, int needed,
+                           struct inode *inode)
+{
+       return  __ldiskfs_journal_ensure_credits(handle, needed, needed,
+               ldiskfs_trans_default_revoke_credits(inode->i_sb));
+}
+
+static int osd_extend_restart_trans(handle_t *handle, int needed,
+                                   struct inode *inode)
+{
+       int rc;
+
+       rc = ldiskfs_journal_ensure_credits(handle, needed,
+               ldiskfs_trans_default_revoke_credits(inode->i_sb));
+       /* this means journal has been restarted */
+       if (rc > 0)
+               rc = 0;
+
+       return rc;
+}
+#else
+static int osd_extend_trans(handle_t *handle, int needed,
+                           struct inode *inode)
 {
        if (ldiskfs_handle_has_enough_credits(handle, needed))
                return 0;
@@ -940,16 +963,18 @@ static int osd_extend_trans(handle_t *handle, int needed)
                                      needed - handle->h_buffer_credits);
 }
 
-static int osd_extend_restart_trans(handle_t *handle, int needed)
+static int osd_extend_restart_trans(handle_t *handle, int needed,
+                                   struct inode *inode)
 {
 
-       int rc = osd_extend_trans(handle, needed);
+       int rc = osd_extend_trans(handle, needed, inode);
 
        if (rc <= 0)
                return rc;
 
        return ldiskfs_journal_restart(handle, needed);
 }
+#endif /* HAVE_LDISKFS_JOURNAL_ENSURE_CREDITS */
 
 static int osd_ldiskfs_map_write(struct inode *inode, struct osd_iobuf *iobuf,
                                 struct osd_device *osd, sector_t start_blocks,
@@ -1054,7 +1079,7 @@ cont_map:
                         * credits to insert 1 extent into extent tree.
                         */
                        credits = osd_chunk_trans_blocks(inode, blen);
-                       rc = osd_extend_trans(handle, credits);
+                       rc = osd_extend_trans(handle, credits, inode);
                        if (rc < 0)
                                GOTO(cleanup, rc);
                        /*
@@ -1069,7 +1094,12 @@ cont_map:
                                        count, &disk_size, user_size);
                                if (rc)
                                        GOTO(cleanup, rc);
+#ifdef HAVE_LDISKFS_JOURNAL_ENSURE_CREDITS
+                               rc = ldiskfs_journal_restart(handle, credits,
+                                       ldiskfs_trans_default_revoke_credits(inode->i_sb));
+#else
                                rc = ldiskfs_journal_restart(handle, credits);
+#endif
                                if (rc)
                                        GOTO(cleanup, rc);
                                start_blocks += count;
@@ -1473,7 +1503,8 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt,
                        handle_t *handle = ldiskfs_journal_current_handle();
 
                        LASSERT(handle != NULL);
-                       rc = osd_extend_restart_trans(handle, save_credits);
+                       rc = osd_extend_restart_trans(handle, save_credits,
+                                                     inode);
                }
        } else {
                /* no pages to write, no transno is needed */
@@ -1918,7 +1949,7 @@ static int osd_ldiskfs_write_record(struct dt_object *dt, void *buf,
                if (unlikely(IS_ERR_OR_NULL(bh) && !sync))
                        CWARN(
                              "%s: adding bh without locking off %llu (block %lu, size %d, offs %llu)\n",
-                             inode->i_sb->s_id,
+                             osd_ino2name(inode),
                              offset, block, bufsize, *offs);
 
                if (IS_ERR_OR_NULL(bh)) {
@@ -1952,8 +1983,8 @@ static int osd_ldiskfs_write_record(struct dt_object *dt, void *buf,
 
                        CERROR(
                               "%s: error reading offset %llu (block %lu, size %d, offs %llu), credits %d/%d: rc = %d\n",
-                              inode->i_sb->s_id, offset, block, bufsize, *offs,
-                              credits, handle->h_buffer_credits, err);
+                              osd_ino2name(inode), offset, block, bufsize,
+                              *offs, credits, handle->h_buffer_credits, err);
                        break;
                }
 
@@ -2178,7 +2209,7 @@ static int osd_fallocate(const struct lu_env *env, struct dt_object *dt,
                }
 
                /* TODO: quota check */
-               rc = osd_extend_restart_trans(handle, credits);
+               rc = osd_extend_restart_trans(handle, credits, inode);
                if (rc)
                        break;
 
@@ -2210,11 +2241,11 @@ static int osd_fallocate(const struct lu_env *env, struct dt_object *dt,
        }
 
 out:
-       inode_unlock(inode);
-
        /* extand credits if needed for operations such as attribute set */
        if (rc >= 0)
-               rc = osd_extend_restart_trans(handle, save_credits);
+               rc = osd_extend_restart_trans(handle, save_credits, inode);
+
+       inode_unlock(inode);
 
        RETURN(rc);
 }