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=-2.3 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, USER_AGENT_SANE_1 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 CDCF6C432C1 for ; Tue, 24 Sep 2019 15:45:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8B2D02146E for ; Tue, 24 Sep 2019 15:45:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pZBYEkeV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B2D02146E 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 22B926B0005; Tue, 24 Sep 2019 11:45:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DC636B0006; Tue, 24 Sep 2019 11:45:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CB5E6B0007; Tue, 24 Sep 2019 11:45:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0202.hostedemail.com [216.40.44.202]) by kanga.kvack.org (Postfix) with ESMTP id DFE1D6B0005 for ; Tue, 24 Sep 2019 11:45:08 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 7ECBE8243781 for ; Tue, 24 Sep 2019 15:45:08 +0000 (UTC) X-FDA: 75970237896.27.sheet14_841c215670e2d X-HE-Tag: sheet14_841c215670e2d X-Filterd-Recvd-Size: 5434 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Sep 2019 15:45:07 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id t3so2259190edw.13 for ; Tue, 24 Sep 2019 08:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=DE8+FbEIcVR5ddCwEcV8fUyORS7y9yBce98R3wD5OgQ=; b=pZBYEkeVsAqETL/uX9Sj2naqOG8d+iinZSGaRqymbfiuKbrI6MofbnAFRwc5OLY3cO YOlxDd0On4ZdH2Ky124tzY/ibHUWgiJiiJGbhBztbeI0bhyPQGbD7OcGHVaJ9W6Nn4Np wq6Km+svcYXMdF7Nz26ZcNkE11DNi2VxX5hBWT0aHjx0D/t5e8c+KwBracz1Ufv+WKYr 84dTzlUKoyXePov4O8iwWqUSozztRxrz3xgXIUaqZ9UiKE0DmZ4tFKm9VF9RkVpqmGKA JODq+clchBGEIkSKM1mWRy6fImcBkEoDFFvr2Nf194avzVldEo+vqmbsqrubNcSANTDC rPlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=DE8+FbEIcVR5ddCwEcV8fUyORS7y9yBce98R3wD5OgQ=; b=O0V2dMBzAdxKeUpb8huoStSf+ly2fQvd9ixVxfuyaZ0lr45U49JuOHCMgH4b/zm4o/ 1YEobzrHTfpwcyBWKrhS/7VfHrXhcAYoMOl6asYgKQtbIN14OfUa4DKtpxat1MkIFmxd qYz9bgAfVgmehnEV4tKnw2FFcXFer425UZiwD9UjH6jIQbCrFNomVc/uUaoSHTsh/bMc +ZLX+/rulDZ4PprtUXaNfOrxWwxqpGg2+C7gegZtRcBNq4Jg8Kvhb4wg8lybLon7EGZ4 LZvLk9zyJBHs+6TmvBqUqBTfPQD9bb+zmasunY9Nh3u8/IseOeQMT5GurH0/jq3mCkwr /iig== X-Gm-Message-State: APjAAAWKuHIhW+Rf6tnDWUdLAvtrQ0BZakqU28AoYFjDryYe5Jr+Qu2J IziTIDc8aveJRq4c2gO7iZo= X-Google-Smtp-Source: APXvYqz79VUZxlZWSAwnN9wusrngQi4fEktGTKUykQjNFq8gWnp4jcOcSgjJMSzCQNGJiOvGK83DNw== X-Received: by 2002:a17:906:3485:: with SMTP id g5mr2971417ejb.76.1569339906538; Tue, 24 Sep 2019 08:45:06 -0700 (PDT) Received: from [10.68.217.182] ([217.70.210.43]) by smtp.gmail.com with ESMTPSA id s9sm245584ejf.44.2019.09.24.08.45.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Sep 2019 08:45:05 -0700 (PDT) Subject: Re: [PATCH 3/3] xfs: Fix stale data exposure when readahead races with hole punch To: Jan Kara Cc: "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-mm@kvack.org, Amir Goldstein , Boaz Harrosh , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org References: <20190829131034.10563-1-jack@suse.cz> <20190829131034.10563-4-jack@suse.cz> <20190829155204.GD5354@magnolia> <20190830152449.GA25069@quack2.suse.cz> <20190918123123.GC31891@quack2.suse.cz> <53b7b7b9-7ada-650c-0a32-291a242601f3@gmail.com> <20190924152337.GE11819@quack2.suse.cz> From: Boaz Harrosh Message-ID: <6ba323dc-57aa-ffc1-3807-e7209979abcc@gmail.com> Date: Tue, 24 Sep 2019 18:45:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20190924152337.GE11819@quack2.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 24/09/2019 18:23, Jan Kara wrote: > On Mon 23-09-19 15:33:05, Boaz Harrosh wrote: >> On 18/09/2019 15:31, Jan Kara wrote: >> <> >>>>> Is there a test on xfstests to demonstrate this race? >>>> >>>> No, but I can try to create one. >>> >>> I was experimenting with this but I could not reproduce the issue in my >>> test VM without inserting artificial delay at appropriate place... So I >>> don't think there's much point in the fstest for this. >>> >>> Honza >>> >> >> If I understand correctly you will need threads that direct-write >> files, then fadvise(WILL_NEED) - in parallel to truncate (punch_hole) these >> files - In parallel to trash caches. >> (Direct-write is so data is not present in cache when you come to WILL_NEED >> it into the cache, otherwise the xfs b-trees are not exercised. Or are you >> more worried about the page_cache races? >> ) > > What I was testing was: > Fill file with data. But are you sure data is not in page cache after this stage? Also this stage sould create multiple extents perhaps with gaps in between > One process does fadvise(WILLNEED) block by block from end of the file. > Another process punches hole into the file. > (Perhaps randome placement that spans multiple extents in one go) > If they race is the right way, following read will show old data instead of > zeros. And as I said I'm able to hit this but only if I add artificial > delay between truncating page cache and actually removing blocks. > I was more afraid of iterating on a btree or xarray in parallel of it being destroyed / punched. I think if you iterate backwards in the WILLNEED case the tree/xarry corruption is less likely But now that I think about it. Maybe your case is very different to mine, because read_pages() in xfs does take the ilock. I'm not familiar with this code. > Honza > But I guess the window is very small then Thanks Boaz