Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp3884567pxy; Mon, 26 Apr 2021 12:04:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkexmL/na0j9pLczuSwzFHFWKrcMM+9VuSN4TQlQ4tktK5iNY1mCSgN4/Q0Xdp3cQH1WAo X-Received: by 2002:a17:906:1984:: with SMTP id g4mr19676844ejd.525.1619463883237; Mon, 26 Apr 2021 12:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619463883; cv=none; d=google.com; s=arc-20160816; b=CFL8DbiTkgmqPs+AZkS9gwEnPr2BGYp475zh1vGl8Q8ywJcvjZuBZYKWiwCUhP08M3 6KeGq+QHPUwDVN9Zmw48Hbv0KuzDgh1q1xSnNrl/kElbkbbTtmBsIKpeo9ZuDeIPUTBj fVoCHR6kXEvgKyVQyOcSm9LIuqyk879V7kG6PcfQ7p1ThsyyBi6fTrigROm9f76p6ifq vG+LHNmqMT4pf6fnRHEkRdvYbVykcdIAXyr9wueOQNnj9Q019CCBKhxWdRxwjQhkFT/k jf248tSsPyKE+o6G///3S5tvFJmwcWtIQdLMVnNNviNRzAwseSlXa1S3e9gX2+CTGquB ILgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=ouGZBrLLWit6/ZcOCgBmqDAJzjKl2dpVcZkTyeLSBYo=; b=xvEclIxxilVtiQShGkn/m2fnLw3r3Ypm2U/80F5xgdV6k5O50Ftw0WVO3Cj6ficE9x 4N+s50d0zHGyzSOqcwfbAvCLGGErKivNS/Ch1SNWPLq04R0zNlbFmBK8CyJWMelALZLd C/ibnlkaXmxWpwQLzRgm1CPtCaSxzhVFKbNmMi2s0ME3liznX+zDiFWxBVD+frY7gLZl TvRljOclPR13mDkEn3X0DzoOEbOAScAeJbcHC5x1xPURpyb/UZRSD3rlSMmtQKf08ZZ6 8FjXkZ57735e9PeSYpALOTPOgqqvaL+dMT8seoqC398MhpbkyTz1hcop60qtrWLH7QIS eAhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UaKPBLGl; 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 dn5si572908edb.220.2021.04.26.12.04.14; Mon, 26 Apr 2021 12:04:43 -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=UaKPBLGl; 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 S239906AbhDZTDd (ORCPT + 99 others); Mon, 26 Apr 2021 15:03:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34802 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239866AbhDZTDc (ORCPT ); Mon, 26 Apr 2021 15:03:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619463770; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ouGZBrLLWit6/ZcOCgBmqDAJzjKl2dpVcZkTyeLSBYo=; b=UaKPBLGlulw8usBvnFSBcsomiGesJhBqB0JotOgbxmK35yirHGi4WdOO4osqTshVVIrpM5 Iwv6qs5AulTLVy5p8T+9R1EAUJ8VJT7HAE1vvt1eOBT89aIWzvrCRpu+8WSYf32LySFxzq D7HUBlPvtP7VrOqInkyAAsFg35Gxc3g= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-RpKwdlkHPhagaCEiMLrtug-1; Mon, 26 Apr 2021 15:02:48 -0400 X-MC-Unique: RpKwdlkHPhagaCEiMLrtug-1 Received: by mail-qv1-f70.google.com with SMTP id p2-20020ad452e20000b0290177fba4b9d5so24181069qvu.6 for ; Mon, 26 Apr 2021 12:02:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ouGZBrLLWit6/ZcOCgBmqDAJzjKl2dpVcZkTyeLSBYo=; b=Ibgqz7oLcfgnT4pd9C3F9I5v73Q9qRX7pcSKLRyX7eGyA56ba+1GRe4S2iFxQNMpeZ Qioy5lhayl7urbLUNlQwFkKIH2umJe28shbL5tppPw0UwFvfaUv4UwP+X+wwwZuOcy2W TSZkGug32hbSsEst03IMCfIaY1ymWLShgpnLOLTlrNzmlIuo5py8FZPwLMgiU/A0yngr qxmt3iNAnGfVQCNUVOnLEZ9XWTByVMGrdxb5INAsUvtV72jlboVBpmnqd7Og5bMADZZV 27i/Xb+x2cfjo28j6/POtDx8Fy66DoUfiOv2tMYYzI23gMEzCQ0wUe+AJch+4sColpHo pEXQ== X-Gm-Message-State: AOAM5321b42MZpmgP/4r455VZyJTWgUS8tuIbAYglBdsJo9a8oxvBLqL dzbFSvNjRlr3v5V2J/3NOxcHlg22JBUcTDan1TBffbnB4tH8ifqZY1zq7MtVbACJ+iSo6XAeSFZ XqRZG4r7Wz8+vqYYed1TV X-Received: by 2002:a05:6214:12ab:: with SMTP id w11mr2594686qvu.14.1619463768332; Mon, 26 Apr 2021 12:02:48 -0700 (PDT) X-Received: by 2002:a05:6214:12ab:: with SMTP id w11mr2594656qvu.14.1619463768135; Mon, 26 Apr 2021 12:02:48 -0700 (PDT) Received: from [192.168.1.180] (68-20-15-154.lightspeed.rlghnc.sbcglobal.net. [68.20.15.154]) by smtp.gmail.com with ESMTPSA id c17sm11477744qtd.71.2021.04.26.12.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Apr 2021 12:02:47 -0700 (PDT) Message-ID: <9e5744b2b647a8ff9cdea6efb58c39adde48f7f0.camel@redhat.com> Subject: Re: [PATCH] iov_iter: Four fixes for ITER_XARRAY From: Jeff Layton To: David Howells , Alexander Viro Cc: 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 , linux-kernel@vger.kernel.org Date: Mon, 26 Apr 2021 15:02:46 -0400 In-Reply-To: <3545034.1619392490@warthog.procyon.org.uk> References: <161918448151.3145707.11541538916600921083.stgit@warthog.procyon.org.uk> <161918446704.3145707.14418606303992174310.stgit@warthog.procyon.org.uk> <3545034.1619392490@warthog.procyon.org.uk> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.0 (3.40.0-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, 2021-04-26 at 00:14 +0100, 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, > I did a test run with your v7 pile, this patch, and my ceph fscache rework patches and it did fine. You can add: Tested-by: Jeff Layton