Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp657521imi; Fri, 22 Jul 2022 06:47:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdNKlzWi7Br5JiDd2mHd8mJkZru4Rr3jo2WR5WV/httk1ZK2+OSJ9g3BvBXh84IeS9lv++ X-Received: by 2002:a17:90b:2c0b:b0:1ef:aa42:f19b with SMTP id rv11-20020a17090b2c0b00b001efaa42f19bmr17746608pjb.211.1658497655286; Fri, 22 Jul 2022 06:47:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658497655; cv=none; d=google.com; s=arc-20160816; b=BpyJ4M43m3QskZ+6pIBoBMReABH4UZ8qYJHCBbmJmd6FTP34bBL9u/NtNIUkv/d+Vn PL14oQLgJNnI79bEXr7U000K9fMPa5/QQzyoVrBB996DPmf878wv7zPE6HIjyUKfwJOK JyiiRYtklxPb49eTdScSHT86S/g662eZLVcSIjKww7Bm57b8WhotAVSykPP8sQO7cAsm ltnVnqbyfhAS8APACJbyxzYO1z8QTLZaRM4B6WluSWyWafvqvfMXBFwnAgIw7OYiG7qq 4A6uvP7CJyMXomST+HWKRJC0v2FhssEsi3WN0boWn6JjR2Dbb0T2r0K0uX0+RjV+FF87 SfIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=djjBMqN91Q4Epn4IxbRWvDwPSlip0NJ3nUXOi51bNSk=; b=GCVNWgt50TOaYjqiFhikQ22ZrLWkcO/6ykWg7MSJzn9lXM6/nDiae+BBZ5JH/mSwyM 9Yg9QTWY1aCZ+5TdD7CbcXycJzd6a32lvXq0IcSVA8KlLZ4yYFD2MdNPJFb5RBiqWBnS VdqgIMHYdFR7UTDWWk1omyaMKyj0ztt4V4GLazKd1IFOt9ohyEvqoDBqXv5ixPW28/Wh zrUB0PkymGU0wjgN0BqzXYDEiTXU3Ej0Hxdawr0UyklCtKfrKsXBoi/vFMN56eX25FYW du9LvFlYqWKv3b9t3hqR/UlMLH7F9kgLI1vOmDPMNdWbsnIqwYeaTxW8Ws/VmDtViNrY UT4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bhd5FkYe; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a170902dacb00b0016be773edb6si6412859plx.32.2022.07.22.06.47.11; Fri, 22 Jul 2022 06:47:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bhd5FkYe; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-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 S234364AbiGVNnd (ORCPT + 99 others); Fri, 22 Jul 2022 09:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231807AbiGVNnd (ORCPT ); Fri, 22 Jul 2022 09:43:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4B56BC38; Fri, 22 Jul 2022 06:43:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CA273B82902; Fri, 22 Jul 2022 13:43:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7494DC341CE; Fri, 22 Jul 2022 13:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658497409; bh=JNOrMYsPoDL/eg223R4yc86YLW3fK7oVbRQvzymB0mY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bhd5FkYew0GcS8oEu+bqOlnsgnmU+VsNCCMQX2rGAcqZqSuu23bAV4yDtuWpB0BMO +QFQl6/sxJEyBtNNz2PN4KAJoiI3Jd8+WZd3m9O28mbsz5fD8PdLcHbSSCXbLkFEKw U2MG0GjephE0OZfUbirN3FXsCm2/0YV4UvdwfZspnAZNWau78FR6x31+m3S78N7lMB gGNSYlPjPsqJYukTGaZkmMbgZqjhkWxVp90ozL4K6OSRtqaiE2Ls6KEJdY7dgf86OB EapUJeYRKYtcI0l+c/fDeJFB4yy604nR/VTRdbTd/zg3exnfMHi/z7RtBI5eEgP7V3 p970KZAj8XQiQ== Received: by mail-wr1-f48.google.com with SMTP id d16so6550008wrv.10; Fri, 22 Jul 2022 06:43:29 -0700 (PDT) X-Gm-Message-State: AJIora+DzfumLhVqBzNKXwOxwvszXcrxwBkvjGnDBGgnkytkzKvAo+QV +f2WvaGRk0Kr9+QVhvfEd8CAkE+yMGaKjpy+Oa4= X-Received: by 2002:adf:de0a:0:b0:21e:45b0:e917 with SMTP id b10-20020adfde0a000000b0021e45b0e917mr10796wrm.434.1658497407859; Fri, 22 Jul 2022 06:43:27 -0700 (PDT) MIME-Version: 1.0 References: <20220715184433.838521-1-anna@kernel.org> <20220715184433.838521-7-anna@kernel.org> <20220718011552.GK3600936@dread.disaster.area> In-Reply-To: From: Anna Schumaker Date: Fri, 22 Jul 2022 09:43:11 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 6/6] NFSD: Repeal and replace the READ_PLUS implementation To: Josef Bacik Cc: Dave Chinner , Chuck Lever III , Linux NFS Mailing List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Jul 22, 2022 at 9:32 AM Josef Bacik wrote: > > On Fri, Jul 22, 2022 at 08:45:13AM -0400, Anna Schumaker wrote: > > On Thu, Jul 21, 2022 at 4:48 PM Josef Bacik wrote: > > > > > > On Tue, Jul 19, 2022 at 04:46:50PM -0400, Anna Schumaker wrote: > > > > On Sun, Jul 17, 2022 at 9:16 PM Dave Chinner wrote: > > > > > > > > > > On Fri, Jul 15, 2022 at 07:08:13PM +0000, Chuck Lever III wrote: > > > > > > > On Jul 15, 2022, at 2:44 PM, Anna Schumaker wrote: > > > > > > > > > > > > > > From: Anna Schumaker > > > > > > > > > > > > > > Rather than relying on the underlying filesystem to tell us where hole > > > > > > > and data segments are through vfs_llseek(), let's instead do the hole > > > > > > > compression ourselves. This has a few advantages over the old > > > > > > > implementation: > > > > > > > > > > > > > > 1) A single call to the underlying filesystem through nfsd_readv() means > > > > > > > the file can't change from underneath us in the middle of encoding. > > > > > > > > > > Hi Anna, > > > > > > > > > > I'm assuming you mean the vfs_llseek(SEEK_HOLE) call at the start > > > > > of nfsd4_encode_read_plus_data() that is used to trim the data that > > > > > has already been read out of the file? > > > > > > > > There is also the vfs_llseek(SEEK_DATA) call at the start of > > > > nfsd4_encode_read_plus_hole(). They are used to determine the length > > > > of the current hole or data segment. > > > > > > > > > > > > > > What's the problem with racing with a hole punch here? All it does > > > > > is shorten the read data returned to match the new hole, so all it's > > > > > doing is making the returned data "more correct". > > > > > > > > The problem is we call vfs_llseek() potentially many times when > > > > encoding a single reply to READ_PLUS. nfsd4_encode_read_plus() has a > > > > loop where we alternate between hole and data segments until we've > > > > encoded the requested number of bytes. My attempts at locking the file > > > > have resulted in a deadlock since vfs_llseek() also locks the file, so > > > > the file could change from underneath us during each iteration of the > > > > loop. > > > > > > > > > > > > > > OTOH, if something allocates over a hole that the read filled with > > > > > zeros, what's the problem with occasionally returning zeros as data? > > > > > Regardless, if this has raced with a write to the file that filled > > > > > that hole, we're already returning stale data/hole information to > > > > > the client regardless of whether we trim it or not.... > > > > > > > > > > i.e. I can't see a correctness or data integrity problem here that > > > > > doesn't already exist, and I have my doubts that hole > > > > > punching/filling racing with reads happens often enough to create a > > > > > performance or bandwidth problem OTW. Hence I've really got no idea > > > > > what the problem that needs to be solved here is. > > > > > > > > > > Can you explain what the symptoms of the problem a user would see > > > > > that this change solves? > > > > > > > > This fixes xfstests generic/091 and generic/263, along with this > > > > reported bug: https://bugzilla.kernel.org/show_bug.cgi?id=215673 > > > > > > > > > > > > 2) A single call to the underlying filestem also means that the > > > > > > > underlying filesystem only needs to synchronize cached and on-disk > > > > > > > data one time instead of potentially many speeding up the reply. > > > > > > > > > > SEEK_HOLE/DATA doesn't require cached data to be sync'd to disk to > > > > > be coherent - that's only a problem FIEMAP has (and syncing cached > > > > > data doesn't fix the TOCTOU coherency issue!). i.e. SEEK_HOLE/DATA > > > > > will check the page cache for data if appropriate (e.g. unwritten > > > > > disk extents may have data in memory over the top of them) instead > > > > > of syncing data to disk. > > > > > > > > For some reason, btrfs on virtual hardware has terrible performance > > > > numbers when using vfs_llseek() with files that are already in the > > > > server's cache. I think it had something to do with how they lock > > > > extents, and some extra work that needs to be done if the file already > > > > exists in the server's memory but it's been a few years since I've > > > > gone into their code to figure out where the slowdown is coming from. > > > > See this section of my performance results wiki page: > > > > https://wiki.linux-nfs.org/wiki/index.php/Read_Plus_May_2022#BTRFS_3 > > > > > > > > > > I just did this locally, once in my test vm's and once on my continuous > > > performance testing hardware and I'm not able to reproduce the numbers, so I > > > think I'm doing something wrong. > > > > > > My test is stupid, I just dd a 5gib file, come behind it and punch holes every > > > other 4k. Then I umount and remount, SEEK_DATA+SEEK_HOLE through the whole > > > file, and then do it again so I have uncached and cached. The numbers I'm > > > seeing are equivalent to ext4/xfs. Granted on my VM I had to redo the test > > > because I had lockdep and other debugging on which makes us look stupid because > > > of the extent locking stuff, but with it off everything appears normal. > > > > > > Does this more or less mirror your testing? Looking at our code we're not doing > > > anything inherently stupid, so I'm not entirely sure what could be the problem. > > > Thanks, > > > > I think that's pretty close to what the server is doing with the > > current code, except the NFS server would also do a read for every > > data segment it found. I've been using `vmtouch` to make sure the file > > doesn't get evicted from the server's page cache for my cached data. > > > > I messed with it some more and I can't get it to be slow. If you trip over > something like this again just give a shout and I'd be happy to dig in. Thanks, Interesting. The only other suggestion I can think of is to try it over NFS, could be some interaction with how the server is opening files. Anna > > Josef