1 [linux-unionfs added to Cc]
3 On Tue, May 19, 2015 at 09:51:20AM +0200, Bastian Bittorf wrote:
6 > sorry for writing directly to you, feel free to forward
7 > this to the appropriate mailinglist.
9 > we have a problem with mainline overlay filesystem on kernel 3.18:
10 > https://dev.openwrt.org/ticket/19564
13 > when the working filesystem is full, overlays fails with:
15 > overlayfs: failed to create directory /overlay/work/work
17 > what is strange, that we call it with:
19 > mount(overlay, "/mnt", "overlay", MS_NOATIME, lowerdir)
22 > http://nbd.name/gitweb.cgi?p=fstools.git;a=blob;f=libfstools/mount.c;h=81176ce399b4cd8e2d347c0008c13dec92407f55;hb=e6004000ff15d7bd32cf5663e8690fc94d7ec747#l125
24 > do you have an idea whats wrong?
25 > 1) is it really needed, that we need space for creating dir "/overlay/work"?
26 > 2) why does overlay need "/overlay/work/work"?
28 The work directory is needed for atomic copy-up and similar. It is not actually
29 necessary to mount a read-only overlay. Post 4.0 it is possible to mount the
30 overlay without workdir (but even then it won't happen automatically in case the
31 upper fs is full, so this should be fixed in the latest kernel too).
33 Could you please try the following patch? If the workdir can't be created it
34 will fall back to mounting the overlay read-only.
40 fs/overlayfs/copy_up.c | 3 +++
41 fs/overlayfs/dir.c | 9 +++++++++
42 fs/overlayfs/super.c | 12 +++++++++---
43 3 files changed, 21 insertions(+), 3 deletions(-)
45 --- a/fs/overlayfs/copy_up.c
46 +++ b/fs/overlayfs/copy_up.c
47 @@ -311,6 +311,9 @@ int ovl_copy_up_one(struct dentry *paren
48 struct cred *override_cred;
51 + if (WARN_ON(!workdir))
54 ovl_path_upper(parent, &parentpath);
55 upperdir = parentpath.dentry;
57 --- a/fs/overlayfs/dir.c
58 +++ b/fs/overlayfs/dir.c
59 @@ -222,6 +222,9 @@ static struct dentry *ovl_clear_empty(st
63 + if (WARN_ON(!workdir))
64 + return ERR_PTR(-EROFS);
66 err = ovl_lock_rename_workdir(workdir, upperdir);
69 @@ -322,6 +325,9 @@ static int ovl_create_over_whiteout(stru
70 struct dentry *newdentry;
73 + if (WARN_ON(!workdir))
76 err = ovl_lock_rename_workdir(workdir, upperdir);
79 @@ -506,6 +512,9 @@ static int ovl_remove_and_whiteout(struc
80 struct dentry *opaquedir = NULL;
83 + if (WARN_ON(!workdir))
87 opaquedir = ovl_check_empty_and_clear(dentry);
88 err = PTR_ERR(opaquedir);
89 --- a/fs/overlayfs/super.c
90 +++ b/fs/overlayfs/super.c
91 @@ -741,9 +741,15 @@ static int ovl_fill_super(struct super_b
92 ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry);
93 err = PTR_ERR(ufs->workdir);
94 if (IS_ERR(ufs->workdir)) {
95 - pr_err("overlayfs: failed to create directory %s/%s\n",
96 - ufs->config.workdir, OVL_WORKDIR_NAME);
97 - goto out_put_lower_mnt;
98 + if (err == -ENOSPC || err == -EROFS) {
99 + pr_warning("overlayfs: failed to create work directory (%s), mounting read-only\n", err == ENOSPC ? "ENOSPC" : "EROFS");
100 + sb->s_flags |= MS_RDONLY;
101 + ufs->workdir = NULL;
103 + pr_err("overlayfs: failed to create directory %s/%s\n",
104 + ufs->config.workdir, OVL_WORKDIR_NAME);
105 + goto out_put_lower_mnt;