提交 38877f4e 编写于 作者: E Eric Sandeen 提交者: Theodore Ts'o

simplify some logic in ext4_mb_normalize_request

While reading through some of the mballoc code it seems that a couple
spots in the size normalization function could be streamlined.

The test for non-overlapping PAs can be or'd for the start & end
conditions, and the tests for adjacent PAs can be else-if'd - 
it's essentially independently testing:

	if (A + B <= C)
		...
	if (A > C)
		...

These cannot both be true so it seems like the else-if might
be slightly more efficient and/or informative.
Signed-off-by: NEric Sandeen <sandeen@redhat.com>
Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
上级 0373130d
...@@ -3184,23 +3184,18 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, ...@@ -3184,23 +3184,18 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
BUG_ON(!(ac->ac_o_ex.fe_logical >= pa_end || BUG_ON(!(ac->ac_o_ex.fe_logical >= pa_end ||
ac->ac_o_ex.fe_logical < pa->pa_lstart)); ac->ac_o_ex.fe_logical < pa->pa_lstart));
/* skip PA normalized request doesn't overlap with */ /* skip PAs this normalized request doesn't overlap with */
if (pa->pa_lstart >= end) { if (pa->pa_lstart >= end || pa_end <= start) {
spin_unlock(&pa->pa_lock);
continue;
}
if (pa_end <= start) {
spin_unlock(&pa->pa_lock); spin_unlock(&pa->pa_lock);
continue; continue;
} }
BUG_ON(pa->pa_lstart <= start && pa_end >= end); BUG_ON(pa->pa_lstart <= start && pa_end >= end);
/* adjust start or end to be adjacent to this pa */
if (pa_end <= ac->ac_o_ex.fe_logical) { if (pa_end <= ac->ac_o_ex.fe_logical) {
BUG_ON(pa_end < start); BUG_ON(pa_end < start);
start = pa_end; start = pa_end;
} } else if (pa->pa_lstart > ac->ac_o_ex.fe_logical) {
if (pa->pa_lstart > ac->ac_o_ex.fe_logical) {
BUG_ON(pa->pa_lstart > end); BUG_ON(pa->pa_lstart > end);
end = pa->pa_lstart; end = pa->pa_lstart;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册