Bug 763975 (GLUSTER-2243)

Summary: Copying file with "cp -a" to a different name causes files to be linked
Product: [Community] GlusterFS Reporter: Riku Paakkunainen <riku.paakkunainen>
Component: coreAssignee: Pranith Kumar K <pkarampu>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: urgent    
Version: 3.1.1CC: amarts, anush, gluster-bugs, saurabh, vijay
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: fuse
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Anush Shetty 2010-12-20 11:35:02 UTC
Looks like it is working for me. Can you give your more details about your setup. What was the underlying filesystem?

/mnt/gluster# echo 'Content in file1.txt' >> file1.txt

/mnt/gluster# cat file1.txt 

Content in file1.txt
/mnt/gluster# cp -a file1.txt file2.txt

root@pitta:/mnt/gluster# cat file2.txt 
Content in file1.txt

/mnt/gluster# echo 'Additional content should go in file2.txt but goes to file1.txt as
> well?!' >> file2.txt

/mnt/gluster# cat file2.txt 
Content in file1.txt
Additional content should go in file2.txt but goes to file1.txt as
well?!

/mnt/gluster# cat file1.txt 
Content in file1.txt
root@pitta:/mnt/gluster#

Comment 1 Riku Paakkunainen 2010-12-20 14:25:52 UTC
Overview:
Copying file with "cp -a" to a different name causes files to be linked. And editing the new copied files applies the changes on the original file as well.

Steps to Reproduce:
cd /mnt/gluster
echo 'Content in file1.txt' >> file1.txt
cat file1.txt
less file1.txt
cp -a file1.txt file2.txt
cat file2.txt
less file2.txt
echo 'Additional content should go in file2.txt but goes to file1.txt as well?!' >> file2.txt
diff file1.txt file2.txt
cat file1.txt
less file1.txt
cat file2.txt
less file2.txt
nano -w file2.txt
- Type something and save CTRL-X
diff file1.txt file2.txt
cat file1.txt
less file1.txt
cat file2.txt
less file2.txt
ls -la

Environment: Gluster 3.1.1 x86_64 rpms installed on CentOS 5.5
Native Fuse/Glusterfs mounted on client /mnt/gluster

Comment 2 Riku Paakkunainen 2010-12-21 04:37:47 UTC
Sorry my steps to reproduce didn't work as expected. It seems there needs to be a small delay between the commands.

Here are the steps I tested properly:
cd /mnt/gluster2
echo 'Content in example1.txt' >> example1.txt
cat example1.txt
sleep 1
cp -a example1.txt example2.txt
sleep 1
echo 'Content added to example2.txt' >> example2.txt
sleep 1
cat example1.txt
cat example2.txt
ls -la
sleep 2
ls -la

And the same with output:
[root@dev3 gluster2]# cd /mnt/gluster2
[root@dev3 gluster2]# echo 'Content in example1.txt' >> example1.txt
[root@dev3 gluster2]# cat example1.txt
Content in example1.txt
[root@dev3 gluster2]# sleep 1
[root@dev3 gluster2]# cp -a example1.txt example2.txt
[root@dev3 gluster2]# sleep 1
[root@dev3 gluster2]# echo 'Content added to example2.txt' >> example2.txt
[root@dev3 gluster2]# sleep 1
[root@dev3 gluster2]# cat example1.txt
Content in example1.txt
Content added to example2.txt
[root@dev3 gluster2]# cat example2.txt
Content in example1.txt
[root@dev3 gluster2]# ls -la
total 32
drwxr-xr-x 2 root root 4096 Dec 21 09:27 .
drwxr-xr-x 4 root root 4096 Dec 17 15:44 ..
-rw-r--r-- 1 root root   54 Dec 21 09:27 example1.txt
-rw-r--r-- 1 root root   54 Dec 21 09:27 example2.txt
[root@dev3 gluster2]# sleep 2
[root@dev3 gluster2]# ls -la
total 32
drwxr-xr-x 2 root root 4096 Dec 21 09:27 .
drwxr-xr-x 4 root root 4096 Dec 17 15:44 ..
-rw-r--r-- 1 root root   54 Dec 21 09:27 example1.txt
-rw-r--r-- 1 root root   24 Dec 21 09:27 example2.txt
[root@dev3 gluster2]# 

Filesystem is CentOS 5.5 default ext3.

This setup is my test environment but the same problem occurs in my production setup which is a 2 brick replica.

Client:
[root@dev3 gluster2]# mount
glusterfs#rikuvmcentos2.xxx.xx:/rplocal-gluster2 on /mnt/gluster2 type fuse (rw,allow_other,default_permissions,max_read=131072)

