Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp42971rdh; Tue, 6 Feb 2024 18:38:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0fLMMIr20yZ97o3khXfbRtQM+J84/ScJKODv63wFnHnLg2/O1gGmI3SeL55TaDQlyhB5o X-Received: by 2002:a05:6808:4446:b0:3bf:e5fc:d124 with SMTP id ep6-20020a056808444600b003bfe5fcd124mr4228597oib.18.1707273521961; Tue, 06 Feb 2024 18:38:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707273521; cv=pass; d=google.com; s=arc-20160816; b=kRDpzvng22xwaqM1LZA36TXaHU4oFVMHCSckvuDcETdbGss7LnyxIJMN2hDfkZ6U/w tfIcdBWrzYIZoYPvBPmlcldsShOimCXix3gWkn6TIHkUpFcXDRhabr3EXKEyHclOPlZ+ LQCvJ8oBY42Oj63XpXQ9f+xnxIOoCcJDPeh8YgcBi+HP1A9eZti7DNqcRpWc6Q+d1uM6 TTTojwhpBf8lZPe3VlFSXzE8zyP6uDJP1ScMhhOZ26zUA63aQsTFt9pBw5hTfjw5L9k0 s9YnxfVoxRbJta0xNTs25hQM5U/o8KqZyyvjljUH+Otq40S+MS3Wa2NPWg9Ppbo/dVjr OqeA== 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=BVsEEWLQGZX07FZQldrpv0fblveMaQMwFSNSeOK+Uvg=; fh=ZP6GJtPqDIbodVaVPouw+yV2ZKj7N8mMz8In7NXnhGs=; b=biea4n5Q6ArrD8TP74G3X30YADWtwC3aaGcWPnsplFESzZBt9BLfQ1wL3QLuCyFk2w 0zZIFMN0a7BXV2BIbhhak6b5yOdOONCyfzqMjhq+l2vODFaAlRPJ/Th36uV4S0MDoS3Y 3d7IH9K5+83DhMkFBVpHYS7lr6Ul9jBdU0breQAiRkzXF6anDkI2pwOzUf35HY+9H0cZ BIGY/CY0YmWzz/mrr+bG8EfGHASplrHEgQq80j1dgJ6uPQWiu1TCzOPETLYB6Xp99cY9 Joijprgq9CaOiV9q4/cpuztK9zZmOQBLwvRXdhyHlcRd+KOfK+xrZZ9tCGxj5ndMHLxN 86Qg==; 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-55827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55827-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUMlijOFfejPaPLubKCGUUtdzvhAPVY2q/l54XIrLJUdy/SQdoqsey5VKTBi5v2+12FckwrlsBrGyQofOxzjvLfJavtbg5Luln8Bz7hjQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q21-20020a056a00085500b006e063f625f6si410142pfk.395.2024.02.06.18.38.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 18:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-55827-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55827-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DECB2B295B1 for ; Wed, 7 Feb 2024 02:02:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4A0EDDD4; Wed, 7 Feb 2024 02:02:07 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [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 AC3DDDDB3 for ; Wed, 7 Feb 2024 02:02:05 +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=1707271327; cv=none; b=HJuCjuYuMDABPUc2GVzTpMZ0vqsaI4PDqqW7X+LBIFuIbV8s5iwOWCs3l/iOdOy9Wt2KjGMsKU+05DU9g7YlxpiGSA3EX0wnUDxpsgt9Q+J2Mj8JwdLpJJZHzEezfyyByomypwu+JNXPauZUAVYOGd2UxR58VvgD7Zrgfjy3pGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707271327; c=relaxed/simple; bh=dqkBJAgvOf54M17NAgC2bdZdD8Q1alVaZw9A7jwQE4Y=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bSpliixB2MA72MADrhBhktGSaFWbM8Z9VCeFNmQJ/MhZ0/KXtWUZpW1dYbcwyhkZJRdOtjk09ia06+3aISy4A7F6biam4fMdjza4esa93B23yGMAz6wu24dpD1uegEF+fLYx9wZeO4w806763bgnFhv+oTvkLJfxIBDmxyGfHp8= 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 41721Nq0075264; Wed, 7 Feb 2024 10:01:23 +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 4TV3Hv3prTz2K4cJ2; Wed, 7 Feb 2024 10:01:15 +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; Wed, 7 Feb 2024 10:01:20 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH v2 0/4] f2fs: fix panic issue in small capacity device Date: Wed, 7 Feb 2024 10:01:00 +0800 Message-ID: <1707271264-5551-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 41721Nq0075264 A panic issue happened in a reboot test in small capacity device as following: 1.The device size is 64MB, and main area has 24 segments, and CONFIG_F2FS_CHECK_FS is not enabled. 2.There is no any free segments left shown in free_segmap_info, then another write request cause get_new_segment get a out-of-bound segment with segno 24. 3.panic happen in update_sit_entry because access invalid bitmap pointer. More detail shown in following patch sets. The three patches are splited here because the modifications are relatively independent and more readable. --- Changes of v2: stop checkpoint when get a out-of-bound segment --- Zhiguo Niu (4): f2fs: correct counting methods of free_segments in __set_inuse f2fs: fix panic issue in update_sit_entry f2fs: enhance judgment conditions of GET_SEGNO f2fs: stop checkpoint when get a out-of-bounds segment fs/f2fs/file.c | 7 ++++++- fs/f2fs/segment.c | 21 ++++++++++++++++----- fs/f2fs/segment.h | 7 ++++--- include/linux/f2fs_fs.h | 1 + 4 files changed, 27 insertions(+), 9 deletions(-) -- 1.9.1