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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 34035C433EF for ; Fri, 10 Sep 2021 18:50:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1CDD06124E for ; Fri, 10 Sep 2021 18:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbhIJSvz (ORCPT ); Fri, 10 Sep 2021 14:51:55 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:43840 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhIJSvz (ORCPT ); Fri, 10 Sep 2021 14:51:55 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOlbn-002y3l-6h; Fri, 10 Sep 2021 18:50:43 +0000 Date: Fri, 10 Sep 2021 18:50:43 +0000 From: Al Viro To: Jens Axboe Cc: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, torvalds@linux-foundation.org Subject: Re: [PATCH 1/3] iov_iter: add helper to save iov_iter state Message-ID: References: <20210910182536.685100-1-axboe@kernel.dk> <20210910182536.685100-2-axboe@kernel.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210910182536.685100-2-axboe@kernel.dk> Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org On Fri, Sep 10, 2021 at 12:25:34PM -0600, Jens Axboe wrote: > +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; > +} No. You can have iovec and kvec handled jointly (struct iovec and struct kvec always have the same size). You can *not* do that to bvec - check sizeof of struct bio_vec and struct iovec on 32bit targets.