Bug 1116670

Summary: grub2-mkconfig loads btrfs and ext4 kernel module and never unloads them
Product: Red Hat Enterprise Linux 7 Reporter: masanari iida <masanari_iida>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: agk, bmr, dkutalek, fweimer, gavin, isenfeld, lmiksik, mhradile, mhruscak, plambri, pmoravec, sbradley
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-3.3-2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 04:52:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1274384, 1295396, 1298112, 1313485    

Description masanari iida 2014-07-07 02:37:24 UTC
Description of problem:
Even a system which is not using btrfs at all, sosreport load btrfs
and ext4 kernel modules and never unload it.

Version-Release number of selected component (if applicable):
sos-3.0-23.el7.noarch

How reproducible:
Always

Steps to Reproduce:
0. Install OS on xfs filesystem. No btrfs on the system.
1. lsmod > /tmp/lsmod.before
2. Execute sosreport
3. lsmod > /tmp/lsmod.after 
4. diff /tmp/lsmod.before /tmp/lsmod.after

Actual results:

# diff /tmp/lsmod.before /tmp/lsmod.after
1a2,13
> fuse                   87661  1
> btrfs                 856675  0
> zlib_deflate           26914  1 btrfs
> raid6_pq               97812  1 btrfs
> xor                    21411  1 btrfs
> vfat                   17411  0
> msdos                  17332  0
> fat                    65913  2 vfat,msdos
> ext4                  528957  0
> mbcache                14958  1 ext4
> jbd2                   98341  1 ext4
> binfmt_misc            17468  1
71c83
< libcrc32c              12644  2 xfs,bnx2x
---
> libcrc32c              12644  3 xfs,bnx2x,btrfs

Expected results:

After sosreport run, the kernel modules loaded on the system
should be same as before

Comment 2 Bryn M. Reeves 2014-07-07 09:41:38 UTC
sos itself doesn't load any kernel modules so this must be a side-effect of something else that's run during collection.

Verifying the modules list after each plugin invocation points the finger at grub2:

# rmmod ext4 btrfs
# lsmod | egrep 'ext4|btrfs'
# time sosreport --batch --debug --build --quiet -o grub2
# lsmod | egrep 'ext4|btrfs'
btrfs                 856675  0 
ext4                  528957  0 
zlib_deflate           26914  1 btrfs
raid6_pq               97812  1 btrfs
xor                    21411  1 btrfs
mbcache                14958  1 ext4
jbd2                   98341  1 ext4
libcrc32c              12644  2 xfs,btrfs

Manual testing confirms it's grub2-mkconfig:

# rmmod ext4 btrfs
# grub2-mkconfig &> /dev/null
# lsmod | egrep 'ext4|btrfs'
btrfs                 856675  0 
ext4                  528957  0 
zlib_deflate           26914  1 btrfs
raid6_pq               97812  1 btrfs
xor                    21411  1 btrfs
mbcache                14958  1 ext4
jbd2                   98341  1 ext4
libcrc32c              12644  2 xfs,btrfs

Changing component to grub2.

Comment 4 Peter Jones 2015-03-12 19:42:11 UTC
There's really not a reasonable way to do this - os-prober is just doing "mount -t btrfs", and there's no way for it to know what modules got loaded as a result, what modules you should or should not have loaded, what else may have loaded a module at the same time, etc.  So we can't really choose what to unload, and we can't really implement something like snapshots of the module list that we try to roll back to by unloading.

There's not really any *problem* with having extra modules loaded which you're not using, either.  So if this is a big issue for you, the best thing would be to to make sure sosreport isn't running its module that's calling os-prober.

