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 X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F120FC433DB for ; Wed, 10 Mar 2021 20:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EF4564FC9 for ; Wed, 10 Mar 2021 20:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231522AbhCJUtY (ORCPT ); Wed, 10 Mar 2021 15:49:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:59072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230491AbhCJUtX (ORCPT ); Wed, 10 Mar 2021 15:49:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 208F664FC6; Wed, 10 Mar 2021 20:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615409362; bh=8Lubpt2RtIi1IKD8AnfhhcFsPyM8ZlZWqojFGL66AEo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PQhX5z72m4tWNc1wPcJL4+eNCCqDixQzxar0vIqh+ktQmQmEMsYW2KARrqaR/sQz4 xpu0uPizxIRDEbDLwNJkkihaImSz+OqHzM6htvp4AHC9W4ll/3jEg2WbWoZ4tyAOl7 XkRO6Dg4iZygdESiVlzkh5G4V3li+h3I0Uc84TN4rj3JWGIf9McWsQP4FCfYvLSofw 5I86XkYXRXb76K/gPmswQCXUYxkai7RHD5vZ+HhgNvAVVe3QWJcbOZ2uzdhuntCUMp kAy8FBMwT8QmYbaoMNw70iSw8ElSfrOJ14GwFobOzWND+101iubMUZkqpDuoL4TXua 2uqd9ngJtrxig== Date: Wed, 10 Mar 2021 12:49:20 -0800 From: Jaegeuk Kim To: Huang Jianan Cc: Matthew Wilcox , Weichao Guo , rpalethorpe@suse.de, kernel test robot , lkp@intel.com, Linux Memory Management List , Chao Yu , LKML , lkp@lists.01.org, ltp@lists.linux.it Subject: Re: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail Message-ID: References: <20210308072510.GA902@xsang-OptiPlex-9020> <87h7llhnfe.fsf@suse.de> <20210309040144.GH3479805@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/10, Huang Jianan wrote: > Hi Richard, > > On 2021/3/9 12:01, Matthew Wilcox wrote: > > On Tue, Mar 09, 2021 at 10:23:35AM +0800, Weichao Guo wrote: > > > Hi Richard, > > > > > > On 2021/3/8 19:53, Richard Palethorpe wrote: > > > > Hello, > > > > > > > > > kern :err : [ 187.461914] F2FS-fs (sda1): Swapfile does not align to section > > > > > commit 02eb84b96bc1b382dd138bf60724edbefe77b025 > > > > > Author: huangjianan@oppo.com > > > > > Date: Mon Mar 1 12:58:44 2021 +0800 > > > > > f2fs: check if swapfile is section-alligned > > > > > If the swapfile isn't created by pin and fallocate, it can't be > > > > > guaranteed section-aligned, so it may be selected by f2fs gc. When > > > > > gc_pin_file_threshold is reached, the address of swapfile may change, > > > > > but won't be synchronized to swap_extent, so swap will write to wrong > > > > > address, which will cause data corruption. > > > > > Signed-off-by: Huang Jianan > > > > > Signed-off-by: Guo Weichao > > > > > Reviewed-by: Chao Yu > > > > > Signed-off-by: Jaegeuk Kim > > > > The test uses fallocate to preallocate the swap file and writes zeros to > > > > it. I'm not sure what pin refers to? > > > 'pin' refers to pinned file feature in F2FS, the LBA(Logical Block Address) > > > of a file is fixed after pinned. Without this operation before fallocate, > > > the LBA may not align with section(F2FS GC unit), some LBA of the file may > > > be changed by F2FS GC in some extreme cases. > > > > > > For this test case, how about pin the swap file before fallocate for F2FS as > > > following: > > > > > > ioctl(fd, F2FS_IOC_SET_PIN_FILE, true); > > No special ioctl should be needed. f2fs_swap_activate() should pin the > > file, just like it converts inline inodes and disables compression. > > Now f2fs_swap_activate() will pin the file. The problem is that when > f2fs_swap_activate() > > is executed, the file has been created and may not be section-aligned. > > So I think it would be better to consider aligning the swapfile during > f2fs_swap_activate()? Does it make sense to reallocate blocks like in f2fs_swap_activate(), set_inode_flag(inode, FI_PIN_FILE); truncate_pagecache(inode, 0); f2fs_truncate_blocks(inode, 0, true); expand_inode_data(); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaegeuk Kim Date: Wed, 10 Mar 2021 12:49:20 -0800 Subject: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail In-Reply-To: References: <20210308072510.GA902@xsang-OptiPlex-9020> <87h7llhnfe.fsf@suse.de> <20210309040144.GH3479805@casper.infradead.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it On 03/10, Huang Jianan wrote: > Hi Richard, > > On 2021/3/9 12:01, Matthew Wilcox wrote: > > On Tue, Mar 09, 2021 at 10:23:35AM +0800, Weichao Guo wrote: > > > Hi Richard, > > > > > > On 2021/3/8 19:53, Richard Palethorpe wrote: > > > > Hello, > > > > > > > > > kern :err : [ 187.461914] F2FS-fs (sda1): Swapfile does not align to section > > > > > commit 02eb84b96bc1b382dd138bf60724edbefe77b025 > > > > > Author: huangjianan@oppo.com > > > > > Date: Mon Mar 1 12:58:44 2021 +0800 > > > > > f2fs: check if swapfile is section-alligned > > > > > If the swapfile isn't created by pin and fallocate, it can't be > > > > > guaranteed section-aligned, so it may be selected by f2fs gc. When > > > > > gc_pin_file_threshold is reached, the address of swapfile may change, > > > > > but won't be synchronized to swap_extent, so swap will write to wrong > > > > > address, which will cause data corruption. > > > > > Signed-off-by: Huang Jianan > > > > > Signed-off-by: Guo Weichao > > > > > Reviewed-by: Chao Yu > > > > > Signed-off-by: Jaegeuk Kim > > > > The test uses fallocate to preallocate the swap file and writes zeros to > > > > it. I'm not sure what pin refers to? > > > 'pin' refers to pinned file feature in F2FS, the LBA(Logical Block Address) > > > of a file is fixed after pinned. Without this operation before fallocate, > > > the LBA may not align with section(F2FS GC unit), some LBA of the file may > > > be changed by F2FS GC in some extreme cases. > > > > > > For this test case, how about pin the swap file before fallocate for F2FS as > > > following: > > > > > > ioctl(fd, F2FS_IOC_SET_PIN_FILE, true); > > No special ioctl should be needed. f2fs_swap_activate() should pin the > > file, just like it converts inline inodes and disables compression. > > Now f2fs_swap_activate() will pin the file. The problem is that when > f2fs_swap_activate() > > is executed, the file has been created and may not be section-aligned. > > So I think it would be better to consider aligning the swapfile during > f2fs_swap_activate()? Does it make sense to reallocate blocks like in f2fs_swap_activate(), set_inode_flag(inode, FI_PIN_FILE); truncate_pagecache(inode, 0); f2fs_truncate_blocks(inode, 0, true); expand_inode_data(); From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1471987026310538465==" MIME-Version: 1.0 From: Jaegeuk Kim To: lkp@lists.01.org Subject: Re: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail Date: Wed, 10 Mar 2021 12:49:20 -0800 Message-ID: In-Reply-To: List-Id: --===============1471987026310538465== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 03/10, Huang Jianan wrote: > Hi Richard, > = > On 2021/3/9 12:01, Matthew Wilcox wrote: > > On Tue, Mar 09, 2021 at 10:23:35AM +0800, Weichao Guo wrote: > > > Hi Richard, > > > = > > > On 2021/3/8 19:53, Richard Palethorpe wrote: > > > > Hello, > > > > = > > > > > kern :err : [ 187.461914] F2FS-fs (sda1): Swapfile does not a= lign to section > > > > > commit 02eb84b96bc1b382dd138bf60724edbefe77b025 > > > > > Author: huangjianan(a)oppo.com > > > > > Date: Mon Mar 1 12:58:44 2021 +0800 > > > > > f2fs: check if swapfile is section-alligned > > > > > If the swapfile isn't created by pin and fallocate, it can'= t be > > > > > guaranteed section-aligned, so it may be selected by f2fs g= c. When > > > > > gc_pin_file_threshold is reached, the address of swapfile m= ay change, > > > > > but won't be synchronized to swap_extent, so swap will writ= e to wrong > > > > > address, which will cause data corruption. > > > > > Signed-off-by: Huang Jianan > > > > > Signed-off-by: Guo Weichao > > > > > Reviewed-by: Chao Yu > > > > > Signed-off-by: Jaegeuk Kim > > > > The test uses fallocate to preallocate the swap file and writes zer= os to > > > > it. I'm not sure what pin refers to? > > > 'pin' refers to pinned file feature in F2FS, the LBA(Logical Block Ad= dress) > > > of a file is fixed after pinned. Without this operation before falloc= ate, > > > the LBA may not align with section(F2FS GC unit), some LBA of the fil= e may > > > be changed by F2FS GC in some extreme cases. > > > = > > > For this test case, how about pin the swap file before fallocate for = F2FS as > > > following: > > > = > > > ioctl(fd, F2FS_IOC_SET_PIN_FILE, true); > > No special ioctl should be needed. f2fs_swap_activate() should pin the > > file, just like it converts inline inodes and disables compression. > = > Now f2fs_swap_activate() will pin the file. The problem is that when > f2fs_swap_activate() > = > is executed, the file has been created and may not be section-aligned. > = > So I think it would be better to consider aligning the swapfile during > f2fs_swap_activate()? Does it make sense to reallocate blocks like in f2fs_swap_activate(), set_inode_flag(inode, FI_PIN_FILE); truncate_pagecache(inode, 0); f2fs_truncate_blocks(inode, 0, true); expand_inode_data(); --===============1471987026310538465==--