Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[maintenance][leo_storage] Needs to deliver moving AVS directory after launching #660

Closed
yosukehara opened this issue Mar 29, 2017 · 8 comments

Comments

@yosukehara
Copy link
Member

yosukehara commented Mar 29, 2017

I've realized we need to deliver moving AVS directories after launching a LeoFS system to more smoothly migrate it. The current version of LeoStorage creates many symlinks under AVS' directories which are log, object, and metadata.

@yosukehara
Copy link
Member Author

I've fixed this issue, and shared an operation example as below:

Execute mv_avs_dir.sh

$ sh mv_avs_dir.sh ./package/leo_storage/avs/ /var/leofs/
::: LeoFS / move-avs-directories :::

[INFO]
   Src dir: ./package/leo_storage/avs
  Dest dir: /var/leofs

/home/yosuke/dev/projects/leo-project/leofs
/home/yosuke/dev/projects/leo-project/leofs
/home/yosuke/dev/projects/leo-project/leofs
[CREATED] /var/leofs/log/leo_object_storage_0.20170329.16.1 > /var/leofs/log/leo_object_storage_0
[CREATED] /var/leofs/log/leo_object_storage_1.20170329.16.1 > /var/leofs/log/leo_object_storage_1
[CREATED] /var/leofs/log/leo_object_storage_2.20170329.16.1 > /var/leofs/log/leo_object_storage_2
[CREATED] /var/leofs/log/leo_object_storage_3.20170329.16.1 > /var/leofs/log/leo_object_storage_3
[CREATED] /var/leofs/log/leo_object_storage_4.20170329.16.1 > /var/leofs/log/leo_object_storage_4
[CREATED] /var/leofs/log/leo_object_storage_5.20170329.16.1 > /var/leofs/log/leo_object_storage_5
[CREATED] /var/leofs/log/leo_object_storage_6.20170329.16.1 > /var/leofs/log/leo_object_storage_6
[CREATED] /var/leofs/log/leo_object_storage_7.20170329.16.1 > /var/leofs/log/leo_object_storage_7
/home/yosuke/dev/projects/leo-project/leofs
[CREATED] /var/leofs/object/0.avs_63657990626 > /var/leofs/object/0.avs
[CREATED] /var/leofs/object/1.avs_63657990626 > /var/leofs/object/1.avs
[CREATED] /var/leofs/object/2.avs_63657990626 > /var/leofs/object/2.avs
[CREATED] /var/leofs/object/3.avs_63657990625 > /var/leofs/object/3.avs
[CREATED] /var/leofs/object/4.avs_63657990625 > /var/leofs/object/4.avs
[CREATED] /var/leofs/object/5.avs_63657990624 > /var/leofs/object/5.avs
[CREATED] /var/leofs/object/6.avs_63657990624 > /var/leofs/object/6.avs
[CREATED] /var/leofs/object/7.avs_63657990623 > /var/leofs/object/7.avs
/home/yosuke/dev/projects/leo-project/leofs
[CREATED] /var/leofs/metadata/0_63657990626 > /var/leofs/metadata/0
[CREATED] /var/leofs/metadata/1_63657990626 > /var/leofs/metadata/1
[CREATED] /var/leofs/metadata/2_63657990626 > /var/leofs/metadata/2
[CREATED] /var/leofs/metadata/3_63657990625 > /var/leofs/metadata/3
[CREATED] /var/leofs/metadata/4_63657990625 > /var/leofs/metadata/4
[CREATED] /var/leofs/metadata/5_63657990624 > /var/leofs/metadata/5
[CREATED] /var/leofs/metadata/6_63657990624 > /var/leofs/metadata/6
[CREATED] /var/leofs/metadata/7_63657990623 > /var/leofs/metadata/7
/home/yosuke/dev/projects/leo-project/leofs
[FINISHED]

Before

