Skip to contentSkip to conversation

ovl: fix mount fail because the upper doesn't have space

PATCH In review Yunlong Xing 3 participants 3 messages Jul 20, 2023 – Aug 2, 2023 Overlay filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ovl: fix mount fail because the upper doesn't have space

The current ovlfs mount flow:

ovl_fill_super
|_ovl_get_workdir
|_ovl_make_workdir
|_ovl_check_rename_whiteout

In ovl_check_rename_whiteout(), a new file is attempted to create.But if the upper doesn't have space to do this, it will return error -ENOSPC, causing the mount fail. It means that if the upper is full, the overlayfs cannot be mounted. It is not reasonable, so this patch will omit this error and continue mount flow.

Fixes cad218ab3320 ("ovl: check if upper fs supports RENAME_WHITEOUT")

---
changes of v2: Following Amir's suggestion, assuming it is not supported if the check fails because the upper does't have space
---
changes of v3: fix error of the '"' character in pr_warn()

---
 fs/overlayfs/super.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/overlayfs/super.c +4 -3
index 5b069f1a1e44..486493711650 100644
@@ -744,12 +744,13 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs,
 
 	/* Check if upper/work fs supports RENAME_WHITEOUT */
 	err = ovl_check_rename_whiteout(ofs);
-	if (err < 0)
+	if (err < 0 && err != -ENOSPC)
 		goto out;
 
-	rename_whiteout = err;
+	rename_whiteout = err > 0;
 	if (!rename_whiteout)
-		pr_warn("upper fs does not support RENAME_WHITEOUT.\n");
+		pr_warn("upper fs does not support RENAME_WHITEOUT (%i).\n",
+			err);
 
 	/*
 	 * Check if upper/work fs supports (trusted|user).overlay.* xattr

base-commit: eb26cbb1a754ccde5d4d74527dad5ba051808fad

Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Yunlong Xing

The current ovlfs mount flow:

ovl_fill_super
|_ovl_get_workdir
|_ovl_make_workdir
|_ovl_check_rename_whiteout

Quoted 5 lines

In ovl_check_rename_whiteout(), a new file is attempted to create.But if the upper doesn't have space to do this, it will return error -ENOSPC, causing the mount fail. It means that if the upper is full, the overlayfs cannot be mounted. It is not reasonable, so this patch will omit this error and continue mount flow.

Wouldn't mounting without upper (two or more lower layers) work in this case?

Thanks,
Miklos

#2 lore raw
Quoted 10 lines · Miklos Szeredi
Quoted 8 lines · Yunlong Xing

The current ovlfs mount flow:

ovl_fill_super
|_ovl_get_workdir
|_ovl_make_workdir
|_ovl_check_rename_whiteout

Quoted 7 lines
Quoted 5 lines

In ovl_check_rename_whiteout(), a new file is attempted to create.But if the upper doesn't have space to do this, it will return error -ENOSPC, causing the mount fail. It means that if the upper is full, the overlayfs cannot be mounted. It is not reasonable, so this patch will omit this error and continue mount flow.

Wouldn't mounting without upper (two or more lower layers) work in this case?

Sorry miklos, I don't understand what you mean.

The case is in "ovl_make_workdir" flow, "ovl_check_rename_whiteout" will attempt to
create a temp file. The "upper" partition(e.g scratch partition)is completely full,the
create will fail. So, the overlay mounting will failed

Quoted 3 lines

Thanks,
Miklos