Bug 205668

Summary: [ext2fs] [patch] cannot mount EXT4 filesystems which weren't cleanly unmounted
Product: Base System Reporter: Damjan Jovanovic <damjan.jov>
Component: kernAssignee: Pedro F. Giffuni <pfg>
Status: Closed FIXED    
Severity: Affects Some People CC: fs, pfg
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to add support for the EXT2F_INCOMPAT_RECOVER flag
none
Ignore EXT2F_INCOMPAT_RECOVER when mounting ext4 none

Description Damjan Jovanovic 2015-12-28 16:06:01 UTC
Created attachment 164769 [details]
Patch to add support for the EXT2F_INCOMPAT_RECOVER flag

If a disk with the EXT4 filesystem wasn't cleanly unmounted, it will have the EXT2F_INCOMPAT_RECOVER flag set on its feature flags, visible as "needs_recovery" in the "Filesystem features" of "tune2fs -l /dev/<disk>".

Our ext2fs module doesn't know about this flag, and ends up treating a disk in this state as having unsupported features, logging the inappropriate and confusing message:

WARNING: mount of <disk> denied due to unsupported optional features

to dmesg and unable to mount it until fsck.ext4 even if mounting read-only or forced.

My attached patch adds support for this flag and treats it as supported, warning if the filesystem wasn't cleanly unmounted like it already does with the other 2 ways of marking it as such.
Comment 1 Pedro F. Giffuni freebsd_committer freebsd_triage 2015-12-28 19:25:42 UTC
I'll take it ...
Comment 2 Pedro F. Giffuni freebsd_committer freebsd_triage 2015-12-28 20:10:01 UTC
Created attachment 164776 [details]
Ignore EXT2F_INCOMPAT_RECOVER when mounting ext4

The flag appears only in ext4 and appears to be realated with journalling, neither of which we actually support fully.

This simpler patch should "fix" it.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-12-29 15:52:39 UTC
A commit references this bug:

Author: pfg
Date: Tue Dec 29 15:51:52 UTC 2015
New revision: 292872
URL: https://svnweb.freebsd.org/changeset/base/292872

Log:
  ext2: recognize ext4 INCOMPAT_RECOVER flag

  This is a flag specific for journalling in ext4.
  Add it to the list of ext4 features we ignore for
  read-only purposes.

  PR:		205668
  MFC after:	1 week

Changes:
  head/sys/fs/ext2fs/ext2fs.h
Comment 4 Damjan Jovanovic 2016-01-03 04:52:02 UTC
Hi Pedro. Thank you, your patch gets the filesystem to mount. However there is no warning that it hasn't been cleanly unmounted.
Comment 5 Pedro F. Giffuni freebsd_committer freebsd_triage 2016-01-03 14:36:08 UTC
(In reply to Damjan Jovanovic from comment #4)
Hi Damjan;

Yes, this is consistent with us ignoring the feature: read-only operation should not touch the disk and warning only when unmounting would give the impression that *we* somehow corrupted the information. Let the rw implementation (in linux) deal with it.

An alternative would have been to simply not mount the disk and let the user deal with ext4 fsck (I think that was what was happening originally).
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-01-06 16:25:16 UTC
A commit references this bug:

Author: pfg
Date: Wed Jan  6 16:25:01 UTC 2016
New revision: 293236
URL: https://svnweb.freebsd.org/changeset/base/293236

Log:
  MFC	r292872:

  ext2: recognize ext4 INCOMPAT_RECOVER flag

  This is a flag specific for journalling in ext4.
  Add it to the list of ext4 features we ignore for
  read-only purposes.

  PR:		205668

Changes:
_U  stable/10/
  stable/10/sys/fs/ext2fs/ext2fs.h
Comment 7 commit-hook freebsd_committer freebsd_triage 2016-01-06 16:28:18 UTC
A commit references this bug:

Author: pfg
Date: Wed Jan  6 16:27:18 UTC 2016
New revision: 293237
URL: https://svnweb.freebsd.org/changeset/base/293237

Log:
  MFC	r292872:

  ext2: recognize ext4 INCOMPAT_RECOVER flag

  This is a flag specific for journalling in ext4.
  Add it to the list of ext4 features we ignore for
  read-only purposes.

  PR:		205668

Changes:
_U  stable/9/sys/
_U  stable/9/sys/fs/
  stable/9/sys/fs/ext2fs/ext2fs.h
Comment 8 Pedro F. Giffuni freebsd_committer freebsd_triage 2016-01-06 17:51:07 UTC
This should be solved in all supported FreeBSD versions now.
Thanks!