Unverified Commit 4f1da763 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10683 ocfs2: fix DIO failure due to insufficient transaction credits

parents cafc1d1d c6c647b7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2373,6 +2373,11 @@ static int ocfs2_dio_end_io_write(struct inode *inode,
	}

	list_for_each_entry(ue, &dwc->dw_zero_list, ue_node) {
		ret = ocfs2_assure_trans_credits(handle, credits);
		if (ret < 0) {
			mlog_errno(ret);
			break;
		}
		ret = ocfs2_mark_extent_written(inode, &et, handle,
						ue->ue_cpos, 1,
						ue->ue_phys,
+17 −0
Original line number Diff line number Diff line
@@ -449,6 +449,23 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)
	return status;
}

/*
 * Make sure handle has at least 'nblocks' credits available. If it does not
 * have that many credits available, we will try to extend the handle to have
 * enough credits. If that fails, we will restart transaction to have enough
 * credits. Similar notes regarding data consistency and locking implications
 * as for ocfs2_extend_trans() apply here.
 */
int ocfs2_assure_trans_credits(handle_t *handle, int nblocks)
{
	int old_nblks = jbd2_handle_buffer_credits(handle);

	trace_ocfs2_assure_trans_credits(old_nblks);
	if (old_nblks >= nblocks)
		return 0;
	return ocfs2_extend_trans(handle, nblocks - old_nblks);
}

/*
 * If we have fewer than thresh credits, extend by OCFS2_MAX_TRANS_DATA.
 * If that fails, restart the transaction & regain write access for the
+2 −0
Original line number Diff line number Diff line
@@ -244,6 +244,8 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb,
int			     ocfs2_commit_trans(struct ocfs2_super *osb,
						handle_t *handle);
int			     ocfs2_extend_trans(handle_t *handle, int nblocks);
int			     ocfs2_assure_trans_credits(handle_t *handle,
						int nblocks);
int			     ocfs2_allocate_extend_trans(handle_t *handle,
						int thresh);

+2 −0
Original line number Diff line number Diff line
@@ -2578,6 +2578,8 @@ DEFINE_OCFS2_ULL_UINT_EVENT(ocfs2_commit_cache_end);

DEFINE_OCFS2_INT_INT_EVENT(ocfs2_extend_trans);

DEFINE_OCFS2_INT_EVENT(ocfs2_assure_trans_credits);

DEFINE_OCFS2_INT_EVENT(ocfs2_extend_trans_restart);

DEFINE_OCFS2_INT_INT_EVENT(ocfs2_allocate_extend_trans);