From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF91C77B75 for ; Mon, 8 May 2023 10:37:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234733AbjEHKhA (ORCPT ); Mon, 8 May 2023 06:37:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234738AbjEHKgh (ORCPT ); Mon, 8 May 2023 06:36:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDDE51BD7 for ; Mon, 8 May 2023 03:36:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 691786279C for ; Mon, 8 May 2023 10:36:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69347C433EF; Mon, 8 May 2023 10:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1683542174; bh=Gl5Byci5qH/0fnraDLl/CWuxLnM+iUCqU9yqv1bYXv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okhJkocay+kxoiBWafu91mB97VGCUvj5th3NZp6fGCLVqGLE3m4JOJkMQQxFcanEN tMh95K5qM5lbP7HPIW9MtoSObrVrNlcJJDGvBWKsS9Xph94wNjKj355F9+sDj1k4cr qvd9dJ4usGNcCm47xgELkHB7gnEuWCxsYvsLqI5Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yonggil Song , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.2 319/663] f2fs: fix uninitialized skipped_gc_rwsem Date: Mon, 8 May 2023 11:42:25 +0200 Message-Id: <20230508094438.541918702@linuxfoundation.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508094428.384831245@linuxfoundation.org> References: <20230508094428.384831245@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yonggil Song [ Upstream commit c17caf0ba3aa3411b96c71b4ce24be1040b8f3e8 ] When f2fs skipped a gc round during victim migration, there was a bug which would skip all upcoming gc rounds unconditionally because skipped_gc_rwsem was not initialized. It fixes the bug by correctly initializing the skipped_gc_rwsem inside the gc loop. Fixes: 6f8d4455060d ("f2fs: avoid fi->i_gc_rwsem[WRITE] lock in f2fs_gc") Signed-off-by: Yonggil Song Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 6e2cae3d2e717..72cda2f9380f2 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1795,8 +1795,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) prefree_segments(sbi)); cpc.reason = __get_cp_reason(sbi); - sbi->skipped_gc_rwsem = 0; gc_more: + sbi->skipped_gc_rwsem = 0; if (unlikely(!(sbi->sb->s_flags & SB_ACTIVE))) { ret = -EINVAL; goto stop; -- 2.39.2