From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A606296BD2 for ; Thu, 12 Feb 2026 11:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770897113; cv=none; b=GgL3pZarKEaHxFda0XlB13pvLfORELOt6YlMMKniG5OAXwy5VJmX3M1a5yw1bCt/PaCKbyfYUzOSjUyUZsvVZmsF4/p3V7ilKd42VwoLER2rYcdceQBq0lG6YuEmYnDPhdHMuu1Q4Jhzel1hjCMmYj20ASThv5Wrj+B5VsenZfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770897113; c=relaxed/simple; bh=XjSWJvCqXNs6KFHlJCEjDBXFilEFAsp8RQ/y0dAQPl8=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=fuPAF4BwAbPU531X/BDoHCxe2h7BLvypbSmkkavFipDeVdnwgPndx86DXm1TQLI+UEQhmPS2/8FdWB7neKKi0TLy5AkovyPhcaS1AXzgqR1S2tZf4agprnO/9EN1AZjBHZuSAESzT3SYWn4RDe1PmfB72B8P5jGiyp8EYEuobeE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FhQMjqt9; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FhQMjqt9" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-38709eaf012so12661171fa.0 for ; Thu, 12 Feb 2026 03:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770897110; x=1771501910; darn=vger.kernel.org; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=icNB5xuvo+j+qezx7gqf5Y6Yw5qJ0+ofGzzhpNwJwdA=; b=FhQMjqt90S68QJBXL9jHocY7B1/g5ZRIw4R14Jz+q8ubrflb3FFjMjVVlBxz2Hi0VC 0dnIBz/gzOseJszrl/f6To9dnq3zIQmBrE2uq6bq0Ovnr3t6Ia26bEm/EL3ZVhgKGiZZ wQ//I9DlDaDkl9wDQF/XYTMzSS6V1ph0rqylYdQcs3t19ho+cjMCq+OqV9gLICvEpsZr Y06Sm3TKWgqdUHJhAHoRcyfWmegywK32x990iLePGZFvgtE1Fpv0CJZ08tt3/hZBJNDx yMjYZXUOv1u0ya1pDSipjc908Q1650HRawkTSMMf6GcDdJb2iLZfYEMQYvDiMb9kVIex /d8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770897110; x=1771501910; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=icNB5xuvo+j+qezx7gqf5Y6Yw5qJ0+ofGzzhpNwJwdA=; b=pRoH3GdOy0WSFbgtASv4RzyAGgj3q/cAv/GSajsTqqLfnbw9m42ChFfrdnR3jFuTAL Fg6WGF2ZOecwZIakMTefS0YQe+RAXzQdI309aP6qf4MpAtzYTmHGN0MTdu5o81VM7E7h z4bcw92fjKpNkoXmpO7zkh38dRj9Zxelxoir5/ibyhjH+/PaddnbOCc/nqlQYupTzW9/ 35iKhMAjMRSVy90On9HeYKEKaURhkFll7MdSxQa6EUlykmifQXWWzQvZlfoSSgebytI9 OAq6+e0WWSWLvF8fOqa1C9MHBXKigpEpIY29dwaK1QI70nFsAcTt6lmGUPy/neM725jC 0buQ== X-Forwarded-Encrypted: i=1; AJvYcCV6z9fFVwnY9adVx4iYRmHNIIu5JvbTt0RTcm2t7I7Fj5b9jnr28eZM3jlxwzRQfOzKyu9OianU8pUJAL8=@vger.kernel.org X-Gm-Message-State: AOJu0YxjNARh+c3XnzlTvSbx2BUQsRkCtxjZU7Sl4Ksq3C+HAXM7Pa1S efiZSFEmdL8u1nLEtKNperlI6GbW00KyHJAO1ZLJNsf1jHa0TLI1sAFp X-Gm-Gg: AZuq6aI0uZO0wrzyB3bmt9KH2eygDeKpViP7dcavfp0cyO9U5ATzuasn5IISP/yV0ct twYbE1gLMpRPHvtn/8nTBWnAjlxQ/pWp2cWGkEYOWYuWIClRKpF+IgGiZ1int1lakyOqlJscg2R j7XHcxzQ/a+gyqz/vD2jpQOsinoa3G202UFL9LPaOrFyIRLzEiMuBu3hzffUnfyPw/mzeju3Dj8 JtqJlM1uUUnSJQ9oGn2LYMLgaprM26FQr66IYrOuUSYMllnu67F4chqUDG8NV5YBomJhQkbpVpF YAWfd1qxUglzdMPvhLO2VdHmQah+HGvl9XlGR+G8fBrtArG8XatsMli35TVmIbT3H9O2mbwi5/Y dBmpkjHL9shq86bh+V043nHegflqUUvtzwkg5JIghplACcX89rLwzkQhkUY9W3zIQXA/fgDsLqD 1lwido7JoZDpjQvHqrFNF9gLKhLzN48hx1kpFQEHBb4BC1 X-Received: by 2002:a05:651c:4193:b0:382:624d:a703 with SMTP id 38308e7fff4ca-38712c1064amr7134971fa.45.1770897109932; Thu, 12 Feb 2026 03:51:49 -0800 (PST) Received: from [10.128.170.182] ([77.234.210.12]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-3870689e107sm7206681fa.14.2026.02.12.03.51.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Feb 2026 03:51:48 -0800 (PST) Message-ID: <4b207a36-5789-41d2-ac17-df86d4cde6da@gmail.com> Date: Thu, 12 Feb 2026 14:51:47 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: viro@zeniv.linux.org.uk, brauner@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org From: Vyacheslav Kovalevsky Subject: File name is not persisted if opened with O_SYNC and O_TRUNC flags Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Detailed description ==================== Hello, there seems to be an issue with O_SYNC flag when used together with O_TRUNC on various file systems. Opening a file with O_SYNC (or using fsync(fd)) should persist directory entry. However, if O_SYNC is used together with O_TRUNC the file will be missing if system crashes. According to POSIX this is OK, but most file systems provide stronger guarantees (would be actually nice to have a more recent documentation on this behavior). This happens on Btrfs, ext4, XFS, F2FS and likely other file systems. System info =========== Linux version 6.19-rc7, also tested on 6.17 How to reproduce ================ ``` #include #include #include #include #include #include #include int main() {   int status;   status = creat("file", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);   printf("CREAT: %d\n", status);   close(status);   status = open("file", O_RDWR | O_TRUNC | O_SYNC);   printf("OPEN: %d\n", status); } // after the crash `file` is missing ``` Steps: 1. Create and mount new file system in default configuration. 2. Change directory to root of the file system and run the compiled test. 3. Cause hard system crash (e.g. QEMU `system_reset` command). 4. Remount file system after crash. 5. Observe that file is missing.