Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp39465pxa; Fri, 31 Jul 2020 06:08:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM4Ck01gd6plFm+R2Pc+hoKSuOVjsiuW8XRyvbPrl9EBS2o5YCQxzOvUqUBuU6ejMVgHD6 X-Received: by 2002:a05:6402:508:: with SMTP id m8mr3653719edv.279.1596200921798; Fri, 31 Jul 2020 06:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596200921; cv=none; d=google.com; s=arc-20160816; b=Tdk5WH4v3hWjc2SFaVG/8B6xzcp+inhL+r1D3zvIZiS2eFxP2aGLkg+zXQ52Hp6Utt jZJZR5IDJeIzHzbRCs/HDGFC5B5vNvEiNUr/iBuLd7u8J9nXcw4ao4zK+LiV7fxv/kPU lJgJflnB9HAwpFoyB1fI9sbViHiUIPuyq096Nw3DlXbZjzlUH+jZYorYgnJgg5QyS8X0 nAPYb/QznzVTl1OuNJTx9SFxj3dXV1x4NQi4g2prsO1GqUDGRxdtKtU2bcqgxheROcom pqEZk8BtDt9YXUSEoBTSoYE9GfnRX3lVNXdDWrNx3TynxRsF1vJsm8sLn9LLGj6uPhpX sgGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=yj2xoKAlywTl8ua8JXKgkinbNIInpoi9iZwApZLpN2A=; b=vGZerAgHH+c3kcMOyd/fyBd6DvOFRt+zN5GnQqKDom/FBqAc5h+caAxZyqL+iW9H8T 709RTCSwCaY3vyeAfpf0bBOfvvgU/Wgl/PvY8dB4sQowdPPICrci+TcQDV/ANaUIlqqc QnWACRblgAXcMPgJ2ZPqt3C0bDu5UB7C6KrtJ6KGU9tcLSO27/DFAVilNorJwuS08u/H HbHJWeaFw/TrKnH3MO0hcdrBXLWNMb2N0Kas+rVbrwhfweh96wwaAT4fbfp2U3p9WxMP bnqXZNB4ZRZPOYGKXqXqrzPb8FTTU0l+nM8GGWwDsvIU5v1ixGmNgElPy3BvtpbxuDD7 Oy7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=lxhLj+6v; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si5212803ejd.575.2020.07.31.06.08.19; Fri, 31 Jul 2020 06:08:41 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=lxhLj+6v; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730881AbgGaNIN (ORCPT + 99 others); Fri, 31 Jul 2020 09:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbgGaNIM (ORCPT ); Fri, 31 Jul 2020 09:08:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1576C061574; Fri, 31 Jul 2020 06:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=yj2xoKAlywTl8ua8JXKgkinbNIInpoi9iZwApZLpN2A=; b=lxhLj+6vz4x4ci3cMgZ260rQw0 OJj6UHCushW5rXV/rva78XtNf8Lqj9latQCF+qH8fJDo2i3+qSOYB5Ee1OQMfti4CudmhNRKXmWGn V37fFhMvteQiPOxnsLmZLLDONGsNCv4WmgI3KO86/GqYMPeh6skRpctvUxr92QVr1PEuh6wkywaDN UDr6jqSIq6jc5oLRhr4SjIWiBwYrzhIrfqXvXaWo5zcht1R+faNn32zi1c0Y5nVk6NZeY71vyLjNA jS0iTJtNbZvsSZSfaBv0oij76BB3ZkVOsMsT/yCA0noHRDX1QksuDxj5lLM+/O7LH44gdHbu8nIMk 7C1vL1bw==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1UlW-0004do-Ce; Fri, 31 Jul 2020 13:08:02 +0000 Date: Fri, 31 Jul 2020 14:08:02 +0100 From: "hch@infradead.org" To: Damien Le Moal Cc: "hch@infradead.org" , Kanchan Joshi , Jens Axboe , Pavel Begunkov , Kanchan Joshi , "viro@zeniv.linux.org.uk" , "bcrl@kvack.org" , Matthew Wilcox , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-aio@kvack.org" , "io-uring@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-api@vger.kernel.org" , SelvaKumar S , Nitesh Shetty , Javier Gonzalez , Johannes Thumshirn , Naohiro Aota Subject: Re: [PATCH v4 6/6] io_uring: add support for zone-append Message-ID: <20200731130802.GA16665@infradead.org> References: <20200731064526.GA25674@infradead.org> <20200731091416.GA29634@infradead.org> <20200731094135.GA4104@infradead.org> <20200731125110.GA11500@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200731125110.GA11500@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And FYI, this is what I'd do for a hacky aio-only prototype (untested): diff --git a/fs/aio.c b/fs/aio.c index 91e7cc4a9f179b..42b1934e38758b 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1438,7 +1438,10 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2) } iocb->ki_res.res = res; - iocb->ki_res.res2 = res2; + if ((kiocb->ki_flags & IOCB_REPORT_OFFSET) && res > 0) + iocb->ki_res.res2 = kiocb->ki_pos - res; + else + iocb->ki_res.res2 = res2; iocb_put(iocb); } @@ -1452,6 +1455,8 @@ static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb) req->ki_flags = iocb_flags(req->ki_filp); if (iocb->aio_flags & IOCB_FLAG_RESFD) req->ki_flags |= IOCB_EVENTFD; + if (iocb->aio_flags & IOCB_FLAG_REPORT_OFFSET) + req->ki_flags |= IOCB_REPORT_OFFSET; req->ki_hint = ki_hint_validate(file_write_hint(req->ki_filp)); if (iocb->aio_flags & IOCB_FLAG_IOPRIO) { /* diff --git a/include/linux/fs.h b/include/linux/fs.h index f5abba86107d86..522b0a3437d420 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -316,6 +316,7 @@ enum rw_hint { #define IOCB_WRITE (1 << 6) #define IOCB_NOWAIT (1 << 7) #define IOCB_NOIO (1 << 9) +#define IOCB_REPORT_OFFSET (1 << 10) struct kiocb { struct file *ki_filp; diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h index 8387e0af0f768a..e4313d7aa3b7e7 100644 --- a/include/uapi/linux/aio_abi.h +++ b/include/uapi/linux/aio_abi.h @@ -55,6 +55,7 @@ enum { */ #define IOCB_FLAG_RESFD (1 << 0) #define IOCB_FLAG_IOPRIO (1 << 1) +#define IOCB_FLAG_REPORT_OFFSET (1 << 2) /* read() from /dev/aio returns these structures. */ struct io_event {