$ ls -l ./package/leo_storage/avs/log/
total 32
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_0 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_0.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_0.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_1 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_1.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_1.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_2 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_2.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_2.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_3 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_3.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_3.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_4 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_4.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_4.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_5 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_5.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_5.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_6 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_6.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_6.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 106 Mar 29 16:10 leo_object_storage_7 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/log/leo_object_storage_7.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke   0 Mar 29 16:10 leo_object_storage_7.20170329.16.1

$ ls -l ./package/leo_storage/avs/object/
total 64
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 0.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/0.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 0.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 1.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/1.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 1.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 2.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/2.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 2.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 3.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/3.avs_63657990625
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 3.avs_63657990625
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 4.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/4.avs_63657990625
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 4.avs_63657990625
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 5.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/5.avs_63657990624
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 5.avs_63657990624
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 6.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/6.avs_63657990624
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 6.avs_63657990624
lrwxrwxrwx 1 yosuke yosuke  92 Mar 29 16:10 7.avs -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/object/7.avs_63657990623
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:10 7.avs_63657990623

$ ls -l ./package/leo_storage/avs/metadata/
total 64
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 0 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/0_63657990626/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 0_63657990626
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 1 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/1_63657990626/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 1_63657990626
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 2 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/2_63657990626/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 2_63657990626
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 3 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/3_63657990625/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 3_63657990625
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 4 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/4_63657990625/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 4_63657990625
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 5 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/5_63657990624/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 5_63657990624
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 6 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/6_63657990624/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 6_63657990624
lrwxrwxrwx 1 yosuke yosuke   91 Mar 29 16:10 7 -> /home/yosuke/dev/projects/leo-project/leofs/package/leo_storage/avs/metadata/7_63657990623/
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:10 7_63657990623

After

$ ls -l log/
total 0
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_0 -> /var/leofs/log/leo_object_storage_0.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_0.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_1 -> /var/leofs/log/leo_object_storage_1.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_1.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_2 -> /var/leofs/log/leo_object_storage_2.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_2.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_3 -> /var/leofs/log/leo_object_storage_3.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_3.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_4 -> /var/leofs/log/leo_object_storage_4.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_4.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_5 -> /var/leofs/log/leo_object_storage_5.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_5.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_6 -> /var/leofs/log/leo_object_storage_6.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_6.20170329.16.1
lrwxrwxrwx 1 yosuke yosuke 49 Mar 29 16:11 leo_object_storage_7 -> /var/leofs/log/leo_object_storage_7.20170329.16.1
-rw-rw-r-- 1 yosuke yosuke  0 Mar 29 16:11 leo_object_storage_7.20170329.16.1

$ ls -l object/
total 32
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 0.avs -> /var/leofs/object/0.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 0.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 1.avs -> /var/leofs/object/1.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 1.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 2.avs -> /var/leofs/object/2.avs_63657990626
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 2.avs_63657990626
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 3.avs -> /var/leofs/object/3.avs_63657990625
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 3.avs_63657990625
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 4.avs -> /var/leofs/object/4.avs_63657990625
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 4.avs_63657990625
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 5.avs -> /var/leofs/object/5.avs_63657990624
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 5.avs_63657990624
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 6.avs -> /var/leofs/object/6.avs_63657990624
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 6.avs_63657990624
lrwxrwxrwx 1 yosuke yosuke  35 Mar 29 16:11 7.avs -> /var/leofs/object/7.avs_63657990623
-rw-rw-r-- 1 yosuke yosuke 194 Mar 29 16:11 7.avs_63657990623

$ ls -l metadata/
total 32
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 0 -> /var/leofs/metadata/0_63657990626
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 0_63657990626
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 1 -> /var/leofs/metadata/1_63657990626
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 1_63657990626
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 2 -> /var/leofs/metadata/2_63657990626
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 2_63657990626
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 3 -> /var/leofs/metadata/3_63657990625
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 3_63657990625
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 4 -> /var/leofs/metadata/4_63657990625
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 4_63657990625
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 5 -> /var/leofs/metadata/5_63657990624
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 5_63657990624
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 6 -> /var/leofs/metadata/6_63657990624
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 6_63657990624
lrwxrwxrwx 1 yosuke yosuke   33 Mar 29 16:11 7 -> /var/leofs/metadata/7_63657990623
drwxrwxr-x 9 yosuke yosuke 4096 Mar 29 16:11 7_63657990623
yosuke@ubuntu1604s:/var/leofs$

