Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp292243rdb; Mon, 29 Jan 2024 02:22:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IGoqvDXtUfRIQt+QSSwDWVKSwi4rM+20h+2NsTgojBXTBHFYAXQ+nBdAKaAIZjMAdh4xIu0 X-Received: by 2002:ad4:5ca6:0:b0:68c:5a42:41a3 with SMTP id q6-20020ad45ca6000000b0068c5a4241a3mr6261qvh.34.1706523776639; Mon, 29 Jan 2024 02:22:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706523776; cv=pass; d=google.com; s=arc-20160816; b=DRHLOVxS7YB2z30jqDkjgtSlPZfpocRIYUF4C4sN47pk4thd63gMBzNjcbARYqf0th XvjX3keuels3hIkIl1E7NtUyJ7+JE9xd7ikxC++aSWDPJ+BNnE6x1b1hd8gs4I7LUHrR 99a9yfmRxNmTcEBz0dh1ANmcyQCcxqy06ddJrxU4l3cdcU2HhXVqgs2UvhHWH/fkL+l1 XnwbCej4kzf2KtXeoTrCdDIw+9x7gVS8fJ7z+5zgadse8disyTXQhyYW33uV0pPGNCke //hz8ByELCmRyP6QEx0c290ZxanhRHL4QXS/WiVz7hoFfamuIho/up3azYMp541Wfzmc aaZw== 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=hTuUer4yaG6DVAm2a9jKK2HUeFUSVWlzPOvFgdzGE5Y=; fh=r88ULmOhzmh3DE8RgcUXK+PF5Q+3czCYkx5yGhGfkR0=; b=QA3Wydgzaq2mddy+AaPMRgv76og7iEU4BvKpicyNSGwzQCIu0wUuafv8eGVTDwByDV cBRmjC/b28skveSCJLQ4tiQTq8V/1ffbwNrwWLzFvjNNSIzVgcQ2+cGl/5/cHZBb+/JV HdCDu5tvEsp7/K2cehMiv0PkKyz8CPoOAXJDVovrjdzGnpnNQbTfDnASQiLLPbcz2oEn tM+LI3jXkGF3m9E2RH2p1hsi0tkouAncf8EZZMb80/rhxpArGrvvHaJ0Qn7gdG0ZhsRV CY+XL0usAKisROvboBGaq5avuDN9KegsgzSeY8XO48GMRNkSI0StGBJcZnxNaQVfw1xD STIA== 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-42528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42528-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 iy3-20020a0562140f6300b0068c3b1c7563si5588115qvb.473.2024.01.29.02.22.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 02:22:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42528-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-42528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42528-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 659951C20CB5 for ; Mon, 29 Jan 2024 10:22:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54A2856451; Mon, 29 Jan 2024 10:22:49 +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 6437755E71 for ; Mon, 29 Jan 2024 10:22:43 +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=1706523768; cv=none; b=PFDGRE+kGr7+uB9RBKwQrmj7/Xfn7PQ0qCAhtlulbXrp57llB9XMCscJghbR2N/4jFewVF+k3qg4MrxXXnwv6wAZHO93fd/ACCuJO/OWwS1RkdEKhzIukTd7ucbXOXHosco5jdMHFWPHlBQ5zndvgivpCsHoo6TTJXuhCI2xucQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706523768; c=relaxed/simple; bh=NBbhsZaz19V96HRs9sSIIpn6TGJqcZVy49tBd7L4BPY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=TkdS6oK7dkXnCknghBQT5zjG1SCxv5pOl/PICQSTt4kqQ/TFZFoP/TMeiVtQskRTluofNys0mKiPSNwvweXO9vN46QeiVepRgfs8MLviO+iff1065VRhHCuPzrRcf4zDO25n0N47ynQ+i5O7Y9eRBIhMBvEEJy/rwnMmmECS07o= 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 40TALmxZ021624; Mon, 29 Jan 2024 18:21:48 +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 4TNkfv3tnnz2R5Td1; Mon, 29 Jan 2024 18:14: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; Mon, 29 Jan 2024 18:21:46 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH 0/3] f2fs: fix panic issue in small capacity device Date: Mon, 29 Jan 2024 18:21:24 +0800 Message-ID: <1706523684-24540-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: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 40TALmxZ021624 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 three patches. The three patches are splited here because the modifications are relatively independent and more readable. Zhiguo Niu (3): 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 fs/f2fs/file.c | 7 ++++++- fs/f2fs/segment.c | 9 ++++++--- fs/f2fs/segment.h | 7 ++++--- 3 files changed, 16 insertions(+), 7 deletions(-) -- 1.9.1