Re: [PATCH v2] ksmbd: return the cause of a failed link

From: Ian Bridges

Date: Sun Nov 29 2026 - 09:42:56 EST


Hi Namjae,

Thanks for the review. Please drop this patch. I'm moving the work to
my backlog, for two reasons.

The patch does not fix a bug. A link that should fail already fails,
and only the status is less exact than it could be. And your comments
showed me that a correct change is a bigger job than I expected.

The core problem is that one errno often has more than one meaning by
the time it reaches the handler. Your -EXDEV comment is one case. The
lookup returns it for a name that leaves the share, and the link code
returns it for a different mount. The FUSE case is another. vfs_link()
returns -EPERM for an immutable file and also for a filesystem that
refuses hard links, and the i_op check only finds some of the second
kind. A shared map in the handler cannot tell these apart. Each one
needs a special case next to the map, and v2 was already collecting
them.

I tried a version that solves this at the source. Each helper in vfs.c
returns errnos that have one meaning each. Where the VFS itself gives
one errno for two causes, the helper looks at the state after the
failure to find the cause, without reading i_op. Results that are
ksmbd's own decisions set the status where they are decided. Each
handler then ends with the shared map and no special cases.

That gave the right statuses for link in my tests. But it does not
work as a small change. The lookup helpers are shared, so cleaning up
their errnos changes the statuses of smb2_open() and other handlers at
the same time. Some of those handlers also depend on the old values.
To be correct, every handler has to be converted and tested together.
That is a series of its own, and it should not ride on a patch that
fixes no bug.

I'll come back to it once the fixes I have queued are out.

Thanks,
Ian