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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 90DAEC33CB6 for ; Sun, 19 Jan 2020 08:35:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3914D2072B for ; Sun, 19 Jan 2020 08:35:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MICKMx0J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3914D2072B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7232F6B0572; Sun, 19 Jan 2020 03:35:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D3016B0573; Sun, 19 Jan 2020 03:35:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C1046B0574; Sun, 19 Jan 2020 03:35:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0223.hostedemail.com [216.40.44.223]) by kanga.kvack.org (Postfix) with ESMTP id 46A8C6B0572 for ; Sun, 19 Jan 2020 03:35:21 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 0D78D40D7 for ; Sun, 19 Jan 2020 08:35:21 +0000 (UTC) X-FDA: 76393724442.18.dress10_85fa91265272c X-HE-Tag: dress10_85fa91265272c X-Filterd-Recvd-Size: 4848 Received: from mail-il1-f193.google.com (mail-il1-f193.google.com [209.85.166.193]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Sun, 19 Jan 2020 08:35:20 +0000 (UTC) Received: by mail-il1-f193.google.com with SMTP id f10so24830754ils.8 for ; Sun, 19 Jan 2020 00:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WnvCnon0B2vZEtChKK2eAEB4AoqKysFBIa8g4lTbzqs=; b=MICKMx0JRRKjGltjB7+mwIArqOPNrBi52HqBHbIC/HB4t4TdIOP/SYLkIFtT0HLvVG tSDbPRAdaXSTlVN12U/SJSdlA7hKR8rI8PVJrfn7JvU3xZi2O/SjgHo4sP7bZ+nVfoKO 1pJ9NDQ7VCfATu4UcxLAGkBuY8maIv9yjW6OVwQ9lphaVD+BJ88DFDwmQf7nUMMiiepY bY8A1caHiEY6dAQNvSCOO++S/Ov/t9InaB+zvkyWPKZMj87SqgBYptJ3ODw8rwnvTGAB FF7gMujX0GT5MTdulwXvZje0OFRsJU3p+Bzoct9gGiOBvDTSFWCFomcGYXHUAfGZl+7E HMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WnvCnon0B2vZEtChKK2eAEB4AoqKysFBIa8g4lTbzqs=; b=cWgitrJCaSElVe+PmyWlfDpWU1v3jDxt2GF6g/cJkRj0xzQil4vwc/2lUQX8K7Rw4r UYsY7f7N7OZ8/dIKacWjdwRRCldDcba+af8AtvWu0j0OGVo5x7l4UqQu0Cec3F3SgFo0 FdzrzgK3PmSEzGSjt6yR5uZjtOTTxbn3Twfuj0tEC7ms2BvF7M/jsvMIlQHjhC8RBZrS mu232fvgsmolbtr3WL/KIB1MexWnd0Z7bYCbZQAPE4dot+MYQ24C7W+8P7kGC9DFTC7+ evtuai45Asv4IRr9HkzU7whowDZTcrRG1zV5FCF5D9EIegdNJz5aiqcPW/GW5yw4NTW5 EIyQ== X-Gm-Message-State: APjAAAWZ4ldjYmtVtu/Gp8IHhQ3ZFfQ4oYu+X9w+6qKKjt3k9lvnzmhT TTMVz1dJXEl51qvtDNVPp49VZ2Fepyl+EFfMnbM= X-Google-Smtp-Source: APXvYqwZr4ZjR8ayJHlIXAe9Mu2fL/t/GmQP+UeWRJOzS1BF1xB3ciC2rHWyCUrxr286ENDotvVDU1t2Jngvyqsb2EQ= X-Received: by 2002:a92:88d0:: with SMTP id m77mr6344819ilh.9.1579422919785; Sun, 19 Jan 2020 00:35:19 -0800 (PST) MIME-Version: 1.0 References: <20190829131034.10563-1-jack@suse.cz> In-Reply-To: From: Amir Goldstein Date: Sun, 19 Jan 2020 10:35:08 +0200 Message-ID: Subject: Re: [PATCH 0/3 v2] xfs: Fix races between readahead and hole punching To: Jan Kara Cc: linux-xfs , Linux MM , "Darrick J. Wong" , Boaz Harrosh , linux-fsdevel , Matthew Wilcox , Jens Axboe , Dave Chinner Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 17, 2020 at 12:50 PM Amir Goldstein wrote: > > On Thu, Aug 29, 2019 at 4:10 PM Jan Kara wrote: > > > > Hello, > > > > this is a patch series that addresses a possible race between readahead and > > hole punching Amir has discovered [1]. The first patch makes madvise(2) to > > handle readahead requests through fadvise infrastructure, the third patch > > then adds necessary locking to XFS to protect against the race. Note that > > other filesystems need similar protections but e.g. in case of ext4 it isn't > > so simple without seriously regressing mixed rw workload performance so > > I'm pushing just xfs fix at this moment which is simple. > > > > Jan, > > Could you give a quick status update about the state of this issue for > ext4 and other fs. I remember some solutions were discussed. > Perhaps this could be a good topic for a cross track session in LSF/MM? > Aren't the challenges posed by this race also relevant for RWF_UNCACHED? > Maybe a silly question: Can someone please explain to me why we even bother truncating pages on punch hole? Wouldn't it solve the race if instead we zeroed those pages and marked them readonly? The comment above trunacte_pagecache_range() says: * This function should typically be called before the filesystem * releases resources associated with the freed range (eg. deallocates * blocks). This way, pagecache will always stay logically coherent * with on-disk format, and the filesystem would not have to deal with * situations such as writepage being called for a page that has already * had its underlying blocks deallocated. So in order to prevent writepage from being called on a punched hole, we need to make sure that page write fault will be called, which is the same state as if an exiting hole has been read into page cache but not written yet. Right? Wrong? What am I missing here? Thanks, Amir.