Shared folder between container and host is cached?

I have 2 computers. 1 computer install ubuntu server and 1 machine working daily. On ubuntu I installed lxd with snap and I created a container called webServ

webServ container và ubuntu host chia sẻ chung folder sites bằng lệnh

lxc config device add webServ sites disk source=~/rslsync/sites path=/var/www shift=true

Ubuntu host and my 2nd computer sync data with Resilio, including ~/rslsync/sites directory on ubuntu host.

The problem I am having is that if I edit the file directly in the ~/rslsync/sites folder on the ubuntu host then when I go into the webServ container I read the file I will see the updates. But if I edit the file on 2nd computer, it will only see the update on ubuntu host but not in webServ container.

Before:
image

After:
image

I don’t know where the problem is and is there a way to work it out?

That’s most likely a shiftfs caching bug. This can happen in some cases when the underlay is changed but the overlay has cached the file.

I’ve personally had better luck with this with more recent kernels (5.8), so you may want to install the linux-generic-hwe-20.04 kernel on your system and see if that helps.

In general, those kind of issues is what’s caused us to go a completely different route when upstreaming this feature in the Linux kernel and instead doing things at the VFS layer rather than as a standalone filesystem.

The Linux 5.12 kernel should release with this new approach and LXC and LXD will automatically use the new logic when available, hopefully making this a problem of the past over the next year or so (we need some time for things to mature and distributions to adopt suitable kernels).

1 Like

Thank you very much for your quick response.

I’ll try the way you mentioned and let you know the results. I also hope it helps

Unfortunately, after updating the linux kernel, it didn’t help me either @stgraber
image

That sounds very interesting.
I am looking forward for the release and an announcement.