From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 610FC35AC11 for ; Thu, 21 May 2026 08:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779352798; cv=none; b=IMuhBnUSz005Jjf1U/uap3XhrDyJjBlP6CrA1CtThrIphpPnGcWhtK17mU4G8/TsT9r+TY7fXpI6xE15KD9jS9OVOsea+4o2gbIdKz0dibAa2LVNn9K2szTgPYsw5v0f//GXXD5Bq2absMbp++7gSf8x8pyHAkb//tgqA7+ImOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779352798; c=relaxed/simple; bh=rR2s008v9fQqIlomUKgQJRJf62j9C7D2kLJG6ICW/2A=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=g52yCL/xyZBCOQzdsyBm2U6rAWn1Dy+GPSaD+DBt0Ktrc50gjhZs5b6F/EOfSrqS6iE/TWDSDlcVTSxu4FMhE0ut3EJYqtF9s+viuAhsCXdFfCxTgM22fuY23tdHlTryE83WV8I1pdOdhfLs4gezeSbV7D74jh7SgIUqiZyH4YA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XsKuXJ2p; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XsKuXJ2p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3069E1F000E9; Thu, 21 May 2026 08:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779352788; bh=26uZD+IZUffG19NkVVVm9aNMMe6frsDq/dYJD1ulx+M=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=XsKuXJ2pmgYDcqANlFIkUGbH+mtk4upRMmishlZk5xbSSfi/B3/faoO9x3eOMPkvW +obbIUWpudmNKj+2OAVECaYH8+1+LxQ6WXOiTyrRRD/3EMXMlMH3rjq47ht1dTR73v +N/8/0Q9LvuqOjWEk0v4PrOBYsqNAFtAmC9CATqoAZl7DnWtkM6nHYyeUG2A2LFKDe 5YQY5ywBzACm4MYddSxhTqxtSIF0xwrmxfdM0SdK1H42euTlN3j8HALNnPgFyurvmU NXK2ZileujkYoBmTU/Z1JDNclGLBa2Z2CdyNhOKXEz+gYVbqa0/A4raO7zYriN2zgV MxRyZWeWw05IQ== Message-ID: <353a532f-6e22-4aed-8cf8-680c67685754@kernel.org> Date: Thu, 21 May 2026 16:39:42 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, ruipengqi3@gmail.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com Subject: Re: [PATCH] f2fs: submit cached data bios before gc_merge GC To: Wenjie Qi , jaegeuk@kernel.org References: <20260521053050.1785858-1-qiwenjie@xiaomi.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260521053050.1785858-1-qiwenjie@xiaomi.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I've submitted the same fix previously as below: https://lore.kernel.org/linux-f2fs-devel/20260519011438.1168155-1-chao@kernel.org On 5/21/26 13:30, Wenjie Qi wrote: > Commit fefdf0723650 ("f2fs: fix potential deadlock in f2fs_balance_fs()") > added cached DATA bio submission before direct foreground GC in > f2fs_balance_fs(). > > This avoids a deadlock between writeback and GC on cached data folios. > However, when gc_merge is enabled, f2fs_balance_fs() does not execute > foreground GC in the caller. It wakes the background GC thread and waits > for that foreground request to finish. > > That branch currently skips the cached DATA bio submission, so the same > foreground GC request can still start with cached DATA bios pending. > > Move the cached DATA bio submission before the gc_merge branch so both > direct and merged foreground GC paths satisfy the same precondition. > > Fixes: fefdf0723650 ("f2fs: fix potential deadlock in f2fs_balance_fs()") > Signed-off-by: Wenjie Qi > --- > fs/f2fs/segment.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index 7c8ac62b1b0..1ef4edb7707 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -445,6 +445,13 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) > if (has_enough_free_secs(sbi, 0, 0)) > return; > > + /* > + * Submit all cached OPU/IPU DATA bios before triggering > + * foreground GC to avoid potential deadlocks. > + */ > + f2fs_submit_merged_write(sbi, DATA); > + f2fs_submit_all_merged_ipu_writes(sbi); > + > if (test_opt(sbi, GC_MERGE) && sbi->gc_thread && > sbi->gc_thread->f2fs_gc_task) { > DEFINE_WAIT(wait); > @@ -464,13 +471,6 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) > .err_gc_skipped = false, > .nr_free_secs = 1 }; > > - /* > - * Submit all cached OPU/IPU DATA bios before triggering > - * foreground GC to avoid potential deadlocks. > - */ > - f2fs_submit_merged_write(sbi, DATA); > - f2fs_submit_all_merged_ipu_writes(sbi); > - > f2fs_down_write_trace(&sbi->gc_lock, &gc_control.lc); > stat_inc_gc_call_count(sbi, FOREGROUND); > f2fs_gc(sbi, &gc_control);