Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3900203pxy; Mon, 26 Apr 2021 12:29:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDHKb4O7lchN3OSpMe5qnw4R4dhE0TfVH7KilEqwn7oa6z/Sy4QouJtvlV15SC/j920c6x X-Received: by 2002:a17:90a:690b:: with SMTP id r11mr13823904pjj.140.1619465397706; Mon, 26 Apr 2021 12:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619465397; cv=none; d=google.com; s=arc-20160816; b=1DlkB1FBN4Y8Q6c8MubXUMF03STtMvQFIEh+hYIbyt6E4SkMD+jFFWHU3ySQ1n/mst OV0cqxLQY7gAwtYAa4OsoVWV801rcLSpPG+ps6/sAa0ijB4Bb08E5cgvODPNGexWMD6E 6f/EygtyshcMoA4luYpy7EQsZ25+4f287PUFuXxnFQr3S5O5CdGurkRBCNpCGWAQkDp/ po+yhLmETrjXTH1y5k9AwrANTq67l2KGyG4bXcHVK+2kurNkAxTD1Z+OA93TJMfEwS5c xZNNsNJ8g473+w6UIflpFmN94jkJgYMltgoL6C+nT9NLtcKz/sBCrKed2LIrT76YNmIf P1kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=4SqDWTwGLz0yG83bRGbUR1MGHDhF5H6AJtqMldOHVmY=; b=Pd0djclpm/7QZswc+ZiDXvPi/XzppMsZtt17ARLB1vVxjIDctdHAI50soUa+f17UqW onzSW+VZWi9zrWLhSELsTqpdWtFao/KlTaWGqlkzbamEAJb5C+qwQ3LuEEec9EHM1Z/R xrgmTJ0PMvdwqE6qhMMLnmPrGhej1KaiGa61vx2raANZWlictBkGknP6oEEJpRgFTQfL byDyPHMi+cidtCt2FZUhK/I9Ne7wWW0A2nyLFVUCU5284s5rOT7g4wJD15bUVPOMW700 bXCelmUhyzHr6kzR4drQXDQWIIx8oqbnuyJ08ZJPGq03RNCedM3BN5sI1cpsjNi2ZO2v 0HMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LIPJxIL6; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si6241122plf.302.2021.04.26.12.29.41; Mon, 26 Apr 2021 12:29:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LIPJxIL6; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239038AbhDZTYj (ORCPT + 99 others); Mon, 26 Apr 2021 15:24:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38786 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238746AbhDZTYi (ORCPT ); Mon, 26 Apr 2021 15:24:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619465036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4SqDWTwGLz0yG83bRGbUR1MGHDhF5H6AJtqMldOHVmY=; b=LIPJxIL6mPG49c8UviGhh5RGcznz8kPm7uGS0QQKM3iVSEe5+RemkEwthRkmPBgps2wJ5u LId7j4lsf5PNr8QQZ5H9u8XC83MAOh0fv+Iyp8ovtYql34uGNGlMDET4ZDY7gjGVdPhC6b bZ8jOJR7CSm6S1TTHuYSoaieHUCcGa8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-BAwWcPM1PsiTJg_KTP0EFA-1; Mon, 26 Apr 2021 15:23:54 -0400 X-MC-Unique: BAwWcPM1PsiTJg_KTP0EFA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBE0418A08DD; Mon, 26 Apr 2021 19:23:52 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-124.rdu2.redhat.com [10.10.112.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 363631A353; Mon, 26 Apr 2021 19:23:32 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> <161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk> To: Al Viro Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org, Dave Wysochanski , Marc Dionne , "Matthew Wilcox (Oracle)" , Christoph Hellwig , linux-mm@kvack.org, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 01/31] iov_iter: Add ITER_XARRAY MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3651950.1619465011.1@warthog.procyon.org.uk> Date: Mon, 26 Apr 2021 20:23:31 +0100 Message-ID: <3651951.1619465011@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Al Viro wrote: > On Fri, Apr 23, 2021 at 02:28:01PM +0100, David Howells wrote: > > -#define iterate_all_kinds(i, n, v, I, B, K) { \ > > +#define iterate_xarray(i, n, __v, skip, STEP) { \ > > + struct page *head = NULL; \ > > + size_t wanted = n, seg, offset; \ > > + loff_t start = i->xarray_start + skip; \ > > + pgoff_t index = start >> PAGE_SHIFT; \ > > + int j; \ > > + \ > > + XA_STATE(xas, i->xarray, index); \ > > + \ > > + rcu_read_lock(); \ > > + xas_for_each(&xas, head, ULONG_MAX) { \ > > + if (xas_retry(&xas, head)) \ > > + continue; \ > > OK, now I'm really confused; what's to guarantee that restart will not have > you hit the same entry more than once? STEP might be e.g. > > memcpy_to_page(v.bv_page, v.bv_offset, > (from += v.bv_len) - v.bv_len, v.bv_len) > > which is clearly not idempotent - from gets incremented, after all. > What am I missing here? I really need to defer this question to Willy, but as I understand it, xas_retry() only restarts the current iteration. Referring to the comment on xas_reset(): * Resets the error or walk state of the @xas so future walks of the * array will start from the root. Use this if you have dropped the * xarray lock and want to reuse the xa_state. I think that the walk returns to the bottom of the tree and whilst xarray presents an interface that appears to be a contiguous array, it's actually a tree internally - and 'root' is the root of the tree, not the head of the array. Basically, I think it throws away its cached iteration state - which might have been modified - and rewalks the tree to get back to the same index. David