Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp148168lqg; Fri, 1 Mar 2024 00:27:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXYV6WR10E/vUthxUkOap1+mwKr5+O3w0ZM6N7pQZumODDZsatTRXSBU5ycaSQKo0WGz/TjrNxLi7BcUgzdWK+GOgMDazot6LIZdopbZQ== X-Google-Smtp-Source: AGHT+IEvidkeZN6UhzUyy86+ZvQVG8ovO2Pfs27GMAiHI9ycfU5WHQEkeBb5lPZstv6KjVTlNS89 X-Received: by 2002:a05:6214:188b:b0:690:4af1:f1ef with SMTP id cx11-20020a056214188b00b006904af1f1efmr1041123qvb.5.1709281626172; Fri, 01 Mar 2024 00:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709281626; cv=pass; d=google.com; s=arc-20160816; b=xdaDIn/v1lthsHU7Vfuq0FJAN8kYaM7fnnC/csJ2eyVUgs+GgJKak3XlEiejUXIodK RRl10BFBs91Wp0qhW+KxxjcOiTQMIWkkK5eUIpa4mNHD6tmjhNx8vun5pevYUxI+EfQY 7J6P0FXpza5V//t6BzrmJYxpr3Hy5qhfBS1fTLHHoEuAw2XtUou3iUZrQWO11LAH3gNE rJObjwOGCmIS0v9O3WeKkn8ANdbQKW1SHBMhcIjsU2s0dhs17rgThVzqYXchTos5QqUn RV3yZVLuNBDxXa9w4S9445n+1rsGZUutpXxqSDyDFRrav7kRd2HU5MidqvGlz9mgMf5w QI9Q== 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 :message-id:date:subject:cc:to:from; bh=jU8T3b75g+vGsqrESHmfwveJMe4oiSv4D3tDmEcEXDQ=; fh=r88ULmOhzmh3DE8RgcUXK+PF5Q+3czCYkx5yGhGfkR0=; b=XTYoNZWTIoRzcCsuRvQmRYeSQpviLZrKX32O06gBEXvv7fXnds7chsNvMMviZT73iq pWxYhgc6dHSgrgWzYRuEmh8eJvt3zbM6Y1+230BuB0rzeV8VjFBsVgE/9rHUncScANyR T/QECAyHQuT5Yu9gBRUZwpLzFqTsyPa/DItlhqKPpApYXLk77+1svy2XHJxLAWoUFqPZ DGqOsEbOAOcPtUs+f3VdnNgEWE2XJRfXAfw/8yIHE0C0Ca6FqkMNKPkVZ7oe7NuTuKTO ZUhsC5PurR5sLhFb8xyJYhnM1qyfCN1fNWDfpKxqHJF6PLZ3rESdNST1IZ+z3Gz5Jqkx ExUA==; 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-88075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88075-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ed14-20020ad44eae000000b0068c8a605eb5si3164406qvb.96.2024.03.01.00.27.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 00:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-88075-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88075-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E1D821C215E7 for ; Fri, 1 Mar 2024 08:27:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5356F69D33; Fri, 1 Mar 2024 08:27:00 +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 5F76569D05 for ; Fri, 1 Mar 2024 08:26:56 +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=1709281619; cv=none; b=SWAahStQJ0GShN/itO4WW2ybl2CbwYCxaeE6ep5WyfqRbngOCNuWoz4cuU8LduW2KKgQAQU6LA7+STclneOXkxsPhy40+JQbctLr1r6GU7UV3jHxCCwHxfH+rICj04DJS48AxK78aW6wQcMwKbY5R/hqSrn0uHs3oRgxsyO+u24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709281619; c=relaxed/simple; bh=9+cMmk/j1E0sLXVifzfj5cm2/RcLIUpa5OLoC8QQBRM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=TIP7wbEy1J9jucGJGp+zM6+6VUBxbultt39uueKvdvGyi5uQKD1UowX+6DwBoBXPZ+vkTyE/nVGRy7Uco5LH++ngSgXt0jYhP8cY/AwTFk0nm00TVeq7dSSpdqZIyxxQrjwdDgfxxzjpNOY0GWZS6nh7MqdkLzPsuujvHf1e/ys= 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 4218Q82T055542; Fri, 1 Mar 2024 16:26:08 +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 4TmLkN0Dccz2KQsFF; Fri, 1 Mar 2024 16:25:16 +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:05 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH 1/2] f2fs: fix to check return value __allocate_new_segment Date: Fri, 1 Mar 2024 16:25:54 +0800 Message-ID: <1709281555-11373-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 4218Q82T055542 __allocate_new_segment may return error when get_new_segment fails, so its caller should check its return value. Signed-off-by: Zhiguo Niu --- fs/f2fs/f2fs.h | 2 +- fs/f2fs/recovery.c | 2 +- fs/f2fs/segment.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index db05fd0..4331012 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3705,7 +3705,7 @@ void f2fs_allocate_segment_for_resize(struct f2fs_sb_info *sbi, int type, unsigned int start, unsigned int end); int f2fs_allocate_new_section(struct f2fs_sb_info *sbi, int type, bool force); int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi); -void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi); +int f2fs_allocate_new_segments(struct f2fs_sb_info *sbi); int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range); bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc); diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 3078d56..c381f0a 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -851,7 +851,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, f2fs_ra_meta_pages_cond(sbi, blkaddr, ra_blocks); } if (!err) - f2fs_allocate_new_segments(sbi); + err = f2fs_allocate_new_segments(sbi); return err; } diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index cdac4cb..72f6ee3 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3163,16 +3163,19 @@ int f2fs_allocate_pinning_section(struct f2fs_sb_info *sbi) return err; } -void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi) +int f2fs_allocate_new_segments(struct f2fs_sb_info *sbi) { int i; + int err = 0; f2fs_down_read(&SM_I(sbi)->curseg_lock); down_write(&SIT_I(sbi)->sentry_lock); for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) - __allocate_new_segment(sbi, i, false, false); + err += __allocate_new_segment(sbi, i, false, false); up_write(&SIT_I(sbi)->sentry_lock); f2fs_up_read(&SM_I(sbi)->curseg_lock); + + return err; } bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi, -- 1.9.1