From patchwork Fri Mar 1 08:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Niu X-Patchwork-Id: 208691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp935712dyb; Fri, 1 Mar 2024 00:28:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWlqMgYVkzwnV7ZUx227n/Ae42jvafbemqryR2Tq2I+NWG3bENlL8qyknNGJqXj55Eai7lKy4MvZcNv9uMQQxd9y5tADA== X-Google-Smtp-Source: AGHT+IHY3K7GOduIhFOmUC1vlTVcFyo4VTrlhyBiAnNvy1hs1sgc3Oz0jy3GqTJGS/qgg2ftZxz8 X-Received: by 2002:a05:6a00:1950:b0:6e5:2f97:bf44 with SMTP id s16-20020a056a00195000b006e52f97bf44mr1142377pfk.10.1709281693653; Fri, 01 Mar 2024 00:28:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709281693; cv=pass; d=google.com; s=arc-20160816; b=C90QpEDhWLAfO/sfT5twdBwFyu/w06M8eouuHN3QixsgHwQwyp+3bbeY/lbtW0RjBx d54RUKr2hEpMkwBM+ePtHoMTH0owD77aApG+Q9IjmFFwoltEGLkNFGsOGqNL+5mFi9BP JfXtW8qkYGZAZfqmmcydV2S1b8AexGct37biF/B1AVvQcz8b07vl60usaq1ogdW6Qufi e6mTanQpyWTWM5WcFJDUv5J0dZZKH2QSlFtUKhB9LmY6y4Jg16g7GQgmxdUKZh6S9JHN 23ohr9ckXHPuIMpvXVIEbUrGVEKVR0bzmPOOx4r2SGbMdqgyCACPnb4dJKk3XZwc3HzD BxgA== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88075-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x27-20020a056a00189b00b006e45d8bc55esi3134174pfh.361.2024.03.01.00.28.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 00:28:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88075-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-88075-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88075-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0588628ADA7 for ; Fri, 1 Mar 2024 08:27:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 597EF69DF2; Fri, 1 Mar 2024 08:27:01 +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 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 4218Q82T055542 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792311760916438516 X-GMAIL-MSGID: 1792311760916438516 __allocate_new_segment may return error when get_new_segment fails, so its caller should check its return value. Signed-off-by: Zhiguo Niu Reviewed-by: Chao Yu --- 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,