@vstax
Copy link
Contributor

vstax commented Mar 29, 2017

@yosukehara This is nice tool, but I think there are two problems. First, it creates incorrect symlinks in "log" directory. Example log:

[root@leo-s0 shm]# LANG=C ./mv_avs_dir.sh avs/ /mnt/avs/_
::: LeoFS / move-avs-directories :::

[INFO]
   Src dir: avs
  Dest dir: /mnt/avs/_

/dev/shm
/dev/shm
/dev/shm
[CREATED] /mnt/avs/_/log/leo_object_storage_0.20170110.16.1 > /mnt/avs/_/log/leo_object_storage_0
ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_0': File exists
[CREATED] /mnt/avs/_/log/leo_object_storage_0.20170205.19.1 > /mnt/avs/_/log/leo_object_storage_0
ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_0': File exists
[CREATED] /mnt/avs/_/log/leo_object_storage_0.20170218.22.1 > /mnt/avs/_/log/leo_object_storage_0
ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_0': File exists

[..skipped..]

[CREATED] /mnt/avs/_/log/leo_object_storage_0.report.63656901275 > /mnt/avs/_/log/leo_object_storage_0
ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_0': File exists
[CREATED] /mnt/avs/_/log/leo_object_storage_0.report.63656904926 > /mnt/avs/_/log/leo_object_storage_0
[CREATED] /mnt/avs/_/log/leo_object_storage_1.20170110.16.1 > /mnt/avs/_/log/leo_object_storage_1
ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_1': File exists

[..skipped..]

ln: failed to create symbolic link '/mnt/avs/_/log/leo_object_storage_7': File exists
[CREATED] /mnt/avs/_/log/leo_object_storage_7.report.63656904955 > /mnt/avs/_/log/leo_object_storage_7
/dev/shm
[CREATED] /mnt/avs/_/object/0.avs_63656904922 > /mnt/avs/_/object/0.avs
[CREATED] /mnt/avs/_/object/1.avs_63656904926 > /mnt/avs/_/object/1.avs
[CREATED] /mnt/avs/_/object/2.avs_63656904929 > /mnt/avs/_/object/2.avs
[CREATED] /mnt/avs/_/object/3.avs_63656904933 > /mnt/avs/_/object/3.avs
[CREATED] /mnt/avs/_/object/4.avs_63656904937 > /mnt/avs/_/object/4.avs
[CREATED] /mnt/avs/_/object/5.avs_63656904944 > /mnt/avs/_/object/5.avs
[CREATED] /mnt/avs/_/object/6.avs_63656904946 > /mnt/avs/_/object/6.avs
[CREATED] /mnt/avs/_/object/7.avs_63656296549 > /mnt/avs/_/object/7.avs
ln: failed to create symbolic link '/mnt/avs/_/object/7.avs': File exists
[CREATED] /mnt/avs/_/object/7.avs_63656904949 > /mnt/avs/_/object/7.avs
/dev/shm
[CREATED] /mnt/avs/_/metadata/0_63656904922 > /mnt/avs/_/metadata/0
[CREATED] /mnt/avs/_/metadata/0_leo_metadata_0.state > /mnt/avs/_/metadata/0
[CREATED] /mnt/avs/_/metadata/1_63656904926 > /mnt/avs/_/metadata/1
[CREATED] /mnt/avs/_/metadata/1_leo_metadata_1.state > /mnt/avs/_/metadata/1
[CREATED] /mnt/avs/_/metadata/2_63656904929 > /mnt/avs/_/metadata/2
[CREATED] /mnt/avs/_/metadata/2_leo_metadata_2.state > /mnt/avs/_/metadata/2
[CREATED] /mnt/avs/_/metadata/3_63656904933 > /mnt/avs/_/metadata/3
[CREATED] /mnt/avs/_/metadata/3_leo_metadata_3.state > /mnt/avs/_/metadata/3
[CREATED] /mnt/avs/_/metadata/4_63656904937 > /mnt/avs/_/metadata/4
[CREATED] /mnt/avs/_/metadata/4_leo_metadata_4.state > /mnt/avs/_/metadata/4
[CREATED] /mnt/avs/_/metadata/5_63656904945 > /mnt/avs/_/metadata/5
[CREATED] /mnt/avs/_/metadata/5_leo_metadata_5.state > /mnt/avs/_/metadata/5
[CREATED] /mnt/avs/_/metadata/6_63656904946 > /mnt/avs/_/metadata/6
[CREATED] /mnt/avs/_/metadata/6_leo_metadata_6.state > /mnt/avs/_/metadata/6
[CREATED] /mnt/avs/_/metadata/7_63656296549 > /mnt/avs/_/metadata/7
[CREATED] /mnt/avs/_/metadata/7_63656904950 > /mnt/avs/_/metadata/7
[CREATED] /mnt/avs/_/metadata/7_leo_metadata_7.state > /mnt/avs/_/metadata/7
/dev/shm
[FINISHED]

