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.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 8470BC2B9F4 for ; Tue, 22 Jun 2021 22:06:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60E3E611CE for ; Tue, 22 Jun 2021 22:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229746AbhFVWJB (ORCPT ); Tue, 22 Jun 2021 18:09:01 -0400 Received: from mail107.syd.optusnet.com.au ([211.29.132.53]:50582 "EHLO mail107.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbhFVWJB (ORCPT ); Tue, 22 Jun 2021 18:09:01 -0400 Received: from dread.disaster.area (pa49-179-138-183.pa.nsw.optusnet.com.au [49.179.138.183]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id 3F98D7126; Wed, 23 Jun 2021 08:06:40 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1lvoXX-00Fr2Q-Fn; Wed, 23 Jun 2021 08:06:39 +1000 Date: Wed, 23 Jun 2021 08:06:39 +1000 From: Dave Chinner To: Omar Sandoval Cc: Linus Torvalds , Al Viro , 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: <20210622220639.GH2419729@dread.disaster.area> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=F8MpiZpN c=1 sm=1 tr=0 a=MnllW2CieawZLw/OcHE/Ng==:117 a=MnllW2CieawZLw/OcHE/Ng==:17 a=kj9zAlcOel0A:10 a=r6YtysWOX24A:10 a=-uoBkjAQAAAA:8 a=VwQbUJbxAAAA:8 a=7-415B0cAAAA:8 a=SiS6zSyo1DA6T2jvNdwA:9 a=CjuIK1q_8ugA:10 a=y0wLjPFBLyexm0soFTcm:22 a=AjGcO6oz07-iQ99wixmX:22 a=biEYGPWJfzWAr4FL6Ov7:22 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Jun 21, 2021 at 01:55:03PM -0700, Omar Sandoval wrote: > On Mon, Jun 21, 2021 at 01:46:04PM -0700, Omar Sandoval wrote: > > On Mon, Jun 21, 2021 at 12:33:17PM -0700, Linus Torvalds wrote: > > > On Mon, Jun 21, 2021 at 11:46 AM Omar Sandoval wrote: > > > > > > > > How do we get the userspace size with the encoded_iov.size approach? > > > > We'd have to read the size from the iov_iter before writing to the rest > > > > of the iov_iter. Is it okay to mix the iov_iter as a source and > > > > destination like this? From what I can tell, it's not intended to be > > > > used like this. > > > > > > I guess it could work that way, but yes, it's ugly as hell. And I > > > really don't want a readv() system call - that should write to the > > > result buffer - to first have to read from it. > > > > > > So I think the original "just make it be the first iov entry" is the > > > better approach, even if Al hates it. > > > > > > Although I still get the feeling that using an ioctl is the *really* > > > correct way to go. That was my first reaction to the series > > > originally, and I still don't see why we'd have encoded data in a > > > regular read/write path. > > > > > > What was the argument against ioctl's, again? > > > > The suggestion came from Dave Chinner here: > > https://lore.kernel.org/linux-fsdevel/20190905021012.GL7777@dread.disaster.area/ > > > > His objection to an ioctl was two-fold: > > > > 1. This interfaces looks really similar to normal read/write, so we > > should try to use the normal read/write interface for it. Perhaps > > this trouble with iov_iter has refuted that. > > 2. The last time we had Btrfs-specific ioctls that eventually became > > generic (FIDEDUPERANGE and FICLONE{,RANGE}), the generalization was > > painful. Part of the problem with clone/dedupe was that the Btrfs > > ioctls were underspecified. I think I've done a better job of > > documenting all of the semantics and corner cases for the encoded I/O > > interface (and if not, I can address this). The other part of the > > problem is that there were various sanity checks in the normal > > read/write paths that were missed or drifted out of sync in the > > ioctls. That requires some vigilance going forward. Maybe starting > > this off as a generic (not Btrfs-specific) ioctl right off the bat > > will help. > > > > If we do go the ioctl route, then we also have to decide how much of > > preadv2/pwritev2 it should emulate. Should it use the fd offset, or > > should that be an ioctl argument? Some of the RWF_ flags would be useful > > for encoded I/O, too (RWF_DSYNC, RWF_SYNC, RWF_APPEND), should it > > support those? These bring us back to Dave's first point. > > Oops, I dropped Dave from the Cc list at some point. Adding him back > now. Fair summary. The only other thing that I'd add is this is an IO interface that requires issuing physical IO. So if someone wants high throughput for encoded IO, we really need AIO and/or io_uring support, and we get that for free if we use readv2/writev2 interfaces. Yes, it could be an ioctl() interface, but I think that this sort of functionality is exactly what extensible syscalls like preadv2/pwritev2 should be used for. It's a slight variant on normal IO, and that's exactly what the RWF_* flags are intended to be used for - allowing interesting per-IO variant behaviour without having to completely re-implemnt the IO path via custom ioctls every time we want slightly different functionality... Cheers, Dave. -- Dave Chinner david@fromorbit.com