[PATCH 2/5] erofs-utils: mount: Refactor NBD connection logic in erofsmount_nbd()
zhaoyifan (H)
zhaoyifan28 at huawei.com
Fri Dec 26 18:42:32 AEDT 2025
On 2025/12/26 14:57, Gao Xiang wrote:
>
>
> On 2025/12/23 18:04, Yifan Zhao wrote:
>> From: Yifan Zhao <yifan.yfzhao at foxmail.com>
>>
>> The current NBD connection logic has the following issues:
>>
>> 1.It first tries netlink (forking a child), then falls back to ioctl
>> (forking another), causing redundant process overhead and double-opening
>> of erofs_nbd_source on fallback.
>
> But I don't want to open source on the main process. Especially if we'd
> like to trigger multiple layers.
>
> If you really want to optimize this, how about just forking one child
> process for both netlink and ioctl, and opening erofs_nbd_source in
> the child process too.
>
yeah, this is exactly what this patchset did, one child for both netlink
and ioctl.
>> 2.Child processes fail silently, hiding the error cause from the parent
>> and confusing users.
>> 3.erofsmount_startnbd() doesn’t ignore SIGPIPE, causing nbd_loopfn to be
>> killed abruptly without clean up during disconnect.
>> 4.During disconnect, -EPIPE from NBD socket I/O is expected, but
>> erofsmount_nbd_loopfn() does not suppress it, leading to uncessary
>> "NBD worker failed with EPIPE" message printed in erofsmount_startnbd().
>
> Could we address these issues independently?
Fixing issue 2 is limited by the current thread model (previous 'double
error print') problem.
Issue 3 & 4 are almost identical; however, fixing them under the current
codebase would
require additional modifications after this patch is merged. That’s why
I’ve included them in
this patch. I believe they could alternatively be deferred and addressed
separately in a subsequent patch.
Thanks,
Yifan
>
> Thanks,
> Gao Xiang
>
>>
>> This patch consolidates the netlink and ioctl fallback logic into a
>> single child process, eliminating redundant erofs_nbd_source opens. It
>> also ensure SIGPIPE and -EPIPE are properly suppressed during disconnect
>> in erofsmount_nbd_loopfn(), enabling cleanup and graceful exit.
>> Additionally, the child process now reports error code via exit() for
>> better user visibility.
>>
>> Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20251226/868747e3/attachment.htm>
More information about the Linux-erofs
mailing list