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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 C1D8CC43461 for ; Mon, 26 Apr 2021 21:39:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5139661359 for ; Mon, 26 Apr 2021 21:39:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5139661359 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D49376B0036; Mon, 26 Apr 2021 17:39:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD3486B006E; Mon, 26 Apr 2021 17:39:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B25556B0070; Mon, 26 Apr 2021 17:39:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 8F1346B0036 for ; Mon, 26 Apr 2021 17:39:37 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C3DA46D91 for ; Mon, 26 Apr 2021 21:39:36 +0000 (UTC) X-FDA: 78075835152.26.8B5BB8B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id CB6F86000106 for ; Mon, 26 Apr 2021 21:39:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619473175; 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=NHuvsACEl1CI5awLj29+rd0noL/P2DJNg9HAwjCVAH0=; b=bNTcOfleH5WAfOXLkRVTQORyjbtVJ6fvGa1WpJBraj7SoEZQdcV/63Mbdl7PZtsQlIcnf4 MOisyij8cLKSOuxzVzUz/pe3T2D4buv80ckq1S3KOuJWHO8zkwknvzBKwsSJvYhsi+zQxc ZvsBNlWKjLppkO+r4mmaFjkFloMYIwc= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-204-kj5VnJVEO9qmMGIpw2EQDg-1; Mon, 26 Apr 2021 17:39:34 -0400 X-MC-Unique: kj5VnJVEO9qmMGIpw2EQDg-1 Received: by mail-yb1-f197.google.com with SMTP id 7-20020a5b01070000b02904ed6442e5f6so11856647ybx.23 for ; Mon, 26 Apr 2021 14:39:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NHuvsACEl1CI5awLj29+rd0noL/P2DJNg9HAwjCVAH0=; b=asAj8ysggsiHZoCFxGfWMWfx1dH1IGL569Jzdb/wmCg9ndck5m9O5Pq3Z3Hr833j4V m2h0sXO3oxFc8Xm3GSMytko7Tk/RjLr0QEujRXh+mu1uqJDymEWilrBW1o8vTUWoZYuM EO3Gi1hOYIf7bUgkc/PhVo/Ow9LljZJQQmab1eyllwaFGjIMwfEeO/PqCUbIPONa1QDG FFEGfi6EOu895wp635eiViLowtb4tiGcBa+6VCVP5XNLzHQWXYDw6Cl96N05XPFc8Dn5 zDTxHbaggVaCXd7E505q3gOMqk2eGSEYroJ4C2B58U7oNW2h4LS5jMVAnAlamDVP2fxS poBg== X-Gm-Message-State: AOAM532jc5pA0QkllBDwxxoVJjqoVU+05H3u8jSPoFLMJrFKqy11KJpJ nCv5Y4sEbp7xQ13rmlZQ/qWDdj4bY2BR7F4WqVfSnCs5KCslgAgxSPpQqpXQwDkYC1fZzavOVPk Vd77I4dpbDfZTLsXr7YvoxHkVREw= X-Received: by 2002:a25:570b:: with SMTP id l11mr29088371ybb.335.1619473173579; Mon, 26 Apr 2021 14:39:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/wXyKLI4TMmIO0Z2ws4xZcCt+U06V+2s2ssmR8wS8k2UbBaQ4UBIARhy5tO0ovMMwmoBxnLEWETwJaLxTado= X-Received: by 2002:a25:570b:: with SMTP id l11mr29088337ybb.335.1619473173244; Mon, 26 Apr 2021 14:39:33 -0700 (PDT) MIME-Version: 1.0 References: <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> <161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk> <3545034.1619392490@warthog.procyon.org.uk> In-Reply-To: <3545034.1619392490@warthog.procyon.org.uk> From: David Wysochanski Date: Mon, 26 Apr 2021 17:38:57 -0400 Message-ID: Subject: Re: [PATCH] iov_iter: Four fixes for ITER_XARRAY To: David Howells Cc: Alexander Viro , linux-fsdevel , Marc Dionne , "Matthew Wilcox (Oracle)" , Christoph Hellwig , linux-mm@kvack.org, linux-cachefs , linux-afs@lists.infradead.org, linux-nfs , linux-cifs , ceph-devel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, Trond Myklebust , Anna Schumaker , Steve French , Dominique Martinet , Jeff Layton , Linux Kernel Mailing List Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dwysocha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: ok35fu5fhfq4fyk6krrqfx8ujismm4zk X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CB6F86000106 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619473171-335319 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 Sun, Apr 25, 2021 at 7:15 PM David Howells wrote: > > Hi Al, > > I think this patch should include all the fixes necessary. I could merge > it in, but I think it might be better to tag it on the end as an additional > patch. > > David > --- > iov_iter: Four fixes for ITER_XARRAY > > Fix four things[1] in the patch that adds ITER_XARRAY[2]: > > (1) Remove the address_space struct predeclaration. This is a holdover > from when it was ITER_MAPPING. > > (2) Fix _copy_mc_to_iter() so that the xarray segment updates count and > iov_offset in the iterator before returning. > > (3) Fix iov_iter_alignment() to not loop in the xarray case. Because the > middle pages are all whole pages, only the end pages need be > considered - and this can be reduced to just looking at the start > position in the xarray and the iteration size. > > (4) Fix iov_iter_advance() to limit the size of the advance to no more > than the remaining iteration size. > > Reported-by: Al Viro > Signed-off-by: David Howells > Link: https://lore.kernel.org/r/YIVrJT8GwLI0Wlgx@zeniv-ca.linux.org.uk [1] > Link: https://lore.kernel.org/r/161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk [2] > --- > include/linux/uio.h | 1 - > lib/iov_iter.c | 5 +++++ > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/uio.h b/include/linux/uio.h > index 5f5ffc45d4aa..d3ec87706d75 100644 > --- a/include/linux/uio.h > +++ b/include/linux/uio.h > @@ -10,7 +10,6 @@ > #include > > struct page; > -struct address_space; > struct pipe_inode_info; > > struct kvec { > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index 44fa726a8323..61228a6c69f8 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c > @@ -791,6 +791,8 @@ size_t _copy_mc_to_iter(const void *addr, size_t bytes, struct iov_iter *i) > curr_addr = (unsigned long) from; > bytes = curr_addr - s_addr - rem; > rcu_read_unlock(); > + i->iov_offset += bytes; > + i->count -= bytes; > return bytes; > } > }) > @@ -1147,6 +1149,7 @@ void iov_iter_advance(struct iov_iter *i, size_t size) > return; > } > if (unlikely(iov_iter_is_xarray(i))) { > + size = min(size, i->count); > i->iov_offset += size; > i->count -= size; > return; > @@ -1346,6 +1349,8 @@ unsigned long iov_iter_alignment(const struct iov_iter *i) > return size | i->iov_offset; > return size; > } > + if (unlikely(iov_iter_is_xarray(i))) > + return (i->xarray_start + i->iov_offset) | i->count; > iterate_all_kinds(i, size, v, > (res |= (unsigned long)v.iov_base | v.iov_len, 0), > res |= v.bv_offset | v.bv_len, > You can add Tested-by: Dave Wysochanski I added this patch on top of your v7 series then added my current NFS patches to use netfs lib. I ran xfstests with fscache enabled on NFS versions (3, 4.0, 4.1, 4.2), as well as connectathon and some unit tests.