Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5375669rwl; Sun, 8 Jan 2023 14:02:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXumInxE1Iam0UXzi2fD026wHjL/YEliK0ZpeDIs2mynzu8wOpI+FFsS+z3+TsVxSBOL4GAS X-Received: by 2002:a17:907:6d12:b0:7c1:79f5:9545 with SMTP id sa18-20020a1709076d1200b007c179f59545mr76376032ejc.42.1673215336436; Sun, 08 Jan 2023 14:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673215336; cv=none; d=google.com; s=arc-20160816; b=YSVDcXXy56fC6kYdqbVm7qTiQYd+FboIBLhpKL35C2E1FCmnwGU/9q/s6X4bLSmmRt dzS4tlNVqKDogu5dOvVgXEFI3NIdVS5HCjVY8v2j9kRTyCe2TPx4OZz9MDdUipd5BHnn KWjTS1vAz+tmIDUNeBgHcBi79UnhA8qTskNb2bNjfp/bYtFrSceQbUYVORRMOxOh3vlq 3kbO+qJ8Zmi4bohFDF1R11ntv+SsAai1qEJaSfWGN+3/JKFYFDW264/8CPb+4cf7d6qO LheRcNrUSPGndf65YtaGohOVk3P/3/NK20HQO+m5eWot9iYy73e6ubOPE/169+U3JLjl medg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CRwtLPQVjsAJ21UOF2AH7QhDRVRLxvztJgAiY0hGtps=; b=QHbsnmCs2E5S9db4WXSJMBB1VLA6mXXslF5uxeAR19z6ovVaxcJygCz8ImojQPoD5U ZPdubwNOv7XyxLkmDA79tEY2f0Ym+XtIPcSvJDzSPraFw8UbQZO7XJybnFYQdYU6B7Lf MPwOxnzcQ/rEvAw1H6Ym3C2FywJqLsBFE3DPSyjACk9f3rO0DcT1+DuPVSkneke1POmY B7J8kX7xGJXG39739d+UVq4B3UCqa8d5fUMFYnxmAk6HsReRW3ShvWbogKcFFaW95nHI AIJno0JvO52v1R+s8BNpbpuw236u7INSBVldod45m+4Fp4s2FE7H952e1cbFStucJXbW gVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b=DsZ97qPf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g25-20020a170906595900b007c4f6c371b0si6016582ejr.230.2023.01.08.14.01.45; Sun, 08 Jan 2023 14:02:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=@fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b=DsZ97qPf; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbjAHV7c (ORCPT + 99 others); Sun, 8 Jan 2023 16:59:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjAHV7R (ORCPT ); Sun, 8 Jan 2023 16:59:17 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC6B7A477 for ; Sun, 8 Jan 2023 13:59:16 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id d15so7551569pls.6 for ; Sun, 08 Jan 2023 13:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CRwtLPQVjsAJ21UOF2AH7QhDRVRLxvztJgAiY0hGtps=; b=DsZ97qPfn+vhMdmHYEQPR03qcl9I5p3jIShJCNMi//ZMrFVxdOkuAoJXqcs+tB5RSn QcB2rzxaDJsmmMHCrqxeHYghKoFZvvg7wB5mLhGYKV48tedYlwkoEzx1s/m70EOBI2w2 klEp7yZCwCm88twDimFpRT6cC1lu+7jbwr+H0MoQAMbdhgTr3zn/4TglQJI7SViU4JGk 1KCpRBlXvfMm4ES6Pvk1YmnXNDU6K9Sy6JqxdOe3BWz24QSH3ChdaqmtlBtzXkPUiJ2c s3DclSILRi9x57F4Db/3FKDA4w5rvwJooG2wdUG1z3gpMr3HgweiKuBc9blESspj6yTD E6kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CRwtLPQVjsAJ21UOF2AH7QhDRVRLxvztJgAiY0hGtps=; b=v0lg3rc3y2t90LgitI4B6fNM1t/9Jp/Fa9TdB8iFa2fy8R2hyg5Ok3XvDIFMItE4HZ wGDK+qJabh7Fdu+rCuuqlGf9STGobTTLyVttKlQ2Hx53884F88NyFGrriY1d3HdrgVdk chEoOg5sdpvQpU53QwPsOPVV5ee5rtmIZWTVpvREQvEugjtq/kMCgbuVw/9ktKs37PVp wxuL9EwCN/+f1iIaAFBNde8Uabv67/toC/BVUUUwf7AFBSsxn4avVR7r5fd08bWXf7HD 4aNiUGE4laB9wISV4+oD6D/SvNWtepI+LOlXnLXtgABQUM8Ey1C4wVuU79mLU7K6WYTf MTBg== X-Gm-Message-State: AFqh2koNJqRSViyIcZOrxb4j4vddgy2gyq+kEs9c+vLM9IzU9thUjWvw UmQBDZQWzffiCrzw3PIYDXmHCg== X-Received: by 2002:a17:90a:aa92:b0:226:b425:3540 with SMTP id l18-20020a17090aaa9200b00226b4253540mr16679445pjq.36.1673215156237; Sun, 08 Jan 2023 13:59:16 -0800 (PST) Received: from dread.disaster.area (pa49-186-146-207.pa.vic.optusnet.com.au. [49.186.146.207]) by smtp.gmail.com with ESMTPSA id jx12-20020a17090b46cc00b00225a8024b8bsm4127825pjb.55.2023.01.08.13.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 13:59:15 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1pEdh9-000l2I-TM; Mon, 09 Jan 2023 08:59:11 +1100 Date: Mon, 9 Jan 2023 08:59:11 +1100 From: Dave Chinner To: Andreas Gruenbacher Cc: Christoph Hellwig , "Darrick J . Wong" , Alexander Viro , Matthew Wilcox , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, cluster-devel@redhat.com Subject: Re: [RFC v6 08/10] iomap/xfs: Eliminate the iomap_valid handler Message-ID: <20230108215911.GP1971568@dread.disaster.area> References: <20230108194034.1444764-1-agruenba@redhat.com> <20230108194034.1444764-9-agruenba@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230108194034.1444764-9-agruenba@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-ext4@vger.kernel.org On Sun, Jan 08, 2023 at 08:40:32PM +0100, Andreas Gruenbacher wrote: > Eliminate the ->iomap_valid() handler by switching to a ->get_folio() > handler and validating the mapping there. > > Signed-off-by: Andreas Gruenbacher I think this is wrong. The ->iomap_valid() function handles a fundamental architectural issue with cached iomaps: the iomap can become stale at any time whilst it is in use by the iomap core code. The current problem it solves in the iomap_write_begin() path has to do with writeback and memory reclaim races over unwritten extents, but the general case is that we must be able to check the iomap at any point in time to assess it's validity. Indeed, we also have this same "iomap valid check" functionality in the writeback code as cached iomaps can become stale due to racing writeback, truncated, etc. But you wouldn't know it by looking at the iomap writeback code - this is currently hidden by XFS by embedding the checks into the iomap writeback ->map_blocks function. That is, the first thing that xfs_map_blocks() does is check if the cached iomap is valid, and if it is valid it returns immediately and the iomap writeback code uses it without question. The reason that this is embedded like this is that the iomap did not have a validity cookie field in it, and so the validity information was wrapped around the outside of the iomap_writepage_ctx and the filesystem has to decode it from that private wrapping structure. However, the validity information iin the structure wrapper is indentical to the iomap validity cookie, and so the direction I've been working towards is to replace this implicit, hidden cached iomap validity check with an explicit ->iomap_valid call and then only call ->map_blocks if the validity check fails (or is not implemented). I want to use the same code for all the iomap validity checks in all the iomap core code - this is an iomap issue, the conditions where we need to check for iomap validity are different for depending on the iomap context being run, and the checks are not necessarily dependent on first having locked a folio. Yes, the validity cookie needs to be decoded by the filesystem, but that does not dictate where the validity checking needs to be done by the iomap core. Hence I think removing ->iomap_valid is a big step backwards for the iomap core code - the iomap core needs to be able to formally verify the iomap is valid at any point in time, not just at the point in time a folio in the page cache has been locked... -Dave. -- Dave Chinner david@fromorbit.com