X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_io.c;h=4e2c0e3a5dca9967c41ebbd786608005770377b6;hp=dac36d241d4ca660fb201e7ac42377d61c8f25ed;hb=cf48a2d23bca685e1076e45370c5d3763c9a9952;hpb=36c62df64b5f3e2a45ca36bef5b6f62c866c8d92 diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index dac36d2..4e2c0e3 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -931,7 +931,23 @@ 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) +{ + return ldiskfs_journal_ensure_credits(handle, needed, + ldiskfs_trans_default_revoke_credits(inode->i_sb)); +} +#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 +956,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 +1072,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 +1087,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 +1496,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 */ @@ -2178,7 +2202,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 +2234,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); }