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.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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 2FC81C43215 for ; Mon, 25 Nov 2019 09:17:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD33620823 for ; Mon, 25 Nov 2019 09:17:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="Kv+a6C+O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD33620823 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7B7FC6B05C1; Mon, 25 Nov 2019 04:17:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 767046B05C7; Mon, 25 Nov 2019 04:17:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 658106B05C8; Mon, 25 Nov 2019 04:17:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 4FF226B05C1 for ; Mon, 25 Nov 2019 04:17:36 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id F3665A2B6 for ; Mon, 25 Nov 2019 09:17:35 +0000 (UTC) X-FDA: 76194246870.04.grape86_42423ff095848 X-HE-Tag: grape86_42423ff095848 X-Filterd-Recvd-Size: 6493 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Nov 2019 09:17:35 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id t5so14935205ljk.0 for ; Mon, 25 Nov 2019 01:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZHZjuct0CLXN3AYcQ+YfYJz+luTtYA/oliVypF8e6hc=; b=Kv+a6C+O8YeU1QaBfhf0j35CEfH/LR23KqQcSQNZ8dEsGWE2Q23YPJVaSt1OOuaLbd 5jBPpWKpaHfKNAEUsyutTc6kHaSoIg23DbBYqQy5weekxhj35gYoDoaifr46Yq7lW5RQ mO1FmglcYhLebSjuvQ6EwuP5ZB4NPus1UBDqlh3NXwcinyYbUY4541wS9uNzZXRax1lz lBxJCiPU1GZ2UM5E7rweB19wEagyR1dGyqpqvWo++g9AjoWy4VNJfxkbhzaFzDXPcaPv FL9wu6KlgjOU68rQLaWeTMflE/baiE/V+KVXwhMxvwy8Us681Uhnj9vpSVntW6kQ82FD c8TQ== 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=ZHZjuct0CLXN3AYcQ+YfYJz+luTtYA/oliVypF8e6hc=; b=mSCOVMaVQ8CSGXBm5/q64bon20umfFRDrVVnev4g6nI3Cv/4L89R3Cp8uUK5eF18l5 48fclK5LjlHxv8VQjoEaTSyk8WHVrIn88EsWpoXqmOcLKHawGHWXrEZZIjT1QLpR5rCc BCrYVEd6CfPvd0iu+R+ozzHYPxUr0CZkTWLQhQaviyiuiHQZP7i6sN08lvN4rMIIG6x+ Whva+2daxe81uzctzUvKSC6yJnpVKUHts0L+ar5/6rOwHq1AAmjW8rOy3/4pWDtbPqM+ zemQc5RTSGodPQ4S+Ez4UxQWcDN0m3RrXosWa8NmJAdF4SjIqvilH7+QZt7Thk2bPdVC Ic1A== X-Gm-Message-State: APjAAAVvpD4ULQTbR1/FNUSys5tPWkQDbkaPiTErYyxNxdLEUlTrnkGg j+2it1YQ0VP/ADomGH3f38sZmQ== X-Google-Smtp-Source: APXvYqxd5dos5A6z8ycGXVe7nHwhuoFOM7ml7F4GD0vhqjvmIeNnVd78WDsUG2ScyfwFJZNDkXJSMg== X-Received: by 2002:a2e:760d:: with SMTP id r13mr20970401ljc.15.1574673453729; Mon, 25 Nov 2019 01:17:33 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id b3sm3238431lfq.10.2019.11.25.01.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2019 01:17:33 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id E895C1032C4; Mon, 25 Nov 2019 12:17:41 +0300 (+03) Date: Mon, 25 Nov 2019 12:17:41 +0300 From: "Kirill A. Shutemov" To: Andreas Gruenbacher Cc: Linus Torvalds , Steven Whitehouse , Konstantin Khlebnikov , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Johannes Weiner , cluster-devel@redhat.com, Ronnie Sahlberg , Steve French , Bob Peterson Subject: Re: [RFC PATCH 0/3] Rework the gfs2 read and page fault locking Message-ID: <20191125091741.firh7stqcpniwvga@box> References: <20191122235324.17245-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191122235324.17245-1-agruenba@redhat.com> User-Agent: NeoMutt/20180716 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 Sat, Nov 23, 2019 at 12:53:21AM +0100, Andreas Gruenbacher wrote: > Hello, > > this patch series moves the glock lock taking in gfs2 from the > ->readpage and ->readpages inode operations to the ->read_iter file and > ->fault vm operations. To achieve that, we add flags to the > generic_file_read_iter and filemap_fault generic helpers. > > This proposal was triggered by the following discussion: > > https://lore.kernel.org/linux-fsdevel/157225677483.3442.4227193290486305330.stgit@buzz/ > > In that thread, Linus argued that filesystems should make sure the inode > size is sufficiently up-to-date before calling the generic helpers, and > that filesystems can do it themselves if they want more than that. > That's surely doable. However, implementing those operations properly > at the filesystem level quickly becomes complicated when it gets to > things like readahead. In addition, those slightly modified copies of > those helpers would surely diverge from their originals over time, and > maintaining them properly would become hard. So I hope the relatively > small changes to make the original helpers slightly more flexible will > be acceptable instead. > > With the IOCB_CACHED flag added by one of the patches in this series, > the code that Konstantin's initial patch adds to > generic_file_buffered_read could be made conditional on the IOCB_CACHED > flag being cleared. That way, it won't misfire on filesystems that > allow a stale inode size. (I'm not sure if any filesystems other than > gfs2 are actually affected.) > > Some additional explanation: > > The cache consistency model of filesystems like gfs2 is such that if > pages are found in an inode's address space, those pages as well as the > inode size are up to date and can be used without taking any filesystem > locks. If a page is not cached, filesystem locks must be taken before > the page can be read; this will also bring the inode size up to date. > > Thus far, gfs2 has taken the filesystem locks inside the ->readpage and > ->readpages address space operations. A better approach seems to be to > take those locks earlier, in the ->read_iter file and ->fault vm > operations. This would also avoid a lock inversion in ->readpages. > > We obviously want to avoid taking the filesystem locks unnecessarily > when the pages we are looking for are already cached; otherwise, we > would cripple performance. So we need to check if those pages are > present first. That's actually exactly what the generic_file_read_iter > and filemap_fault helpers do already anyway, except that they will call > into ->readpage and ->readpages when they find pages missing. Instead > of that, we'd like those helpers to return with an error code that > allows us to retry the operation after taking the filesystem locks. Do you see IOCB_CACHED/FAULT_FLAG_CACHED semantics being usable for anyting beyond gfs2? -- Kirill A. Shutemov