From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87E8DC761A6 for ; Sat, 1 Apr 2023 01:01:17 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1piPcI-00082f-Ll; Sat, 01 Apr 2023 01:01:15 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1piPcH-00082Z-3D for linux-f2fs-devel@lists.sourceforge.net; Sat, 01 Apr 2023 01:01:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: Subject:From:References:Cc:To:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mC5lgCpWiVErRdOUsS4kk+MDBnluSPTGN4PngsFM3Zo=; b=g03gvOaCuH10fhxkrR1lkP0lsR zqyxlhESt9a7QUNm1WfY/ciS6OcbtK/ZISU2bhNRtj5xjhIT3gOpPkR2E1Eq+wuS0/gtqN7ySdR5q mLJTR1UHYCzqVRvF+HYTZD4goRnNlp/zwzsbIM3MjkqEW2Nltp4163Wg3jnvrfNPqc+E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:Subject:From: References:Cc:To:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mC5lgCpWiVErRdOUsS4kk+MDBnluSPTGN4PngsFM3Zo=; b=NGoc7fHkESKE1dEDsZz4VPl8OT c5ZaQC592xT6TtrPJyWULGyGB/JafMS2xKwx/cffw1fwxXYNXFiTpO5rDXpgpfNzLhErZYyF9iVvw twIGbwehSqpSLptUzooMKGhgJtTqGT/5XqsPQh72cIGVVAKfXYOcfNmFmLJ38wKwbeqs=; Received: from ams.source.kernel.org ([145.40.68.75]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1piPcG-00BRqy-FD for linux-f2fs-devel@lists.sourceforge.net; Sat, 01 Apr 2023 01:01:13 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 97307B8322C; Sat, 1 Apr 2023 01:01:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70020C433EF; Sat, 1 Apr 2023 01:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680310863; bh=tt7ZGatFV1hjdhv+xFUnZBFTFezV1KSetDds2ucKZNs=; h=Date:To:Cc:References:From:Subject:In-Reply-To:From; b=janccKIkv8gk5FEqwL/V+sypzlpq4VKfugp40dB6anoP5nnRNthYLPOkEfwEJ7cdJ j7MogpyMRpzNioQVQhOZpLQSKoBI1jVCSBDSwEia/Ga+jgrS1tewbGxgUNjygTltw0 vZ8ixmvySVtuX7D4ZpF76C3li+cBtzLsH1+1UwFs+nXq+XRYmRNBnPa9OovYqYo4+/ fFECcg/GgLz0FVsEwhTi1U936XArQt5FUSoSNJrCtUqHmwMROp8LLBf2rt7BH8OCoT jrpo3I3356eoXIB0tiZFTO5HeQp4NmQXBwsdra2KKn9gbSkF9iM3upx92YFOa5V1ih Vo3P/JEDThlrw== Message-ID: Date: Sat, 1 Apr 2023 09:00:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: Bo Ye , Jaegeuk Kim , Matthias Brugger , AngeloGioacchino Del Regno , xiongping1 , qixiaoyu1 References: <20230331092658.72386-1-bo.ye@mediatek.com> <20230331092658.72386-2-bo.ye@mediatek.com> From: Chao Yu In-Reply-To: <20230331092658.72386-2-bo.ye@mediatek.com> X-Headers-End: 1piPcG-00BRqy-FD Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: add __pack attribute for extent_info X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Qilin Tan , yongdong.zhang@mediatek.com, linux-kernel@vger.kernel.org, light.hsieh@mediatek.com, linux-f2fs-devel@lists.sourceforge.net, linux-mediatek@lists.infradead.org, browse.zhang@mediatek.com, linux-arm-kernel@lists.infradead.org, peng.zhou@mediatek.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 2023/3/31 17:26, Bo Ye wrote: > From: Qilin Tan > > Need add __pack for struct extent_info to align to memory > layout of struct rb_entry. Jaegeuk has fixed this bug w/ below patchset, please check it: https://lore.kernel.org/linux-f2fs-devel/20230313201216.924234-1-jaegeuk@kernel.org/ Thanks, > > struct rb_entry { > struct rb_node rb_node; /* rb node located in rb-tree */ > union { > struct { > unsigned int ofs; /* start offset of the entry */ > unsigned int len; /* length of the entry */ > }; > unsigned long long key; /* 64-bits key */ > } __packed; > }; > > struct extent_info { > unsigned int fofs; /* start offset in a file */ > unsigned int len; /* length of the extent */ > union { > ... > /* block age extent_cache */ > struct { > /* block age of the extent */ > unsigned long long age; > /* last total blocks allocated */ > unsigned long long last_blocks; > }; > }; > > The new fields(age, last_blocks) are u64 in change 71644dff4811, it > cause the memory alignment based on 8 bytes in some complier. So the > field fofs and len are alloced with 8 bytes and using the last 4 byts. > Its memory is not aligned with struct rb_entry. the ofs of rb_entry > pointer to a invalid value and cause writing file failed. > > struct extent_info's offset should be 12 rather than 16 from the > beginning of struct rb_entry. > > The offset dump for the bad case as: > kworker/u16:6: [name:f2fs&]f2fs_lookup_rb_tree_for_insert:MTK_DEBUG: ino=1629 re=0xc675dc08 ofs=0 re->ofs=0, re->len=68 ei=0xc675dc18 ei.fofs=68 ei.len=277 > > Fixes: 71644dff4811 ("f2fs: add block_age-based extent cache") > Signed-off-by: Bo Ye > Signed-off-by: Qilin Tan > --- > fs/f2fs/f2fs.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index b0ab2062038a..7c690667a42f 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -660,7 +660,7 @@ struct extent_info { > unsigned long long last_blocks; > }; > }; > -}; > +} __packed; > > struct extent_node { > struct rb_node rb_node; /* rb node located in rb-tree */ _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel