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=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 8E307C433B4 for ; Mon, 26 Apr 2021 19:24:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BA1A61289 for ; Mon, 26 Apr 2021 19:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240221AbhDZTYn (ORCPT ); Mon, 26 Apr 2021 15:24:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24086 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239934AbhDZTYm (ORCPT ); Mon, 26 Apr 2021 15:24:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619465039; 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=iPescA7+mdsUbYmNeIfUoXCyhDmro2YHWlD7D68Y9NRY0dIi4a1TXT9wm0ys3kb0JNcfEk pYSdtGJ5dBkpmzO5baZ/NQyC4u4z4dXCKoHhRJlp8L/sJjjICMGiDKFRqpYPGZL/vK+j1E fArWddvNPCgBES8OtvfG5Crk+xfMppI= 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-cifs@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