From patchwork Tue Oct 8 18:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1994379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=UYRRLgfl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XNQ5p3DLKz1xsn for ; Wed, 9 Oct 2024 05:48:46 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 733DF384F4B8 for ; Tue, 8 Oct 2024 18:48:44 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 7F196386182B for ; Tue, 8 Oct 2024 18:46:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7F196386182B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7F196386182B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728413211; cv=none; b=A1RQ9sC52AQUEtNmLwwG1M3reaUjZzUBWi5Jm8iqArAAQQ5NEK5NDCE9mgZs+p5+0p4+bvwv1G9Xte7g2o98vooRqIJD1NGGZ4YE4GTTz6LmxTcYdTLeT7CzDLAhE8xoqKth+5lOg5pR3ah28IuwNaMeIQTSuOnOyAjg20Yciaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728413211; c=relaxed/simple; bh=/aYQGAU3Su135GPwzEH+L6A8bBFw0QPCrlz8CW+nnVQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=k4ghMfG9mZjz5YaCjwo6fBoa5TIlYufVZel+Q5ozM3ieOFZWkEd0zjZHxWEl5+Qhcx+Iw9tYRbmct8yfOqPib188femh4tBhyYP2TEGdc2Y3WH02j2HgO7r/mhvBuZv1lKd3EKrzGfkLAjIwsVGCqXmjgwg6BBY9VhgyIAgaQ04= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-20c593d6b1cso8501095ad.0 for ; Tue, 08 Oct 2024 11:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728413208; x=1729018008; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yugl+fzHUaSuJP5DmRFd4Zg5nfU3j/2AGy3BgOBBXes=; b=UYRRLgfloSDbJlx0SEZqr3XAhHik5ZPM5gKKb3cwlXIA0aZhvNevjyGjNsyctAUtUy twJggcuwyA5s6J1F70HeKBQOYkspMLpONRWrPPtaDuQSMlIAyUbOXfPUVqE7J5XXkX8m fYeC+SwCiObrcJz7CeVnFT15orR5TfSOVJZnPaTOi8UaPNfOtkPiSjTzsC+mwnpBveak psev/MPcTXTdJqZB2HiPu/uhj4ORwhMVct4jTGWwkjQUiP7aTRbN1lBMVfOt9uTjpvtY p6T1R6H76ArWPBDL4HiZDwJueTHUmpPirDeeuW6nO+GMTsrjXO9Dys0dOI6fmjTKj2Ta a0pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728413208; x=1729018008; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yugl+fzHUaSuJP5DmRFd4Zg5nfU3j/2AGy3BgOBBXes=; b=aJ2VTP6U3zoJR6aFSUQ1DVBFNdiLgTS7vF/2rejl4ZwNt1pGMurVfspkzbDrhoZMSp uL6fSBzommM35D1+5BB/p5UKwpvkd/CQPAso+hb1WT1iXzbZ7jYvqJeSoKnisX+o81Vz 675BuqfpEgmN9w+hlozY61fY+lPJLEMOxvpVcqSXJLNuwDLRFAbNRPNlBhPrSveZlDRH wsNsTWvb4M+fLkSz5zd8tvJ8P228v6e8TfhJVH4S9/j7o6C8gfr+9FNw/Su1J/sKgbHn uxLWFJtNFqaTc2dOvcYFcTD+uwBqfiJCI1M6DPA/PS7yH2hJ7/8GC7fUvj8Xwgcc7L2b upTw== X-Gm-Message-State: AOJu0YwTwwm3sLV6qfHZofq1Ru3EaM9mAAOVsjpfSFpN3Fe70MCSp8XY 5CVnVis+ybi9V9Rckyq229I/Wkgv2ne+hbMR5hSEjxYlWS1d7ut/jmFESsGpa3CDUoNQIR2+kq5 aUIQ= X-Google-Smtp-Source: AGHT+IHPe/WVbCUFaYRgV19oFBFArQZg/drmuXF2+5yjz0kan4bs01J47jWvO7aq+eGrPa6Iy/a/jA== X-Received: by 2002:a17:903:41d0:b0:20b:5fb6:8dd4 with SMTP id d9443c01a7336-20bfdfd51c3mr237748725ad.21.1728413208325; Tue, 08 Oct 2024 11:46:48 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c2:68d6:61bb:ff14:bcb3:8ace]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c1395dc41sm58068535ad.217.2024.10.08.11.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 11:46:47 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers Subject: [PATCH v2 7/8] misc: Add support for Linux uio.h RWF_ATOMIC flag Date: Tue, 8 Oct 2024 15:45:29 -0300 Message-ID: <20241008184634.245607-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008184634.245607-1-adhemerval.zanella@linaro.org> References: <20241008184634.245607-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Linux 6.11 adds the new flag for pwritev2 (commit c34fc6f26ab86d03a2d47446f42b6cd492dfdc56). Checked on x86_64-linux-gnu on 6.11 kernel. Reviewed-by: H.J. Lu --- manual/llio.texi | 13 +++++++++++++ misc/tst-preadvwritev2-common.c | 5 ++++- sysdeps/unix/sysv/linux/bits/uio-ext.h | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/manual/llio.texi b/manual/llio.texi index 05ab44c6e7..0eb336f70b 100644 --- a/manual/llio.texi +++ b/manual/llio.texi @@ -1381,6 +1381,19 @@ Per-IO synchronization as if the file was opened with @code{O_APPEND} flag. @item RWF_NOAPPEND This flag allows an offset to be honored, even if the file was opened with @code{O_APPEND} flag. + +@item RWF_ATOMIC +Indicate that the write is to be issued with torn-write prevention. The +input buffer should follow some contraints: the total length should be +power-of-2 in size and also sizes between @code{atomic_write_unit_min} +and @code{atomic_write_unit_max}, the @code{struct iovec} count should be +up to @code{atomic_write_segments_max}, and the offset should be +naturally-aligned with regard to total write length. + +The @code{atomic_*} values can be obtained with @code{statx} along with +@code{STATX_WRITE_ATOMIC} flag. + +This is a Linux-specific extension. @end vtable When the source file is compiled with @code{_FILE_OFFSET_BITS == 64} the diff --git a/misc/tst-preadvwritev2-common.c b/misc/tst-preadvwritev2-common.c index 8e04ff7282..4556421a43 100644 --- a/misc/tst-preadvwritev2-common.c +++ b/misc/tst-preadvwritev2-common.c @@ -37,8 +37,11 @@ #ifndef RWF_NOAPPEND # define RWF_NOAPPEND 0 #endif +#ifndef RWF_ATOMIC +# define RWF_ATOMIC 0 +#endif #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT \ - | RWF_APPEND | RWF_NOAPPEND) + | RWF_APPEND | RWF_NOAPPEND | RWF_ATOMIC) /* Generic uio_lim.h does not define IOV_MAX. */ #ifndef IOV_MAX diff --git a/sysdeps/unix/sysv/linux/bits/uio-ext.h b/sysdeps/unix/sysv/linux/bits/uio-ext.h index ead7a09156..85ed21bac5 100644 --- a/sysdeps/unix/sysv/linux/bits/uio-ext.h +++ b/sysdeps/unix/sysv/linux/bits/uio-ext.h @@ -48,6 +48,8 @@ extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec, #define RWF_NOWAIT 0x00000008 /* per-IO nonblocking mode. */ #define RWF_APPEND 0x00000010 /* per-IO O_APPEND. */ #define RWF_NOAPPEND 0x00000020 /* per-IO negation of O_APPEND */ +#define RWF_ATOMIC 0x00000040 /* Write is to be issued with torn-write + prevention. */ __END_DECLS