Server:
[root@rikuvmcentos2 gluster_data_local2]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)

[root@rikuvmcentos2 gluster_data_local2]# gluster volume info

Volume Name: rplocal-gluster
Type: Distribute
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: rikuvmcentos2.xxx.xx:/gluster_data_local

Volume Name: rplocal-gluster2
Type: Distribute
Status: Started
Number of Bricks: 1
Transport-type: tcp
Bricks:
Brick1: rikuvmcentos2.xxx.xx:/gluster_data_local2
[root@rikuvmcentos2 gluster_data_local2]# 

/gluster_data_local and /gluster_data_local2 are directories on the root filesystem.

Comment 3 Pranith Kumar K 2011-02-01 08:53:59 UTC
This is already fixed in 3.1.2
pranith @ ~/workspace/afr-repo/build
17:23:09 :) $ sudo su -
root@pranith-laptop:~# cd /mnt/client
root@pranith-laptop:/mnt/client# echo 'Content in example1.txt' >> example1.txt
root@pranith-laptop:/mnt/client# cat example1.txt
Content in example1.txt
root@pranith-laptop:/mnt/client# sleep 1
root@pranith-laptop:/mnt/client# cp -a example1.txt example2.txt
root@pranith-laptop:/mnt/client# sleep 1
root@pranith-laptop:/mnt/client# echo 'Content added to example2.txt' >> example2.txt
root@pranith-laptop:/mnt/client# sleep 1
root@pranith-laptop:/mnt/client# cat example1.txt
Content in example1.txt
root@pranith-laptop:/mnt/client# cat example2.txt
Content in example1.txt
Content added to example2.txt
root@pranith-laptop:/mnt/client# ls -la
total 16
drwxr-xr-x 2 root root 4096 2011-02-01 17:23 .
drwxr-xr-x 6 root root 4096 2010-12-14 14:47 ..
-rw-r--r-- 1 root root   24 2011-02-01 17:23 example1.txt
-rw-r--r-- 1 root root   54 2011-02-01 17:23 example2.txt
root@pranith-laptop:/mnt/client# sleep 2
root@pranith-laptop:/mnt/client# ls -la
total 16
drwxr-xr-x 2 root root 4096 2011-02-01 17:23 .
drwxr-xr-x 6 root root 4096 2010-12-14 14:47 ..
-rw-r--r-- 1 root root   24 2011-02-01 17:23 example1.txt
-rw-r--r-- 1 root root   54 2011-02-01 17:23 example2.txt
root@pranith-laptop:/mnt/client#

Comment 4 Saurabh 2011-02-18 07:27:45 UTC

Working properly over nfs mount, 

Log:-

gluster@ubuntu1:/mnt/nfs-test$ echo 'Content in example1.txt' >> example1.txt
gluster@ubuntu1:/mnt/nfs-test$ cat example1.txt 
Content in example1.txt
gluster@ubuntu1:/mnt/nfs-test$ sleep 1
gluster@ubuntu1:/mnt/nfs-test$ cp -a example1.txt example2.txt
gluster@ubuntu1:/mnt/nfs-test$ sleep 1
gluster@ubuntu1:/mnt/nfs-test$ echo 'Content added to example2.txt' >> example2.txt
gluster@ubuntu1:/mnt/nfs-test$ sleep 1
gluster@ubuntu1:/mnt/nfs-test$ cat example1.txt 
Content in example1.txt
gluster@ubuntu1:/mnt/nfs-test$ cat example2.txt 
Content in example1.txt
Content added to example2.txt


Need to check over fuse mount.

Comment 5 Saurabh 2011-02-18 09:08:40 UTC
works over fuse mount also,

gluster@ubuntu1:/mnt/gluster-test$ echo 'Content in example1.txt' >> example1.txt
gluster@ubuntu1:/mnt/gluster-test$ cat example1.txt 
Content in example1.txt
gluster@ubuntu1:/mnt/gluster-test$ sleep 1
gluster@ubuntu1:/mnt/gluster-test$ cp -a example1.txt example2.txt
gluster@ubuntu1:/mnt/gluster-test$ sleep 1
gluster@ubuntu1:/mnt/gluster-test$ echo 'Content added to example2.txt' >> example2.txt
gluster@ubuntu1:/mnt/gluster-test$ sleep 1
gluster@ubuntu1:/mnt/gluster-test$ cat example1.txt 
Content in example1.txt
gluster@ubuntu1:/mnt/gluster-test$ cat example2.txt 
Content in example1.txt
Content added to example2.txt