Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp6988706imm; Sun, 20 May 2018 15:45:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr+ZQEj2h1wJIxY6auUegV8oShrb0NzZQa9RxGrFpus3aXl5hXyqQ4sBgIk1zzDZyzz/4fa X-Received: by 2002:a63:9e53:: with SMTP id r19-v6mr13790429pgo.50.1526856355705; Sun, 20 May 2018 15:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526856355; cv=none; d=google.com; s=arc-20160816; b=xPyVBiuhjKeUfcb4PukgfR9TBmByy6siqXwW50lP/DBYHzTW8VGaN6ILAqB1gGrmLH 33b+NtrgzteClim0YYMM6Gse+PHeDYpghvmkAhTtCnXuafm1rPXHz2jg0vScTf+Y0aqc dTBPmdXcGRdC5USDAU6z1/av+WVy8cA98ecb/gLxe0hC7dSpqAvZdKNwtP3Lq1WRSoSM j+D8oCvCsnYJSqGw4yP98CxvMuyM9KnxVxvWTPf/EXaIfuWuzefjcswBo1I8TPdp/SB6 mBvVBiMtdaBrEimmUOXkJO4ppSg4cvf+Kstn+MkNxvVXQMq+8AKYhCWkYR7zx+1Y0AiI fr5g== 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=1ciRPcHyMqLf4nyrDF1N0hUJVV+Ahxz7OMlzkKDHXQg=; b=xJSIRJkciylkzi+fHGwJGS1x3YjX1zCvCloGIDuXadTI+gqP0y4utgRf9GWhIfivif zFk0ciTj1rBU2ec6INPfDLa82bzC2ih2RHwH5B2ABlpYMq8++Gc5zTfE9RGPHNT5M0pn d6cD6oE1nZJ8eiGzTvQlCjt0GLKltiS82UK2oWj4BA/Ci0faqRucGO53QiFcCox4Eo3M 3i3nOUZUYGeJDNtMD/YpKOQOgdY233sRZ/orHSSS2oUUtZDIisn7S+qGZ33nIKURtB6T HjdCb3HAiUqb6CAxFHrNuYcWFQ2Ngc6yEezL9se+ZApkXLJSOVvMUBRi+fq+X6qkiXWt fE0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bzBJaj7D; 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 t5-v6si13033161ply.598.2018.05.20.15.45.41; Sun, 20 May 2018 15:45:55 -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=bzBJaj7D; 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 S1751681AbeETWpa (ORCPT + 99 others); Sun, 20 May 2018 18:45:30 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:44929 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbeETWp2 (ORCPT ); Sun, 20 May 2018 18:45:28 -0400 Received: by mail-qt0-f193.google.com with SMTP id d3-v6so16841178qtp.11; Sun, 20 May 2018 15:45:28 -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=1ciRPcHyMqLf4nyrDF1N0hUJVV+Ahxz7OMlzkKDHXQg=; b=bzBJaj7DqclAU50CjK9AXUPVn/NCJsvhXeq94mAyXsQdXAtpqOZNTYKONbAiJpVP3u cBiPVyZ+FxD1tCvu1XJhkYfDCKXEK29/duLywMwgMBXxKr+CI41t6Ykn6bG99HXNUJ5Z bEHnczmuB4lclPw/Gd3IezOJwBX978Ffn7dle+A+irR4InzLtteCboMjC5zEzEWDvGyC ntIwnm2CM+4t7Y5wiL6v1FZACjUyJEt57gp1FTufifyb+eFI2kzYfQcq3W7JFikE5rPh D2qMcnpncegOUTEvwXloT2ebZ/GGFUFjWMejTgXbGCKyeUzTjDLr0X4uZT9PshP5F34b BvPQ== 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=1ciRPcHyMqLf4nyrDF1N0hUJVV+Ahxz7OMlzkKDHXQg=; b=fKB0IRLi5tOjD94wIuaDxABS2mnlnog4ySk/DXlE1J4XA/fSorxhPMJNrVO8MIfXB+ eWOs59K5de9gWlHGweNL4lbY5oGQFh9qm4riNnQApUUeSbxoMvPHCawxaaDf6aECD49m oGxCnNkFu9a9UZUcw9v0kVOaho3777PofFystSR6pwit5ekKRSVfgzC4g19SnYi/GLf6 xwXlq4zooUvN4WMDQCeLXDsHRd2A4DxhWG6jKfPSilgN4ztqPR37Ajdi+yWbcEH1qnSA h/1tYDQTv39OG6zlZMyGYHbYyvkM+uJjGemMrnGRhkC19ZcgEKy3BnysO3Y/nNXxgXsn ZrVQ== X-Gm-Message-State: ALKqPwe+85Tvh9WibMHPQ2zf2JexCaR/Vd9z0b0MzhTdMoRX7pmCmGA/ F8hF0u2vYqt9kTkUAj6L5A== X-Received: by 2002:ac8:2bb8:: with SMTP id m53-v6mr16630127qtm.340.1526856327881; Sun, 20 May 2018 15:45:27 -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 q10-v6sm10109398qtk.7.2018.05.20.15.45.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 May 2018 15:45:26 -0700 (PDT) Date: Sun, 20 May 2018 18:45:24 -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: <20180520224524.GC11495@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'm not going to go and redo locking in XFS and ext4 as a prerequisite to merging bcachefs. Sorry, but that's a bit crazy. I am more than happy to work on the locking itself if we can agree on what semantics we want out of it. We have two possible approaches, and we're going to have to pick one first: the locking can be done at the top of the IO stack (like ext4 and I'm guessing xfs), but then we're adding locking overhead to buffered reads and writes that don't need it because they're only touching pages that are already in cache. Or we can go with my approach, pushing down the locking to only when we need to add pages to the page cache. I think if we started out by merging my approach, it would be pretty easy to have it make use of Mathew's fancy xarray based range locking when that goes in, the semantics should be similar enough. If people are ok with and willing to use my approach, I can polish it up - add lockdep support and whatever else I can think of, and attempt to get rid of the stupid recursive part. But that's got to be decided first, where in the call stack the locking should be done.