Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp314391rwd; Wed, 17 May 2023 19:17:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6c/4w6+bTyX7d7Xl9+HskyjUf+rb7crnDPxodwohS6HtSYPP3+PCuVqqpTOIXF6QBXbAaV X-Received: by 2002:aa7:888b:0:b0:64d:fd0:dd1a with SMTP id z11-20020aa7888b000000b0064d0fd0dd1amr2006307pfe.16.1684376226973; Wed, 17 May 2023 19:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684376226; cv=none; d=google.com; s=arc-20160816; b=pOFLAX38l2gsmlLDbWmzDENJjh1WHO0l0WUz6SiBK+cciMVTBC4+YiJecb7BruRXVy SM5n3MOBT8HuGCY67mSV1FRvzqb5ghSkNAnUhkFcXA5wCAfPHrAkwTKTADtI3WTN4Dw0 meLdgfOkDW6ChsuXTiJLnMi5Ep1Qb/sK5xWagywOQHO18PgZymyACK+wfLypVZ0+pH7t Ay9YaPv1qVTnSv+4yfGfaeJ+z5SrlLlLnT1CjBdLqOiyLeJBPrPsfj2zgzf0QzHr0bkD HWh8RGQlXXaQ4EArJ/Yp9nrtnI8deTp3ft9U1oOg7uWxTewcHUJoLOrBPGLO0lqj5u1m vMwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SdV0goewcGmuy/6335YdK/XJ/7rBJXpm75Fh/KmafWU=; b=eQ4a4i449z4qv7c+3NCgqAktLU2LXzYYEdM7YTOx8eTM74q1ZB9T6nLU+BYkFwVQdp 7HdwUhrvwaEPAk6bHalUTADo3sGZywIadBhGxV7tjwui0y2sq0lJ5gVchApYIdoUNwC0 yH5xFgJ5QKoYXPtVfB3PqPVvXyDOGLQnwLFkWRnRyJONR8qBgE+YYLnOC5ChxCn6kKS4 /dgVUcpVIvYaQfaZEfvGlOn9PM8lWJ2mmAgHxBFZR6i8FuE4H4uMdGFOzD983La6jQu3 JNlytRf0lbDKYhOwBZBhNHVANHdHX3YJliEKiB39YJJBkeCRzoFJHcOkV5bzB1EvRNTx HqPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XIy6OmaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j190-20020a636ec7000000b005023e0f160dsi291913pgc.489.2023.05.17.19.16.51; Wed, 17 May 2023 19:17:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XIy6OmaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbjERCOe (ORCPT + 99 others); Wed, 17 May 2023 22:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjERCOc (ORCPT ); Wed, 17 May 2023 22:14:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 911181BC2 for ; Wed, 17 May 2023 19:14:31 -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 251DE64C0E for ; Thu, 18 May 2023 02:14:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58F2AC433D2; Thu, 18 May 2023 02:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684376070; bh=OwjcGbmDK0/S7e6sOvtktnpx86Q7FvXDtBnxCrJYRgo=; h=From:To:Cc:Subject:Date:From; b=XIy6OmaAIEiyG3bPneXThJW5wNKmcutAertTyWgT4DFZCUitgzlPnMNVtEG6Inv// O5qYPpAp4QE9dqmR/xSGXxw2+jkcBzVlF1fRxtiaeJT18T7NdyxEPw8gCSmEh0rgnX M3OTw9ULG1jMittJMOZWF7SyyvPkBAwmEno0SSN11mli8FJYiXuZqQanFZoLDC//f8 AR1fhnTdqihaFEjJtFAiFx9vhsbUYq32NGrQ3f/vG2zEbxZ3WlSWKhJ+OTJX8Pv8fq 8d6UNsJ58rZzrCeZer1O1od5FoyMDZmqNWUVUhWZe6dzy/gAoywg2NLvy4Fn1CYgGY HjURd3q2hFdZQ== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v3] f2fs: flush error flags in workqueue Date: Thu, 18 May 2023 10:14:12 +0800 Message-Id: <20230518021412.2037728-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In IRQ context, it wakes up workqueue to record errors into on-disk superblock fields rather than in-memory fields. Fixes: 1aa161e43106 ("f2fs: fix scheduling while atomic in decompression path") Fixes: 95fa90c9e5a7 ("f2fs: support recording errors into superblock") Signed-off-by: Chao Yu --- v3: - add fixes lines. fs/f2fs/compress.c | 2 +- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 26 +++++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 905b7c39a2b3..1132d3cd8f33 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -744,7 +744,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task) /* Avoid f2fs_commit_super in irq context */ if (!in_task) - f2fs_save_errors(sbi, ERROR_FAIL_DECOMPRESSION); + f2fs_handle_error_async(sbi, ERROR_FAIL_DECOMPRESSION); else f2fs_handle_error(sbi, ERROR_FAIL_DECOMPRESSION); goto out_release; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index faa27f41f39d..8d4eaf4d2246 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3563,6 +3563,7 @@ void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag); void f2fs_handle_critical_error(struct f2fs_sb_info *sbi, unsigned char reason, bool irq_context); void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error); +void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error); int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover); int f2fs_sync_fs(struct super_block *sb, int sync); int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 374c990810ea..f19217219c3b 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3989,6 +3989,11 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi) f2fs_down_write(&sbi->sb_lock); spin_lock_irqsave(&sbi->error_lock, flags); + if (sbi->error_dirty) { + memcpy(F2FS_RAW_SUPER(sbi)->s_errors, sbi->errors, + MAX_F2FS_ERRORS); + sbi->error_dirty = false; + } memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON); spin_unlock_irqrestore(&sbi->error_lock, flags); @@ -4028,12 +4033,10 @@ static bool f2fs_update_errors(struct f2fs_sb_info *sbi) return need_update; } -void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error) +static void f2fs_record_errors(struct f2fs_sb_info *sbi, unsigned char error) { int err; - f2fs_save_errors(sbi, error); - f2fs_down_write(&sbi->sb_lock); if (!f2fs_update_errors(sbi)) @@ -4047,6 +4050,23 @@ void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error) f2fs_up_write(&sbi->sb_lock); } +void f2fs_handle_error(struct f2fs_sb_info *sbi, unsigned char error) +{ + f2fs_save_errors(sbi, error); + f2fs_record_errors(sbi, error); +} + +void f2fs_handle_error_async(struct f2fs_sb_info *sbi, unsigned char error) +{ + f2fs_save_errors(sbi, error); + + if (!sbi->error_dirty) + return; + if (!test_bit(error, (unsigned long *)sbi->errors)) + return; + schedule_work(&sbi->s_error_work); +} + static bool system_going_down(void) { return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF -- 2.40.1