Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1425745rdd; Wed, 10 Jan 2024 21:03:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGblpAcoj23SoruzTbGFDvwlBe7qSq6gJdOIPHPaY9w5uqIp6CUJYX/dcv6Icif/8ofUhO8 X-Received: by 2002:a17:907:7215:b0:a2c:225b:a03c with SMTP id dr21-20020a170907721500b00a2c225ba03cmr328046ejc.21.1704949401261; Wed, 10 Jan 2024 21:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704949401; cv=none; d=google.com; s=arc-20160816; b=G0h79XpCWQEh/DEyCxeNBZtDxseOwXTH0rj5j09FYVDZShuEWsgi9iuMt30rTTwZSj w7f8Zyw3ETY8AS6PI8zZ+dfa72fmtr5vuA3NpM8+k5zs8a5joSMJ57gzxJs+BB4MAvg5 nDl2fz6DwhlLg+kACZu6rroeDhL0cNbvx4i2PhkeYr5DWKObQH7K6dhFS0+jWbVXwdQm lYGrL7qmZBsz1Z1Qs/v3lO7nEfj2dMCQ3jvzrC+6sAPNiyIq1GqIr10C5T/5M+XDfwfx mWNZ52Nemyr/AHQnki6NJyylV58R7NMq4XeXF7S5tZgGXX134bixwd76Cyxq4eg37jKE Zpzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=0HsQvP22IqvAprAUrWo9wX//o45hQJSEEnY0Adf591g=; fh=P5VsqkV850Ij9C3sM8smW4Lx+RO6g/2QV6qezGXaoTw=; b=GAL5Rg5b3ZkGsorRtijRZ5oFOxUiijGaY5GkHanuCI99e08f0k8MiYmVzy3DR7WyF+ ZuZvSmJL6t+w/s5A0rT1oCUQg1ir7CEd7nWDWdQufEJEp5iDmCN99q5K7ldaLPi6n+L/ Mm/0kpmSPZal/Gyn//TjqoUBwkPkN68cqHB9kEf8Bj3tpKy93hafGZxotOkuBH1y1SAC KNEmnRbSxtUeevdrnOlR5Jb1s5Hx4m7PhYCBWZn5iX7kcwd7HQt4mydIAE4zG/QvAXR+ TttaSGkyuDGZlyVin0LOh7kafRa3XZEgtMMinv/VjiOuc8G9BvdobhZe04YdqBqgeUhB Ku9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23067-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r17-20020a170906281100b00a2ba4b0f8bdsi147061ejc.774.2024.01.10.21.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 21:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-23067-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23067-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 04B501F24200 for ; Thu, 11 Jan 2024 05:03:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62983569C; Thu, 11 Jan 2024 05:03:05 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 004DA4693; Thu, 11 Jan 2024 05:03:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 2AD3D68CFE; Thu, 11 Jan 2024 06:02:57 +0100 (CET) Date: Thu, 11 Jan 2024 06:02:57 +0100 From: Christoph Hellwig To: "Darrick J. Wong" Cc: Christoph Hellwig , Dave Chinner , John Garry , axboe@kernel.dk, kbusch@kernel.org, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz, 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, jbongio@google.com, linux-scsi@vger.kernel.org, ming.lei@redhat.com, bvanassche@acm.org, ojaswin@linux.ibm.com Subject: Re: [PATCH v2 00/16] block atomic writes Message-ID: <20240111050257.GA4457@lst.de> References: <20231219051456.GB3964019@frogsfrogsfrogs> <20231219052121.GA338@lst.de> <76c85021-dd9e-49e3-80e3-25a17c7ca455@oracle.com> <20231219151759.GA4468@lst.de> <20231221065031.GA25778@lst.de> <73d03703-6c57-424a-80ea-965e636c34d6@oracle.com> <20240110091929.GA31003@lst.de> <20240111014056.GL722975@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240111014056.GL722975@frogsfrogsfrogs> User-Agent: Mutt/1.5.17 (2007-11-01) On Wed, Jan 10, 2024 at 05:40:56PM -0800, Darrick J. Wong wrote: > struct statx statx; > struct fsxattr fsxattr; > int fd = open('/foofile', O_RDWR | O_DIRECT); > > ioctl(fd, FS_IOC_GETXATTR, &fsxattr); > > fsxattr.fsx_xflags |= FS_XFLAG_FORCEALIGN | FS_XFLAG_WRITE_ATOMIC; > fsxattr.fsx_extsize = 16384; /* only for hardware no-tears writes */ > > ioctl(fd, FS_IOC_SETXATTR, &fsxattr); > > statx(fd, "", AT_EMPTY_PATH, STATX_ALL | STATX_WRITE_ATOMIC, &statx); > > if (statx.stx_atomic_write_unit_max >= 16384) { > pwrite(fd, &iov, 1, 0, RWF_SYNC | RWF_ATOMIC); > printf("HAPPY DANCE\n"); > } I think this still needs a check if the fs needs alignment for atomic writes at all. i.e. struct statx statx; struct fsxattr fsxattr; int fd = open('/foofile', O_RDWR | O_DIRECT); ioctl(fd, FS_IOC_GETXATTR, &fsxattr); statx(fd, "", AT_EMPTY_PATH, STATX_ALL | STATX_WRITE_ATOMIC, &statx); if (statx.stx_atomic_write_unit_max < 16384) { bailout(); } fsxattr.fsx_xflags |= FS_XFLAG_WRITE_ATOMIC; if (statx.stx_atomic_write_alignment) { fsxattr.fsx_xflags |= FS_XFLAG_FORCEALIGN; fsxattr.fsx_extsize = 16384; /* only for hardware no-tears writes */ } if (ioctl(fd, FS_IOC_SETXATTR, &fsxattr) < 1) { bailout(); } pwrite(fd, &iov, 1, 0, RWF_SYNC | RWF_ATOMIC); printf("HAPPY DANCE\n");