From nobody Sat Feb 04 22:30:49 2023 X-Original-To: bugs@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 4P8S0V1nv3z3kTMG for ; Sat, 4 Feb 2023 22:30:50 +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 4P8S0T6V6xz3tfs for ; Sat, 4 Feb 2023 22:30:49 +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=1675549849; 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; bh=SL/WWqXSNDv7hG98uc6PoJABoFyuSSBiV0ZtYcQbqng=; b=g5V0feewUKPbmHVIIEUbC9ZgtqvIamJG1co9HefHxkZIH640oXCmALNQlvdvO7KqJkSQeU orxDE+xqJeZDLjEl1rfrvoITGeTL0/+p3t0i2MAKlcFaXy3T894tnoj4AKlHjefBNthS4z vmKm4yqugpgNJc6OZuEFjKY9m2NFchZ6PtmSRHeev3IWy+eXksORf5EFgbak7wpmpM+ZCc t0/x8OczN9qv55aypc8TG5k0CO6LsmGxuuNngXouRLY3RYh9Vfuefo4UE///Vegi+pSBnS /l5kMHas/AKfNTaPnyFhbkwtc1ZOfEuTyj42s1SGGC63DVSb8o4i9DSSYdcZ4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675549849; a=rsa-sha256; cv=none; b=kT/lanNRjaQltE+f9AtZ8Ts/Ti9rHXgdnYWnpOk7UzU5RYAGMk9KyVvIoErYTzzL2l8MDk RCmYtjluuh8Xp9GIXJi4sskV23ohKIYtlGGuUEZU/Im3zX1yaQznH4bDDYm0h+SUzFIz2K qjgTRF8bvJXNB/iJHEFoBUhmVCZ6DZJE/5EVuZ0Vlo953T4NTS5ZePuFuM3nnV79bz9hoV 4KDmRRIepxWgJEmF5p39iSL+edYmLXEQw0kbSQYWY65L4/018n02xl2ZmpYTuMWkRKwcFa 2QDo2eOnSN2kTT2kGdN7ttYyKt1KtUo7KClPXpMDo0XzngpB1+kxtEopSkNYow== 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 4P8S0T5ZqgzX82 for ; Sat, 4 Feb 2023 22:30:49 +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 314MUnuf063246 for ; Sat, 4 Feb 2023 22:30:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 314MUnuI063244 for bugs@FreeBSD.org; Sat, 4 Feb 2023 22:30:49 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: bugs@FreeBSD.org Subject: [Bug 269330] fusefs: data corruption with mmap and either o_direct or fspacectl Date: Sat, 04 Feb 2023 22:30:49 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: asomers@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: 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: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D269330 Bug ID: 269330 Summary: fusefs: data corruption with mmap and either o_direct or fspacectl Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: asomers@FreeBSD.org Similar to 269261, it's possible to trigger data corruption in fusefs by writing via mmap and then doing directish I/O. The general pattern is this: 1) A write via mmap creates some dirty pages but doesn't flush them 2) Either a write with O_DIRECT or an fspacectl operation overlaps with the region from step 1. fspacectl operates similarly to writes with O_DIRECT in this regard, because both bypass the cache and go directly to the fuse daem= on. 2a) fusefs invalidates the cache for all pages in that region, including pa= ges that are only partially written or deallocated. It checks for pages that a= re dirty, but the B_CACHE bit apparently isn't set for pages dirtied via mmap 3) A subsequent read operation reads zeros from the partially deallocated p= age, including regions of that page that shouldn't have been deallocated. Questions: 1) Why isn't B_CACHE set in pages that were dirtied by mmap? 2) Is there a better way to find dirty pages? 3) If I replace fuse_inval_buf_range with vnode_pager_purge_range, similarl= y to what's done in zfs_free_range, it fixes the interaction of mmap with fspace= ctl. However, vnode_pager_purge_range apparently fails to invalidate entire pag= es that were cached by normal (non-mmap) reads. Why is that? --=20 You are receiving this mail because: You are the assignee for the bug.=