Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5665091pxv; Wed, 21 Jul 2021 10:44:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDU3QsdzYOXNqiQTvBdVRbbgxdI+s6kZ7JEoMGO9tANonphB7UkhBSGd8ob/xDoyjkA4sE X-Received: by 2002:a92:d8d2:: with SMTP id l18mr25009146ilo.165.1626889481364; Wed, 21 Jul 2021 10:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626889481; cv=none; d=google.com; s=arc-20160816; b=MYOFeW3Xp85HixKQyFmNEzGZnqlPTOviD5OA36HjdZ6ExACl/fjstv4OuDPIDOqgz5 725B/ppYA0J5EBe6FMiAzYndwMgyRoq6FEyvij4P5wq2OAbAb91J8Ph1Nhp99A6vd+a3 MNOZkv4GCNwlROacRmmm207k+Ok2k/reX8Uk6QHLlGoDs71yO9WXD0q+fqQY9Rd7PAPA N31sIP7kwcGrKNm0uUJrfcMoyygYyUESE9BRns+DfBQTMm4jnIvE+jg9emlUYWKpGxgq crRccjrBUC2S7zHt0BNcb5vStdeIslmK918zSh8bJX5u6MWExX0mLUkfxYZcIxHVzKzg YF9A== 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=3dOn7+nrEQrDF2IcT4kr/9MG9FoA4OKzs2zFSvE50Nw=; b=CCyUcvUOjO5QjV6elMw+ER4egRGaTQl4jdYzFR2UR3VMHMDWuBypf6OA2H67ScNlqj lRFnbeAD3mXptJChS8KTwx1D6zvpDzI2eyN9Fd3AMBkRBXQR2/IWDfWZLIMAG2Y9cnV4 e0aN9ubYsqwGSz7GmfPpsgFuEufwqQnv8GEKYbbwpS1f9BY2hiyUx+mgjMlI+Fjt4kg2 FDrwSZxcw5AfA4sqJzWo5mWj53OpbU4lykoiCucj9qp5ydVvAS9BStsavgvhRN0+UYB4 nnV8izOMgsKncXCWCfNysSSDNZjulEwjePsyEVlgfuo266ybGcaeBWyjbdlt0bt3jlTw 0y7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TzH38iu4; 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 d7si18743648iop.31.2021.07.21.10.44.20; Wed, 21 Jul 2021 10:44:41 -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=TzH38iu4; 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 S229973AbhGURDP (ORCPT + 99 others); Wed, 21 Jul 2021 13:03:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43401 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229959AbhGURDO (ORCPT ); Wed, 21 Jul 2021 13:03:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626889430; 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=3dOn7+nrEQrDF2IcT4kr/9MG9FoA4OKzs2zFSvE50Nw=; b=TzH38iu4sbKjMeSzIj4A9hkBCxoOWBslcRg9QjkKIzPbXnlYxN131oqdv1/qQTw66TXhtR lkccyP9TpFdWluBEwEpqWirqyCohCNUlYVm5kpKh4woyj/ZKYEjofNVkIAS8HBWN7+kjZS DqKMAeF/ptjBkBU1qD4DrvfcCWRqMNg= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-p7qijrImNBa85wIjpkJofA-1; Wed, 21 Jul 2021 13:43:49 -0400 X-MC-Unique: p7qijrImNBa85wIjpkJofA-1 Received: by mail-qt1-f199.google.com with SMTP id t6-20020ac80dc60000b029024e988e8277so1945357qti.23 for ; Wed, 21 Jul 2021 10:43: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=3dOn7+nrEQrDF2IcT4kr/9MG9FoA4OKzs2zFSvE50Nw=; b=kULOwF1f5zgfnT3JDN6wKH1LtzzGJF0nSkVu1bkRcxgFrwGuLuh6PTvvk3r87apEk4 b3k/FLC9KoPe3EmdHtwKNJffYHFCWa0LIkUR7Xb5A0vZX9e/BbGClw76gdbC/PEhjD3v 6VzFXtuQ8R0A+Ftm6zRpqG1L61YFk+ZGfbQHN6Qjj8C0syhmrFCtBycnJLuptWaXF5dn T7lC9gt5y0HiHEl+P9JRzy9AxDN5T5+mUmImmufCpZ4YSb2lsqIf6uq+fXscljBOi4WH wKzmtQpmbbdiN8etpqRJpqfxhf5YO51IdD2sfyNG536v+vsPkXXfbBgO+C6AN40uyUlj dzrg== X-Gm-Message-State: AOAM531uREUaft3J8RmckZaqRTlpiwPc2ZHf+2J0lEINNnESp3UA0Fo4 zAADANR0LmhfsOt5FMjcc0PZWm5XGs3Ja69PgaWcZnalbgAwwhTZ7eVPuVzbrKhaT9ZEgrZu/Dz luFKQ9iGhHCt1HZisjQ67 X-Received: by 2002:a05:622a:1653:: with SMTP id y19mr18163560qtj.305.1626889428563; Wed, 21 Jul 2021 10:43:48 -0700 (PDT) X-Received: by 2002:a05:622a:1653:: with SMTP id y19mr18163539qtj.305.1626889428351; Wed, 21 Jul 2021 10:43:48 -0700 (PDT) Received: from [192.168.1.3] (68-20-15-154.lightspeed.rlghnc.sbcglobal.net. [68.20.15.154]) by smtp.gmail.com with ESMTPSA id r16sm11484664qke.73.2021.07.21.10.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 10:43:47 -0700 (PDT) Message-ID: Subject: Re: [RFC PATCH 03/12] netfs: Remove netfs_read_subrequest::transferred From: Jeff Layton To: David Howells , linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , Anna Schumaker , Steve French , Dominique Martinet , Mike Marshall , David Wysochanski , Shyam Prasad N , Miklos Szeredi , Linus Torvalds , 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, devel@lists.orangefs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 21 Jul 2021 13:43:47 -0400 In-Reply-To: <162687511125.276387.15493860267582539643.stgit@warthog.procyon.org.uk> References: <162687506932.276387.14456718890524355509.stgit@warthog.procyon.org.uk> <162687511125.276387.15493860267582539643.stgit@warthog.procyon.org.uk> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.40.3 (3.40.3-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, 2021-07-21 at 14:45 +0100, David Howells wrote: > Remove netfs_read_subrequest::transferred as it's redundant as the count on > the iterator added to the subrequest can be used instead. > > Signed-off-by: David Howells > --- > > fs/afs/file.c | 4 ++-- > fs/netfs/read_helper.c | 26 ++++---------------------- > include/linux/netfs.h | 1 - > include/trace/events/netfs.h | 12 ++++++------ > 4 files changed, 12 insertions(+), 31 deletions(-) > > diff --git a/fs/afs/file.c b/fs/afs/file.c > index ca529f23515a..82e945dbe379 100644 > --- a/fs/afs/file.c > +++ b/fs/afs/file.c > @@ -315,8 +315,8 @@ static void afs_req_issue_op(struct netfs_read_subrequest *subreq) > return netfs_subreq_terminated(subreq, -ENOMEM, false); > > fsreq->subreq = subreq; > - fsreq->pos = subreq->start + subreq->transferred; > - fsreq->len = subreq->len - subreq->transferred; > + fsreq->pos = subreq->start + subreq->len - iov_iter_count(&subreq->iter); > + fsreq->len = iov_iter_count(&subreq->iter); > fsreq->key = subreq->rreq->netfs_priv; > fsreq->vnode = vnode; > fsreq->iter = &subreq->iter; > diff --git a/fs/netfs/read_helper.c b/fs/netfs/read_helper.c > index 715f3e9c380d..5e1a9be48130 100644 > --- a/fs/netfs/read_helper.c > +++ b/fs/netfs/read_helper.c > @@ -148,12 +148,7 @@ static void __netfs_put_subrequest(struct netfs_read_subrequest *subreq, > */ > static void netfs_clear_unread(struct netfs_read_subrequest *subreq) > { > - struct iov_iter iter; > - > - iov_iter_xarray(&iter, READ, &subreq->rreq->mapping->i_pages, > - subreq->start + subreq->transferred, > - subreq->len - subreq->transferred); > - iov_iter_zero(iov_iter_count(&iter), &iter); > + iov_iter_zero(iov_iter_count(&subreq->iter), &subreq->iter); > } > > static void netfs_cache_read_terminated(void *priv, ssize_t transferred_or_error, > @@ -173,14 +168,9 @@ static void netfs_read_from_cache(struct netfs_read_request *rreq, > bool seek_data) > { > struct netfs_cache_resources *cres = &rreq->cache_resources; > - struct iov_iter iter; > > netfs_stat(&netfs_n_rh_read); > - iov_iter_xarray(&iter, READ, &rreq->mapping->i_pages, > - subreq->start + subreq->transferred, > - subreq->len - subreq->transferred); > - > - cres->ops->read(cres, subreq->start, &iter, seek_data, > + cres->ops->read(cres, subreq->start, &subreq->iter, seek_data, > netfs_cache_read_terminated, subreq); > } > The above two deltas seem like they should have been in patch #2. > @@ -419,7 +409,7 @@ static void netfs_rreq_unlock(struct netfs_read_request *rreq) > if (pgend < iopos + subreq->len) > break; > > - account += subreq->transferred; > + account += subreq->len - iov_iter_count(&subreq->iter); > iopos += subreq->len; > if (!list_is_last(&subreq->rreq_link, &rreq->subrequests)) { > subreq = list_next_entry(subreq, rreq_link); > @@ -635,15 +625,8 @@ void netfs_subreq_terminated(struct netfs_read_subrequest *subreq, > goto failed; > } > > - if (WARN(transferred_or_error > subreq->len - subreq->transferred, > - "Subreq overread: R%x[%x] %zd > %zu - %zu", > - rreq->debug_id, subreq->debug_index, > - transferred_or_error, subreq->len, subreq->transferred)) > - transferred_or_error = subreq->len - subreq->transferred; > - > subreq->error = 0; > - subreq->transferred += transferred_or_error; > - if (subreq->transferred < subreq->len) > + if (iov_iter_count(&subreq->iter)) > goto incomplete; > I must be missing it, but where does subreq->iter get advanced to the end of the current read? If you're getting rid of subreq->transferred then I think that has to happen above, no? > complete: > @@ -667,7 +650,6 @@ void netfs_subreq_terminated(struct netfs_read_subrequest *subreq, > incomplete: > if (test_bit(NETFS_SREQ_CLEAR_TAIL, &subreq->flags)) { > netfs_clear_unread(subreq); > - subreq->transferred = subreq->len; > goto complete; > } > > diff --git a/include/linux/netfs.h b/include/linux/netfs.h > index 5e4fafcc9480..45d40c622205 100644 > --- a/include/linux/netfs.h > +++ b/include/linux/netfs.h > @@ -116,7 +116,6 @@ struct netfs_read_subrequest { > struct iov_iter iter; /* Iterator for this subrequest */ > loff_t start; /* Where to start the I/O */ > size_t len; /* Size of the I/O */ > - size_t transferred; /* Amount of data transferred */ > refcount_t usage; > short error; /* 0 or error that occurred */ > unsigned short debug_index; /* Index in list (for debugging output) */ > diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h > index 4d470bffd9f1..04ac29fc700f 100644 > --- a/include/trace/events/netfs.h > +++ b/include/trace/events/netfs.h > @@ -190,7 +190,7 @@ TRACE_EVENT(netfs_sreq, > __field(enum netfs_read_source, source ) > __field(enum netfs_sreq_trace, what ) > __field(size_t, len ) > - __field(size_t, transferred ) > + __field(size_t, remain ) > __field(loff_t, start ) > ), > > @@ -202,7 +202,7 @@ TRACE_EVENT(netfs_sreq, > __entry->source = sreq->source; > __entry->what = what; > __entry->len = sreq->len; > - __entry->transferred = sreq->transferred; > + __entry->remain = iov_iter_count(&sreq->iter); > __entry->start = sreq->start; > ), > > @@ -211,7 +211,7 @@ TRACE_EVENT(netfs_sreq, > __print_symbolic(__entry->what, netfs_sreq_traces), > __print_symbolic(__entry->source, netfs_sreq_sources), > __entry->flags, > - __entry->start, __entry->transferred, __entry->len, > + __entry->start, __entry->len - __entry->remain, __entry->len, > __entry->error) > ); > > @@ -230,7 +230,7 @@ TRACE_EVENT(netfs_failure, > __field(enum netfs_read_source, source ) > __field(enum netfs_failure, what ) > __field(size_t, len ) > - __field(size_t, transferred ) > + __field(size_t, remain ) > __field(loff_t, start ) > ), > > @@ -242,7 +242,7 @@ TRACE_EVENT(netfs_failure, > __entry->source = sreq ? sreq->source : NETFS_INVALID_READ; > __entry->what = what; > __entry->len = sreq ? sreq->len : 0; > - __entry->transferred = sreq ? sreq->transferred : 0; > + __entry->remain = sreq ? iov_iter_count(&sreq->iter) : 0; > __entry->start = sreq ? sreq->start : 0; > ), > > @@ -250,7 +250,7 @@ TRACE_EVENT(netfs_failure, > __entry->rreq, __entry->index, > __print_symbolic(__entry->source, netfs_sreq_sources), > __entry->flags, > - __entry->start, __entry->transferred, __entry->len, > + __entry->start, __entry->len - __entry->remain, __entry->len, > __print_symbolic(__entry->what, netfs_failures), > __entry->error) > ); > > -- Jeff Layton