Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5227884imm; Tue, 18 Sep 2018 06:23:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbFOsz8Oovr/fCMpjBDhhs+4zuXs0zsi5VuGNDIgriPSpFedGSdE9pj7Qw+rTndIBRGKAv1 X-Received: by 2002:a63:9b09:: with SMTP id r9-v6mr27975606pgd.324.1537276986338; Tue, 18 Sep 2018 06:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537276986; cv=none; d=google.com; s=arc-20160816; b=hBYYVD6HG9wV+/BWv1c5RL82xwes9JXbGhqNteDd9JlTTHW+KEIc/rZaO1QG93PSj5 P1Ls7OL2H8teAVSySXnCu2/2lwVOWcbAmxpdfR0Nrmop2YGkDtMsOu4ytZIAIEXKuFHJ 0Xf9l/R32NshUIZh6SytoB6NbZlenAVJ3pq1AkIxVRmLz4+yWYqsB+aU8Ddeu47YTOlr HO01h77QgJyW1xOcgen9Ck6jKiZzDGqVeFyKMWHxAQ60lb339aaEPKGQhlMoRckt0iIi qylxMLfrASpFalU28BvXH/NAm3sCrBkzJCBvnB9ahMzODD5+0V8bdessqIi/8JvXW+Yl TGag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=h2/zw1XW56E/F6VNEe2PMjhYWHfISL7+F6aMe+4QrYw=; b=C4xnYez/IJtAoQFgY+uEB40X0Eaoa4HexEk25UvEwJKaq2UQgoIZNTXx63LZuGtZwv wbAtCtRIzag6kCIn8JN+zSMd57+/d0l4iBNLoKMQi/u8C+4vG7wlEyfQrV8BqYFbQkzX tjP1jW+RYqDSx7cIfKZrLtXRvnNlg9DfNHuMcP57I7A7Gz8snuYQltDTNTDY9D/a3rS6 oIJKAePGTviyCwSI7CF6RbNjJ4SbLpYzvrPpcL4yNs9t+EUopiK4gloCm6Y1mvlwbnw6 LvYJ7p5/Crs55Qmg1RdmtMRqIgTde9jRpA5jVMANYZlZqxNNW8kj0/wCAEb1egh0pOW/ Mtag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kh6toQjf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a98-v6si19218584pla.396.2018.09.18.06.22.49; Tue, 18 Sep 2018 06:23:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kh6toQjf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729780AbeIRSye (ORCPT + 99 others); Tue, 18 Sep 2018 14:54:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:57928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729747AbeIRSyd (ORCPT ); Tue, 18 Sep 2018 14:54:33 -0400 Received: from [192.168.0.101] (unknown [49.77.217.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 146B82146D; Tue, 18 Sep 2018 13:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1537276919; bh=j41sgoeYYs4xcoMxxjh7WldDlBOpBtXoKYOPRrqsd+E=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Kh6toQjfVBagSvSPuaa/YJDXDl5bua0/v50OMeVBIRCOa//vBiZjBUeX9rn1smbIK 5szjm5NMJsBwbTd2mO5/QLXd6mEX2j2wpenMLx4EqNsPTSBXmXwLynKsLCrRr608zf 5NrnvbQlUAxvi+i07uLxoYDJI4ITdJoCW/9hZRzg= Subject: Re: [PATCH] f2fs: avoid GC causing encrypted file corrupted To: Yunlong Song , jaegeuk@kernel.org, yuchao0@huawei.com, yunlong.song@icloud.com Cc: miaoxie@huawei.com, bintian.wang@huawei.com, shengyong1@huawei.com, heyunlei@huawei.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <1537274393-78441-1-git-send-email-yunlong.song@huawei.com> From: Chao Yu Message-ID: <19e63fa7-1a48-c1de-eef5-cde242e8300d@kernel.org> Date: Tue, 18 Sep 2018 21:21:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1537274393-78441-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/9/18 20:39, Yunlong Song wrote: > The encrypted file may be corrupted by GC in following case: > > Time 1: | segment 1 blkaddr = A | GC -> | segment 2 blkaddr = B | > Encrypted block 1 is moved from blkaddr A of segment 1 to blkaddr B of > segment 2, > > Time 2: | segment 1 blkaddr = B | GC -> | segment 3 blkaddr = C | > > Before page 1 is written back and if segment 2 become a victim, then > page 1 is moved from blkaddr B of segment 2 to blkaddr Cof segment 3, > during the GC process of Time 2, f2fs should wait for page 1 written back > before reading it, or move_data_block will read a garbage block from > blkaddr B since page is not written back to blkaddr B yet. > > Commit 6aa58d8a ("f2fs: readahead encrypted block during GC") introduce > ra_data_block to read encrypted block, but it forgets to add > f2fs_wait_on_page_writeback to avoid racing between GC and flush. > > Signed-off-by: Yunlong Song Reviewed-by: Chao Yu Thanks,