Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1672299rbb; Mon, 26 Feb 2024 18:37:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU8U1pOA/1goq2Qyn5QX3HBlKOKStUcJ+icIg6tOCkfNsW0/giBXFDY4+OvnkM+oXtLB09JXS3YYafkU3bsZZKzg5qtA7zvxsw4G/2GeA== X-Google-Smtp-Source: AGHT+IHcJkyqsPwplmZjWv9vYIKZplNdISmxBKQug8lFEsGAsQcr7bRuyQawb5vWjoIYUdRlDJPH X-Received: by 2002:a05:6870:f143:b0:21e:635c:a5b7 with SMTP id l3-20020a056870f14300b0021e635ca5b7mr11665968oac.3.1709001428600; Mon, 26 Feb 2024 18:37:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709001428; cv=pass; d=google.com; s=arc-20160816; b=v4H2fVedAXwLi5shxp967dqoVEkQEmVXKRmRZBAAz/OryyDOW7CYf1F9eRkio5W9XG sPhUDk7CCFl9C//fY5Duehlm3YDxGxwmSoPuF59/XgTJbxFHWqAQtImRjnH8caF7NVln tdVjDabm8KsTffnZyqCrlAambJAn8JOAkJZdkO95ubGFbn2Q8quD6sGfZBkLLG8t8hr3 VKU4MjXe9xqcY25HmiR8IoREVM/9QX6Wbsi6o5R+1PVQKx4OKtWEy1SDSfGu2xVaxrO4 om4y5nw4frn4sD4jb3teLAE2n+WnNxDS+eux1xifEt8hYx2WrF+QKZxOHBflC8HZ+fff pkNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=RKnTk+J+FX3ola1FbmaFj80zZDlGsKyOPaOv8pvNq9Y=; fh=025P9jqObRKDd8F8c9y8oLUaEbWthnSr6vxK5Z13D54=; b=w3kDRuxsUirT+rLCRlDUIEpvvde0/snVoxX7vRfUM55dEoCmINPmRVXnP9gd0OUKuG srD2bTa6448mEoDLkcgmFeeTEBxEp+NPogXIBObhOExvF2c3lrNzjgi3FunQC9e9LVBN PFaIYSe1EXev2aqLdjB+cYcaRpKoAzgcLpEZ/Q9lcCRQvohs9vJJL5oQNWO3juRcO60F F4fUfmfCc28YILNflI9QG/RVoFP5wGFM92s2TOhiYFNhj2/ZoF9849+NG4GAog4KCVCN eTjkH1Uadr5WHoCkiFLgHvhu3s7h3hHXIOTz+XttDPcg5AvOBYYid2j+yDrsD8PO0+Cj CU7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=di71mfYX; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82612-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e63-20020a636942000000b005dc505aef9asi4551887pgc.354.2024.02.26.18.37.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 18:37:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82612-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=di71mfYX; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82612-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ADE87284643 for ; Tue, 27 Feb 2024 02:35:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7589A125B9; Tue, 27 Feb 2024 02:35:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="di71mfYX" Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C41F4746E for ; Tue, 27 Feb 2024 02:35:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709001313; cv=none; b=HTosNq6LzcyyNPe/vSjrwJpjUoTd3a6NFWxerO6vE+AvTm2F4BqoSOiv9Jk3ukhqWlpYypItjsR/UOsuwMj6fLzfTfnkzTG2pFTZ+T+ZZrmTr6gUZLsiE0fr/s3WHEXfPhBf7+khk/7oT1KZOmMoVt+Rwlndv0QYsCRL4cTZqcU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709001313; c=relaxed/simple; bh=vzU2YaorHwvaPNHI/TTfps8jJxR3eDtvTDV4A/+6TmA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CFBtMOl7bevw7nHduHqBlWsuvj+QLNOhkDvtJ8r+13HtVvK+6Q6XQcKYBzfCo8gPjhAE7fLJnlbdeaGJVgC11Cd21+HPw5a9K2xy/9Dz5HUzI426bfegt1hjiB0v+UTYGLAOpLNFY4R/hDy1/QO7vv0YQKyUq2mYkp79LteMvOY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=di71mfYX; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-565a3910f86so3816812a12.3 for ; Mon, 26 Feb 2024 18:35:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709001310; x=1709606110; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RKnTk+J+FX3ola1FbmaFj80zZDlGsKyOPaOv8pvNq9Y=; b=di71mfYXSxzaYddQXIKT2sQZD9rwqQ82ebdk+bOzsSf24+FRPLxXSzC5xv0T+Mi3fG ub4OXz97CKZe2ShhhDgzYjCVzIbuQDDNGrpnKywGUOH1jP6ZXoWmtvN7cSSCxQ2YmwE6 7c7LJ628+RPE1U3oXTfneHHtEGext6/FEza7lyqWiKtclCiMoxtFQZ3VEq9YwND4xp7c 0tUiikpvsZPbCR83nxzIfB3iTxNKiuBblTFgDepBDZqCwThqodP3iyVNxKRTi0PZmV9v KXV+elM9jti/DrQpfpJArN4kSLbMLjftjHZVxGJ735Bzwn4c2Hy+4M9G78AjIWvrDtwr j0lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709001310; x=1709606110; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RKnTk+J+FX3ola1FbmaFj80zZDlGsKyOPaOv8pvNq9Y=; b=H8lbXmZZyrjc4/3xkeprPbUd3wOzViTklgo/VfmQGvnX3K0+3TYkhe1u+SngMDap4e FF9IazbfzAp9byLsOfuCOvgHvVToaA3m9nem+lmO4EvdWHOnGhNbrZPVzjo6o+RVOe7t pwQ6gS0UDKLCIhuCrLM3Ipk6DiJhy4uJJW5qj/ZS68MzUyvJLHKj4GldX7z+0n12Q4Zc Gpqy223dqBL+IxOwsFO6P6I90zTirP4MP+ghxIOR6cRVf+FtI8ucG9iuSt67ImTRD/B1 sWxtkpr1bxlAfALjb5JtgbAWqF/QnHn1Kq3ldF1Habf/L42GxrGbOPqCT/0r2GDcM6uN lDbw== X-Forwarded-Encrypted: i=1; AJvYcCW/vO0eRbBGxliCnpnOb8P7O2N9XXxoC3so7HalQE810rcpx2LZtyBHCnmce3IgsIHDrqmfCNhN79W1lVH/BrB1Tkx5Wimd8jdZWSpO X-Gm-Message-State: AOJu0YzjViARs6h9aUQsfwX37S6PZA+PYQ/mZ89UxQCML6UcBtTauzUb F5sEe8rkfuBl2LrjJJKqlh7srBzIUxVOK0OeBPDak8OQqbYpHDBZhzR6lsDb8Xq5usz4AU9KfNd C1Si5JXt/N9BEuud7w9wwj4H5Dg5FMwQ+BBY= X-Received: by 2002:aa7:d5d5:0:b0:564:3392:e9db with SMTP id d21-20020aa7d5d5000000b005643392e9dbmr5247469eds.33.1709001309894; Mon, 26 Feb 2024 18:35:09 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1707271264-5551-1-git-send-email-zhiguo.niu@unisoc.com> <88459a22-a21c-4c3d-8371-31d7d713b536@kernel.org> In-Reply-To: From: Zhiguo Niu Date: Tue, 27 Feb 2024 10:34:58 +0800 Message-ID: Subject: Re: [PATCH v2 0/4] f2fs: fix panic issue in small capacity device To: Jaegeuk Kim Cc: Chao Yu , Zhiguo Niu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, ke.wang@unisoc.com, hongyu.jin@unisoc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 27, 2024 at 9:13=E2=80=AFAM Jaegeuk Kim wr= ote: > > On 02/26, Zhiguo Niu wrote: > > Dear Chao, > > > > On Fri, Feb 23, 2024 at 10:38=E2=80=AFAM Chao Yu wrot= e: > > > > > > On 2024/2/23 10:01, Zhiguo Niu wrote: > > > > > > > > > > > > On Thu, Feb 22, 2024 at 8:30=E2=80=AFPM Chao Yu > wrote: > > > > > > > > On 2024/2/7 10:01, Zhiguo Niu wrote: > > > > > A panic issue happened in a reboot test in small capacity de= vice > > > > > as following: > > > > > 1.The device size is 64MB, and main area has 24 segments, an= d > > > > > CONFIG_F2FS_CHECK_FS is not enabled. > > > > > 2.There is no any free segments left shown in free_segmap_in= fo, > > > > > then another write request cause get_new_segment get a out-o= f-bound > > > > > segment with segno 24. > > > > > 3.panic happen in update_sit_entry because access invalid bi= tmap > > > > > pointer. > > > > > > > > Zhiguo, > > > > > > > > Can you please try below patch to see whether it can fix your p= roblem? > > > > > > > > https://lore.kernel.org/linux-f2fs-devel/20240222121851.883141-= 3-chao@kernel.org > > > > > > > > Thanks, > > > > > > > > > > > > Dear Chao, > > > > I need to coordinate the testing resources. The previous testing ha= s been stopped because it was fixed with the current patch. In addition, th= is requires stability testing to reproduce, so it will take a certain amoun= t of time. If there is any situation, I will tell you in time. > > > > > > Zhiguo, thank you! > > > > We tested this patch this weekend on the previous version with > > problem, and it can not reproduce panic issues, > > so this patch should fix the original issue. > > thanks=EF=BC=81 > Dear Jaegeuk, > Hey, do you guys please point out which patches were tested without what? This problem occurred during our platform stability testing. it can be fixed by my this patch set, mainly be fixed by: f2fs: fix panic issue in update_sit_entry & f2fs: enhance judgment conditions of GET_SEGNO and Chao's patch can also fix this problems testing without my patch > IOWs, which patches should I remove and keep Chao's patch? I think chao's patch is more reasonable, it does error handling more comple= te. but my patch just do some sanity check for return value of GET_SEGNO Same as other codes(update_segment_mtime) and i think it also needed except this part: diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index 3bf2ce46fa0907..bb22feeae1cfcb 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -96,7 +96,8 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & (BLKS_PER_SEG(sbi) - 1)) #define GET_SEGNO(sbi, blk_addr) \ - ((!__is_valid_data_blkaddr(blk_addr)) ? \ + ((!__is_valid_data_blkaddr(blk_addr) || \ + !f2fs_is_valid_blkaddr(sbi, blk_addr, DATA_GENERIC)) ? \ NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \ GET_SEGNO_FROM_SEG0(sbi, blk_addr))) #define CAP_BLKS_PER_SEC(sbi) because Chao's patch let new_addr=3Dnull_addr when get_new_segment returns NOSPACE, so I think this can be reverted and it also saves code running time. How about Chao's opinions? thanks! > > > > > > > > > BTW, I've tested this patch for a while, and it looks there is no iss= ue w/ > > > FAULT_NO_SEGMENT fault injection is on. > > > > > > > btw, Why can=E2=80=99t I see this patch on your branch^^? > > > > https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/log/= ?h=3Ddev-test > > > > > > Too lazy to push patches in time, will do it in this weekend. :P > > > > > > > thanks=EF=BC=81 > > > > > > > > > > > > > > > > > > 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 segme= nt > > > > > --- > > > > > > > > > > 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(-) > > > > > > > > >