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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51B8CC4332F for ; Wed, 16 Nov 2022 00:11:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF55B6B0071; Tue, 15 Nov 2022 19:10:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BA5226B0072; Tue, 15 Nov 2022 19:10:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6D4A6B0073; Tue, 15 Nov 2022 19:10:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 979076B0071 for ; Tue, 15 Nov 2022 19:10:59 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 709B240CD7 for ; Wed, 16 Nov 2022 00:10:59 +0000 (UTC) X-FDA: 80137375038.28.D6D826F Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by imf04.hostedemail.com (Postfix) with ESMTP id 09C6240009 for ; Wed, 16 Nov 2022 00:10:58 +0000 (UTC) Received: by mail-pl1-f182.google.com with SMTP id io19so14908821plb.8 for ; Tue, 15 Nov 2022 16:10:58 -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=rD/RoHfyEVT+SdG0X/B7iu3/BEAtoC054FO09SaHPUM=; b=J9/xSM0XEioLbGpgDvTlTfAO+wvEzOuT9B+ffrzh4yOeJmd6IO5uNeubjHHgcpzMQn L7GHJe1a7x4fVqfUaShD3u0+cNXAiCaVBkQElLwO14bM0F6tC4SBdbdvnWDU/3+HfuSS srt7KHvhAMwkamFH4Q1YqkX8UgR3iaOLp/hwO7brMr/B1bV0YxCpoOircPWHc7HhhIKB WXYC0Hz/iWNYJfYtxxMk6TI6F/7LXAv4O/3p+c+einOmPAUrAdUufroV52acch40cczv DQAaH6AAeEFalflQQC53fC3CYbVX0FoAeCIAUO/kRXm436L1Z4hjby/RN8Wuig9fy/G5 VtWQ== 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=rD/RoHfyEVT+SdG0X/B7iu3/BEAtoC054FO09SaHPUM=; b=XgniCN5XdbK/vAARXR+FoUNVeQW1orgUaGEHRiEHRdjV/XYXU8U2V1VPLchEK/l/Vr Vofaz6oq9Xba335v0Sy6H8R84i6CfLSWv49j5jzz/OP7Xma2QAB0nW3P8HBko0m6/Q7D n/6D7juzJAlYSUedl0DTNFh59CCpVgGtZd5muWiGadPLyfurCdQEmuZSaWb0o8wf0HEz CPCN0ws8+KVu6crMeOwL2zrNZC96OA6QNA8Ixbd9acAtjPAZSMOcinsYNVzVlmdHHA3J XkgzetKDBdTIMKZtUGxKkjofYU/w35y8DFeZI4ikXnb/Plvi0rlZjcJ9sDwuUXOzChLo 4x+Q== X-Gm-Message-State: ANoB5pnPsN4DNklyvNrMbYKTTxZWIKcdmtzET18h5CharWVpqDmZqvR6 X99kT1DXK+XVAcMUtJyOLcrQzQ== X-Google-Smtp-Source: AA0mqf73DdXQXS2w87TsSXf0A7sXLMiMFeStSpJUGScVZwiTAEWFsHzhK74pTokSwLZAOOFCNSZp3g== X-Received: by 2002:a17:902:c3ca:b0:17f:b05:bbc4 with SMTP id j10-20020a170902c3ca00b0017f0b05bbc4mr6318913plj.41.1668557457951; Tue, 15 Nov 2022 16:10:57 -0800 (PST) Received: from dread.disaster.area (pa49-181-106-210.pa.nsw.optusnet.com.au. [49.181.106.210]) by smtp.gmail.com with ESMTPSA id g75-20020a62524e000000b0056164b52bd8sm9417299pfb.32.2022.11.15.16.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 16:10:57 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1ov60z-00EhIc-W4; Wed, 16 Nov 2022 11:10:54 +1100 Date: Wed, 16 Nov 2022 11:10:53 +1100 From: Dave Chinner To: Christoph Hellwig Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 8/9] xfs: use iomap_valid method to detect stale cached iomaps Message-ID: <20221116001053.GZ3600936@dread.disaster.area> References: <20221115013043.360610-1-david@fromorbit.com> <20221115013043.360610-9-david@fromorbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668557459; a=rsa-sha256; cv=none; b=32ja5s9ZM05uz5v/8m0SGaGfm5cr2AMbe2XlhFFqeIzDhjxjoGJbDdrUoU6B+rTrbQv/O9 GauHNnAcJnTCv065miuZT5L5NI+btKrLxjLuBALIFk8QRTADM2fx377ZDbgXlWAHAnp+r9 vYsj/8OYJysncFwQ5aKm6aFC9ilZlWw= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b="J9/xSM0X"; spf=none (imf04.hostedemail.com: domain of david@fromorbit.com has no SPF policy when checking 209.85.214.182) smtp.mailfrom=david@fromorbit.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668557459; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rD/RoHfyEVT+SdG0X/B7iu3/BEAtoC054FO09SaHPUM=; b=Yw/3X7WD+gRnqLhPUAgWeJGziulVtFZgp5EfSMSH5gazzE+YzA2Sh1mfRjBDxc/NIySIT9 /woOYIl6XM96BFD4LjdqjdfMqkIcGEGG/q8P66IJnpgyXRV5XSMsueQMebUViOZKYoyn5x R3bY7a3/dXQPrNm1fX/2HBmhM+5f4RE= X-Stat-Signature: rjzh89eouufwjd7uufxwr89b6x8jxurj X-Rspamd-Queue-Id: 09C6240009 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=fromorbit-com.20210112.gappssmtp.com header.s=20210112 header.b="J9/xSM0X"; spf=none (imf04.hostedemail.com: domain of david@fromorbit.com has no SPF policy when checking 209.85.214.182) smtp.mailfrom=david@fromorbit.com; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1668557458-944349 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 Tue, Nov 15, 2022 at 12:49:49AM -0800, Christoph Hellwig wrote: > On Tue, Nov 15, 2022 at 12:30:42PM +1100, Dave Chinner wrote: > > +/* > > + * Check that the iomap passed to us is still valid for the given offset and > > + * length. > > + */ > > +static bool > > +xfs_iomap_valid( > > + struct inode *inode, > > + const struct iomap *iomap) > > +{ > > + struct xfs_inode *ip = XFS_I(inode); > > + u64 cookie = 0; > > + > > + if (iomap->flags & IOMAP_F_XATTR) { > > + cookie = READ_ONCE(ip->i_af.if_seq); > > + } else { > > + if ((iomap->flags & IOMAP_F_SHARED) && ip->i_cowfp) > > + cookie = (u64)READ_ONCE(ip->i_cowfp->if_seq) << 32; > > + cookie |= READ_ONCE(ip->i_df.if_seq); > > + } > > + return cookie == iomap->validity_cookie; > > How can this be called with IOMAP_F_XATTR set? It can't be. *Yet*. However: ->iomap_begin can be called to map an attribute fork, and ->iomap_valid *could* be called on the attr iomap that is returned. At which point, the iomap needs to be self-describing and the validation cookie needs to hold the attr fork sequence number for everything to work. Failing to handle/validate attr iomaps correctly would clearly be an XFS implementation bug and making it work correctly is trivial and costs nothing. Hence making it work is a no-brainer - leaving it as a landmine for someone else to trip over in future is a poor outcome for everyone. > Also the code seems to duplicate xfs_iomap_inode_sequence, so > we just call that: > > return cookie == xfs_iomap_inode_sequence(XFS_I(inode), iomap->flags); Yup, will fix. -Dave. -- Dave Chinner david@fromorbit.com