Comment 5 Pavel Moravec 2015-03-27 14:28:42 UTC
(In reply to Peter Jones from comment #4)
> There's really not a reasonable way to do this - os-prober is just doing
> "mount -t btrfs", and there's no way for it to know what modules got loaded
> as a result, what modules you should or should not have loaded, what else
> may have loaded a module at the same time, etc.  So we can't really choose
> what to unload, and we can't really implement something like snapshots of
> the module list that we try to roll back to by unloading.
> 
> There's not really any *problem* with having extra modules loaded which
> you're not using, either.  So if this is a big issue for you, the best thing
> would be to to make sure sosreport isn't running its module that's calling
> os-prober.

This is my understanding as well. Running sosreport may redundantly load some kernel modules that wont be unloaded by sosreport itself. That consumes some small amount of resources like memory - just for the very first run of sosreport on the machine (since reboot).

Is there some other impact than that?

Comment 6 Florian Weimer 2015-06-24 11:31:41 UTC
(In reply to Peter Jones from comment #4)
> There's not really any *problem* with having extra modules loaded which
> you're not using, either.

Except that sosreport *explicitly* promises that it will not make any changes to the system configuration, so the current behavior leads to extremely poor user experience.

Comment 8 Pavel Moravec 2015-08-28 07:05:55 UTC
too late to accept to 7.2, should be in 7.3

Comment 10 Pavel Moravec 2015-12-19 14:46:43 UTC
devel_ack+ due to patch in upstream via commit 08f5b211dbbf143b3f3ce5e8328947f01adb86cd

Comment 12 Mike McCune 2016-03-28 23:20:28 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 13 Pavel Moravec 2016-05-06 18:25:39 UTC
*** Bug 1333911 has been marked as a duplicate of this bug. ***

Comment 17 Pavel Moravec 2016-05-26 07:13:46 UTC
Per comment:

https://github.com/sosreport/sos/pull/822#discussion_r64427095

this is not supposed to be fixed in sosreport. Since:

- grub2-mkconfig collects such valuable information for CEE associates that it needs to be present in sosreport regardless of some kernel module currently loaded or not. I.e. even on systems with e.g. ext4 module unloaded, the command output needs to be collected.

- theoretically, sos can (after running grub2-mkconfig) manually unload the modules not loaded before the command execution, but exactly this sanity work should be done by the grub2-mkconfig program itself.

Therefore, I am changing component from sos to grub2.



Updated bugzilla report for grub2 / grub2-mkconfig:

Description of problem:
Even a system which is not using btrfs at all, grub2-mkconfig loads btrfs
and ext4 kernel modules and never unloads them.

Version-Release number of selected component (if applicable):
grub2-tools-2.02-0.34.el7_2.x86_64

How reproducible:
Always

Steps to Reproduce:
0. Install OS on xfs filesystem. No btrfs on the system.
1. run commands:
lsmod > /tmp/lsmod.before
grub2-mkconfig > /dev/null 2>&1
lsmod > /tmp/lsmod.after 
diff /tmp/lsmod.before /tmp/lsmod.after

Actual results:

# diff /tmp/lsmod.before /tmp/lsmod.after
1a2,3
> btrfs                 960776  0 
> ext4                  578819  0 
3,5c5,7
< zlib_deflate           26914  0 
< raid6_pq               97812  0 
< xor                    21411  0 
---
> zlib_deflate           26914  1 btrfs
> raid6_pq               97812  1 btrfs
> xor                    21411  1 btrfs
10,11c12,13
< mbcache                14958  0 
< jbd2                  102940  0 
---
> mbcache                14958  1 ext4
> jbd2                  102940  1 ext4
81c83
< crc32c_intel           22079  1 
---
> crc32c_intel           22079  2 

Expected results:
empty diff / btrfs and ext4 modules unloaded at the end.

Comment 19 Bryn M. Reeves 2016-05-26 11:48:47 UTC
> - theoretically, sos can (after running grub2-mkconfig) manually unload the
> modules

No it can't (in theory or otherwise) for essentially the same reasons Peter outlines in comment #4 - if os-prober/grub2-mkconfig cannot do this then sos certainly can't either.

The only way this can work is if there is a way to tell os-prober to not attempt anything that could load a module.

Comment 20 Peter Jones 2016-06-17 20:21:45 UTC
This is still not a grub2 or os-prober bug.  They are both working as intended, and the things you seem not to like are required features.

If you want grub2-mkconfig but need to avoid the side effects os-prober has, the best answer may be invoking grub2-mkconfig with GRUB_DISABLE_OS_PROBER=true in the environment, which will skip the os probes entirely.

Comment 22 Pavel Moravec 2016-06-20 07:48:43 UTC
(In reply to Peter Jones from comment #20)
> This is still not a grub2 or os-prober bug.  They are both working as
> intended, and the things you seem not to like are required features.
> 
> If you want grub2-mkconfig but need to avoid the side effects os-prober has,
> the best answer may be invoking grub2-mkconfig with
> GRUB_DISABLE_OS_PROBER=true in the environment, which will skip the os
> probes entirely.

Thanks, that works.

Updated sos PR: https://github.com/sosreport/sos/pull/822#commits-pushed-637d96d

Comment 29 errata-xmlrpc 2016-11-04 04:52:41 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-2380.html