All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: ltp@lists.linux.it
Subject: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail
Date: Wed, 10 Mar 2021 12:49:20 -0800	[thread overview]
Message-ID: <YEkw0J9VEg66AgIt@google.com> (raw)
In-Reply-To: <c84bf5c9-501e-6c25-1728-a7c6281093fd@oppo.com>

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 <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 <huangjianan@oppo.com>
> > > > >       Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> > > > >       Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > > > >       Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > > 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();

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: lkp@lists.01.org
Subject: Re: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail
Date: Wed, 10 Mar 2021 12:49:20 -0800	[thread overview]
Message-ID: <YEkw0J9VEg66AgIt@google.com> (raw)
In-Reply-To: <c84bf5c9-501e-6c25-1728-a7c6281093fd@oppo.com>

[-- Attachment #1: Type: text/plain, Size: 2475 bytes --]

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(a)oppo.com <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 <huangjianan@oppo.com>
> > > > >       Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> > > > >       Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > > > >       Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > > 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();

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Huang Jianan <huangjianan@oppo.com>
Cc: Matthew Wilcox <willy@infradead.org>,
	Weichao Guo <guoweichao@oppo.com>,
	rpalethorpe@suse.de, kernel test robot <oliver.sang@intel.com>,
	lkp@intel.com, Linux Memory Management List <linux-mm@kvack.org>,
	Chao Yu <yuchao0@huawei.com>, LKML <linux-kernel@vger.kernel.org>,
	lkp@lists.01.org, ltp@lists.linux.it
Subject: Re: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail
Date: Wed, 10 Mar 2021 12:49:20 -0800	[thread overview]
Message-ID: <YEkw0J9VEg66AgIt@google.com> (raw)
In-Reply-To: <c84bf5c9-501e-6c25-1728-a7c6281093fd@oppo.com>

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 <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 <huangjianan@oppo.com>
> > > > >       Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> > > > >       Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > > > >       Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > > > 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();


  reply	other threads:[~2021-03-10 20:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  7:25 [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail kernel test robot
2021-03-08  7:25 ` kernel test robot
2021-03-08  7:25 ` kernel test robot
2021-03-08 11:53 ` [LTP] " Richard Palethorpe
2021-03-08 11:53   ` Richard Palethorpe
2021-03-08 11:53   ` Richard Palethorpe
2021-03-09  2:23   ` Weichao Guo
2021-03-09  2:23     ` Weichao Guo
2021-03-09  2:23     ` Weichao Guo
2021-03-09  4:01     ` Matthew Wilcox
2021-03-09  4:01       ` Matthew Wilcox
2021-03-09  4:01       ` Matthew Wilcox
2021-03-10  2:32       ` Huang Jianan
2021-03-10  2:32         ` Huang Jianan
2021-03-10  2:32         ` Huang Jianan
2021-03-10 20:49         ` Jaegeuk Kim [this message]
2021-03-10 20:49           ` Jaegeuk Kim
2021-03-10 20:49           ` Jaegeuk Kim
2021-03-23  9:04           ` Chao Yu
2021-03-23  9:04             ` Chao Yu
2021-03-23  9:04             ` Chao Yu
2021-04-29 13:08             ` Weichao Guo
2021-04-29 13:08               ` Weichao Guo
2021-04-29 13:08               ` Weichao Guo
2021-04-30  1:48               ` Gao Xiang
2021-04-30  1:48                 ` Gao Xiang
2021-04-30  1:48                 ` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YEkw0J9VEg66AgIt@google.com \
    --to=jaegeuk@kernel.org \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.