Result:

[root@leo-s0 shm]# LANG=C ls -l /dev/shm/avs/log/leo_object_storage_0 /mnt/avs/_/log/leo_object_storage_0
lrwxrwxrwx. 1 leofs leofs 47 Mar 29 18:00 /dev/shm/avs/log/leo_object_storage_0 -> /mnt/avs/log/leo_object_storage_0.20170329.18.1
lrwxrwxrwx. 1 root  root  49 Mar 29 18:51 /mnt/avs/_/log/leo_object_storage_0 -> /mnt/avs/_/log/leo_object_storage_0.20170110.16.1

Also it created incorrect link to AVS file - to older version (but this is bug specific to my system, I wrote about it here: #644 (comment))

[root@leo-s0 shm]# LANG=C ls -l /dev/shm/avs/object/7.avs /mnt/avs/_/object/7.avs
lrwxrwxrwx. 1 leofs leofs 33 Mar 16 20:35 /dev/shm/avs/object/7.avs -> /mnt/avs/object/7.avs_63656904949
lrwxrwxrwx. 1 root  root  35 Mar 29 18:51 /mnt/avs/_/object/7.avs -> /mnt/avs/_/object/7.avs_63656296549

This can be fixed by using ln -sf - symlink will be overwritten until it links to latest version.

Second problem is that when run as root, it doesn't carry ownership of original files, if they are owned by some other user. This is fixed by using -p option for cp.

I've checked with these changes (vstax@3f12d3e) and it works fine after that.

@mocchira mocchira reopened this Mar 29, 2017
@yosukehara
Copy link
Member Author

yosukehara commented Mar 29, 2017

@vstax Thank you for sharing the informative report. I'll fix that.

@yosukehara
Copy link
Member Author

@mocchira I'd like to ask you to review the code whether other problems still exist or not.

@mocchira
Copy link
Member

@yosukehara Yes I'm now reviewing while considering @vstax suggestions. I will drop the comment later.

@mocchira
Copy link
Member

@yosukehara @vstax

Review here.

Second problem is that when run as root, it doesn't carry ownership of original files, if they are owned by some other user. This is fixed by using -p option for cp.

Right.
Should be fixed with -p as @vstax suggestion.

This can be fixed by using ln -sf - symlink will be overwritten until it links to latest version.

Nod enough.
This hack can make a symlink to a wrong destination file in some cases.

Cases for not working.

  1. "avs/log" have a "leo_object_storage_${seq}.report.${timestamp}" file like the below. (This can happen in case diagnose|compaction executed.)
$ ls -al package/leo_storage/avs/log/
total 92
drwxrwxr-x 2 leofs leofs 4096 Mar 30 11:00 .
drwxrwxr-x 5 leofs leofs 4096 Mar 30 10:37 ..
lrwxrwxrwx 1 leofs leofs   89 Mar 30 11:00 leo_object_storage_0 -> /home/leofs/dev/leofs.18.3/package/leo_storage/avs/log/leo_object_storage_0.20170330.11.1
-rw-rw-r-- 1 leofs leofs  239 Mar 30 10:39 leo_object_storage_0.20170330.10.1
-rw-rw-r-- 1 leofs leofs    0 Mar 30 11:00 leo_object_storage_0.20170330.11.1
-rw-rw-r-- 1 leofs leofs  343 Mar 30 10:39 leo_object_storage_0.report.63658057179

Now those entries wrongly migrated into

$ ls -al tmp/log/
total 92
drwxrwxr-x 2 leofs leofs 4096 Mar 30 10:55 .
drwxrwxr-x 5 leofs leofs 4096 Mar 30 10:55 ..
lrwxrwxrwx 1 leofs leofs   74 Mar 30 10:55 leo_object_storage_0 -> /home/leofs/dev/leofs.18.3/tmp/log/leo_object_storage_0.report.63658057179
-rw-rw-r-- 1 leofs leofs  239 Mar 30 10:39 leo_object_storage_0.20170330.10.1
-rw-rw-r-- 1 leofs leofs    0 Mar 30 10:39 leo_object_storage_0.20170330.10.2
-rw-rw-r-- 1 leofs leofs  343 Mar 30 10:39 leo_object_storage_0.report.63658057179

OMG! Now the symlink refer to a report file NOT the original one

  1. Multiple (files|directories) per one entry under "avs/{object,metadata}" exist like the below. (This can happen in case a compaction failed for some reason also failed to remove a temporal compacted file.)
$ ls -al package/leo_storage/avs/object/
total 96
drwxrwxr-x 2 leofs leofs  4096 Mar 30 10:37 .
drwxrwxr-x 5 leofs leofs  4096 Mar 30 10:37 ..
lrwxrwxrwx 1 leofs leofs    75 Mar 30 10:37 0.avs -> /home/leofs/dev/leofs.18.3/package/leo_storage/avs/object/0.avs_63658057055
-rw-rw-r-- 1 leofs leofs   719 Mar 30 10:38 0.avs_63658057055
-rw-rw-r-- 1 leofs leofs   522 Mar 30 10:37 0.avs_63658057072

Now those wrongly migrated into

$ ls -al tmp/object/
total 64
drwxrwxr-x 2 leofs leofs  4096 Mar 30 10:55 .
drwxrwxr-x 5 leofs leofs  4096 Mar 30 10:55 ..
lrwxrwxrwx 1 leofs leofs    55 Mar 30 10:55 0.avs -> /home/leofs/dev/leofs.18.3/tmp/object/0.avs_63658057072
-rw-rw-r-- 1 leofs leofs   719 Mar 30 10:38 0.avs_63658057055
-rw-rw-r-- 1 leofs leofs   522 Mar 30 10:37 0.avs_63658057072

OMG! Now the symlink refer to a temporal compacted file NOT the original one

That being said, we have to track which files/directories were symlinked in the first place.

Also one more thing for the code clarity.
Code that tried to trim the suffixed slash can be written by

-if `echo $src | tail -c2 | grep -q '/'` ; then
-    src=`echo $src | rev | cut -c 2- | rev`
-fi
-if `echo $dest | tail -c2 | grep -q '/'` ; then
-    dest=`echo $dest | rev | cut -c 2- | rev`
-fi

+src=${src%/}
+dest=${dest%/}

That's all from me.

@yosukehara
Copy link
Member Author

yosukehara commented Mar 30, 2017

In conclusion, I need to fix two problems:

  • Fix ownership of the files (It is able to fix @vstax 's code, cp -rp $src/* $dest/ )
  • Restore the simlink of each file.

yosukehara added a commit to yosukehara/leofs that referenced this issue Apr 4, 2017
yosukehara added a commit to yosukehara/leofs that referenced this issue Apr 5, 2017
mocchira pushed a commit that referenced this issue Apr 5, 2017
@yosukehara
Copy link
Member Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants