Skip to content

Commit 309a85b

Browse files
Xiaowei.Hutorvalds
authored andcommitted
ocfs2: ac->ac_allow_chain_relink=0 won't disable group relink
ocfs2_block_group_alloc_discontig() disables chain relink by setting ac->ac_allow_chain_relink = 0 because it grabs clusters from multiple cluster groups. It doesn't keep the credits for all chain relink,but ocfs2_claim_suballoc_bits overrides this in this call trace: ocfs2_block_group_claim_bits()->ocfs2_claim_clusters()-> __ocfs2_claim_clusters()->ocfs2_claim_suballoc_bits() ocfs2_claim_suballoc_bits set ac->ac_allow_chain_relink = 1; then call ocfs2_search_chain() one time and disable it again, and then we run out of credits. Fix is to allow relink by default and disable it in ocfs2_block_group_alloc_discontig. Without this patch, End-users will run into a crash due to run out of credits, backtrace like this: RIP: 0010:[<ffffffffa0808b14>] [<ffffffffa0808b14>] jbd2_journal_dirty_metadata+0x164/0x170 [jbd2] RSP: 0018:ffff8801b919b5b8 EFLAGS: 00010246 RAX: 0000000000000000 RBX: ffff88022139ddc0 RCX: ffff880159f652d0 RDX: ffff880178aa3000 RSI: ffff880159f652d0 RDI: ffff880087f09bf8 RBP: ffff8801b919b5e8 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000001e00 R11: 00000000000150b0 R12: ffff880159f652d0 R13: ffff8801a0cae908 R14: ffff880087f09bf8 R15: ffff88018d177800 FS: 00007fc9b0b6b6e0(0000) GS:ffff88022fd40000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: 000000000040819c CR3: 0000000184017000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process dd (pid: 9945, threadinfo ffff8801b919a000, task ffff880149a264c0) Call Trace: ocfs2_journal_dirty+0x2f/0x70 [ocfs2] ocfs2_relink_block_group+0x111/0x480 [ocfs2] ocfs2_search_chain+0x455/0x9a0 [ocfs2] ... Signed-off-by: Xiaowei.Hu <xiaowei.hu@oracle.com> Reviewed-by: Srinivas Eeda <srinivas.eeda@oracle.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 32918dd commit 309a85b

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎fs/ocfs2/suballoc.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ ocfs2_block_group_alloc_discontig(handle_t *handle,
642642
* cluster groups will be staying in cache for the duration of
643643
* this operation.
644644
*/
645-
ac->ac_allow_chain_relink = 0;
645+
ac->ac_disable_chain_relink = 1;
646646

647647
/* Claim the first region */
648648
status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits,
@@ -1823,7 +1823,7 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
18231823
* Do this *after* figuring out how many bits we're taking out
18241824
* of our target group.
18251825
*/
1826-
if (ac->ac_allow_chain_relink &&
1826+
if (!ac->ac_disable_chain_relink &&
18271827
(prev_group_bh) &&
18281828
(ocfs2_block_group_reasonably_empty(bg, res->sr_bits))) {
18291829
status = ocfs2_relink_block_group(handle, alloc_inode,
@@ -1928,7 +1928,6 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
19281928

19291929
victim = ocfs2_find_victim_chain(cl);
19301930
ac->ac_chain = victim;
1931-
ac->ac_allow_chain_relink = 1;
19321931

19331932
status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
19341933
res, &bits_left);
@@ -1947,7 +1946,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
19471946
* searching each chain in order. Don't allow chain relinking
19481947
* because we only calculate enough journal credits for one
19491948
* relink per alloc. */
1950-
ac->ac_allow_chain_relink = 0;
1949+
ac->ac_disable_chain_relink = 1;
19511950
for (i = 0; i < le16_to_cpu(cl->cl_next_free_rec); i ++) {
19521951
if (i == victim)
19531952
continue;

‎fs/ocfs2/suballoc.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct ocfs2_alloc_context {
4949

5050
/* these are used by the chain search */
5151
u16 ac_chain;
52-
int ac_allow_chain_relink;
52+
int ac_disable_chain_relink;
5353
group_search_t *ac_group_search;
5454

5555
u64 ac_last_group;

0 commit comments

Comments
 (0)