Skip to contentSkip to conversation

passthrough question

DISCUSSION Amir Goldstein 3 participants 4 messages Apr 12, 2024 – Apr 13, 2024 7 messages not in the archive VFS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAOQ4uxjOYcNxNf2S0yFxBgV9zPMhOQOxY72v5ToCxCPJ2S0e+g@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAOQ4uxjNF4Kdae5uos4Ch9qBvmAC2kSH58+wVr=F865XhVZsNQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAOQ4uxhnSDshQmjn-39Q9TbMJLZiWiYXf+8YLVqB7nPW1L5fBw@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): G2XhehibMSoDHBWhAJVS3UfIT1-OlMgYkwAgTu5v2ys1BIUCznJ1B475OEKLBFf6M9gnlpXqFIkrsWRmofllLba2b7cRogWLODZQ5Ma748w=@spawn.link

#7 lore raw

Hi Antonio,

I allowed myself to reply to this snip on-list because my answer is relevant to the
wider audience.

Quoted 11 lines · Antonio SJ Musumeci

On Wednesday, April 10th, 2024 at 9:28 AM, Amir Goldstein <[email protected]> wrote:

Not sure if that allows you to implement passthrough with mergerfs, but this is what the kernel implements.

Now that I've looked at things more closely I've realized that the passthrough requirements are in conflict with some design assumptions I made in mergerfs. Not that I can't hack around them but certainly isn't as clean as I'd like. Going to need to put critical sections around open and release to ensure no concurrent opens of the same node.

While considering different ways to take advantage of passthrough it dawned on me that it would have been nice if there was a fh value that was attached to a node on first lookup and could be freed after last forget.

That is roughly the plan for the next phase for getattr() passthrough:
https://lore.kernel.org/linux-fsdevel/CAOQ4uxgVmG6QGVHEO1u-F3XC_1_sCkP=ekfEZtgeSpsrTkX21w@mail.gmail.com/

Not fh value per-se but a backing id, allocated and attached to fuse inode on LOOKUP reply, which sticks with this inode until evict/forget. OPEN replies on this sort of inode would have to either explicitly state FOPEN_PASSTHROUGH or we can allow the kernel to imply passthrough mode open in this case. Not sure.

Sweet Tea said that he will be working on this new API, so now he has another prospective user to test and to validate the design choices.

Thanks,
Amir.

#8 lore raw
Quoted 5 lines · Amir Goldstein

Not fh value per-se but a backing id, allocated and attached to fuse inode on LOOKUP reply, which sticks with this inode until evict/forget. OPEN replies on this sort of inode would have to either explicitly state FOPEN_PASSTHROUGH or we can allow the kernel to imply passthrough mode open in this case. Not sure.

Hmm, maybe allowing a zero backing_id to mean "use current backing inode" would be sane. And if there's no current backing for the inode, and a zero backing ID is given then it would just return -ENOENT or something.

I wouldn't change anything else, so FOPEN_PASSTHROUGH would still need to be given and all the other states would work. The only difference would be that LOOKUP would allow setting up a backing path (need to think about naming, because all these backing somethings are a bit confusing).

Thoughts?

Thanks,
Miklos

#9 lore raw
Quoted 14 lines · Miklos Szeredi
Quoted 5 lines · Amir Goldstein

Not fh value per-se but a backing id, allocated and attached to fuse inode on LOOKUP reply, which sticks with this inode until evict/forget. OPEN replies on this sort of inode would have to either explicitly state FOPEN_PASSTHROUGH or we can allow the kernel to imply passthrough mode open in this case. Not sure.

Hmm, maybe allowing a zero backing_id to mean "use current backing inode" would be sane. And if there's no current backing for the inode, and a zero backing ID is given then it would just return -ENOENT or something.

Quoted 7 lines

I wouldn't change anything else, so FOPEN_PASSTHROUGH would still need to be given and all the other states would work. The only difference would be that LOOKUP would allow setting up a backing path (need to think about naming, because all these backing somethings are a bit confusing).

Thoughts?

Sounds good, except returning ENOENT to user for open with zero backing id is confusing, so I think it has to be EIO like all the other illegal passthrough open replies.

Thanks,
Amir.

#10 lore raw
Quoted 8 lines · Amir Goldstein

Sounds good, except returning ENOENT to user for open with zero backing id is confusing, so I think it has to be EIO like all the other illegal passthrough open replies.

Thanks,
Amir.

Been at the Texas Linux Fest past couple days so I've not really had time to look at what you've done for lookup yet. Will do so soon.

RE fh: I think adding a "fh" to more of the protocol could be useful. I find it extremely convenient with file lifecycle management and if it could exist for node lifecycle too that could simplify server code. This just came to mind while trying to rework my server to use passthrough and haven't dug into the code to see how plausible it is.

RE FOPEN_PASSTHROUGH and complications I've found: I've found another practical issue. Granted this is a "me" problem in how mergerfs was designed but none the less a, I think, serious issue for me. mergerfs is multiuser. It runs at root, multithreaded, and will seteuid to ensure the syscalls it makes are in the user context of the client app (where appropriate.) Unless there is some API I'm unfamiliar with there is no way in Linux to open an existing fd. Instead you are expected to open /proc/self/fd/%d. But in my case since the process is running as root /proc/self/fd/ is owned by root:root and mode 0500. While a chown will return success on /proc/self/fd/ it has no effect and a chmod fails with EPERM. So non-root can't open the file. The only thing I can think of to do is to store all the details about the file and on future opens open the filepath and ensure it is the same file before returning back to the kernel otherwise return an error.