Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4699920pxf; Tue, 23 Mar 2021 18:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzirMaI4/9AO/rF+qQjBYHuWZ49BmiPhMJgK+coFfoCA9tTLQm3oYWqbjgwlJ3ljmnG5Xse X-Received: by 2002:a17:906:8583:: with SMTP id v3mr1015383ejx.361.1616549088368; Tue, 23 Mar 2021 18:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616549088; cv=none; d=google.com; s=arc-20160816; b=upFhkJ5K068IEh1b/tUvOj4s532Jjqs/nR/pf6sbKz+FRVquAjz+0e6gI+rbJFND2Y +f23AdzQiGWe5KOuhvW8gxPMEzIqcK5+xucUoogal0FDcUpY5aptLQ8C7pZI6qvoTILn O+SXGijjDZhL6J05LYLxh/+0W3uY2ARxwCYrBGLac+XlC7DBnUDorvvpu05px6XZReY2 sA5J1vree/7XWMLs0QttlaTOz501s6z+O6jT061iO9rD6ql1LzIfXQLN91GKkNJwH0w7 IGCYluNmhg8YbC/AJqtHe8x+gNbkHNyYWrDNj/5u0RT6SPH3jidborQPtON+GzzuU10J RprQ== 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:dkim-signature; bh=rx9kgaZb+bgnOxaSkCx+gVKC93JmPftdrzb7m++xRDY=; b=yUEDU4SVUpGyTO/HdVZgOFvUcl3PMAE3Na+zkQYDi7YCHq9XHDuDl2sRp3QI8gNdTb jlUBd4qkfnPgwGcuc7jVfjYq54RxQl9xDoHcIOBfqOkEz2rILfdbNX92e+pvNMYMqhsI MUjpWncGZ9Y6/8m8lerZFjaBsyAGqrmz3n5hkzrJXx2XjPfWyYIK4REZucCJfOeTOTo0 OHp6hJZat2imSbCkGxcKgQvgswXw90mPBvFoSJFYsll47gW8EZpI6AG6dVQZwvpsrepB fMoVCzMcabJFtaZDX2+DB4X25lqkMUy/TUlU/0G7tt+djj+ovgutuJdWCnPp84Pm+ez2 6ogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ctFllR8M; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq5si603031edb.98.2021.03.23.18.24.25; Tue, 23 Mar 2021 18:24:48 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ctFllR8M; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229792AbhCWN4o (ORCPT + 99 others); Tue, 23 Mar 2021 09:56:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:54216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbhCWN42 (ORCPT ); Tue, 23 Mar 2021 09:56:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B19C6199F; Tue, 23 Mar 2021 13:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616507787; bh=8lKy2kI8+VRpgd7UaH5wsraNigVbnf5gjlgvvdBwnBE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=ctFllR8M5ADN0PQZGilMeRK2vxtz2PfkIZU/rB+oJPFpyrze0z1jirtPfRojTZe7E K01johJh0sVT0XKGOnU64IktnMSgnZxXU6wiax1/38dRhg6j9LaGsV+yG++7q64tUw 14WWIO+Jldbd+pHJ1SwnvFwRfEx1aqP6ADIeycO+RrYseD/Nv8OHdh3TwN/IupPFoU 6kRJOLAcnAsFBY5rNa4gFBXu70qInd+nqc7T2yaYnRG2tfJyzRgngYsW6zq4D/UxLY AWmdUbpOuu3HFsgdh5IOBweu2byr8HoJbL/Yv5vkutu2kCphIuxIcoWwgifginyA+H kpnt6hN17p83g== Subject: Re: [PATCH] f2fs: fix to align to section for fallocate() on pinned file To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu References: <20210305095601.96591-1-yuchao0@huawei.com> From: Chao Yu Message-ID: Date: Tue, 23 Mar 2021 21:56:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210305095601.96591-1-yuchao0@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/5 17:56, Chao Yu wrote: > Now, fallocate() on a pinned file only allocates blocks which aligns > to segment rather than section, so GC may try to migrate pinned file's > block, and after several times of failure, pinned file's block could > be migrated to other place, however user won't be aware of such > condition, and then old obsolete block address may be readed/written > incorrectly. > > To avoid such condition, let's try to allocate pinned file's blocks > with section alignment. > > Signed-off-by: Chao Yu Jaegeuk, Could you please check and apply below diff into original patch? --- fs/f2fs/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 236f3f69681a..24fa68fdcaa0 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1648,13 +1648,13 @@ static int expand_inode_data(struct inode *inode, loff_t offset, return 0; if (f2fs_is_pinned_file(inode)) { - block_t len = (map.m_len >> sbi->log_blocks_per_seg) << - sbi->log_blocks_per_seg; + block_t sec_blks = BLKS_PER_SEC(sbi); + block_t len = rounddown(map.m_len, sec_blks); - if (map.m_len % sbi->blocks_per_seg) - len += sbi->blocks_per_seg; + if (map.m_len % sec_blks) + len += sec_blks; - map.m_len = sbi->blocks_per_seg; + map.m_len = sec_blks; next_alloc: if (has_not_enough_free_secs(sbi, 0, GET_SEC_FROM_SEG(sbi, overprovision_segments(sbi)))) { -- 2.22.1