Bug 1809124

Summary: one iso can't mount to different files at the same time.
Product: [Fedora] Fedora Reporter: 1014938109
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 31CC: jonathan, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-03 11:51:13 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:

Description 1014938109 2020-03-02 13:43:46 UTC
Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 1014938109 2020-03-02 13:51:18 UTC
(In reply to 1014938109 from comment #0)
> Description of problem:
> I can't mount the same iso file to different mount point.
> 
> Version-Release number of selected component (if applicable):
> util-linux-2.35.1-1.fc32
> 
> How reproducible:
> mount /home/test.iso /mnt
> mount: /mnt: WARNING: device write-protected, mounted read-only.
> mount /home/test.iso /home/test10
> mount: /test10: /dev/loop0 already mounted on /mnt.
>
> Steps to Reproduce:
> 1.mount /home/test.iso /mnt
> 2.mount /home/test.iso /home/test10
> 3.
> 
> Actual results:
> mount: /test10: /dev/loop0 already mounted on /mnt.
> 
> Expected results:
> mount successful.
> 
> Additional info:
  I can do the mounting successful on centos7.5.

Comment 2 Karel Zak 2020-03-03 09:01:18 UTC
The problem is that mount(8) uses "rw" mode to mount the filesystem by default. 

It is no problem for the first attempt as mount(8) able to detect that for iso kernel returns EACCES and then mount(8_
repeats the mount syscal with RDONLY flag:

  # strace -e mount mount Fedora-Workstation-Live-x86_64-31-1.9.iso /mnt/A
  mount("/dev/loop0", "/mnt/A", "iso9660", 0, NULL) = -1 EACCES (Permission denied)
  mount("/dev/loop0", "/mnt/A", "iso9660", MS_RDONLY, NULL) = 0


It is problem for the second attemp:

  # strace -e mount mount Fedora-Workstation-Live-x86_64-31-1.9.iso /mnt/B
  mount("/dev/loop0", "/mnt/B", "iso9660", 0, NULL) = -1 EBUSY (Device or resource busy)
  mount: /mnt/B: /dev/loop0 already mounted on /mnt/A.

In this case, the kernel returns EBUSY, but mount(8) is not able to recover from this situation 
to repeat mount again with "ro"...

I guess old kernels return also EACCES for the second attempt (you can try it), unfortunately, EBUSY 
makes more sense in this context. I'll try to improve mount(8) to correctly react to EBUSY  in this context.


There is a very simple workaround, just use "mount --read-only <img> <pointpoint>".

Comment 3 Karel Zak 2020-03-03 11:51:13 UTC
Implemented in upstream commit: https://github.com/karelzak/util-linux/commit/11b916cdabd9f57a4cddf10fd743af2165930dcd

Fedora package will be updated after upgrade to v2.36 (summer 2020 or so). 

Thanks for your report!

Comment 4 1014938109 2020-03-05 11:15:00 UTC
(In reply to Karel Zak from comment #3)
> Implemented in upstream commit:
> https://github.com/karelzak/util-linux/commit/
> 11b916cdabd9f57a4cddf10fd743af2165930dcd
> 
> Fedora package will be updated after upgrade to v2.36 (summer 2020 or so). 
> 
> Thanks for your report!

Thank you for your excellent work.
The problem has been fixed.
I used these two commits.
11b916cdabd9f57a4cddf10fd743af2165930dcd
acd229fc2afe0c402cca3b21e0490be71dec2725