From patchwork Tue Sep 14 14:17:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12493609 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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 8BC62C4332F for ; Tue, 14 Sep 2021 14:18:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F4CD6108B for ; Tue, 14 Sep 2021 14:18:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbhINOTj (ORCPT ); Tue, 14 Sep 2021 10:19:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233534AbhINOTN (ORCPT ); Tue, 14 Sep 2021 10:19:13 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD1FC061764 for ; Tue, 14 Sep 2021 07:17:56 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id g9so17249546ioq.11 for ; Tue, 14 Sep 2021 07:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z7c8syQSjn5yBCKSSFtxNAKMp+iDYztMNgRmqIUn/y4=; b=ot4kB+Ih3QhytiaAfiLfEBF0Igh+Z2lvHWRkckVTvNJwEqmcJ/J1Vu9OAEa44SAd+J 7+HPo2kLRSDdZFK97efrKeLZ9ucPXeCut16oOePaS5gtMCeBNmi+LZIVpBy8srXdin2u 1p1vemZiAsGj4p9qBMCwYUYecc5m1fbXhBd9JmL8SGyyGaI0kOjFTEWxIjKyjb588yn/ j9bQW78HkWFbcvcTAOSt8gSwoqb5G/bJng3dqqYDCvfaR6nq1sOTtlfXH0MWfjm+U6xf S9BBNadbk/bELyDBwb6R287yv+jEm7xkk3R1V7duDv+yzi9t2/Evv4DBhvZTQh/aLRsr Gbuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z7c8syQSjn5yBCKSSFtxNAKMp+iDYztMNgRmqIUn/y4=; b=3XI4/b7BKJTK+wm1bEVxLChS/2pAVJkL5zweaWDN+2hDa0l/BEGxEObCUIRG2vqy3d 4CzQEAb2QIY+VynDJsvWyvJ8ruxEhPs2WfaaxApNEgFieX7geh4Q47XBFyNQ54xWWfIM 7PATATEBeVpp2kTHUIoQI9a9N6RZqQtpi1qwkHzebPV/TYPqKxevhpnwOoRuGVFbfgvf v1Kt2YS1OB2ntkPkCa8k+aNdk0gJ7u+kvNJN7WaKj3o3ezL3ocoJHeBHOAUSc1yNW0Mx OaxppCQJDeTIZvaT9jMDH5fk0zz+wZVHp8hdODGsC5st6BC9/mThosUJksMoNl2oP52r GJdw== X-Gm-Message-State: AOAM531RjV6PULe/UZz9N4MaJvy6MANI2UJOtpL+RoJOMiLeDEGKEOC/ lgk8UuAdazioJGJNBGRT2EozGA== X-Google-Smtp-Source: ABdhPJwHJDdCWKE4tIBEqkfAhQtAcMRw/R/WoKebKZMWNAPpX4dOsCBr92Sms5Kzb0IRQ9Y2wbj9RA== X-Received: by 2002:a6b:5c17:: with SMTP id z23mr13746798ioh.3.1631629075962; Tue, 14 Sep 2021 07:17:55 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id p135sm6673803iod.26.2021.09.14.07.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 07:17:55 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, Jens Axboe Subject: [PATCH 1/3] iov_iter: add helper to save iov_iter state Date: Tue, 14 Sep 2021 08:17:48 -0600 Message-Id: <20210914141750.261568-2-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210914141750.261568-1-axboe@kernel.dk> References: <20210914141750.261568-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In an ideal world, when someone is passed an iov_iter and returns X bytes, then X bytes would have been consumed/advanced from the iov_iter. But we have use cases that always consume the entire iterator, a few examples of that are iomap and bdev O_DIRECT. This means we cannot rely on the state of the iov_iter once we've called ->read_iter() or ->write_iter(). This would be easier if we didn't always have to deal with truncate of the iov_iter, as rewinding would be trivial without that. We recently added a commit to track the truncate state, but that grew the iov_iter by 8 bytes and wasn't the best solution. Implement a helper to save enough of the iov_iter state to sanely restore it after we've called the read/write iterator helpers. This currently only works for IOVEC/BVEC/KVEC as that's all we need, support for other iterator types are left as an exercise for the reader. Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wiacKV4Gh-MYjteU0LwNBSGpWrK-Ov25HdqB1ewinrFPg@mail.gmail.com/ Signed-off-by: Jens Axboe --- include/linux/uio.h | 15 +++++++++++++++ lib/iov_iter.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/linux/uio.h b/include/linux/uio.h index 5265024e8b90..984c4ab74859 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -27,6 +27,12 @@ enum iter_type { ITER_DISCARD, }; +struct iov_iter_state { + size_t iov_offset; + size_t count; + unsigned long nr_segs; +}; + struct iov_iter { u8 iter_type; bool data_source; @@ -55,6 +61,14 @@ static inline enum iter_type iov_iter_type(const struct iov_iter *i) return i->iter_type; } +static inline void iov_iter_save_state(struct iov_iter *iter, + struct iov_iter_state *state) +{ + state->iov_offset = iter->iov_offset; + state->count = iter->count; + state->nr_segs = iter->nr_segs; +} + static inline bool iter_is_iovec(const struct iov_iter *i) { return iov_iter_type(i) == ITER_IOVEC; @@ -233,6 +247,7 @@ ssize_t iov_iter_get_pages(struct iov_iter *i, struct page **pages, ssize_t iov_iter_get_pages_alloc(struct iov_iter *i, struct page ***pages, size_t maxsize, size_t *start); int iov_iter_npages(const struct iov_iter *i, int maxpages); +void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state); const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index f2d50d69a6c3..755c10c5138c 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1972,3 +1972,39 @@ int import_single_range(int rw, void __user *buf, size_t len, return 0; } EXPORT_SYMBOL(import_single_range); + +/** + * iov_iter_restore() - Restore a &struct iov_iter to the same state as when + * iov_iter_save_state() was called. + * + * @i: &struct iov_iter to restore + * @state: state to restore from + * + * Used after iov_iter_save_state() to bring restore @i, if operations may + * have advanced it. + * + * Note: only works on ITER_IOVEC, ITER_BVEC, and ITER_KVEC + */ +void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state) +{ + if (WARN_ON_ONCE(!iov_iter_is_bvec(i) && !iter_is_iovec(i)) && + !iov_iter_is_kvec(i)) + return; + i->iov_offset = state->iov_offset; + i->count = state->count; + /* + * For the *vec iters, nr_segs + iov is constant - if we increment + * the vec, then we also decrement the nr_segs count. Hence we don't + * need to track both of these, just one is enough and we can deduct + * the other from that. ITER_KVEC and ITER_IOVEC are the same struct + * size, so we can just increment the iov pointer as they are unionzed. + * ITER_BVEC _may_ be the same size on some archs, but on others it is + * not. Be safe and handle it separately. + */ + BUILD_BUG_ON(sizeof(struct iovec) != sizeof(struct kvec)); + if (iov_iter_is_bvec(i)) + i->bvec -= state->nr_segs - i->nr_segs; + else + i->iov -= state->nr_segs - i->nr_segs; + i->nr_segs = state->nr_segs; +} From patchwork Tue Sep 14 14:17:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12493611 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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 CC47DC433EF for ; Tue, 14 Sep 2021 14:18:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B64FB6109E for ; Tue, 14 Sep 2021 14:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233594AbhINOTl (ORCPT ); Tue, 14 Sep 2021 10:19:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbhINOTR (ORCPT ); Tue, 14 Sep 2021 10:19:17 -0400 Received: from mail-il1-x133.google.com (mail-il1-x133.google.com [IPv6:2607:f8b0:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0F2DC061768 for ; Tue, 14 Sep 2021 07:17:57 -0700 (PDT) Received: by mail-il1-x133.google.com with SMTP id h29so14170294ila.2 for ; Tue, 14 Sep 2021 07:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QAR123urz57PkLjJI7L4tM4W+19Um5s2CkATxO6nEmU=; b=QruGRAFr2oSjMVUb8MXBl/rC/bZuD8zYtP9CP0OiIQnUUmkXC798A37UKEx98F1NJz jNmLX133VNu3Cr/aYV/vNiwKWg0gdau6ttA+r9Iu/UIfSHEcwCTKP7zNpnpvxWY7Jsxu ptPPXVKIyA7i+JDT6tPY7SbRDRJHphvVzHibMQIw2wNusXkSbZkfSTpgyce8N1E8rUHp 9MqAPdk1QdrdH90WX/343EHbbYGME4PaSqoLmKmiJWTrBM6YgkjECdOSOiJmRk5MNc5C yOJUVxBugYKudVLdujvkw4JmL0TDKQs0Dx4xSBBOmLXCvPpZ5FgQJ04JoM8jV2KgiZKp 54eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QAR123urz57PkLjJI7L4tM4W+19Um5s2CkATxO6nEmU=; b=yHlpZwPUHWOSz8S+oO+6oCgm7QG2VMILpmxJaAypppvBYOL4mdujjVBxk1KpJ5xDkO /kPl0LHP2SAAz8gfBdKIAgtNxe3KyQQgnYUOVpCAdsWNYAh5VC7apMqj9Nw8FN+wR/rl MT2XyXLrOiN5+1b9EheBv6uCEvW+gMY8nEy4GdoycR0+PLU5CEH87s4MRDR7Mr4heiHg QEyt++isLGXVhktYCOFuXq1FuJhBNYVS48+t/SeUifx/yPX0ffNDuM2bUHtC7uiECvoZ hvWDGU8sID7qKH4cBH+PH6zUyy+F949dnY2+b9A1YipSEgHP+YttWeJdK1ltkUSQhScB +Hbg== X-Gm-Message-State: AOAM532KsguOYbNG+C48PyucdgFzeNuxD0PtBxFHIzGelOIR/+Q+zQL6 Scg8DfBKAMfHTbbeDaYe2Hu++S+1JWELjGHOGfo= X-Google-Smtp-Source: ABdhPJwMDKrzQZuKJQDWhrq87YkZzAIVO9KJIAF0XeD/7eYRoldBbxYwIO4Yt3kH6+E8svRjC7TIMg== X-Received: by 2002:a05:6e02:2184:: with SMTP id j4mr12507827ila.30.1631629076816; Tue, 14 Sep 2021 07:17:56 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id p135sm6673803iod.26.2021.09.14.07.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 07:17:56 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, Jens Axboe Subject: [PATCH 2/3] io_uring: use iov_iter state save/restore helpers Date: Tue, 14 Sep 2021 08:17:49 -0600 Message-Id: <20210914141750.261568-3-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210914141750.261568-1-axboe@kernel.dk> References: <20210914141750.261568-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Get rid of the need to do re-expand and revert on an iterator when we encounter a short IO, or failure that warrants a retry. Use the new state save/restore helpers instead. We keep the iov_iter_state persistent across retries, if we need to restart the read or write operation. If there's a pending retry, the operation will always exit with the state correctly saved. Signed-off-by: Jens Axboe --- fs/io_uring.c | 62 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 855ea544807f..dbc97d440801 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -712,6 +712,7 @@ struct io_async_rw { struct iovec fast_iov[UIO_FASTIOV]; const struct iovec *free_iovec; struct iov_iter iter; + struct iov_iter_state iter_state; size_t bytes_done; struct wait_page_queue wpq; }; @@ -2608,8 +2609,7 @@ static bool io_resubmit_prep(struct io_kiocb *req) if (!rw) return !io_req_prep_async(req); - /* may have left rw->iter inconsistent on -EIOCBQUEUED */ - iov_iter_revert(&rw->iter, req->result - iov_iter_count(&rw->iter)); + iov_iter_restore(&rw->iter, &rw->iter_state); return true; } @@ -3310,12 +3310,16 @@ static int io_setup_async_rw(struct io_kiocb *req, const struct iovec *iovec, if (!force && !io_op_defs[req->opcode].needs_async_setup) return 0; if (!req->async_data) { + struct io_async_rw *iorw; + if (io_alloc_async_data(req)) { kfree(iovec); return -ENOMEM; } io_req_map_rw(req, iovec, fast_iov, iter); + iorw = req->async_data; + iov_iter_save_state(&iorw->iter, &iorw->iter_state); } return 0; } @@ -3334,6 +3338,7 @@ static inline int io_rw_prep_async(struct io_kiocb *req, int rw) iorw->free_iovec = iov; if (iov) req->flags |= REQ_F_NEED_CLEANUP; + iov_iter_save_state(&iorw->iter, &iorw->iter_state); return 0; } @@ -3437,19 +3442,23 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) struct kiocb *kiocb = &req->rw.kiocb; struct iov_iter __iter, *iter = &__iter; struct io_async_rw *rw = req->async_data; - ssize_t io_size, ret, ret2; bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; + struct iov_iter_state __state, *state; + ssize_t ret, ret2; if (rw) { iter = &rw->iter; + state = &rw->iter_state; + iov_iter_restore(iter, state); iovec = NULL; } else { ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; + state = &__state; + iov_iter_save_state(iter, state); } - io_size = iov_iter_count(iter); - req->result = io_size; + req->result = iov_iter_count(iter); /* Ensure we clear previously set non-block flag */ if (!force_nonblock) @@ -3463,7 +3472,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) return ret ?: -EAGAIN; } - ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size); + ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), req->result); if (unlikely(ret)) { kfree(iovec); return ret; @@ -3479,30 +3488,36 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) /* no retry on NONBLOCK nor RWF_NOWAIT */ if (req->flags & REQ_F_NOWAIT) goto done; - /* some cases will consume bytes even on error returns */ - iov_iter_reexpand(iter, iter->count + iter->truncated); - iov_iter_revert(iter, io_size - iov_iter_count(iter)); ret = 0; } else if (ret == -EIOCBQUEUED) { goto out_free; - } else if (ret <= 0 || ret == io_size || !force_nonblock || + } else if (ret <= 0 || ret == req->result || !force_nonblock || (req->flags & REQ_F_NOWAIT) || !need_read_all(req)) { /* read all, failed, already did sync or don't want to retry */ goto done; } + iov_iter_restore(iter, state); + ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true); if (ret2) return ret2; iovec = NULL; rw = req->async_data; - /* now use our persistent iterator, if we aren't already */ - iter = &rw->iter; + /* now use our persistent iterator and state, if we aren't already */ + if (iter != &rw->iter) { + iter = &rw->iter; + state = &rw->iter_state; + } do { - io_size -= ret; rw->bytes_done += ret; + iov_iter_advance(iter, ret); + if (!iov_iter_count(iter)) + break; + iov_iter_save_state(iter, state); + /* if we can retry, do so with the callbacks armed */ if (!io_rw_should_retry(req)) { kiocb->ki_flags &= ~IOCB_WAITQ; @@ -3520,7 +3535,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) return 0; /* we got some bytes, but not all. retry. */ kiocb->ki_flags &= ~IOCB_WAITQ; - } while (ret > 0 && ret < io_size); + } while (ret > 0); done: kiocb_done(kiocb, ret, issue_flags); out_free: @@ -3543,19 +3558,24 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) struct kiocb *kiocb = &req->rw.kiocb; struct iov_iter __iter, *iter = &__iter; struct io_async_rw *rw = req->async_data; - ssize_t ret, ret2, io_size; bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; + struct iov_iter_state __state, *state; + ssize_t ret, ret2; if (rw) { iter = &rw->iter; + state = &rw->iter_state; + iov_iter_restore(iter, state); iovec = NULL; } else { ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; + state = &__state; + iov_iter_save_state(iter, state); } - io_size = iov_iter_count(iter); - req->result = io_size; + req->result = iov_iter_count(iter); + ret2 = 0; /* Ensure we clear previously set non-block flag */ if (!force_nonblock) @@ -3572,7 +3592,7 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) (req->flags & REQ_F_ISREG)) goto copy_iov; - ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), io_size); + ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), req->result); if (unlikely(ret)) goto out_free; @@ -3619,9 +3639,9 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags) kiocb_done(kiocb, ret2, issue_flags); } else { copy_iov: - /* some cases will consume bytes even on error returns */ - iov_iter_reexpand(iter, iter->count + iter->truncated); - iov_iter_revert(iter, io_size - iov_iter_count(iter)); + iov_iter_restore(iter, state); + if (ret2 > 0) + iov_iter_advance(iter, ret2); ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false); return ret ?: -EAGAIN; } From patchwork Tue Sep 14 14:17:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12493607 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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6DF2EC43217 for ; Tue, 14 Sep 2021 14:18:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C4226108B for ; Tue, 14 Sep 2021 14:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233569AbhINOTk (ORCPT ); Tue, 14 Sep 2021 10:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233572AbhINOTR (ORCPT ); Tue, 14 Sep 2021 10:19:17 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B400C0613C1 for ; Tue, 14 Sep 2021 07:17:58 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id a20so14189248ilq.7 for ; Tue, 14 Sep 2021 07:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7aCyMA3VxhptRQuh2ttvtkXb5nYxSvlQb9n4PnL14HE=; b=bwE/2/tK2n1UYEGcn7p4EO23vPC1et3DKrZqIRlb0ERou43Q2SvnNa+LgCzk3oN1Ns vfSTHXNoybsZ3qJitqsVHVy4RRYNMuqHmdPn2AdjQoouunmLYKskG1aYWL0/xU1ZskVD r1vZDSzz5PxlDNXczWAs1lm4eR8XESGIslPTDWIQABxKz1QrBoVm+McKh40xyz3E3weO D5A6HVm41Nfno/Cewagz61s56582gqO4jhc3/kuG6WSKoKo8fH3hV0HhQfYL9hgnpUoM 8Yp3b9IkQJ+LWLZLc7CO+1L9hwQEDKJDXJjnkJ/qDrKNPOUkvdfocf9yZb5hKAo8dk1o ccOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7aCyMA3VxhptRQuh2ttvtkXb5nYxSvlQb9n4PnL14HE=; b=5oAzh7PopynBvTBAbC7Fy3nqDbkq5mNvxFcCVmlRkaiHTcZ2EEahY9RXIE2lLz8jQN v68RcO5o5CYoIx3e4yARPEpsVXD4T2Sy95sRMWZfq419FtbFcaRtH3OEEajva6SbTnUn jqoBJRzRkrRHWqVztiLgD/x2sVZI7fcAkbmOBx0qzpNxPNaCpOE4TKP4Bf3tlYAqyvrz ISKorawNLTdIHsmmoLCOShb2xssk32g/Z8ziHagMMn5lzhLD5OSoeqOe9QOTJm+guUYm j8LIwCECEA0b3vuPhAA1v4fmOzjXbVN6ULISUELrzPZBzb1bo5xGA/zKP/5mf0/rIyA7 vsqA== X-Gm-Message-State: AOAM531jwDDGCFl98yCbab89SokiUcwKRcOoJsWVvy+vB1RLAqaa0LHm DPOzgi+ijr0sW1V7aYHfljzT+5kWe94tMqosRgU= X-Google-Smtp-Source: ABdhPJwUFL7j7IrHbZjylmb2vw1tz5jvS/34hnWnm/Nfk2WoRkDcgbycQlBs74N5ui4q0mrqU31lBA== X-Received: by 2002:a92:6802:: with SMTP id d2mr12086283ilc.40.1631629077503; Tue, 14 Sep 2021 07:17:57 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id p135sm6673803iod.26.2021.09.14.07.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 07:17:57 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, Jens Axboe Subject: [PATCH 3/3] Revert "iov_iter: track truncated size" Date: Tue, 14 Sep 2021 08:17:50 -0600 Message-Id: <20210914141750.261568-4-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210914141750.261568-1-axboe@kernel.dk> References: <20210914141750.261568-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This reverts commit 2112ff5ce0c1128fe7b4d19cfe7f2b8ce5b595fa. We no longer need to track the truncation count, the one user that did need it has been converted to using iov_iter_restore() instead. Signed-off-by: Jens Axboe --- include/linux/uio.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 984c4ab74859..207101a9c5c3 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -53,7 +53,6 @@ struct iov_iter { }; loff_t xarray_start; }; - size_t truncated; }; static inline enum iter_type iov_iter_type(const struct iov_iter *i) @@ -270,10 +269,8 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count) * conversion in assignement is by definition greater than all * values of size_t, including old i->count. */ - if (i->count > count) { - i->truncated += i->count - count; + if (i->count > count) i->count = count; - } } /* @@ -282,7 +279,6 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count) */ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) { - i->truncated -= count - i->count; i->count = count; }