Skip to content

Commit 38e3bc5

Browse files
amir73ilgregkh
authored andcommitted
ovl: fix failure to fsync lower dir
commit d796e77 upstream. As a writable mount, it is not expected for overlayfs to return EINVAL/EROFS for fsync, even if dir/file is not changed. This commit fixes the case of fsync of directory, which is easier to address, because overlayfs already implements fsync file operation for directories. The problem reported by Raphael is that new PostgreSQL 10.0 with a database in overlayfs where lower layer in squashfs fails to start. The failure is due to fsync error, when PostgreSQL does fsync on all existing db directories on startup and a specific directory exists lower layer with no changes. Reported-by: Raphael Hertzog <raphael@ouaza.com> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Tested-by: Raphaël Hertzog <hertzog@debian.org> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a468a37 commit 38e3bc5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/overlayfs/readdir.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,14 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
434434
struct dentry *dentry = file->f_path.dentry;
435435
struct file *realfile = od->realfile;
436436

437+
/* Nothing to sync for lower */
438+
if (!OVL_TYPE_UPPER(ovl_path_type(dentry)))
439+
return 0;
440+
437441
/*
438442
* Need to check if we started out being a lower dir, but got copied up
439443
*/
440-
if (!od->is_upper && OVL_TYPE_UPPER(ovl_path_type(dentry))) {
444+
if (!od->is_upper) {
441445
struct inode *inode = file_inode(file);
442446

443447
realfile = lockless_dereference(od->upperfile);

0 commit comments

Comments
 (0)