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: 833608 Delivered-To: patch@linaro.org Received: by 2002:adf:a1d9:0:b0:367:895a:4699 with SMTP id v25csp448526wrv; Tue, 8 Oct 2024 11:48:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFsRwAHMVKjIq20Zu+Eh2KFUvf2RYr0CPCL2rGqgY6B7SSjGVBIUe28q6S9RZmDDp1tqze/g==@linaro.org X-Google-Smtp-Source: AGHT+IFjANq9Ed4suakb+33JLp/vb5c5ypUDUJk5QsgwbAhzy+aB3tDg56MmWnhvetetGOZoY/UX X-Received: by 2002:a05:6102:955:b0:4a3:bd34:11bb with SMTP id ada2fe7eead31-4a405780037mr10529649137.14.1728413319765; Tue, 08 Oct 2024 11:48:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728413319; cv=pass; d=google.com; s=arc-20240605; b=W0TLTAr/rKuB/eZcRgvmEkN/YIIjSbRKHD2KYUL1k12DRlixhfcmBfjmeu62CTknTV SwZBG1lGGvL+y569uJpawSne6OB/tXYTUIKW6vA+UleL0Pg5KepL9CwQfz9I4yrq9zvG YSxtfQq8TudLrEmlCzhfi5RD8TFBpb5WNMPDTL4dRmo/JkhpeH7yBWCko7aaOM7tkfUJ djK9M6bWLlrL5vFsiWDtjT/8z2H64J0ZuA6nqpLwTQQB1mXO0lnIIS+LwMIzxAgyLqDK J7uR95fLUIZTmnS8piI4z6w5R/UXgKswocPrmH0r10c7PmxcICOTKnNpqFteM3WVZ/5X Hi1Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Yugl+fzHUaSuJP5DmRFd4Zg5nfU3j/2AGy3BgOBBXes=; fh=y8c+zjefmHK4fStUusN64Sx8n6mpTt8O9P1WOVzrReM=; b=d2Y1aS1Nxj0pXAprDSz7qQiep1DTPFWvLFoz6BO44RN5rMs4NjedYfofxiik2WXsOd 15d0j922ZJIw2Kv9c/XICtgajF7fY7pD1OeTQXtCH/eMPZT9Qd/8KtTZjtrVIJxQlPIW Hra/FyhBmmwlh/JbcVsm823n7wqh3EmQUcTvAl2FnG/rlK8ZJ72R3uMLEdxWphVDk9Z6 jBjZCR32/bkF+Lvq/mFWaTwblQo0El7R/A3/oRKVU/98sg+wxNzC0rOuvlrM7GACWtdX N+WlEHlJ3fR4db6b59qB6jCzjRNOXe8kyu6jnCcne/FBlHnJ8DnTG0ZDBB1m5YWiUV9O 3w6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYRRLgfl; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d75a77b69052e-45da74ea495si88402421cf.163.2024.10.08.11.48.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 11:48:39 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UYRRLgfl; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5148E3850203 for ; Tue, 8 Oct 2024 18:48:39 +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-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~patch=linaro.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