Bug 835782

Summary: when create the netfs pool, virsh pool-create-as do not remount the target dir which is mounted for another device firstly.
Product: Red Hat Enterprise Linux 6 Reporter: Daisy Wu <jwu>
Component: libvirtAssignee: Osier Yang <jyang>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 6.3CC: acathrow, dallan, dyasny, jwu, jyang, mzhan, rwu, veillard, whuang, yalzhang, yisun, yupzhang, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.13-3.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:18:08 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 Daisy Wu 2012-06-27 06:13:37 UTC
Description of problem:
virsh pool-create-as do not remount the target dir which is mounted for another device firstly.

Version-Release number of selected component (if applicable):
libvirt-0.9.10-21.el6.x86_64
qemu-kvm-0.12.1.2-2.295.el6.x86_64

# uname -a
Linux jwu.redhat.com 2.6.32-278.el6.x86_64 #1 SMP Fri Jun 1 14:17:12 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

How reproducible:
always

Steps to Reproduce:
1. Make sure the dir "/mnt" on the host is mounted for another device firstly, just like
#mount /dev/sda7 /mnt
#mount
/dev/sda7 on /mnt type ext4 (rw)
.....

2. create a netfs pool and make sure the target is "/mnt", just like
#virsh pool-create-as pool-nfs --type netfs --source-host 10.66.6.23 --source-path /tmp/libvirt --target /mnt/
Pool pool-nfs created


3. check the status of pool-nfs, it is active.
# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------    
pool-nfs             active     no        
....

# virsh pool-dumpxml pool-nfs
<pool type='netfs'>
  <name>pool-nfs</name>
  <uuid>a303f2e6-e4ef-c354-d4a0-d71664be5fc5</uuid>
  <capacity unit='bytes'>61926887424</capacity>
  <allocation unit='bytes'>39120146432</allocation>
  <available unit='bytes'>22806740992</available>
  <source>
    <host name='10.66.6.23'/>
    <dir path='/tmp/libvirt'/>
    <format type='auto'/>
  </source>
  <target>
    <path>/mnt</path>
    <permissions>
      <mode>0700</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>


4. check the host, the /mnt is not remounted for netfs, it is still mount for /dev/sda7
#mount
/dev/sda7 on /mnt type ext4 (rw)
.....   


Actual results:
As above.

Expected results:
The /mnt should be remounted for netfs, just like:
#mount
/dev/sda7 on /mnt type ext4 (rw)
10.66.6.23:/tmp/libvirt on /mnt type nfs (rw,vers=4,addr=10.66.6.23,clientaddr=10.66.71.235)

Additional info:
1. after step 4,pool-destroy will umount the existing nfs which is not related to the fs pool.

# virsh pool-destroy pool-nfs
Pool pool-nfs destroyed

# mount
no "/dev/sda7 on /mnt type ext4 (rw)" exist.

2. If the /mnt is not mounted for another device firstly, virsh pool-create-as works well.

Comment 2 Osier Yang 2012-06-27 14:33:00 UTC
patch posted upstream.

https://www.redhat.com/archives/libvir-list/2012-June/msg01252.html

Comment 3 Osier Yang 2012-06-28 03:56:26 UTC
(In reply to comment #2)
> patch posted upstream.
> 
> https://www.redhat.com/archives/libvir-list/2012-June/msg01252.html

pushed upstream, move to POST.

Comment 5 Daniel Veillard 2012-07-20 06:46:07 UTC
upstream commit:
8116529409357c82824fb280165ea0ee6f2d6277   2012-06-28 11:53:40

Daniel

Comment 7 Huang Wenlong 2012-07-24 02:46:30 UTC
Verify this bug with : 
libvirt-0.9.13-3.el6.x86_64

1)
#mount /dev/sda3 /mnt/mig 

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              40G  8.0G   30G  22% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda3             9.7G  150M  9.0G   2% /mnt/mig

2) # virsh pool-create-as netfs --type netfs --source-host 10.66.5.12 --source-path /mnt/data/images/ --target /mnt/mig
error: Failed to create pool netfs
error: Requested operation is not valid: Target '/mnt/mig' is already mounted


Report error as expected

Comment 8 errata-xmlrpc 2013-02-21 07:18:08 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.

http://rhn.redhat.com/errata/RHSA-2013-0276.html

Comment 9 yalzhang@redhat.com 2016-06-30 06:28:25 UTC
Hi Osier,

The performance of libvirt 1.2.17 is the same. 
But after update libvirt to 1.3.5 currently, the performance changed. 
Not sure if there is any risk.
Please help to check,thank you very much!

Description of problem:
when create the netfs pool, virsh pool-create-as will remount the target dir which is mounted for another device firstly. 
And umount the origin one. After destroy the pool, the local dir will mount again.

Version-Release number of selected component (if applicable):
libvirt-1.3.5-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. 
# mount /dev/sda3 /mnt

2. Write something in the /dev/sda3
# ls /mnt
test  test1 lost+found
# mount
....
/dev/sda3                946M  2.5M  878M   1% /mnt

3. Create a netfs pool mount on /mnt, it will succeed, which is different from before.
# virsh pool-create-as netfs --type netfs --source-host 10.66.5.0 --source-path /tmp/nfs --target /mnt
Pool netfs created
# mount
......
/dev/sda3 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
10.66.5.0:/tmp/nfs on /mnt type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.66.5.194,local_lock=none,addr=10.66.5.0)
# ls /mnt
aaa.img  al  rhel6u1-fv-nfs-pool.raw
# df -a
......
/dev/sda3                       -        -         -    - /mnt
10.66.5.0:/tmp/nfs      419225600 59729920 359495680  15% /mnt

4. 
# virsh destroy netfs
Pool netfs destroyed
# df -a 
/dev/sda3                  967864    2472    899008   1% /mnt
# ls /mnt
test  test1 lost+found

Comment 10 yalzhang@redhat.com 2016-07-20 04:54:43 UTC
It is a kernel feature change.

# mount /dev/sda3 /mnt
# touch /mnt/sda3
# mount /dev/sda4 /mnt ===> the mount will succeed
# touch /mnt/sda4


# mount ====> list historical mounted info
......
/dev/sda3 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
/dev/sda4 on /mnt type ext4 (rw,relatime,seclabel,data=ordered)

# df -lh ====> list current mounted info
Filesystem               Size  Used Avail Use% Mounted on
.....
/dev/sda4                 17G   45M   16G   1% /mnt

# umount /mnt  ===>/dev/sda4 will be umounted, and /dev/sda3 will recover

# df -lh
Filesystem               Size  Used Avail Use% Mounted on
......
/dev/sda3                9.1G   37M  8.6G   1% /mnt
# ll /mnt
total 16
drwx------. 2 root root 16384 Jul 20 12:39 lost+found
-rw-r--r--. 1 root root     0 Jul 20 12:49 sda3