Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp43866ybh; Mon, 20 Jul 2020 09:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaBsqIWi05dR8UAstLLvkOziPdBpaK9iBUEoO2/Hm+jNJ46FydCmZ4CEAkosg3fg+nDKxA X-Received: by 2002:a17:907:aad:: with SMTP id bz13mr22319226ejc.276.1595263993722; Mon, 20 Jul 2020 09:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595263993; cv=none; d=google.com; s=arc-20160816; b=JFq0ykBW5CCrvrRJfIHvprGHgMDK+W+LiV86tdx8WF8DspmylSf9xIc53QJrpgyX/C bCwcKBcmzrqak2wkLAgxoPpywgb1nb6BFa+uXxZapFB8FCCfS0SisqiOaEm/QtYAJbB9 7yjUEx/SXokqiTgrRr4lSDUTQiHKwDk7lsE39nSan0qTNKEjarrakPFbDnIHNTA+9XU8 JTrqUu4VXLUEFHNEzbs+GztDRpvNe/4NtDlV35klsE29lcy+NrTVtDv3QufRY50prz+O dfBX8Y7MEBwUidsLN/uEUPFdjkXHFG7h4gDxXOnOqz9/3TyvC3DOKfEcc5b+32/PX4LU XrYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=C4b8qhvwAjwGhT6JyfXt5H1f2fkHwdgJiTZMLInpoWY=; b=F/swvcYybyQ+fC5N/cQU1JGnqKBbLVlwOaE1l98nZUNSJZIsANFd6qhoXtke9l2yRd NPwjUd9IN1ipcbx4yMUZYffc6YhiRHW7UYYfuJJc5WCydb19ZJAIKe7B30uBZW6T2Eb6 vFQKcEEskFlK1BALgWfZndfkZwSmy4o3Ri01+elUq790pEGdZ+pbIb59mPNxgd5mh951 90O6q0U9bYn9TywR7dDXv2PXMGE3rgxfQb/RhObycz1lhHQZJcbSLFqc2dZKOp51ebHU li4vVrmZS+AgZOQiLMD6MROq2GRBS/eqJ68Bwb6/9zO6xTOqZJ1noZ0HwxbQYUo/RzXN h5sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GgOnivf6; 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 gl18si10350725ejb.588.2020.07.20.09.52.50; Mon, 20 Jul 2020 09:53:13 -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=GgOnivf6; 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 S1729771AbgGTQu0 (ORCPT + 99 others); Mon, 20 Jul 2020 12:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728495AbgGTQuZ (ORCPT ); Mon, 20 Jul 2020 12:50:25 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49520C061794; Mon, 20 Jul 2020 09:50:25 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id o2so199691wmh.2; Mon, 20 Jul 2020 09:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C4b8qhvwAjwGhT6JyfXt5H1f2fkHwdgJiTZMLInpoWY=; b=GgOnivf6O+qwfUQUg2D0y3V0uajSxUn+4a5Q0Y5M//QasuxiU8RHZZn1QL0HBjDCbl iUAfDLFaqvv8m0HXaPekB/UL3aUJHgT371PTLFy2LuffToVmY93vEXxpjdkoggrcDtRF Un03YyD+9nc+MZA39zGLDH/J3s4J6xxPPe0IeVxW8L79nBV2HJggUcfSQur+WGv7ilXA fe8YI85YZfKb9CbDfxloBSKCAu3h5PtcGaQdXdT3ztcqhrBfazl31QLCX3x7UN3UaNyf XP5bPuN2AHaA2KxUwSltX5CLE+zZ84QPu3yaHrqZmHGDo6mEv5zFFxzVYGp/fLkhuDTl mN2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C4b8qhvwAjwGhT6JyfXt5H1f2fkHwdgJiTZMLInpoWY=; b=WflUH8LMEhdFv85KNuhOXKFHEfMGx/E/+L2OMcIjxe7Kgx02+itPyQWLF7m3wdDZQu bE82LbXCgv14RNs4WBO+d4hbu5/NSKbeZnFDA6hvGoQHywUkltbYDiGci+536DhEpXow sSUAx8IMLZG/xjVUibGB+NVOoVcGdI3zsYY2u3ZOmfcRbfvJMnzv83SBVq3VuiMgKmgL rW+q5BgWh+DnQ5BJR9hkl4eTzXTh3a1R5h7RpOyd+2YAYTuYvBHSKlhZfVM1zT26vH76 zqNkmuQm1/rXz+KfndDj/IK5u8BMpvRjffD/L8EQ9LxxMmfXD7qw/QUUfnFw6W+BwxBV nUqQ== X-Gm-Message-State: AOAM530fMwpdjW0T4LA5m3n3CTaH9mPqRhKtxzeCA3PjP42SlOXugtMQ tjN2KCL3D9Z91swOkFoqA6v8e5P0w5WNcq2+lLU= X-Received: by 2002:a1c:2485:: with SMTP id k127mr231539wmk.138.1595263823888; Mon, 20 Jul 2020 09:50:23 -0700 (PDT) MIME-Version: 1.0 References: <20200709085501.GA64935@infradead.org> <20200709140053.GA7528@infradead.org> <2270907f-670c-5182-f4ec-9756dc645376@kernel.dk> <20200710131054.GB7491@infradead.org> <20200710134824.GK12769@casper.infradead.org> <20200710134932.GA16257@infradead.org> <20200710135119.GL12769@casper.infradead.org> In-Reply-To: From: Kanchan Joshi Date: Mon, 20 Jul 2020 22:19:57 +0530 Message-ID: Subject: Re: [PATCH v3 4/4] io_uring: add support for zone-append To: Matthew Wilcox Cc: Christoph Hellwig , Jens Axboe , Kanchan Joshi , viro@zeniv.linux.org.uk, bcrl@kvack.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, "Matias Bj??rling" , linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, Selvakumar S , Nitesh Shetty , Javier Gonzalez Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 10, 2020 at 7:41 PM Kanchan Joshi wrote: > > On Fri, Jul 10, 2020 at 7:21 PM Matthew Wilcox wrote: > > > > On Fri, Jul 10, 2020 at 02:49:32PM +0100, Christoph Hellwig wrote: > > > On Fri, Jul 10, 2020 at 02:48:24PM +0100, Matthew Wilcox wrote: > > > > If we're going to go the route of changing the CQE, how about: > > > > > > > > struct io_uring_cqe { > > > > __u64 user_data; /* sqe->data submission passed back */ > > > > - __s32 res; /* result code for this event */ > > > > - __u32 flags; > > > > + union { > > > > + struct { > > > > + __s32 res; /* result code for this event */ > > > > + __u32 flags; > > > > + }; > > > > + __s64 res64; > > > > + }; > > > > }; > > > > > > > > then we don't need to change the CQE size and it just depends on the SQE > > > > whether the CQE for it uses res+flags or res64. > > > > > > How do you return a status code or short write when you just have > > > a u64 that is needed for the offset? > > > > it's an s64 not a u64 so you can return a negative errno. i didn't > > think we allowed short writes for objects-which-have-a-pos. > > If we are doing this for zone-append (and not general cases), "__s64 > res64" should work -. > 64 bits = 1 (sign) + 23 (bytes-copied: cqe->res) + 40 > (written-location: chunk_sector bytes limit) And this is for the scheme when single CQE is used with bits refactoring into "_s64 res64" instead of res/flags. 41 bits for zone-append completion = in bytes, sufficient to cover chunk_sectors size zone 1+22 bits for zone-append bytes-copied = can cover 4MB bytes copied (single I/O is capped at 4MB in NVMe) + * zone-append specific flags +#define APPEND_OFFSET_BITS (41) +#define APPEND_RES_BITS (23) + +/* * IO completion data structure (Completion Queue Entry) */ struct io_uring_cqe { - __u64 user_data; /* sqe->data submission passed back */ - __s32 res; /* result code for this event */ - __u32 flags; + __u64 user_data; /* sqe->data submission passed back */ + union { + struct { + __s32 res; /* result code for this event */ + __u32 flags; + }; + /* Alternate for zone-append */ + struct { + union { + /* + * kernel uses this to store append result + * Most significant 23 bits to return number of + * bytes or error, and least significant 41 bits + * to return zone-relative offset in bytes + * */ + __s64 res64; + /*for user-space ease, kernel does not use*/ + struct { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u64 append_offset : APPEND_OFFSET_BITS; + __s32 append_res : APPEND_RES_BITS; +#elif defined(__BIG_ENDIAN_BITFIELD) + __s32 append_res : APPEND_RES_BITS; + __u64 append_offset : APPEND_OFFSET_BITS; +#endif + }__attribute__ ((__packed__)); + }; + }; + }; }; -- Joshi