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,DKIM_SIGNED, DKIM_VALID,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 A939CC49EA5 for ; Thu, 24 Jun 2021 06:14:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EAAA613DC for ; Thu, 24 Jun 2021 06:14:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231297AbhFXGRQ (ORCPT ); Thu, 24 Jun 2021 02:17:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbhFXGRQ (ORCPT ); Thu, 24 Jun 2021 02:17:16 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFF21C06175F for ; Wed, 23 Jun 2021 23:14:57 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id e33so3869806pgm.3 for ; Wed, 23 Jun 2021 23:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1OJqZ/QIcBDy8sybu98JPQTBBJnoCTUnMzw1F6ER0So=; b=0FG5lPc1+hCO8lyN+ScMXNSFrKPUfkzushS6MV+G1DcGXg/cN/4o+ssceHVkn/BSH8 w+NlPMHiyGG9JakM0+ZweeixZhjWbDbbS7BblCCiQGeHkfcgwfEWmFZjtZAdL8fZ9aU1 Rj6YhNcZIyc3u93zXlpXWT/MlXRPADUH86lv+YAwdoWRwuYKQ+i8bHuF4b/p1noGcvPC ejBH8Ko3OptDf0m/rifDNRWVxPJpTiGfidxbk+wUbmVgd8TSWqfZBMu7yvlJMz0Lz1Fm Fwrk7Wa9IDhTthhEkOTCRo4Bk/PaE/KMnF8V989jISLO6V8ScaHJISAsuOpUseJOeAVK /yPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1OJqZ/QIcBDy8sybu98JPQTBBJnoCTUnMzw1F6ER0So=; b=KCOXw0DkeKtMu7BJlZXzuoLuJZIWdsKX7dRpW7t6oLXgEUwNVMGbmpPuoTKy1zo2nu TPi1oIMFpRfqdA7a9j8odDruK49VLre/vWG6QzyE3xjCIH/tQPldsw8E4j5hB+S/AClZ k60K/rR2dhKOiuZ0zDvClJEZJa2J2b7Xf3NEpgGNyU0i/HCPMRrh8OaWmmK8NBr8WE8A GMyqFNLMeQlMDsn9o9+uUceqJkb+jOXBeZ2KsjQBQyf77a8BqYzTme9xjB9l2IkEd/SE lykwTw5X2WtxmK3XyGAEhhzeNLAtLOHNE4133ZRKJ6b9Ezf02m4ZcSX1XoBB9E3LXnsf FIsg== X-Gm-Message-State: AOAM531Pq7Owt5l+siz56bVn/duqm3/S/iq4ct2vOUG4rbKdpV/GkITm o3gQZ+js7UC2yCouzu5n0BKBUA== X-Google-Smtp-Source: ABdhPJzvJif9dvfXZXH1pxwSpQAluO7dKKyV55/1jIcfUr2aXYMHZnvlLjRepXqVmW0ITeKoFf27bg== X-Received: by 2002:aa7:8615:0:b029:303:4428:9dbe with SMTP id p21-20020aa786150000b029030344289dbemr3511287pfn.17.1624515297163; Wed, 23 Jun 2021 23:14:57 -0700 (PDT) Received: from relinquished.localdomain ([2620:10d:c090:400::5:e167]) by smtp.gmail.com with ESMTPSA id c22sm1619576pfv.121.2021.06.23.23.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 23:14:56 -0700 (PDT) Date: Wed, 23 Jun 2021 23:14:54 -0700 From: Omar Sandoval To: Matthew Wilcox Cc: Al Viro , 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: Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Thu, Jun 24, 2021 at 03:00:39AM +0100, Matthew Wilcox wrote: > On Wed, Jun 23, 2021 at 02:58:32PM -0700, Omar Sandoval wrote: > > 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? > > Does that work for O_DIRECT and the required 512-byte alignment? I suppose the kernel could pad the encoded_iov structure with zeroes to the next sector boundary, since zeroes are effectively noops for encoded_iov. (As an aside, RWF_ENCODED is always "direct I/O" in the sense that it bypasses the page cache, but not necessarily in the sense that it does DMA to/from the user buffers. The Btrfs implementation doesn't do the latter yet.)