Commit a9a8344e authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

ext4, jbd2: Provide accessor function for handle credits

Provide accessor function to get number of credits available in a handle
and use it from ext4. Later, computation of available credits won't be
so straightforward.
Reviewed-by: default avatarTheodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-11-jack@suse.czSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent a4130367
...@@ -119,8 +119,8 @@ handle_t *__ext4_journal_start_reserved(handle_t *handle, unsigned int line, ...@@ -119,8 +119,8 @@ handle_t *__ext4_journal_start_reserved(handle_t *handle, unsigned int line,
return ext4_get_nojournal(); return ext4_get_nojournal();
sb = handle->h_journal->j_private; sb = handle->h_journal->j_private;
trace_ext4_journal_start_reserved(sb, handle->h_buffer_credits, trace_ext4_journal_start_reserved(sb,
_RET_IP_); jbd2_handle_buffer_credits(handle), _RET_IP_);
err = ext4_journal_check_start(sb); err = ext4_journal_check_start(sb);
if (err < 0) { if (err < 0) {
jbd2_journal_free_reserved(handle); jbd2_journal_free_reserved(handle);
...@@ -138,10 +138,10 @@ int __ext4_journal_ensure_credits(handle_t *handle, int check_cred, ...@@ -138,10 +138,10 @@ int __ext4_journal_ensure_credits(handle_t *handle, int check_cred,
{ {
if (!ext4_handle_valid(handle)) if (!ext4_handle_valid(handle))
return 0; return 0;
if (handle->h_buffer_credits >= check_cred) if (jbd2_handle_buffer_credits(handle) >= check_cred)
return 0; return 0;
return ext4_journal_extend(handle, return ext4_journal_extend(handle,
extend_cred - handle->h_buffer_credits); extend_cred - jbd2_handle_buffer_credits(handle));
} }
static void ext4_journal_abort_handle(const char *caller, unsigned int line, static void ext4_journal_abort_handle(const char *caller, unsigned int line,
...@@ -289,7 +289,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, ...@@ -289,7 +289,7 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
handle->h_type, handle->h_type,
handle->h_line_no, handle->h_line_no,
handle->h_requested_credits, handle->h_requested_credits,
handle->h_buffer_credits, err); jbd2_handle_buffer_credits(handle), err);
return err; return err;
} }
ext4_error_inode(inode, where, line, ext4_error_inode(inode, where, line,
...@@ -300,7 +300,8 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, ...@@ -300,7 +300,8 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
handle->h_type, handle->h_type,
handle->h_line_no, handle->h_line_no,
handle->h_requested_credits, handle->h_requested_credits,
handle->h_buffer_credits, err); jbd2_handle_buffer_credits(handle),
err);
} }
} else { } else {
if (inode) if (inode)
......
...@@ -288,13 +288,6 @@ static inline int ext4_handle_is_aborted(handle_t *handle) ...@@ -288,13 +288,6 @@ static inline int ext4_handle_is_aborted(handle_t *handle)
return 0; return 0;
} }
static inline int ext4_handle_has_enough_credits(handle_t *handle, int needed)
{
if (ext4_handle_valid(handle) && handle->h_buffer_credits < needed)
return 0;
return 1;
}
#define ext4_journal_start_sb(sb, type, nblocks) \ #define ext4_journal_start_sb(sb, type, nblocks) \
__ext4_journal_start_sb((sb), __LINE__, (type), (nblocks), 0) __ext4_journal_start_sb((sb), __LINE__, (type), (nblocks), 0)
......
...@@ -2314,7 +2314,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, ...@@ -2314,7 +2314,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
flags & XATTR_CREATE); flags & XATTR_CREATE);
brelse(bh); brelse(bh);
if (!ext4_handle_has_enough_credits(handle, credits)) { if (jbd2_handle_buffer_credits(handle) < credits) {
error = -ENOSPC; error = -ENOSPC;
goto cleanup; goto cleanup;
} }
......
...@@ -1645,6 +1645,12 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal) ...@@ -1645,6 +1645,12 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal)
return tid; return tid;
} }
static inline int jbd2_handle_buffer_credits(handle_t *handle)
{
return handle->h_buffer_credits;
}
#ifdef __KERNEL__ #ifdef __KERNEL__
#define buffer_trace_init(bh) do {} while (0) #define buffer_trace_init(bh) do {} while (0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment