Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2275010rbb; Tue, 27 Feb 2024 17:22:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWpXvrIXdQbCfVIWaZalGI/CNCyk7fN4HbtVaQfojPsetZ7w0/b0q7EvNYMrSyb8ZHytHuEmTkq2/TPm/1hYjVn8wQlgHJWq21Gh/ZTHQ== X-Google-Smtp-Source: AGHT+IHynbUelt3+R6vJzfPF/WQQFKjHyTbjf79dY5XPDua1fMFQn5ZWrHc1uhprMFGJBl8RyVhC X-Received: by 2002:a9d:4818:0:b0:6e4:7452:e10 with SMTP id c24-20020a9d4818000000b006e474520e10mr11947321otf.9.1709083321317; Tue, 27 Feb 2024 17:22:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083321; cv=pass; d=google.com; s=arc-20160816; b=T4k1BDzj1TsH65B/drIXJJaJczWxG19Yf6/rrh2xLFQPtrcfYyC7c1f0i1D7cN6Qnj Qi1Z0yoRSQrpLo9xznTUFjYrVqLAF1o52uDe4znlzUl2ygXxh18gB9WJQa1BsPvFFDMC GFTOubM7/EW+e4qGg4lD/gU90YRmjSX1HEkn2OwJ+W1JlyCdFWl+p7o/jk4w1pSbJXLb 6pHQcJgR7zbqBTzDFpk9Dm4EhsKF3Rv1y/o5kDmUaC9E4cTcRVlq7+JfJYHcn9UMlY8x QmzVwSX4HoCCU4p+vIy39r5p1aZ7gt1qDpZ+Df3fm39NBY18MkiZUqmk9506rc1Bwjhq lT2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Dbtb23dmJaegYJf1uRbKTHS4VC7OaJ0kqx0k9cxIJK8=; fh=5AiLTsyZJHa5C3ZZH85Delz06LashDRN8+YvDO5nFOE=; b=sM+MI/qlXWM9dRfJztlePGIhk/BxJ8n7kKLFAbLcQSrQruUF6CzoJe0nP/KwLdr2hU qluCpWI3oihIbxNctAc+8jOwDIxr3CVkWC4AYppgetzFItMWnAyvVOaYvyO3XHRA6TY4 B8UhXYjCPS8kGFuzsWuD/G5c27bEDNM1PuWCC6zTvM+CmJqI0PbIXd4GYyIJPqP9hTV0 C4ocrfjQ6pEQO9FTpSAZ7UJuI6lBVu0ISEWEAU0RQQTmbR7vtLPK6eNZR7NyqK//ifks H/OFCVED60WYJYwo3s/irBZm/wPx2ah6AiDV1Vz3G1RXpgpxZIvC4JlJEVJCy2d1DVzN TE8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ife+onZu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84319-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x123-20020a636381000000b005dc8a33fcc5si6255040pgb.269.2024.02.27.17.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84319-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=@kernel.org header.s=k20201202 header.b=Ife+onZu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84319-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 7F306282C88 for ; Wed, 28 Feb 2024 01:21:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B700B185E; Wed, 28 Feb 2024 01:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ife+onZu" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CD8D6EDD for ; Wed, 28 Feb 2024 01:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709083290; cv=none; b=s1T/G+5e/rwwHXl1v3m6o4H8wxc1uO9fHHvbQ1g9cqwz3NOnmLmvLLTUeYnBr0hYYrF+rbhraPyunSkDi8YnH3L4HLBQVcaL/4Jm/pLtlo+03sbHtSFajTzysIPkE3QNucwyF2t4/Z3nEp9nLf/ea4yGmh2uFjLrByvH+W2bQ4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709083290; c=relaxed/simple; bh=xbDh3NL+tZVp1UyHoiJ9+BKG31EbR4SOQpOg0CSDafg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oFlyScehwKp7G5BpV6Dt8QvM06VDLgTvBBBxEjuOw+C6qKiC5uRjGlYo5qqQBWa3yDKAaJlYEahQO3/EWgzAqSV5RwnHiFdx+5GT/dbrTFlV9+4DwFkIqRVAwdcvNoQyadK5ocz0tS5VRvYh/qh5O9pYwOuVP0fY7P+sKjPOlKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ife+onZu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 771BBC433F1; Wed, 28 Feb 2024 01:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709083290; bh=xbDh3NL+tZVp1UyHoiJ9+BKG31EbR4SOQpOg0CSDafg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ife+onZuQUz70GgqxLfbizZLJsArG7Kkqc9+5dR4MXnVNJAH0fbewtJVQYpd828jP cc1QErW+Y12QtmlXiUePwI01zPk1b5vkSQb1ujOg9cbEcJRY/qOq3gD64sfgzto71L YknoaVHk7DX+dYHku7VYAmgwz/BCCQ5KsJqB+Ut6WiNdXvGaoQxFOOXhPMpC4Hm0Xz UIUM4AxC9U8n/fdGhFhgY+1ixhhEmuUSvmeGGuRCI3RLuc+AtEz0abITYnVcOavZt/ u1Ziw3B0gJgz7BdqqdaynKSPuL0kW1ENKV9mHWIGhg9EsQGQIn2KkjOXBTwFdc4mGY 2l7z1YA8HQ4qA== Message-ID: Date: Wed, 28 Feb 2024 09:21:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/4] f2fs: fix panic issue in small capacity device Content-Language: en-US To: Jaegeuk Kim , Zhiguo Niu Cc: Zhiguo Niu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, ke.wang@unisoc.com, hongyu.jin@unisoc.com References: <1707271264-5551-1-git-send-email-zhiguo.niu@unisoc.com> <88459a22-a21c-4c3d-8371-31d7d713b536@kernel.org> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/2/28 1:18, Jaegeuk Kim wrote: > On 02/27, Zhiguo Niu wrote: >> On Tue, Feb 27, 2024 at 9:13 AM Jaegeuk Kim wrote: >>> >>> On 02/26, Zhiguo Niu wrote: >>>> Dear Chao, >>>> >>>> On Fri, Feb 23, 2024 at 10:38 AM Chao Yu wrote: >>>>> >>>>> On 2024/2/23 10:01, Zhiguo Niu wrote: >>>>>> >>>>>> >>>>>> On Thu, Feb 22, 2024 at 8:30 PM Chao Yu > wrote: >>>>>> >>>>>> On 2024/2/7 10:01, Zhiguo Niu wrote: >>>>>> > 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. >>>>>> >>>>>> Zhiguo, >>>>>> >>>>>> Can you please try below patch to see whether it can fix your problem? >>>>>> >>>>>> 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 has been stopped because it was fixed with the current patch. In addition, this requires stability testing to reproduce, so it will take a certain amount 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! >>> >> 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 complete. >> 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: > > Thanks for confirmation. It seems it'd be better to revert yours and apply > Chao's patch first. If you think there's something to improve on top of it, > could you please send another patch afterwards? Agreed. Thanks, > >> >> 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=null_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 issue w/ >>>>> FAULT_NO_SEGMENT fault injection is on. >>>>> >>>>>> btw, Why can’t I see this patch on your branch^^? >>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/chao/linux.git/log/?h=dev-test >>>>> >>>>> Too lazy to push patches in time, will do it in this weekend. :P >>>>> >>>>>> thanks! >>>>>> >>>>>> >>>>>> > >>>>>> > 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(-) >>>>>> > >>>>>>