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.



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).


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

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

1 Like

@stgraber As Kernel Version 5.12 is now released, I would like to ask some questions:
Above you say that LXD will use the new approach automatically, so I assume it is already included in the latest LXD version?
And does it automatically replace shiftfs and all the shift options?
Or are further settings (like new options) necessary?

Also I assume there will be more information available, especially regarding potential differences and downsides?

@brauner is currently working on it. Once implemented it will automatically replace shiftfs on systems that can handle it.

1 Like

Is currently any workaround for this? Like a drop cache or so?

Yes, that usually helps!

@stgraber Followup-Question:
So I assume that shiftfs will still be supported on systems with older kernels than 5.12?

Yeah, we intend to keep supporting shiftfs in LXD until LXD 5.0 at which point we’ll drop support for it and the only mount shifting option will be to run a 5.12 kernel or higher.

1 Like

And if I may ask, what timeframe are we talking about (approximately)?

LXD 5.0 would be April 2022

1 Like

Useful topic for me, useful information to be applied in my workflow, thanks to all!