From nobody Sun Apr 09 07:23:54 2023 X-Original-To: fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PvNrV6sBFz4426g for ; Sun, 9 Apr 2023 07:23:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PvNrV5sX7z3j0V for ; Sun, 9 Apr 2023 07:23:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681025034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bOrxN2P7MEXCzHUiH8M780uYcRmYg0SIB95ZDsdigLk=; b=h2ei3kOzrGYxAKKTySCETXW7GVLDlOVTJmI+3vyN/y8OfGLosUzc6CIPjfQYzE93e+1MQg QuvuSCN23Qu+hkacFxP6Egj7CgOAgwpX/L/rQw3SPKKxybZFw6iNcHHonftTJ3QjVqRnwu HjP2rkhwnoAa/DMNHIphkfcNxVd1hNNQngiG6gXYXi/csa47LbGKhHHNjG7EFKx1dmIwXh R9uydMhOjejWFM11d5tQTitonQcTsKu8keXf/tqjVhsP3LXgk3NYUmqsfp8dszDPwLOw9/ Jzkc8poQf3gNELwmpVgXsh14fW/OknVIvwie0BNXyxGK2+rAGW6Yf2AgjBmgyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681025034; a=rsa-sha256; cv=none; b=YcskH31AScEtObsT3HGE6mzayz1eJ7uIfn7zfMsx/LRrw6OeBDWuBxSdpT5zFuWL7E2xw9 lFGUE+y7X63HzNuivUwQjRSB4UtZ58ZP9/Dnx4uk73oEwypqn+Wn77OpMHlrEjIuvsikGZ Xcgk3dOD3ddTgF8W6syInVFRm4lPXFA3oBlZQMl0/DntqT07miroUFw+GBnZiOGPob9E7Z Zug5pFxOOiToPq/c++hlpuCzL3x3mMRyGLv3mLncyJKKLxVRgxfRDI1L6qv7cTvUVUNZ+X 0/GV5VaP6O3rnJmejPd7gaCWHPkE/4ePeC+LFyTsoA/24K2XTZeUhzm7P+r4+A== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PvNrV4yswz105W for ; Sun, 9 Apr 2023 07:23:54 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 3397NsBf054282 for ; Sun, 9 Apr 2023 07:23:54 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 3397NsdZ054281 for fs@FreeBSD.org; Sun, 9 Apr 2023 07:23:54 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: fs@FreeBSD.org Subject: [Bug 270632] [ext2fs] files <4096 bytes are corrupted on ext4 filesystems Date: Sun, 09 Apr 2023 07:23:54 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rajeev_v_pillai@yahoo.com X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: fs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D270632 --- Comment #10 from Rajeev Pillai --- (In reply to Rajeev Pillai from comment #9) > If you add `O_DIRECT' to the second open(), [...] As below: ``` #include #include #include #include #include #include static bool prompt(char* msg) { char line[64] =3D ""; printf("%s", msg); fflush(stdout); fgets(line, sizeof line, stdin); return (line[0] =3D=3D 'Y' || line[0] =3D=3D 'y'); } int main(int argc, char* argv[]) { const char* const S =3D "hello world\n"; char* fn; size_t n; int fd, flag; if (argc !=3D 2) errx(1, "filename required"); fn =3D argv[1]; if ((fd =3D open(fn, O_WRONLY|O_CREAT, 0666)) =3D=3D -1) err(1, "%s: open failed", fn); n =3D strlen(S); if (write(fd, S, n) !=3D n) err(1, "%s: write failed", fn);=20 if (close(fd) =3D=3D -1) err(1, "%s: close failed", fn); prompt("Created file. Enter to continue: "); flag =3D O_WRONLY | O_TRUNC; if (prompt("Re-creating file. Add O_DIRECT (y/n)? ")) flag |=3D O_DIRECT; if ((fd =3D open(fn, flag, 0666)) =3D=3D -1) err(1, "%s: open failed", fn); if (prompt("Re-created file. Do lseek to beginning (y/n)? ")) if (lseek(fd, 0L, SEEK_SET) =3D=3D -1) err(1, "%s: lseek failed", fn); prompt("Truncated file. Enter to continue: "); if (write(fd, S, n) !=3D n)=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 err(1, "%s: write failed", fn);=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 if (prompt("Re-wrote file. fsync (y/n)? ")) if (fsync(fd)) err(1, "fsync failed"); if (close(fd) =3D=3D -1)=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 err(1, "%s: close failed", fn);=20=20=20=20 prompt("Done. Enter to exit: "); return 0; } ``` --=20 You are receiving this mail because: You are the assignee for the bug.=