Re: [PATCH v3 2/3] ntfs: sync the volume dirty bit with the recorded error state

From: Hongling Zeng

Date: Tue Sep 08 2026 - 03:35:47 EST



在 2026年09月08日 12:10, Namjae Jeon 写道:
@@ -1621,6 +1666,11 @@ static bool load_system_files(struct ntfs_volume *vol)
ntfs_error(sb, "%s. Mounting read-only%s", es1, es2);
}
NVolSetErrors(vol);
+ /*
+ * Remember it for the lifetime of the mount: see
+ * ntfs_sync_volume_dirty_state().
+ */
+ NVolSetHibernated(vol);
Could you explain why NVolSetHibernated(vol) is called for non-zero
return from check_windows_hibernation_status() ?
Hi:
A non-zero return does not only mean "definitely hibernated": > 0
means hibernation was established or assumed (the documented
"treated as if Windows is suspended" default), while < 0 means the
check itself failed, so hibernation could not be ruled out.

NV_Hibernated is a conservative write gate, not a positive claim: it
keeps ntfs_sync_volume_dirty_state() from writing the $Volume record
on this mount. It has to cover the whole branch because this series
changes what NVolErrors() means for writes: it used to suppress the
flags write, and now the on-disk dirty bit is derived from it on
read-write mounts. Without the separate gate, an rw mount of a
hibernated volume (errors=continue) would gain a filesystem-internal
$Volume write on the first sync_fs() or at unmount - exactly what
the hibernation check exists to prevent.

err < 0 is included for the same reason, only more so: when the
check cannot complete, we cannot prove the volume is safe to write.
Gating wrongly costs an untouched dirty bit; not gating wrongly
costs Windows resuming on a modified image.

Thanks!