Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp561876rdb; Fri, 6 Oct 2023 11:17:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWxcDwUuU4RDl0XukIqdKpWAWYPH0qjsjd6S3WCZ3erjCEISAgIoI/+2SxzzS17Oh8uo9U X-Received: by 2002:a17:90b:38cb:b0:268:1745:b61 with SMTP id nn11-20020a17090b38cb00b0026817450b61mr8474020pjb.34.1696616243090; Fri, 06 Oct 2023 11:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696616243; cv=none; d=google.com; s=arc-20160816; b=XbDNuzoDZe7H44MJo2UJgUXfxdB5W1g7Qjp7BztNA39TcTF90b61oI9IFEiswxqLKK P3X1LdzhQhHDAbNpJK2QvDOQ/0b+QtaGnaEYllDMoeL3axNEGJ9ckL2ruJ6d47nmVUa1 7IrtjPWnqTRfL18sbqFBnzChQCODRPVKR9wyAnAyMlJQGZOuiF6iYNxRzxprOkuRv0T8 rkPUp2iUOYMrcwdMEHrYdXUtHoLabtSEVC1aD6Wikp29R4iwxzUVfcnnzZqe7X8OS0lX Zz2n1IrTpPDXH+bSD3q1sFQglc7pWW4zBCriD4yNVmcF3Q8+iwfz4a2eDYOjfvaE0Xzp qUUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AYLhV8RKvbCInhnzqZ/HGBAbLzuMZXeZ10wGn+QIDt0=; fh=nNV/zBR7zcfYrHAKTH4r0wHs441HqWO9LxxWVHbg2Bw=; b=fBEQXZz7hPrX/eDhU3W1fIPCXxNkmGyU/rC6YbsYRZ4qzvvzzdSMX9K/WZO+8xD0mI nIOb9q1yhBsREyF9kq+bzbRyu8kuoWRfGY5G1wDZeXxUcOxqJ0mvDjVrKFOmgcZqy7PB 2+/qjjc0/DgKfSdyboKqDmoyc2r4RfY56FpWGqd8HvZqHtR0kk7natmeSpcW4YKSXGAN uTlv2r0CCGM/kqn8DWHyNVTWir9X9rHGyJD9EFwrTrlPN/+K97LUW53+EUu/LjNQaRUa DbrxAWizsMVks7vkUfChaU6e+dwhymQ163axkW786Z34beA0pFZNJuBDeB+Kz6c58pRC rjmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="agZMnV/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id gk19-20020a17090b119300b002770c306d55si6398028pjb.87.2023.10.06.11.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 11:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="agZMnV/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DB1C68082DEA; Fri, 6 Oct 2023 11:15:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbjJFSP0 (ORCPT + 99 others); Fri, 6 Oct 2023 14:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232983AbjJFSPZ (ORCPT ); Fri, 6 Oct 2023 14:15:25 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C720BBE for ; Fri, 6 Oct 2023 11:15:23 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-d81afd5273eso2605690276.3 for ; Fri, 06 Oct 2023 11:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696616122; x=1697220922; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AYLhV8RKvbCInhnzqZ/HGBAbLzuMZXeZ10wGn+QIDt0=; b=agZMnV/HJlJNR+eXnUqkrCNrnhdt8cTuH8KPxM8I0UlHzDgSB7yZOnfEzjuFFKmcys px5mNgUlWMDvOhhIQ0tlHY+8PJ6lEWdjJPSApcLl/imzQggHqLnKYP1xPJpvbKX7Pxv/ 8kR/kNwBWBPMQjEU7AXu3y2seqJXmjp4CTdY4oB1MHnwBAD2awuAUZPZnHR4vh0brRey GhZvL/kPa8oQLPzBPzQ1kfkPRDz7LJIeNOKK/15bFxj9KCs7KIWsjDEqTIHOSh+IwdEf ag4eZsxXhkYwVL5qydQ7mcnxfV/I44GhPcxTxAOWs1vxEnC+e8YwG+HGK+zixX8m9djt T7vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696616122; x=1697220922; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AYLhV8RKvbCInhnzqZ/HGBAbLzuMZXeZ10wGn+QIDt0=; b=pP/jW2hjOm2HS5IVM9Z8TVM16SrfixcPN3cfXzErGlYMvpuyU6fb2sBtHx2eFARStY f+AhSVKCfP3eC6Oixp4tPLAmGz/ippQcgTinMt5SOheQNIN9f2allb0/tPCpJWPxInbD jwKYJmF4TbbGCiCCnA2N/eTuIlhJZXtQlWCpgTSzRkGx99E5wOT7/zdhSaUmODoOqmxh cbrcCRrMwZCYYH8lFnvoSZSLw/84pw4TAQIhv6RwdtVWpj8vC2E/OAnRB2pk067sF6Z9 O3sFud3vR+0CdReW2gwKS0yk6w2OKjGFyJSJfV9bhSXG/VKzE+is70KGlzGl2l1fjMaD K/fg== X-Gm-Message-State: AOJu0Ywfqxjmc/xaiQWzerJA8KbVLRCtTtkllVisHV/kCo5psZTYB9qL PICfWnNrC9fgWzvSR2wMZkXTxPpkd7SpW268bGlu6w== X-Received: by 2002:a25:509:0:b0:d7f:cdc8:e184 with SMTP id 9-20020a250509000000b00d7fcdc8e184mr8607707ybf.49.1696616122514; Fri, 06 Oct 2023 11:15:22 -0700 (PDT) MIME-Version: 1.0 References: <20230929102726.2985188-1-john.g.garry@oracle.com> <20230929102726.2985188-5-john.g.garry@oracle.com> In-Reply-To: <20230929102726.2985188-5-john.g.garry@oracle.com> From: Jeremy Bongio Date: Fri, 6 Oct 2023 11:15:11 -0700 Message-ID: Subject: Re: [PATCH 04/21] fs: Add RWF_ATOMIC and IOCB_ATOMIC flags for atomic write support To: John Garry Cc: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, chandan.babu@oracle.com, dchinner@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, linux-api@vger.kernel.org, Prasad Singamsetty Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 06 Oct 2023 11:15:39 -0700 (PDT) What is the advantage of using write flags instead of using an atomic open flag (O_ATOMIC)? With an open flag, write, writev, pwritev would all be supported for atomic writes. And this would potentially require less application changes to take advantage of atomic writes. On Fri, Sep 29, 2023 at 3:28=E2=80=AFAM John Garry wrote: > > From: Prasad Singamsetty > > Userspace may add flag RWF_ATOMIC to pwritev2() to indicate that the > write is to be issued with torn write prevention, according to special > alignment and length rules. > > Torn write prevention means that for a power or any other HW failure, all > or none of the data will be committed to storage, but never a mix of old > and new. > > For any syscall interface utilizing struct iocb, add IOCB_ATOMIC for > iocb->ki_flags field to indicate the same. > > A call to statx will give the relevant atomic write info: > - atomic_write_unit_min > - atomic_write_unit_max > > Both values are a power-of-2. > > Applications can avail of atomic write feature by ensuring that the total > length of a write is a power-of-2 in size and also sized between > atomic_write_unit_min and atomic_write_unit_max, inclusive. Applications > must ensure that the write is at a naturally-aligned offset in the file > wrt the total write length. > > Signed-off-by: Prasad Singamsetty > Signed-off-by: John Garry > --- > include/linux/fs.h | 1 + > include/uapi/linux/fs.h | 5 ++++- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/include/linux/fs.h b/include/linux/fs.h > index b528f063e8ff..898952dee8eb 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -328,6 +328,7 @@ enum rw_hint { > #define IOCB_SYNC (__force int) RWF_SYNC > #define IOCB_NOWAIT (__force int) RWF_NOWAIT > #define IOCB_APPEND (__force int) RWF_APPEND > +#define IOCB_ATOMIC (__force int) RWF_ATOMIC > > /* non-RWF related bits - start at 16 */ > #define IOCB_EVENTFD (1 << 16) > diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h > index b7b56871029c..e3b4f5bc6860 100644 > --- a/include/uapi/linux/fs.h > +++ b/include/uapi/linux/fs.h > @@ -301,8 +301,11 @@ typedef int __bitwise __kernel_rwf_t; > /* per-IO O_APPEND */ > #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010) > > +/* Atomic Write */ > +#define RWF_ATOMIC ((__force __kernel_rwf_t)0x00000020) > + > /* mask of flags supported by the kernel */ > #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ > - RWF_APPEND) > + RWF_APPEND | RWF_ATOMIC) > > #endif /* _UAPI_LINUX_FS_H */ > -- > 2.31.1 >