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 0BDC3C49EA5 for ; Wed, 23 Jun 2021 21:40:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBAFD60FE5 for ; Wed, 23 Jun 2021 21:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbhFWVme (ORCPT ); Wed, 23 Jun 2021 17:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbhFWVmd (ORCPT ); Wed, 23 Jun 2021 17:42:33 -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 F2A47C061574; Wed, 23 Jun 2021 14:40:15 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwAb6-00BdqY-Is; Wed, 23 Jun 2021 21:39:48 +0000 Date: Wed, 23 Jun 2021 21:39:48 +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 01:46:50PM -0700, Omar Sandoval wrote: > Suppose we add a new field representing a new type of encoding to the > end of encoded_iov. On the write side, the caller might want to specify > that the data is encoded in that new way, of course. But on the read > side, if the data is encoded in that new way, then the kernel will want > to return that. The kernel needs to know if the user's structure > includes the new field (otherwise when it copies the full struct out, it > will write into what the user thinks is the data instead). Er... What's the problem with simply copying that extended structure out, followed by the data? IOW, why can't the caller pick the header out of the whole thing and deal with it in whatever way it likes? Why should kernel need to do anything special here? IDGI... Userland had always been able to deal with that kind of stuff; you read e.g. gzipped data into buffer, you decode the header, you figure out how long it is and how far out does the payload begin, etc. How is that different?