[lxc-devel] [RFC] rootfs pinning

Stéphane Graber stgraber at ubuntu.com
Thu Sep 12 18:34:22 UTC 2013


On Thu, Sep 12, 2013 at 08:27:07PM +0200, Christian Seiler wrote:
> Hi there,
> 
> just a quick question: currently, rootfs is pinned with a .hold file in
> the parent directory (which btw. does not help against file systems that
> are already mounted on the host but directly in the rootfs directory).
> The problem with the .hold file is that it doesn't make the directory
> necessarily pretty; I tend to mount all rootfs to /srv/lxc/$container
> (config remaining in /var/lib/lxc), and then when doing a ls /srv/lxc, I
> see tons of .hold files. (I'm not even sure that they are removed after
> container termination - but even if they are, the default state of a
> typical system tends to be that at least some containers are running...)
> 
> Couldn't we just open $rootfs/lxc.hold for writing, keep the fd (as
> current pinfd) and then unlink (!) the file directly? According to POSIX
> semantics, the file is then still open and the pinning should work (now
> also for the above case), but there are no files lying around anymore.
> (Note: I didn't test that, it could well be that that doesn't work.)
> 
> Thoughts?

Removing the file without closing the fd should work fine, just to
confirm, I did:

root at castiana:~# mount -t tmpfs tmpfs /mnt
root at castiana:~# python3
Python 3.3.2+ (default, Jun  5 2013, 10:51:51) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> fd = open("/mnt/a", "w+")
>>> os.remove("/mnt/a")
>>> 
[1]+  Stopped                 python3
root at castiana:~# mount -o remount,ro /mnt
mount: /mnt is busy
root at castiana:~# lsof -n | grep /mnt/a
python3    9300                  root    3u      REG               0,46        0     289559 /mnt/a (deleted)
root at castiana:~# fg
python3
>>> 
root at castiana:~# mount -o remount,ro /mnt
root at castiana:~# umount /mnt
root at castiana:~# 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130912/b275acfa/attachment.pgp>


More information about the lxc-devel mailing list