[LU-9629] lfs migrate does not work as a non-root user Created: 09/Jun/17  Updated: 09/Dec/19  Resolved: 23/Oct/19

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

Type: Improvement Priority: Minor
Reporter: Andreas Dilger Assignee: James A Simmons
Resolution: Fixed Votes: 0
Labels: LTS12, medium

Issue Links:
Related
is related to LU-11501 use the dcache properly with .lustre/fid In Progress
is related to LU-11510 preserve PFL/FLR/DoM layout with lfs_... Resolved
is related to LU-11687 allow "lfs fid2path" on open-unlinked... Open
is related to LU-6051 "lfs_migrate" improvements Resolved
is related to LU-9537 implement "lfs getstripe --fid" for d... Resolved
Rank (Obsolete): 9223372036854775807

 Description   

Patch https://review.whamcloud.com/25851 "LU-6051 utils: allow lfs_migrate to handle hard links" adds the ability to migrate hard-linked files using "lfs fid2path" to determine the names of links to a file, but this command only works as the root user.

$ lfs fid2path myth [0x200016b84:0x10a9b:0x0]
ioctl err -1: Operation not permitted (1)
fid2path: error on FID [0x200016b84:0x10a9b:0x0]: Operation not permitted
$ strace lfs fid2path myth [0x200016b84:0x10a9b:0x0]
open("/etc/mtab", O_RDONLY)             = 3
read(3, "/dev/mapper/vg_twoshoes-lvroot /"..., 4096) = 466
close(3)                                = 0
open("/myth", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = 3
ioctl(3, 0xffffffffc0086696, 0x1b19040) = -1 EPERM (Operation not permitted)

So the open of the root directory succeeded, but the ioctl failed. It would be useful if a regular user could run this same command on files that they own.

Also, the "lfs fid2path" command requires specifying the mountpoint of the filesystem (e.g. /mnt/testfs), but if e.g. "$PWD" is given as the mountpoint then it prepends the whole specified path to the start of the returned pathname rather than the actual mountpoint:

# df .
Filesystem         1K-blocks        Used  Available Use% Mounted on
mookie-gig:/myth 23322497088 16086795940 6593847700  71% /myth
# lfs fid2path . [0x200016b84:0x10a9b:0x0]
ioctl err -19: No such device (19)
fid2path: error on FID [0x200016b84:0x10a9b:0x0]: No such device
# pwd
/myth/tmp/links
# lfs fid2path $PWD [0x200016b84:0x10a9b:0x0]
/myth/tmp/links/tmp/links/hosts
/myth/tmp/links/tmp/links/link1
/myth/tmp/links/tmp/links/link2
:

It would be useful if specifying "." or any other pathname looked up the mountpoint of that directory based on the current working directory and showed the correct pathnames for the links. It is already looking up the mountpoint in /etc/mtab to open the root directory for the ioctl(), so this shouldn't be too much additional work.



 Comments   
Comment by Andreas Dilger [ 17/Dec/17 ]

I believe that fid2path can already work in a subdirectory, it may just need some fixing in lctl to handle the partial path rather than always traversing to the ROOT directory.

The fid2path command could be run in the context of the user, and permission checked on every parent whether the command can continue. If the fid2path hits the designated root directory without error then the command is successful and the path can be returned, otherwise it should return -EACCESS if it doesn't have permission on some directory in the path and not return anything to userspace.

Comment by Gerrit Updater [ 05/Oct/19 ]

Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/36383
Subject: LU-9629 utils: fix lfs_migrate for non-root users
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: eeaf59b2c102f071a90e925b0d69bdba7fa2f0a5

Comment by Andreas Dilger [ 05/Oct/19 ]

The above patch mostly addresses the issue with "lfs_migrate" depending on "lfs fid2path" in order to migrate hard-linked files.  In fact, this is only needed if "lfs migrate" is not working and the fallback "rsync" code is used.  That shouldn't happen with any modern Lustre versions, so there is no requirement for "lfs fid2path" to work for most uses.

It would still be useful to fix the fid2path implementation to work for non-root users as long as the full pathname is accessible to the user, as described above, but that is for a separate patch.

Comment by Gerrit Updater [ 22/Oct/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36383/
Subject: LU-9629 utils: fix lfs_migrate for non-root users
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: dd009a221d14feb463ef1179559e5bbab22efa08

Comment by Peter Jones [ 23/Oct/19 ]

Landed for 2.13

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