RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1303700 - XFS recovery after enabling SELinux and relabeling - root not unmounted
Summary: XFS recovery after enabling SELinux and relabeling - root not unmounted
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: initscripts
Version: 7.2
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: initscripts Maintenance Team
QA Contact: Leos Pol
URL:
Whiteboard:
Depends On: 1281821
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-01 17:08 UTC by Marcel Kolaja
Modified: 2019-12-16 05:20 UTC (History)
13 users (show)

Fixed In Version: initscripts-9.49.30-1.el7_2.1
Doc Type: Bug Fix
Doc Text:
Clone Of: 1281821
Environment:
Last Closed: 2016-03-31 21:55:11 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0526 0 normal SHIPPED_LIVE initscripts bug fix update 2016-04-01 01:50:33 UTC

Description Marcel Kolaja 2016-02-01 17:08:30 UTC
This bug has been copied from bug #1281821 and has been proposed
to be backported to 7.2 z-stream (EUS).

Comment 7 Lukáš Nykrýn 2016-02-24 13:06:41 UTC
I have tried this:

touch /.autorelabel
reboot
add rd.break=pre-shutdown to kernel cmdline
boot

With old initscript package, after relabel, the machine is rebooted -> shutdown dracut was not run.
With new initscript package, after relabel, I got a shell in dracut -> shutdown dracut was run.

Can you please also test this on your machines? If you get a same result, then there is some other bug.

Comment 8 Leos Pol 2016-03-09 08:52:37 UTC
Lukas, thanks for a hint with pre-shutdown break. The real problem was my root is on standard partition. I've tried new installation where root is on xfs over lvm and magically pre-shutdown break, root unmount before reboot, and clean mount works as expected.
I'm not able to recognize if it's still problem of initscripts. If not, switch this bug back to ON_QA, and I'll file new one on this.

=Logs from lvm system:=
...after selinux relabel
[   26.677414] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[   26.691238] systemd-journald[499]: Received SIGTERM from PID 1 (systemd-shutdow).
[   26.704429] type=1305 audit(1457512049.800:12): audit_pid=0 old=658 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1
[   26.719510] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[   26.726746] systemd-shutdown[1]: Unmounting file systems.
[   26.776541] systemd-shutdown[1]: Unmounting /boot.
[   26.781222] XFS (vda1): Unmounting Filesystem
[   26.843621] systemd-shutdown[1]: All filesystems unmounted.
[   26.846079] systemd-shutdown[1]: Deactivating swaps.
[   26.848564] systemd-shutdown[1]: Deactivating swap /dev/dm-1.
[   26.850877] systemd-shutdown[1]: All swaps deactivated.
[   26.853486] systemd-shutdown[1]: Detaching loop devices.
[   26.856749] systemd-shutdown[1]: All loop devices detached.
[   26.860029] systemd-shutdown[1]: Detaching DM devices.
[   26.862707] systemd-shutdown[1]: Detaching DM 253:1.
[   26.875426] systemd-shutdown[1]: Not all DM devices detached, 1 left.
[   26.877910] systemd-shutdown[1]: Detaching DM devices.
[   26.883574] systemd-shutdown[1]: Not all DM devices detached, 1 left.
[   26.887338] systemd-shutdown[1]: Cannot finalize remaining DM devices, continuing.
[   26.895830] systemd-shutdown[1]: Successfully changed into root pivot.
[   26.898130] systemd-shutdown[1]: Returning to initrd...


[   27.020938] dracut Warning: Break before pre-shutdown
dracut Warning: Break before pre-shutdown


Generating "/run/initramfs/rdsosreport.txt"
You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot
after mounting them and attach it to a bug report.

To get more debug information in the report,
reboot with "rd.debug" added to the kernel command line.

Dropping to debug shell.

pre-shutdown:/# [   29.561688] dracut Warning: Killing all remaining processes
dracut Warning: Killing all remaining processes
[   29.629610] XFS (dm-0): Unmounting Filesystem
[   29.663234] dracut Warning: Unmounted /oldroot.
[   29.683074] dracut: Disassembling device-mapper devices
Rebooting.
[   29.716186] Unregister pv shared memory for cpu 1
[   29.719215] Unregister pv shared memory for cpu 0
[   29.749885] Restarting system.
[   29.750611] reboot: machine restart
<snip>
[    2.713568] XFS (dm-0): Mounting V4 Filesystem
[    2.816095] XFS (dm-0): Ending clean mount

# lsblk
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda           252:0    0    9G  0 disk 
├─vda1        252:1    0  500M  0 part /boot
└─vda2        252:2    0  8.5G  0 part 
  ├─rhel-root 253:0    0  7.6G  0 lvm  /
  └─rhel-swap 253:1    0  924M  0 lvm  [SWAP]



