From patchwork Fri Mar 1 08:25:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Niu X-Patchwork-Id: 208690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp935552dyb; Fri, 1 Mar 2024 00:27:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW5jfB9Dd0Vj5pD5I/DuPsBaBbDSWTNNRENTH1lihita3OOviZEY/TfZJIza2ic7lW8gKh9462uSxX3AniH8TlgoQW5eg== X-Google-Smtp-Source: AGHT+IHKVZDJazqL+f96rfB69ab106t7fY7aCc3Zzg6wsQJlgP0amkHO0CmstI2iJ9pIhNN2s3rl X-Received: by 2002:a05:6402:26c5:b0:566:c156:aab8 with SMTP id x5-20020a05640226c500b00566c156aab8mr947777edd.30.1709281665180; Fri, 01 Mar 2024 00:27:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709281665; cv=pass; d=google.com; s=arc-20160816; b=ylr96SDGJHgkfWWsuEofCG0L8hj8z1z6aNixf+OLBSKBFVG+eP4HxUSgPNjVZ/aam1 NiAImMfTaNVAUsWpvVwFSsjtpH7W87oclnxwqL5hM53GF9wo/MNXNSbu411oNmY5jRFk 7E2kTOidyDJPFeV6pGcL5s86ONcjChVOEB0r61DmkX9ZwTFM/3nLTO8JBSm/V2CAwX2I N2mUoxHUwR2NEhTl4yVKN8OkhR25xdSfRVhN2PIxbYte7MLteq8D0bq0f8N7bGNB3D2l 5AvIe5gIdZ1FvXKBx7G4CAJxAh9PXSMZwISsrsgvPRVJDIV5fmLofGu3axHZeP+pV2Xq aWDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from; bh=N97YKCny0Cs6KHLM8g8hM3GRmmGR/JOopzKxWKTSvjQ=; fh=r88ULmOhzmh3DE8RgcUXK+PF5Q+3czCYkx5yGhGfkR0=; b=xMKlag1LdoOxetNP99oJ+DxxBhUxBZ+m+TQeSYkDDDKuwsX0b/r/sW1RXq/z1bKgpL jrx2E8SEWuF4srKMC91F7vZzszDpBrbyUi5WKJ8JQUAnLfm1y5IT8PYLPU0XtmJ29eca 3dJoNhMD+NO5phjerLYHQItJ3NtwgMiHd9OpsQKVuLAWkjFXzD/Mta0p/qp9A2fHGnp8 tpBMmygQTp2T5ora7kkcKKgifOAxCYip/rJy75oD+xAgDmjqM0/rzOouGy9weOakOUML EcfXH5ONv/jD36eKS86kcwEBelbOyviel2hV3Xkb8nQH4po7CSRviSK4I3Sc32BkBSXm NiKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-88076-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88076-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w24-20020aa7da58000000b00560c674e301si1298723eds.667.2024.03.01.00.27.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 00:27:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88076-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-88076-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88076-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 67BA81F2737B for ; Fri, 1 Mar 2024 08:27:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E4D569E13; Fri, 1 Mar 2024 08:27:03 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (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 C25A169D14 for ; Fri, 1 Mar 2024 08:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709281621; cv=none; b=lQzzcGB732AVG986g+lCLZOjPtdFeOuCPT0BiSeIEW3DiBfflBZ73M9eL/jr0hlFlC39JxPMpf3Yob0AOsKgZ8NgK9M5oXeBUl52h4jOX+bkUxtBbX5dnopNMAd1M/JAFCSHoeFYgsV8GWAjSKzDIg3uw6KKdfb+s6SxIwjluf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709281621; c=relaxed/simple; bh=Qkm28q9qiqVdNpBzw+D1ZzW6MaJgVHb4vj9bN4B0IrM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HSsBt9EgtuUsiO6TSmOr63pqUVdVGdE2NomrnLIzVJk2rmIO2Qwz5zBehPkASWU4KG+imU8b5dKT5Tq6Sg/s8WazmTcxhvHaM9znm7Ec20GKLKBXnzusYgVg7pzIRUV4E3WzOVq+TXcN4EoRNQWgz0o4u7EBoV+xhpAm+ELIIqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4218QCKa055787; Fri, 1 Mar 2024 16:26:12 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4TmLkR6XLSz2KQsFF; Fri, 1 Mar 2024 16:25:19 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 1 Mar 2024 16:26:09 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH 2/2] f2fs: fix to check return value of f2fs_gc_range Date: Fri, 1 Mar 2024 16:25:55 +0800 Message-ID: <1709281555-11373-2-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1709281555-11373-1-git-send-email-zhiguo.niu@unisoc.com> References: <1709281555-11373-1-git-send-email-zhiguo.niu@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 4218QCKa055787 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792311731325236925 X-GMAIL-MSGID: 1792311731325236925 f2fs_gc_range may return error, so its caller f2fs_allocate_pinning_section should determine whether to do retry based on ist return value. Also just do f2fs_gc_range when f2fs_allocate_new_section return -EAGAIN, and check cp error case in f2fs_gc_range. Signed-off-by: Zhiguo Niu Reviewed-by: Chao Yu --- fs/f2fs/gc.c | 3 +++ fs/f2fs/segment.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e435e1f..c60b747 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1986,6 +1986,9 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi, unsigned int segno; unsigned int gc_secs = dry_run_sections; + if (unlikely(f2fs_cp_error(sbi))) + return -EIO; + for (segno = start_seg; segno <= end_seg; segno += SEGS_PER_SEC(sbi)) { struct gc_inode_list gc_list = { .ilist = LIST_HEAD_INIT(gc_list.ilist), diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 72f6ee3..1bb3019 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3109,6 +3109,7 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type, { struct curseg_info *curseg = CURSEG_I(sbi, type); unsigned int old_segno; + int err = 0; if (type == CURSEG_COLD_DATA_PINNED && !curseg->inited) goto allocate; @@ -3121,8 +3122,9 @@ static int __allocate_new_segment(struct f2fs_sb_info *sbi, int type, allocate: old_segno = curseg->segno; - if (new_curseg(sbi, type, true)) - return -EAGAIN; + err = new_curseg(sbi, type, true); + if (err) + return err; stat_inc_seg_type(sbi, curseg); locate_dirty_segment(sbi, old_segno); return 0; @@ -3151,13 +3153,14 @@ int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi) err = f2fs_allocate_new_section(sbi, CURSEG_COLD_DATA_PINNED, false); f2fs_unlock_op(sbi); - if (f2fs_sb_has_blkzoned(sbi) && err && gc_required) { + if (f2fs_sb_has_blkzoned(sbi) && err == -EAGAIN && gc_required) { f2fs_down_write(&sbi->gc_lock); - f2fs_gc_range(sbi, 0, GET_SEGNO(sbi, FDEV(0).end_blk), true, 1); + err = f2fs_gc_range(sbi, 0, GET_SEGNO(sbi, FDEV(0).end_blk), true, 1); f2fs_up_write(&sbi->gc_lock); gc_required = false; - goto retry; + if (!err) + goto retry; } return err;