[LU-8034] HSM: Symlink in shadow directory links to a wrong path when archiving files managed by MDT1 Created: 18/Apr/16  Updated: 23/Jul/16  Resolved: 23/Jul/16

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.8.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Tatsushi Takamura Assignee: Robert Read (Inactive)
Resolution: Duplicate Votes: 0
Labels: HSM

Severity: 3
Project: HSM
Rank (Obsolete): 9223372036854775807

 Description   

Symlink in shadow directory links to a wrong path when archiving files managed by MDT1(right path when by MDT0).

To reproduce:

[Clinet]
# mkdir /lustre/mdt0_dir
# lfs mkdir -i 1 /lustre/mdt1_dir/
# echo aaa > /lustre/mdt0_dir/file
# echo aaa > /lustre/mdt1_dir/file
# lfs hsm_archive /lustre/mdt0_dir/file
# lfs hsm_archive /lustre/mdt1_dir/file
[Agent]
# ls -l /mnt/hsm-arc/shadow/mdt0_dir/file
lrwxrwxrwx 1 root root 55 Apr 15 16:04 /mnt/hsm-arc/shadow/mdt0_dir/file -> ../../0006/0000/0403/0000/0002/0000/0x200000403:0x6:0x0
# ls -l /mnt/hsm-arc/shadow/mdt1_dir/file
lrwxrwxrwx 1 root root 58 Apr 15 16:04 /mnt/hsm-arc/shadow/mdt1_dir/file -> ../../../0002/0000/0403/4000/0002/0000/0x240000403:0x2:0x0

This is because lhsmtool_posix counts the number of "/" to figure out how many parent directories to symlink back.
But, llapi_fid2path() adds the pathname to an extra "/" in the case of files managed by MDT1.
So, the symlink links to a wrong path
(This may be a llapi_fid2path's bug).

                ptr = opt.o_hsm_root;
                while (*ptr)
                        (*ptr++ == '/') ? depth-- : 0;

                rc = llapi_fid2path(opt.o_mnt, buf, src + strlen(src),
                                    sizeof(src) - strlen(src), &recno, &linkno);


                /* Figure out how many parent dirs to symlink back */
                ptr = src;
                while (*ptr)
                        (*ptr++ == '/') ? depth++ : 0;
                sprintf(buf, "..");
                while (--depth > 1)
                        strcat(buf, "/..");
[Clinet]
# lfs fid2path /lustre/ 0x200000403:0x6:0x0
/lustre/mdt0_dir/file
# lfs fid2path /lustre/ 0x240000403:0x2:0x0
/lustre//mdt1_dir/file


 Comments   
Comment by Robert Read (Inactive) [ 18/Apr/16 ]

Since llapi_fid2path returns relative paths it probably shouldn't be adding any leading '/' anyway.

Comment by John Hammond [ 18/Apr/16 ]

This issue exists in 2.8.0 but not in 2.9.0. Not sure why exactly.

Comment by Tatsushi Takamura [ 28/Apr/16 ]

I have confirmed that this issue is resolved applying the patch of LU-28.

Thanks.

Comment by Peter Jones [ 23/Jul/16 ]

Thanks for confirming

Generated at Sat Feb 10 02:14:03 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.