[LU-12650] get_root_path() filesystem name compare error that leads to fid2path fail Created: 09/Aug/19  Updated: 28/Oct/19  Resolved: 16/Sep/19

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: Lustre 2.13.0, Lustre 2.12.3

Type: Bug Priority: Minor
Reporter: Artem Blagodarenko (Inactive) Assignee: Artem Blagodarenko (Inactive)
Resolution: Fixed Votes: 0
Labels: patch

Issue Links:
Duplicate
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

get_root_path() returns (for instance) path to "lustre" mount instead "lustre1"
because last symbol is not taking in account during comparison.
This bug has influence to get_root_path() users.

For example, fid2path use get_root_path().

mount -t lustre
 /dev/mapper/mds1_flakey on /mnt/lustre-mds1 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre-MDT0000,mgs,osd=osd-ldiskfs,user_xattr,errors=remount-ro)
 /dev/mapper/ost1_flakey on /mnt/lustre-ost1 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre-OST0000,mgsnode=192.168.1.227@tcp,osd=osd-ldiskfs,errors=remount-ro)
 /dev/mapper/ost2_flakey on /mnt/lustre-ost2 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre-OST0001,mgsnode=192.168.1.227@tcp,osd=osd-ldiskfs,errors=remount-ro)
 192.168.1.227@tcp:/lustre on /mnt/lustre type lustre (rw,seclabel,flock,user_xattr,lazystatfs)
 /tmp/lustre2-mdt on /mnt/lustre2-mds1 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre2-MDT0000,mgsnode=192.168.1.227@tcp,osd=osd-ldiskfs,user_xattr,errors=remount-ro)
 /tmp/lustre2-ost1 on /mnt/lustre2-ost1 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre2-OST0000,mgsnode=192.168.1.227@tcp,osd=osd-ldiskfs,errors=remount-ro)
 /tmp/lustre2-ost2 on /mnt/lustre2-ost2 type lustre (ro,context=unconfined_u:object_r:user_tmp_t:s0,svname=lustre2-OST0001,mgsnode=192.168.1.227@tcp,osd=osd-ldiskfs,errors=remount-ro)
 192.168.1.227@tcp:/lustre2 on /mnt/lustre2 type lustre (rw,seclabel,flock,lazystatfs)
lfs path2fid /mnt/lustre2/foodir3
 [0x200000401:0x1:0x0]

lfs fid2path lustre2 [0x200000401:0x1:0x0]
 lfs fid2path: cannot find '[0x200000401:0x1:0x0]': No such file or
 directory

umount /mnt/lustre
 lfs fid2path lustre2 [0x200000401:0x1:0x0]
 foodir3


 Comments   
Comment by Artem Blagodarenko (Inactive) [ 09/Aug/19 ]

On 2.7 this bug leads to changeling errors. lfs changeling returns information from wrong fs. In muster, changeling completely rewritten, so only fid2path (probably other commands) are failed.

Comment by Alex Zhuravlev [ 09/Aug/19 ]

can you check that with master branch, please?

Comment by Andreas Dilger [ 09/Aug/19 ]

I'd prefer removing get_root_path() as much as possible. Instead of extracting the fsname from /proc/mounts via a complex scan, we can call a single ioctl() to get the filesystem name directly from any file/directory in the filesystem.

For example, patch https://review.whamcloud.com/35451 "LU-12521 llapi: add separate fsname and instance" adds more useful interfaces that get the fsname and instance directly from the kernel.

Comment by Gerrit Updater [ 09/Aug/19 ]

Artem Blagodarenko (c17828@cray.com) uploaded a new patch: https://review.whamcloud.com/35755
Subject: LU-12650 lib: fix strings comparison during mount searching
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 23ae1d0acaaf9385cfbcd93223a8f14bf0850faf

Comment by Artem Blagodarenko (Inactive) [ 09/Aug/19 ]

> can you check that with master branch, please?
The experiment from description was executed on master.

Comment by Artem Blagodarenko (Inactive) [ 09/Aug/19 ]

adilger , thanks for pointing to right solution. I uploaded solution I used to fix this issue here, because it is ready and works. But sure, we can make other patch or both.

Patch above can be useful for other get_root_path() users. We need to deleted this function or fix.

Comment by Gerrit Updater [ 16/Sep/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/35755/
Subject: LU-12650 lib: fix strings comparison during mount searching
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 0817efd73f04bf59d1234887bc3971d2d067067e

Comment by Peter Jones [ 16/Sep/19 ]

Landed for 2.13

Comment by Gerrit Updater [ 17/Sep/19 ]

Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/36211
Subject: LU-12650 lib: fix strings comparison during mount searching
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: 8253429de7c6bfd03e250e6395d76d143aeb3f77

Comment by Gerrit Updater [ 23/Sep/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36211/
Subject: LU-12650 lib: fix strings comparison during mount searching
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: 9ab5dc7b1f3d3814b6d876e427c56415e8c7bb8a

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