やるきなし

2018/07/12 12:15 / overlayfs の挙動がおかしい(Linux 4.17.5)

以下のような状況を想定.

% ls -Rla
.:
total 0
drwxr-xr-x 1 myn    users   24 Jul 12 12:06 ./
drwxr-xr-x 1 myn    users 2018 Jul 12 12:12 ../
drwxr-xr-x 1 myn    users    8 Jul 12 12:13 low/
drwxr-xr-x 1 myn    users    0 Jul 12 12:06 over/
drwxr-xr-x 1 myn    users   16 Jul 12 12:14 up/
drwxr-xr-x 1 myn    users    0 Jul 12 12:14 work/

./low:
total 0
drwxr-xr-x 1 myn    users  8 Jul 12 12:13 ./
drwxr-xr-x 1 myn    users 24 Jul 12 12:06 ../
drwxr-xr-x 1 myn    users 18 Jul 12 12:08 dir0/

./low/dir0:
total 0
drwxr-xr-x 1 myn    users 18 Jul 12 12:08 ./
drwxr-xr-x 1 myn    users  8 Jul 12 12:13 ../
-rw-r--r-- 1 myn    users  0 Jul 12 12:05 test
-rw-r--r-- 1 myn    users  0 Jul 12 12:05 test1

./over:
total 0
drwxr-xr-x 1 myn    users  0 Jul 12 12:06 ./
drwxr-xr-x 1 myn    users 24 Jul 12 12:06 ../

./up:
total 0
drwxr-xr-x 1 myn    users   16 Jul 12 12:14 ./
drwxr-xr-x 1 myn    users   24 Jul 12 12:06 ../
c--------- 1 root   root  0, 0 Jul  6 11:18 dir0
drwxr-xr-x 1 myn    users   20 Jul 12 12:14 dir1/

./up/dir1:
total 0
drwxr-xr-x 1 myn    users   20 Jul 12 12:14 ./
drwxr-xr-x 1 myn    users   16 Jul 12 12:14 ../
-rw-r--r-- 1 myn    users    0 Jul 12 12:09 file0
c--------- 1 root   root  0, 0 Jul  6 11:18 file1

./work:
total 0
drwxr-xr-x 1 myn    users  0 Jul 12 12:14 ./
drwxr-xr-x 1 myn    users 24 Jul 12 12:06 ../

ここで

% sudo mount -t overlay -olowerdir=low,upperdir=up,workdir=work overlay over

で mount すると,

% ls -Rla over
over:
total 0
drwxr-xr-x 1 myn    users 16 Jul 12 12:14 ./
drwxr-xr-x 1 myn    users 26 Jul 12 12:16 ../
drwxr-xr-x 1 myn    users 20 Jul 12 12:14 dir1/

over/dir1:
ls: cannot access 'over/dir1/file1': No such file or directory
total 0
drwxr-xr-x 1 myn    users 20 Jul 12 12:14 ./
drwxr-xr-x 1 myn    users 16 Jul 12 12:14 ../
-rw-r--r-- 1 myn    users  0 Jul 12 12:09 file0
c????????? ? ?      ?      ?            ? file1

といった悲しい状況になる.uppwer 側で消すファイルが lower 側に存在せず,かつ,その directory が uppwer 側でのみ存在する場合に発生する様子(しかも起こったり起こらなかったり).Linux の Version は 4.17.5.