From patchwork Fri Sep 10 18:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12485671 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 6EA5CC4332F for ; Fri, 10 Sep 2021 18:25:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52D47611C0 for ; Fri, 10 Sep 2021 18:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231783AbhIJS0y (ORCPT ); Fri, 10 Sep 2021 14:26:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbhIJS0y (ORCPT ); Fri, 10 Sep 2021 14:26:54 -0400 Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1293C061574 for ; Fri, 10 Sep 2021 11:25:42 -0700 (PDT) Received: by mail-il1-x142.google.com with SMTP id b15so2527628ils.10 for ; Fri, 10 Sep 2021 11:25:42 -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=z6UwIALlp9qFlZishysLlnF/vgKBUJjar/sdwLm2E1E=; b=dZNcocqASUiy5jZRVU/TLOfAW20otqYOWfpooJe7vmHZKfhSewUK6KS/7P0pXPdQkj 3+kOdyBWMLIcswcXQboYRShW8nOsOOELdi5HMqDZPeQyshM1j+sswMZ1KCMC5ShW7dBG mTWGU7AILv7ZuSOV/NXEHeg+4R3tIxaZoSJbfHXdNottnd28sep4Kz4+a1hfF4UvZJdw v9jisaknKnG5XOtcoeLmvt/CXOUlc1yxHBYRoESgUNocsM/gUevm5VxmMBU5Rz881zpG 8/rtFwN/Kq18uUqUEIwLGRwkbSHNbcSR3hMB1wlaiA27t2G9k61TMe151hG6CRYzbqEZ NPNA== 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=z6UwIALlp9qFlZishysLlnF/vgKBUJjar/sdwLm2E1E=; b=04gwfqcizcHhzQshE9LxntLtYYABAdKVaX0uD6ebRyZwcH29qhrpp7Sj2QgZpu1kgF dC/1Y3vL+VOOjDHf9V7oN85XB5kCxu37I3ZQBytjfdMIq8wsbuSQp9njHYXt4t6Pivs5 9jiezqc9xtPMD/veWBc6HmqajmA78DL/HGTntf7v8ouEwt4+T3/sis28AEheAZsZ5jpG Mw06xBkob409FY6PTjegkOeOAxDjqVm5k5ETuU70kMqVzGdPn8qm64uZTXkImHUkiTAI VYum+gUH0bjJQBBoy5HSL2mvRcORwroNObhnyBChRlc7wsOU8tLP7mSfjt+CtW6EKIxh wa5g== X-Gm-Message-State: AOAM531BHVxaD7G3+AF/Yvc9iwiJ/cZhpUgKBZB9SemgdCCq5apLJgXF rqEsxfu+ka7hknT56kPCkvqSTA== X-Google-Smtp-Source: ABdhPJy2Ap63JgqGT3VbYB8Taw2Cw11n5y6v9q7+DWOw06alp0GHbt1eQtzV6CWLUNZVYmQUXvF9WA== X-Received: by 2002:a05:6e02:8f2:: with SMTP id n18mr7268839ilt.256.1631298342339; Fri, 10 Sep 2021 11:25:42 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id c20sm2575149ili.42.2021.09.10.11.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 11:25:42 -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: Fri, 10 Sep 2021 12:25:34 -0600 Message-Id: <20210910182536.685100-2-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210910182536.685100-1-axboe@kernel.dk> References: <20210910182536.685100-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 | 16 ++++++++++++++++ lib/iov_iter.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/linux/uio.h b/include/linux/uio.h index 5265024e8b90..6eaedae5ea2f 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,8 @@ 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, + ssize_t did_bytes); 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..280dbcc523e5 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 + * @did_bytes: bytes to advance @i after restoring it + * + * Used after iov_iter_save_state() to bring restore @i, if operations may + * have advanced it. If @did_bytes is a positive value, then after restoring + * @i it is advanced accordingly. This is useful for handling short reads or + * writes for retry, if lower down the stack @i was advanced further than the + * returned value. If @did_bytes is negative (eg an error), then only the + * state restore is done. + * + * Note: only works on ITER_IOVEC, ITER_BVEC, and ITER_KVEC + */ +void iov_iter_restore(struct iov_iter *i, struct iov_iter_state *state, + ssize_t did_bytes) +{ + 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_{BVEC,IOVEC,KVEC} all have their pointers + * unionized, so we don't need to handle them individually. + */ + i->iov -= state->nr_segs - i->nr_segs; + i->nr_segs = state->nr_segs; +} From patchwork Fri Sep 10 18:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12485673 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 198B2C43217 for ; Fri, 10 Sep 2021 18:25:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0237611C0 for ; Fri, 10 Sep 2021 18:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231846AbhIJS0z (ORCPT ); Fri, 10 Sep 2021 14:26:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbhIJS0z (ORCPT ); Fri, 10 Sep 2021 14:26:55 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4473C061574 for ; Fri, 10 Sep 2021 11:25:43 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id n24so3489036ion.10 for ; Fri, 10 Sep 2021 11:25:43 -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=pF069LFLYqZVT/magmUziYtfqHy/4m6/8hnl00DpDAY=; b=CmUfar/toYDNf6+XiE69fZFXYxQ801ESSSvckrOt+/eErD23/QIWAgb2vYHkN2ITqZ ++rBxpPKEMNgvebOKHumA2kBfTOuSiBe8vs8hd1bzf6lsVt2GWNaGCqXb7pG2iJ/Atib 8JiGDFkZTAIenF8rKz6RgaGgq8zYJcYImTcvUjItTCg9GkPiwKwAgAfi9ZwtsbSi3ZG5 5yMkvpLQMtuUO/H/5m0cUctu0tbgGyMLH0Rn98rE2owm1UXu2PgsAxDisN6ykX+z4Xbv EDJDUvKninScbenbmrIQ5Fi8EKwPV/IOFi22BxxSdtWqDZM98XRbvucEw0cZl7cMz556 8VRw== 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=pF069LFLYqZVT/magmUziYtfqHy/4m6/8hnl00DpDAY=; b=gtxtBfj6QuRsbv5pE38FOdmnlYNIh66qBGDwlC8u9KcDINQGasrFMjTf6+PCV6AC64 Dxmy0I/KkLk6z3Z35mOPZxnpSFC3ryIGs7H3KsyFHmayISeZpbhhMbRPET3sw0wKHzRM iipFCLEASkJCPD/52pSVrIFm45dtOgSH7Dmvv5g3niapG0dT0DhlpOPSARQP1+hzBElH upusFpUgpUCVWACEuGyUz30ciiLmbwts/zoNQwhO2k9dWbpSQ18/Rc4y7S/LrFEGfVIt zFMfeDBxRhkcKWbzkBKsUjvM0qYiMURHaswQrH5Gvpf37N7EC4vcvL/UZXXYf3KRmjWJ JkjQ== X-Gm-Message-State: AOAM531fLGE8GNwU/iS6D3RDVVINxSTge+pRpSMpQp4oCcUea/q/yh+6 gQ2NwULa3Lkj3y2XOudXawWvxg== X-Google-Smtp-Source: ABdhPJyaNgQzkFsKDP8HzGqlkNtbrvMKwA6//1EZVv8VAvQAEHkHLr3F8Iwx/30XzzEbJFRsajv5+w== X-Received: by 2002:a5d:8b4b:: with SMTP id c11mr8181540iot.98.1631298343270; Fri, 10 Sep 2021 11:25:43 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id c20sm2575149ili.42.2021.09.10.11.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 11:25:42 -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: Fri, 10 Sep 2021 12:25:35 -0600 Message-Id: <20210910182536.685100-3-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210910182536.685100-1-axboe@kernel.dk> References: <20210910182536.685100-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. Signed-off-by: Jens Axboe --- fs/io_uring.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 855ea544807f..84e33f751372 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, 0); return true; } @@ -3437,19 +3437,22 @@ 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; iovec = NULL; } else { ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; + state = &__state; } - io_size = iov_iter_count(iter); - req->result = io_size; + req->result = iov_iter_count(iter); + iov_iter_save_state(iter, state); /* Ensure we clear previously set non-block flag */ if (!force_nonblock) @@ -3463,7 +3466,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), state->count); if (unlikely(ret)) { kfree(iovec); return ret; @@ -3479,18 +3482,17 @@ 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 == state->count || !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, ret); + ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true); if (ret2) return ret2; @@ -3501,7 +3503,7 @@ static int io_read(struct io_kiocb *req, unsigned int issue_flags) iter = &rw->iter; do { - io_size -= ret; + state->count -= ret; rw->bytes_done += ret; /* if we can retry, do so with the callbacks armed */ if (!io_rw_should_retry(req)) { @@ -3520,7 +3522,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 && ret < state->count); done: kiocb_done(kiocb, ret, issue_flags); out_free: @@ -3543,19 +3545,23 @@ 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; iovec = NULL; } else { ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; + state = &__state; } - io_size = iov_iter_count(iter); - req->result = io_size; + req->result = iov_iter_count(iter); + iov_iter_save_state(iter, state); + ret2 = 0; /* Ensure we clear previously set non-block flag */ if (!force_nonblock) @@ -3572,7 +3578,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), state->count); if (unlikely(ret)) goto out_free; @@ -3619,9 +3625,7 @@ 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, ret2); ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false); return ret ?: -EAGAIN; } From patchwork Fri Sep 10 18:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 12485675 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 4729DC433EF for ; Fri, 10 Sep 2021 18:25:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D6F6611C0 for ; Fri, 10 Sep 2021 18:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbhIJS07 (ORCPT ); Fri, 10 Sep 2021 14:26:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbhIJS04 (ORCPT ); Fri, 10 Sep 2021 14:26:56 -0400 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE9F0C061574 for ; Fri, 10 Sep 2021 11:25:44 -0700 (PDT) Received: by mail-il1-x130.google.com with SMTP id x5so2986937ill.3 for ; Fri, 10 Sep 2021 11:25:44 -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=HXqLAV2nHQSRvb7ZpTv11qb8Cadrv15U6bJT2tEZrTA=; b=C9n592YCvQVMPC3QJJq8doHR8zymsLndJY7D9sFC7MPjcHYXietRyHeBqWGrPNd8Eh Ramev7MeNwgQevFyw9xHgFNGVl+TJBPmb5KYDOH9lMFERBfoQHZgGUyqarBbcdfsS/bs RIcHmf/0TIdWttSAMJEJYaLIbfSJLyO1Ts8HsHDOQswciqFc+KmOa5B6V3iSrx5qfJMZ LQXRIqmc1XOYT6gHnhua2GK1eRKuJ1puUPfOA3daLzgT2ui441hg6bDnm0DOfFZ+/3PN 1rj1n7m88iN14EDYdY9D/VQhHQsM/f9WNlv7FL4ZJxMb7Vexn2RDYE4wLhL97X+qxyFo UR0w== 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=HXqLAV2nHQSRvb7ZpTv11qb8Cadrv15U6bJT2tEZrTA=; b=hThQr5dEYteL4IR6+GUUEJx6DwEhvZbhKB12x4/d+Te0glyDT+cCnwTnziKvGllJmL q5KR39Iaa2g7W9kkMEOiMy+VAo56sXiCQs16hGV6sJar0pCEJwg0+TiGSNt7P/dhIPBB 2zaj1NuahMuf/cIr00MeWg2bLGRTFio5jxoCKPrc5LeMZEB4oChpKIqxh4mawkSueYZd nm2xJgMgCbm4UTbenyeh5TMYoaX9Mqz4bvwJKllZYM99Rj2vMJiuHWdSGV/4txg8PO2p 5Rt1nMpIsBm83RNIYQLapsqVoiY+JYs2g3xxNvbjbFuUOd2Jt4zeViQrS3IK0lcRwBxX AVWQ== X-Gm-Message-State: AOAM5310Pgd7ojPTHYMT47Wf8EFEg670EJ0k1ImLw3KLq1GPZY1gmAKZ rEiA6IlVjJ4nmraLL+2rhfUgrA== X-Google-Smtp-Source: ABdhPJx8Mme/uzeOQpl1RzbdA7+VQ+YAp0SgCmqt948wv5waJl2kT5lV9BmbUv+0u+x7l5dlVBPYrg== X-Received: by 2002:a05:6e02:1044:: with SMTP id p4mr7281793ilj.227.1631298344198; Fri, 10 Sep 2021 11:25:44 -0700 (PDT) Received: from p1.localdomain ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id c20sm2575149ili.42.2021.09.10.11.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 11:25:43 -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: Fri, 10 Sep 2021 12:25:36 -0600 Message-Id: <20210910182536.685100-4-axboe@kernel.dk> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210910182536.685100-1-axboe@kernel.dk> References: <20210910182536.685100-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 6eaedae5ea2f..7c8aeacc6fa7 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) @@ -271,10 +270,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; - } } /* @@ -283,7 +280,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; }