Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4795741imm; Fri, 18 May 2018 10:46:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrrShLP0lBIGvKmxIQ7ILrrN79fRW+Zg8yG9OhS3sm1723Gd3x5azRVzN5SgkGUwXpzPsaM X-Received: by 2002:a62:6105:: with SMTP id v5-v6mr10292444pfb.197.1526665604453; Fri, 18 May 2018 10:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526665604; cv=none; d=google.com; s=arc-20160816; b=zFuHcuVoQ6nGdu+CGdMMpXAcg/iq+I7XZv6HH1BXM/5rIAHyFW8Czl1v5/z8l0ICnF 5rgPnU3RhqpvSWovvHYBT/cUewB/gi220x6JHa4sOmF5wNgfN7aCOXW3BneApNxTFclS hN8Coc16gz9cYRYeXBrVAkt4vz1V6y7as5J83fZQSAT6Acuk5x2jKWasG9CVh1ajJQXl cO0zqcWKQNhUYAPc8diI8bZCiKj2z/RJRI/Xb+pWkU6JG7/TDUugL+drMMGO4bUAd2xA I2fi+ILYpr+JqBYzpI2vc2OZdV00FwadlE8b6lYndDJZfxssQIUY4X6h/5JaT79OS/WQ b4rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=dRdXRnhGBa/RUQW/a3GnMLG0TMR3d8gvqChhlUtGYLI=; b=n63LK61I6ZgG2dSTmHMU+EB7nlTZZeaOMe3GRZZV8+Yf06UpXCZfMWq3dkC1tsP4wl /RrmKdhLwz0yrnMUifBl6PnA+Ldw4e1GSrQVUTmvRWoEXxQUlC06rsxk+4fUX1bYPFOb j7q4Bvy1h6x/O4egRGteifndDyhwa5Ab36o7oRzsGQYU6PSCqM9b+IdvS5jM7snn/zVM uI4QwH6xB3QMV6g4d6t10YH4tw/FpngQSqx5J5wJ9qZH/BuPpYt2u7d9txYwS7EycAyI xtkCuQhXaJZw0OQE99p98YEh22MzIEkogbzdDV0tH8307XvPWv98a9LNFRD5AFOFqwuR XH9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mJVaYwTN; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v16-v6si7725303pfn.77.2018.05.18.10.46.30; Fri, 18 May 2018 10:46:44 -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=@gmail.com header.s=20161025 header.b=mJVaYwTN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752336AbeERRp7 (ORCPT + 99 others); Fri, 18 May 2018 13:45:59 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:41445 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752295AbeERRpy (ORCPT ); Fri, 18 May 2018 13:45:54 -0400 Received: by mail-qk0-f195.google.com with SMTP id d125-v6so7074421qkb.8; Fri, 18 May 2018 10:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dRdXRnhGBa/RUQW/a3GnMLG0TMR3d8gvqChhlUtGYLI=; b=mJVaYwTNsUU/HjshuEZNqpnnJ4s5tT64TrhI4I5x70MW+kOabjEyDE5VnaR/V0lg5c Ie7/KogbbbB2lxjGJKWL2MH3Lhy5e69hxJ6sLyixaIXunFx9BngsScd0dbf1HDbAdJN6 +Dv4BbJS1b8CUdW+YbkuSP9gxA7Lf0StcJEWP4+T/Ulg1D9Sv1KGAWpgbOdUgi0gKxqK u7sQT41R1lKvxC72ghhe5RHfWzcoyVmnqeORuIFkgmH8MeuQv3bMU3LDzEsF1Nufutne Ql/8hbts7oZQca1/oDrSCVSAY5kVWyCkQ+yGkzN7Mn24mNZKJxsRQouNUlXpD4aoIa0y b9NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dRdXRnhGBa/RUQW/a3GnMLG0TMR3d8gvqChhlUtGYLI=; b=DNDcdHac9jWDVW5B2YoinQtgTE5LAErnTqasOKcwDCpDTEw/vZF/PxtuemoaTM6Gy9 xRKR7D881zQjNShTD5aBx//+yYtU83b04STrXgU0/kbYR4Yu4ZrLgyJ8q3+FqgW0crYD Ka71g3PG00utWz3PjbTeLZTLt9JQYNnLEsW5nsEnOcN9CFHK12h+bH6qgY22Zi9qVHce e2PT/Td40HwIlXeYhql/SzmN+K94JFV3CcmB31rpZofg3JtGDdYkidJCEZF/3wYYqREU fs3Bt0eZ8R43GJJX72cjXvTG74yZ6NgZVzRs2v5zfczH/tRm7gVSkC28UuoNrLhCCYYv tnVw== X-Gm-Message-State: ALKqPwcSS7X9B8F/2P+KkY70rvChyfLAzJYtEaXXgVx0q8hpUMd2f1F/ 6nv0LeI00XXI9NzkQrK6KT3feAhZpQ== X-Received: by 2002:a37:4ccc:: with SMTP id z195-v6mr9492058qka.319.1526665553047; Fri, 18 May 2018 10:45:53 -0700 (PDT) Received: from kmo-pixel (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id n29-v6sm6602951qta.94.2018.05.18.10.45.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 10:45:52 -0700 (PDT) Date: Fri, 18 May 2018 13:45:49 -0400 From: Kent Overstreet To: Christoph Hellwig Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Dave Chinner , darrick.wong@oracle.com, tytso@mit.edu, linux-btrfs@vger.kernel.org, clm@fb.com, jbacik@fb.com, viro@zeniv.linux.org.uk, peterz@infradead.org Subject: Re: [PATCH 01/10] mm: pagecache add lock Message-ID: <20180518174549.GD31737@kmo-pixel> References: <20180518074918.13816-1-kent.overstreet@gmail.com> <20180518074918.13816-3-kent.overstreet@gmail.com> <20180518131305.GA6361@bombadil.infradead.org> <20180518155330.GA16931@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180518155330.GA16931@infradead.org> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 18, 2018 at 08:53:30AM -0700, Christoph Hellwig wrote: > On Fri, May 18, 2018 at 06:13:06AM -0700, Matthew Wilcox wrote: > > > Historically, the only problematic case has been direct IO, and people > > > have been willing to say "well, if you mix buffered and direct IO you > > > get what you deserve", and that's probably not unreasonable. But now we > > > have fallocate insert range and collapse range, and those are broken in > > > ways I frankly don't want to think about if they can't ensure consistency > > > with the page cache. > > > > ext4 manages collapse-vs-pagefault with the ext4-specific i_mmap_sem. > > You may get pushback on the grounds that this ought to be a > > filesystem-specific lock rather than one embedded in the generic inode. > > Honestly I think this probably should be in the core. But IFF we move > it to the core the existing users of per-fs locks need to be moved > over first. E.g. XFS as the very first one, and at least ext4 and f2fs > that copied the approach, and probably more if you audit deep enough. I didn't know about i_mmap_sem, thanks But, using a rw semaphore wouldn't work for dio writes, and I do need dio writes to block pagecache adds in bcachefs since the dio write could overwrite uncompressed data or a reservation with compressed data, which means new writes need a disk reservation. Also I'm guessing ext4 takes the lock at the top of the read path? That sucks for reads that are already cached, the generic buffered read path can do cached reads without taking any per inode locks - that's why I pushed the lock down to only be taken when we have to add a page to the pagecache. Definitely less ugly doing it that way though...