Re: [lxc-users] writeback cache for all container processes?
On Mon, Feb 2, 2015 at 8:35 PM, Fajar A. Nugraha wrote: > On Mon, Feb 2, 2015 at 7:45 PM, Tomasz Chmielewski > wrote: > >> >>> If you want to disable sync for the container, the best you can do is >>> probably use some filesystem that can do so. For example, zfs has >>> "sync=disabled" per-dataset settings. So you can have "sync=standard" >>> for filesystems used by the host, and "sync=disabled" for filesystems >>> used by containers. >>> >> >> That's a weird advice, given that lxc are Linux containers, and ZFS is >> not in Linux kernel (I know that there are some 3rd party porting attempts, >> but it's not really applicable in many situations). >> >> > Honestly, that's the best advice I can give. It's straightforward, simple, > and works. > > There are lots of zfsonlinux users using it on production environment. > Even lxc-create supports zfs as backingstore, to a degree (man lxc-create). > And doing the above is the equivalent of having eatmydata running on > everything that access that dataset. > > FYI, this is what I just tested on ubuntu utopic with lxc 1.1.0 from daily ppa # zfs get sync,compression rpool/lxc NAME PROPERTY VALUE SOURCE rpool/lxc sync disabled inherited from rpool rpool/lxc compression lz4 inherited from rpool # lxc-create -B zfs --zfsroot=rpool/lxc -t download -n test -- -d ubuntu -r utopic -a amd64 Using image from local cache Unpacking the rootfs --- You just created an Ubuntu container (release=utopic, arch=amd64, variant=default) To enable sshd, run: apt-get install openssh-server For security reason, container images ship without user accounts and without a root password. Use lxc-attach or chroot directly into the rootfs to set a root password or create user accounts. # df -h | grep test rpool/lxc/test46G 184M 46G 1% /var/lib/lxc/test/rootfs # zfs get sync,compression,compressratio,used,logicalused rpool/lxc/test NAMEPROPERTY VALUE SOURCE rpool/lxc/test sync disabled inherited from rpool rpool/lxc/test compressionlz4 inherited from rpool rpool/lxc/test compressratio 2.04x - rpool/lxc/test used 183M - rpool/lxc/test logicalused371M - # lxc-start -n test # lxc-ls -f --running NAME STATEIPV4IPV6 GROUPS AUTOSTART -- test RUNNING 10.0.4.111 - - NO # lxc-attach -n test -- hostname test # lxc-attach -n test -- df -h Filesystem Size Used Avail Use% Mounted on rpool/lxc/test 46G 142M 46G 1% / cgroup 12K 0 12K 0% /sys/fs/cgroup none100K 4.0K 96K 4% /dev none4.0K 0 4.0K 0% /sys/fs/cgroup/cgmanager none1.2G 48K 1.2G 1% /run none5.0M 0 5.0M 0% /run/lock none5.9G 0 5.9G 0% /run/shm none100M 0 100M 0% /run/user # lxc-stop -n test -- Fajar ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] writeback cache for all container processes?
On Mon, Feb 2, 2015 at 7:45 PM, Tomasz Chmielewski wrote: > On 2015-02-02 21:37, Fajar A. Nugraha wrote: > > It's certainly possible to do "not applicable" kinds of things with >>> processes and their page cache, i.e.: >>> >>> https://code.google.com/p/pagecache-mangagement/ [1] >>> >>> Or here, disabling O_DIRECT and sync would be sort of matching >>> "feature-wise" with KVM's cache=writeback: >>> >>> http://www.mcgill.org.za/stuff/software/nosync [2] >>> >>> Is it possible to set things like this for all processes in a given >>> lxc container? >>> >> >> What are you trying to achieve? >> > > I'm trying to achieve the equivalent of KVM's cache=writeback (or, > "libeatmydata / nosync") for the whole container. > > What I meant was, what are you trying to achieve by doing that? The ones you mentioned are ways to do something, which might not be applicable in this case. I assume you want to "disable sync completely, even if it means losing data on power failure" (which is what eatmydata does). > > If you want to disable sync for the container, the best you can do is >> probably use some filesystem that can do so. For example, zfs has >> "sync=disabled" per-dataset settings. So you can have "sync=standard" >> for filesystems used by the host, and "sync=disabled" for filesystems >> used by containers. >> > > That's a weird advice, given that lxc are Linux containers, and ZFS is not > in Linux kernel (I know that there are some 3rd party porting attempts, but > it's not really applicable in many situations). > > Honestly, that's the best advice I can give. It's straightforward, simple, and works. There are lots of zfsonlinux users using it on production environment. Even lxc-create supports zfs as backingstore, to a degree (man lxc-create). And doing the above is the equivalent of having eatmydata running on everything that access that dataset. Other possible solutions that I know of either does not work (e.g. eatmydata lxc-start ...) or adds additional layers and complexity (e.g. using an additional layer like iscsi/scst and setting nv_cache=1 on scst) -- Fajar ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] writeback cache for all container processes?
On 2015-02-02 21:37, Fajar A. Nugraha wrote: It's certainly possible to do "not applicable" kinds of things with processes and their page cache, i.e.: https://code.google.com/p/pagecache-mangagement/ [1] Or here, disabling O_DIRECT and sync would be sort of matching "feature-wise" with KVM's cache=writeback: http://www.mcgill.org.za/stuff/software/nosync [2] Is it possible to set things like this for all processes in a given lxc container? What are you trying to achieve? I'm trying to achieve the equivalent of KVM's cache=writeback (or, "libeatmydata / nosync") for the whole container. If you want to disable sync for the container, the best you can do is probably use some filesystem that can do so. For example, zfs has "sync=disabled" per-dataset settings. So you can have "sync=standard" for filesystems used by the host, and "sync=disabled" for filesystems used by containers. That's a weird advice, given that lxc are Linux containers, and ZFS is not in Linux kernel (I know that there are some 3rd party porting attempts, but it's not really applicable in many situations). -- Tomasz Chmielewski http://www.sslrack.com ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] writeback cache for all container processes?
On Mon, Feb 2, 2015 at 7:23 PM, Tomasz Chmielewski wrote: > On 2015-02-02 21:13, Fajar A. Nugraha wrote: > >> You do know that lxc share the same kernel instance as the host OS, >> making such settings not applicable? >> > > Why not? Perhaps I wasn't very specific when starting the thread. > > > KVM runs two kernels. One for the host, the other in the guest. LXC only has one kernel, runs both host and guest, but with namespace separation. All mounts used by the container is essentially the same (at least in terms of cache and sync) as when the host mount and use it. > It's certainly possible to do "not applicable" kinds of things with > processes and their page cache, i.e.: > > https://code.google.com/p/pagecache-mangagement/ > > > Or here, disabling O_DIRECT and sync would be sort of matching > "feature-wise" with KVM's cache=writeback: > > http://www.mcgill.org.za/stuff/software/nosync > > > Is it possible to set things like this for all processes in a given lxc > container? What are you trying to achieve? If you want to disable sync for the container, the best you can do is probably use some filesystem that can do so. For example, zfs has "sync=disabled" per-dataset settings. So you can have "sync=standard" for filesystems used by the host, and "sync=disabled" for filesystems used by containers. -- Fajar ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] writeback cache for all container processes?
On 2015-02-02 21:13, Fajar A. Nugraha wrote: You do know that lxc share the same kernel instance as the host OS, making such settings not applicable? Why not? Perhaps I wasn't very specific when starting the thread. It's certainly possible to do "not applicable" kinds of things with processes and their page cache, i.e.: https://code.google.com/p/pagecache-mangagement/ Or here, disabling O_DIRECT and sync would be sort of matching "feature-wise" with KVM's cache=writeback: http://www.mcgill.org.za/stuff/software/nosync Is it possible to set things like this for all processes in a given lxc container? -- Tomasz Chmielewski http://www.sslrack.com ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
Re: [lxc-users] writeback cache for all container processes?
You do know that lxc share the same kernel instance as the host OS, making such settings not applicable? -- Fajar On Mon, Feb 2, 2015 at 6:59 PM, Tomasz Chmielewski wrote: > Is it possible to start a lxc container with "writeback cache", in a way > similar to KVM's writeback cache? > > From "man kvm": > > cache=writeback > > It will report data writes as completed as soon as the data is > present in the host page cache. This is safe > as long as your guest OS makes sure to correctly flush disk caches > where needed. If your guest OS does not > handle volatile disk write caches correctly and your host crashes or > loses power, then the guest may > experience data corruption. > > > -- > Tomasz Chmielewski > http://www.sslrack.com > > ___ > lxc-users mailing list > lxc-users@lists.linuxcontainers.org > http://lists.linuxcontainers.org/listinfo/lxc-users ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users
[lxc-users] writeback cache for all container processes?
Is it possible to start a lxc container with "writeback cache", in a way similar to KVM's writeback cache? From "man kvm": cache=writeback It will report data writes as completed as soon as the data is present in the host page cache. This is safe as long as your guest OS makes sure to correctly flush disk caches where needed. If your guest OS does not handle volatile disk write caches correctly and your host crashes or loses power, then the guest may experience data corruption. -- Tomasz Chmielewski http://www.sslrack.com ___ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users