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 DF19CC49EA6 for ; Wed, 23 Jun 2021 22:26:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B538D611C1 for ; Wed, 23 Jun 2021 22:26:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbhFWW2x (ORCPT ); Wed, 23 Jun 2021 18:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbhFWW2w (ORCPT ); Wed, 23 Jun 2021 18:28:52 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2197C061574; Wed, 23 Jun 2021 15:26:34 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwBKB-00BeJB-Rn; Wed, 23 Jun 2021 22:26:23 +0000 Date: Wed, 23 Jun 2021 22:26:23 +0000 From: Al Viro To: Omar Sandoval Cc: Linus Torvalds , Dave Chinner , linux-fsdevel , linux-btrfs , Linux API , Kernel Team , Dave Chinner Subject: Re: [PATCH RESEND x3 v9 1/9] iov_iter: add copy_struct_from_iter() Message-ID: References: <20210622220639.GH2419729@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, Jun 23, 2021 at 02:58:32PM -0700, Omar Sandoval wrote: > Ah, I was stuck on thinking about this calling convention: > > struct encoded_iov encoded_iov; > char compressed_data[...]; > struct iovec iov[] = { > { &encoded_iov, sizeof(encoded_iov) }, > { compressed_data, sizeof(compressed_data) }, > }; > preadv2(fd, iov, 2, -1, RWF_ENCODED); > > But what you described would look more like: > > // Needs to be large enough for maximum returned header + data. > char buffer[...]; > struct iovec iov[] = { > { buffer, sizeof(buffer) }, > }; > preadv2(fd, iov, 2, -1, RWF_ENCODED); > // We should probably align the buffer. > struct encoded_iov *encoded_iov = (void *)buffer; > char *data = buffer + encoded_iov->size; > > That's a little uglier, but it should work, and allows for arbitrary > extensions. So, among these three alternatives (fixed size structure > with reserved space, variable size structure like above, or ioctl), > which would you prefer? Variable-sized structure would seem to be the easiest from the kernel POV and the interface is the easiest to describe - "you read the encoded data preceded by the header"...