=Logs from standard partition system:=
...after selinux relabel
[   27.565751] systemd-shutdown[1]: Sending SIGTERM to remaining processes...
[   27.573607] systemd-journald[383]: Received SIGTERM from PID 1 (systemd-shutdow).
[   27.587367] type=1305 audit(1457512073.307:12): audit_pid=0 old=528 auid=4294967295 ses=4294967295 subj=system_u:s
ystem_r:auditd_t:s0 res=1
[   27.618825] systemd-shutdown[1]: Sending SIGKILL to remaining processes...
[   27.623113] systemd-shutdown[1]: Unmounting file systems.
[   27.633162] systemd-shutdown[1]: Unmounting /boot.
[   27.636813] XFS (vda1): Unmounting Filesystem
[   27.720848] systemd-shutdown[1]: All filesystems unmounted.
[   27.722769] systemd-shutdown[1]: Deactivating swaps.
[   27.725581] systemd-shutdown[1]: Deactivating swap /dev/vda2.
[   27.728484] systemd-shutdown[1]: All swaps deactivated.
[   27.731143] systemd-shutdown[1]: Detaching loop devices.
[   27.735062] systemd-shutdown[1]: All loop devices detached.
[   27.738523] systemd-shutdown[1]: Detaching DM devices.
[   27.740761] systemd-shutdown[1]: All DM devices detached.
[   27.745738] systemd-shutdown[1]: Rebooting.
[   27.747210] Unregister pv shared memory for cpu 1
[   27.748884] Unregister pv shared memory for cpu 0
[   27.778396] Restarting system.
<snip>
[    2.127519] XFS (vda3): Mounting V4 Filesystem
[    2.135680] XFS (vda3): Starting recovery (logdev: internal)
[    2.150651] XFS (vda3): Ending recovery (logdev: internal)

# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0    9G  0 disk 
├─vda1 253:1    0  500M  0 part /boot
├─vda2 253:2    0  922M  0 part [SWAP]
└─vda3 253:3    0  7.6G  0 part /

Comment 9 Michal Sekletar 2016-03-14 09:19:35 UTC
In systemd-shutdown we first try to remount filesystem read-only and then we attempt to unmount the filesystem. In case of root fs this fails, but that is expected. After we unmounted everything we could, we then call sync and reboot/shutdown/kexec depending on options.

I don't see any obvious problem with approach described above. I suspect that XFS log message on next boot is probably a bug/known-issue in XFS. I don't know, let's try to ask Dave.

Comment 10 Dave Chinner 2016-03-14 09:38:19 UTC
(In reply to Michal Sekletar from comment #9)
> In systemd-shutdown we first try to remount filesystem read-only and then we
> attempt to unmount the filesystem. In case of root fs this fails, but that
> is expected. After we unmounted everything we could, we then call sync and
> reboot/shutdown/kexec depending on options.
> 
> I don't see any obvious problem with approach described above. I suspect
> that XFS log message on next boot is probably a bug/known-issue in XFS. I
> don't know, let's try to ask Dave.

Sync doesn't provide any guarantees that the log is clean - all it guarantees is that after a subsequent mount all the data and metadata is present in the filesystem. XFS, like ext4, only writes dirty metadata to the log when sync runs, hence requiring log recovery to run to provide the requirements of sync.

Unmount is different - it requires us to write back all the dirty metadata to it's allocated blocks, hence leaving the log clean and not requiring recovery on teh next mount. This is why unmount often takes a lot longer to execute than sync.

IOWs, XFS is behaving exactly as we expect it to here. sync + recovery gives the same result as unmount once the subsequent mount is completed. The only difference is where we take the performance hit for writing back dirty metadata (unmount or log recovery)....

-Dave.

Comment 11 Leos Pol 2016-03-14 10:11:17 UTC
So it looks like we've done everything in the initscripts scope, I'm going to switch this bug to verified and file new one on kernel as Lukas suggested.

Comment 12 Eric Sandeen 2016-03-14 15:40:48 UTC
(In reply to Michal Sekletar from comment #9)
> In systemd-shutdown we first try to remount filesystem read-only and then we
> attempt to unmount the filesystem. In case of root fs this fails, but that
> is expected.

Why is this unique to the setenforce / relabel scenario?  A normal reboot does not cause a log replay on the root fs.

Comment 13 Michal Sekletar 2016-03-14 19:49:15 UTC
(In reply to Eric Sandeen from comment #12)
> (In reply to Michal Sekletar from comment #9)
> > In systemd-shutdown we first try to remount filesystem read-only and then we
> > attempt to unmount the filesystem. In case of root fs this fails, but that
> > is expected.
> 
> Why is this unique to the setenforce / relabel scenario?  A normal reboot
> does not cause a log replay on the root fs.

I think there is no difference if / is on XFS on standard partition. Such setup doesn't require pivot_root to initramfs during shutdown and we only sync() the filesystem. Hence log replay on next mount. But as Dave already pointed out, this is fine, because we are guaranteed that *all* data and meta-data is on disk.

Previously in relabel scenario, we would never restore content of initramfs and pivot_root there even in cases this is necessary. I assume this can cause filesystem corruption in some cases because filesystem *thinks* that data are actually on disk but they are not. Instead are queued for write-back somewhere in DM layer. But as mentioned, we would never pivot_root so we can actually unmount old root fs and detach underlying DM device. This is now fixed.

Comment 15 errata-xmlrpc 2016-03-31 21:55:11 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0526.html


Note You need to log in before you can comment on or make changes to this bug.