Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4083280pxf; Tue, 23 Mar 2021 02:06:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCwEpNg5itUF6yPZ7a+WhiSu0XuuEuD1hwuIzDrQRhLgQ2irfdCC3renKuz2SjFu3JDLei X-Received: by 2002:aa7:c0cd:: with SMTP id j13mr3733096edp.41.1616490404128; Tue, 23 Mar 2021 02:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616490404; cv=none; d=google.com; s=arc-20160816; b=HKpzeR9TMgqueZqutInBjd97/NfEXDaKuGfebYnLdoE9lKBP3zZ+zB9PbWO1BPB4Pg dBxhxaQY/UgEHVh3+buksB5X/FOi1zlepW3VMTSzTg4x+0BZ9kUmpKx412BsBNg1WR31 90IMsjzNK6gOLzeID2P+k3+ZXRMS+oJYIHCdnqZedAC3zbmACQyhGRlFSlGWiK8HN1b5 qiQTc5Zm+bhtQLfIY0lf8dPS8QIypmYlJWJ7EFuHhWuwxkOCHFmrAJJoXu4ZHQXVvgNO /mZtSI7ZX3QSLmcd5NetL6JX7cjcQ5Cp4KpnYhI+fIuc5EDqCm0DM1ErqKX9IFsKboVC p1WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=H7ifqzq91DpfJN7Nx24WlEZUlkHcvpe873nK/RoH7K0=; b=BZbpdUP1UgFl6FMQdS7KWfU+aw4gOOViAGAjPGHkhg70oBXMr14b1h7QTgx/dKhDD8 uOaLCF9oMh1WVrX2kkt2OFfVNle7SVV6CVAcd6dfsvo9SgDIAurFph3cbFhtffmU5mdN 8nnhm1+TfFMkD3zc5LdOpw8D3oZKSsOqSgdOqwnKEOGu6XDOwxUPE1onD4Til6IVAT4k 2a2Q+9ZQ3DtOmpjdeLRQOjM/mQu7mZJA7Nxi0DMZiqHgyuTr1TQmXxCoZoqaDAuUZYd3 ymLBj4uHNUHDeR/kp0zEaY9LUgjWU440UfN0m8N76eBUAdintjR+Nu661xc2plWtObWP 3wsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si8708077edx.268.2021.03.23.02.06.20; Tue, 23 Mar 2021 02:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229764AbhCWJE6 (ORCPT + 99 others); Tue, 23 Mar 2021 05:04:58 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:14433 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbhCWJEj (ORCPT ); Tue, 23 Mar 2021 05:04:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4F4QPd0v2WzkddY; Tue, 23 Mar 2021 17:03:01 +0800 (CST) Received: from [10.136.110.154] (10.136.110.154) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 23 Mar 2021 17:04:32 +0800 Subject: Re: [LTP] [f2fs] 02eb84b96b: ltp.swapon03.fail To: Jaegeuk Kim , Huang Jianan CC: Matthew Wilcox , Weichao Guo , , kernel test robot , , Linux Memory Management List , LKML , , References: <20210308072510.GA902@xsang-OptiPlex-9020> <87h7llhnfe.fsf@suse.de> <20210309040144.GH3479805@casper.infradead.org> From: Chao Yu Message-ID: Date: Tue, 23 Mar 2021 17:04:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.110.154] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/11 4:49, Jaegeuk Kim wrote: > 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); It will corrupt swap header info while relocating whole swapfile... > expand_inode_data(); > . >