Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp993011ybt; Fri, 19 Jun 2020 20:53:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFCPeYN0vRqBFDIXbc+isAmovB22iEVAeXX9WcdUDX4UBgp+t4Dk+ra9kIXgF6AaHz5MjR X-Received: by 2002:a17:906:8253:: with SMTP id f19mr6677575ejx.470.1592625220270; Fri, 19 Jun 2020 20:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592625220; cv=none; d=google.com; s=arc-20160816; b=ZpYNk57H3Xa7DXWPU/ezILW1zaXX1Fi0GFwYloEvY2gSBGsZcq1+IdNjXx86p9WY4S ytMDdIZOzwpwp9LGUFbocQgpK8n3WIKdDrvdY/wP1ybHD45adW5ClNSCx+HcNbTK0bKF JhbE5SH4BPKlUrnxwk7APhhPQqkeaGut2oDVjL989edX0e/PMAf4N+TZDPd+v7VGJLwG QG/OJ1gQNFKvK0fgiVd3uI0VEtyqFNYtCz4spq6Co1zkl4F4Mi69nyXriWSTyBctBnNo R8/K1oLVxARi5/QNllLnRjYJUmSx0RfTq0X2WJwsjp/bmklUx3bcxS6ktXhn3IBCdZLr OJFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:from:references:cc:to:dkim-signature; bh=nzEVZi8volNOB1waOh1GZnF3JShWIxX8djOHFw4lYjw=; b=OXfXi7oFxCoMiWhoXBRjjsxfsxr7wPbwh9QY3GCre9M8xww5Nrvm6XZxmbYYHVvVFb CSvkUmnCiMd/FpjB4ZC9IEVP4hj9uj4M094P9zKTBnxYUztqcaNU/2X5AT3b5twiRE/e p78H8XSr+p4KaOesiazYOCIFC78lyeqmYaRhI5GnIQgRET87L+6wuKQUQyoOnZkBcoe5 8ud9biJz++Br1utVi3lS3mt2VKRNVGXeOKnZYnbNtzCk+7EriztrlqR3CV8JlNupRELN NaEjJW8ST33ZU2gMFzB9U2kNWm8EW/Pm+cy0KazNJ2bdjs3649UIBdeQlpZkWiN52pQX GBTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q0YBv3We; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t13si5149094ejr.37.2020.06.19.20.53.18; Fri, 19 Jun 2020 20:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Q0YBv3We; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390498AbgFSQVt (ORCPT + 99 others); Fri, 19 Jun 2020 12:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390650AbgFSPAk (ORCPT ); Fri, 19 Jun 2020 11:00:40 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FF64C06174E; Fri, 19 Jun 2020 08:00:40 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id dr13so10525967ejc.3; Fri, 19 Jun 2020 08:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nzEVZi8volNOB1waOh1GZnF3JShWIxX8djOHFw4lYjw=; b=Q0YBv3We5zGUJiH2ppbZraxmrVO9qUrHWpju0wO/75wJcDr8dzMrKvzrOSfcvQsCoe oLgsc93oYktBZ7P6tZVtw4A5LRWWt3G6eqw5curW4O2fPb4w395Cfku3EjtPM4Zv+NQW qG/UoTfUp41CP+ocnNC/uW8PM6KceyWt7hnyewi3WOWuqO3ex7OybN1umqk3kxpwq8IL CIQxdvFMdhdDqWWNodWMFBogCZqiSitk0+ZRAMiTXSkQZPYBDmsu7lLe9mF1NQrVQ8qY Os9FtBqXDvim5hk3hkUhP74zj1ZbUs7wFqZz4gCmROn+V80QnyXMeFMe4Tb0c/PdoXNR 1FPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=nzEVZi8volNOB1waOh1GZnF3JShWIxX8djOHFw4lYjw=; b=ebkmuC1Lm5UBW0Ymt9EvAyqd/YjAad9L2VgcB5IR8ylTRN8EIyjQASVQesjuLB2ycC afx9q9aNIzECUUfpt3yc5l9x90JR5kohQ3BgKRZwZ5yo5Q4Ir2TNKXyOsAv2JzUQgEnc +jJMVBI3md3oo6h1mqRhwEhWt7gwwJBWzHSdHAc8qolJhY7vXgAUWJsjSZr+Wh4/Pzz9 IWlhqCfBZFbdiFDguW06OVcmul/Zql9ApRYEAPdXhtOq4Z+zjJS17Pn8X7FTQ3Rkorq0 UUf9BnjMIfS5Yxpx4uWdQCLASldMR70nk3v615LjnFk35lk6CR0/+3yfEGRSVx0xd2PV ZKnA== X-Gm-Message-State: AOAM531NzEMSHf9Kh9l0iN19Crh6t12ufyjlO2FIxViUiN4xVILY9E8Y Lyj64OM0VA+Cv3qfVnIUbgg= X-Received: by 2002:a17:906:8401:: with SMTP id n1mr3731213ejx.479.1592578837970; Fri, 19 Jun 2020 08:00:37 -0700 (PDT) Received: from [192.168.43.243] ([5.100.193.151]) by smtp.gmail.com with ESMTPSA id w3sm4901342ejn.87.2020.06.19.08.00.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Jun 2020 08:00:37 -0700 (PDT) To: Jens Axboe , "javier.gonz@samsung.com" , Damien Le Moal Cc: Kanchan Joshi , "viro@zeniv.linux.org.uk" , "bcrl@kvack.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-aio@kvack.org" , "io-uring@vger.kernel.org" , "linux-block@vger.kernel.org" , "selvakuma.s1@samsung.com" , "nj.shetty@samsung.com" References: <1592414619-5646-1-git-send-email-joshi.k@samsung.com> <1592414619-5646-4-git-send-email-joshi.k@samsung.com> <20200618083529.ciifu4chr4vrv2j5@mpHalley.local> <20200618091113.eu2xdp6zmdooy5d2@mpHalley.local> <20200619094149.uaorbger326s6yzz@mpHalley.local> <31f1c27e-4a3d-a411-3d3b-f88a2d92ce7b@kernel.dk> From: Pavel Begunkov Autocrypt: addr=asml.silence@gmail.com; prefer-encrypt=mutual; keydata= mQINBFmKBOQBEAC76ZFxLAKpDw0bKQ8CEiYJRGn8MHTUhURL02/7n1t0HkKQx2K1fCXClbps bdwSHrhOWdW61pmfMbDYbTj6ZvGRvhoLWfGkzujB2wjNcbNTXIoOzJEGISHaPf6E2IQx1ik9 6uqVkK1OMb7qRvKH0i7HYP4WJzYbEWVyLiAxUj611mC9tgd73oqZ2pLYzGTqF2j6a/obaqha +hXuWTvpDQXqcOZJXIW43atprH03G1tQs7VwR21Q1eq6Yvy2ESLdc38EqCszBfQRMmKy+cfp W3U9Mb1w0L680pXrONcnlDBCN7/sghGeMHjGKfNANjPc+0hzz3rApPxpoE7HC1uRiwC4et83 CKnncH1l7zgeBT9Oa3qEiB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p+R uPwPccEQPWO/NP4fJl2zwC6byjljZhW5kxYswGMLBwb5cDUZAisIukyAa8Xshdan6C2RZcNs rB3L7vsg/R8UCehxOH0C+NypG2GqjVejNZsc7bgV49EOVltS+GmGyY+moIzxsuLmT93rqyII 5rSbbcTLe6KBYcs24XEoo49Zm9oDA3jYvNpeYD8rDcnNbuZh9kTgBwFN41JHOPv0W2FEEWqe JsCwQdcOQ56rtezdCJUYmRAt3BsfjN3Jn3N6rpodi4Dkdli8HylM5iq4ooeb5VkQ7UZxbCWt UVMKkOCdFhutRmYp0mbv2e87IK4erwNHQRkHUkzbsuym8RVpAZbLzLPIYK/J3RTErL6Z99N2 m3J6pjwSJY/zNwuFPs9zGEnRO4g0BUbwGdbuvDzaq6/3OJLKohr5eLXNU3JkT+3HezydWm3W OPhauth7W0db74Qd49HXK0xe/aPrK+Cp+kU1HRactyNtF8jZQbhMCC8vMGukZtWaAwpjWiiH bA== Subject: Re: [PATCH 3/3] io_uring: add support for zone-append Message-ID: <24297973-82ad-a629-e5f5-38a5b12db83a@gmail.com> Date: Fri, 19 Jun 2020 17:59:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <31f1c27e-4a3d-a411-3d3b-f88a2d92ce7b@kernel.dk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/06/2020 17:15, Jens Axboe wrote: > On 6/19/20 3:41 AM, javier.gonz@samsung.com wrote: >> Jens, >> >> Would you have time to answer a question below in this thread? >> >> On 18.06.2020 11:11, javier.gonz@samsung.com wrote: >>> On 18.06.2020 08:47, Damien Le Moal wrote: >>>> On 2020/06/18 17:35, javier.gonz@samsung.com wrote: >>>>> On 18.06.2020 07:39, Damien Le Moal wrote: >>>>>> On 2020/06/18 2:27, Kanchan Joshi wrote: >>>>>>> From: Selvakumar S >>>>>>> >>>>>>> Introduce three new opcodes for zone-append - >>>>>>> >>>>>>> IORING_OP_ZONE_APPEND : non-vectord, similiar to IORING_OP_WRITE >>>>>>> IORING_OP_ZONE_APPENDV : vectored, similar to IORING_OP_WRITEV >>>>>>> IORING_OP_ZONE_APPEND_FIXED : append using fixed-buffers >>>>>>> >>>>>>> Repurpose cqe->flags to return zone-relative offset. >>>>>>> >>>>>>> Signed-off-by: SelvaKumar S >>>>>>> Signed-off-by: Kanchan Joshi >>>>>>> Signed-off-by: Nitesh Shetty >>>>>>> Signed-off-by: Javier Gonzalez >>>>>>> --- >>>>>>> fs/io_uring.c | 72 +++++++++++++++++++++++++++++++++++++++++-- >>>>>>> include/uapi/linux/io_uring.h | 8 ++++- >>>>>>> 2 files changed, 77 insertions(+), 3 deletions(-) >>>>>>> >>>>>>> diff --git a/fs/io_uring.c b/fs/io_uring.c >>>>>>> index 155f3d8..c14c873 100644 >>>>>>> --- a/fs/io_uring.c >>>>>>> +++ b/fs/io_uring.c >>>>>>> @@ -649,6 +649,10 @@ struct io_kiocb { >>>>>>> unsigned long fsize; >>>>>>> u64 user_data; >>>>>>> u32 result; >>>>>>> +#ifdef CONFIG_BLK_DEV_ZONED >>>>>>> + /* zone-relative offset for append, in bytes */ >>>>>>> + u32 append_offset; >>>>>> >>>>>> this can overflow. u64 is needed. >>>>> >>>>> We chose to do it this way to start with because struct io_uring_cqe >>>>> only has space for u32 when we reuse the flags. >>>>> >>>>> We can of course create a new cqe structure, but that will come with >>>>> larger changes to io_uring for supporting append. >>>>> >>>>> Do you believe this is a better approach? >>>> >>>> The problem is that zone size are 32 bits in the kernel, as a number >>>> of sectors. So any device that has a zone size smaller or equal to >>>> 2^31 512B sectors can be accepted. Using a zone relative offset in >>>> bytes for returning zone append result is OK-ish, but to match the >>>> kernel supported range of possible zone size, you need 31+9 bits... >>>> 32 does not cut it. >>> >>> Agree. Our initial assumption was that u32 would cover current zone size >>> requirements, but if this is a no-go, we will take the longer path. >> >> Converting to u64 will require a new version of io_uring_cqe, where we >> extend at least 32 bits. I believe this will need a whole new allocation >> and probably ioctl(). >> >> Is this an acceptable change for you? We will of course add support for >> liburing when we agree on the right way to do this. > > If you need 64-bit of return value, then it's not going to work. Even > with the existing patches, reusing cqe->flags isn't going to fly, as > it would conflict with eg doing zone append writes with automatic > buffer selection. Buffer selection is for reads/recv kind of requests, but appends are writes. In theory they can co-exist using cqe->flags. > > We're not changing the io_uring_cqe. It's important to keep it lean, and > any other request type is generally fine with 64-bit tag + 32-bit result > (and 32-bit flags on the side) for completions. > > Only viable alternative I see would be to provide an area to store this > information, and pass in a pointer to this at submission time through > the sqe. One issue I do see with that is if we only have this > information available at completion time, then we'd need some async punt > to copy it to user space... Generally not ideal. > > A hackier approach would be to play some tricks with cqe->res and > cqe->flags, setting aside a flag to denote an extension of cqe->res. > That would mean excluding zone append (etc) from using buffer selection, > which probably isn't a huge deal. It'd be more problematic for any other > future flags. But if you just need 40 bits, then it could certainly > work. Rigth now, if cqe->flags & 1 is set, then (cqe->flags >> 16) is > the buffer ID. You could define IORING_CQE_F_ZONE_FOO to be bit 1, so > that: > > uint64_t val = cqe->res; // assuming non-error here > > if (cqe->flags & IORING_CQE_F_ZONE_FOO) > val |= (cqe->flags >> 16) << 32ULL; > > and hence use the upper 16 bits of cqe->flags for the upper bits of your > (then) 48-bit total value. How about returning offset in terms of 512-bytes chunks? NVMe is 512B atomic/aligned. We'll lose an ability to do non-512 aligned appends, but it won't hit media as such anyway (will be padded or cached), so personally I don't see much benefit in having it. -- Pavel Begunkov