From: Vivek Goyal <vgoyal@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-unionfs@vger.kernel.org
Cc: jlayton@kernel.org, vgoyal@redhat.com, amir73il@gmail.com,
sargun@sargun.me, miklos@szeredi.hu, willy@infradead.org,
jack@suse.cz, neilb@suse.com, viro@zeniv.linux.org.uk
Subject: [PATCH 2/3] overlayfs: Implement f_op->syncfs() call
Date: Wed, 16 Dec 2020 18:31:48 -0500 [thread overview]
Message-ID: <20201216233149.39025-3-vgoyal@redhat.com> (raw)
In-Reply-To: <20201216233149.39025-1-vgoyal@redhat.com>
Provide an implementation for ->syncfs(). Now if there is an error
returned by sync_filesystem(upper_sb), it will be visible to user
space. Currently in ovl_sync_fs() path, this error is ignored by VFS.
A later patch also adds logic to detect writeback error.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
fs/overlayfs/file.c | 1 +
fs/overlayfs/overlayfs.h | 3 +++
fs/overlayfs/readdir.c | 1 +
fs/overlayfs/super.c | 30 ++++++++++++++++++++++++++++++
4 files changed, 35 insertions(+)
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index efccb7c1f9bc..affc1ba63202 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -806,6 +806,7 @@ const struct file_operations ovl_file_operations = {
.copy_file_range = ovl_copy_file_range,
.remap_file_range = ovl_remap_file_range,
+ .syncfs = ovl_syncfs,
};
int __init ovl_aio_request_cache_init(void)
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index f8880aa2ba0e..1efb13800755 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -520,3 +520,6 @@ int ovl_set_origin(struct dentry *dentry, struct dentry *lower,
/* export.c */
extern const struct export_operations ovl_export_operations;
+
+/* super.c */
+int ovl_syncfs(struct file *file);
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 01620ebae1bd..e89b450c8f8f 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -975,6 +975,7 @@ const struct file_operations ovl_dir_operations = {
#ifdef CONFIG_COMPAT
.compat_ioctl = ovl_compat_ioctl,
#endif
+ .syncfs = ovl_syncfs,
};
int ovl_check_empty_dir(struct dentry *dentry, struct list_head *list)
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 290983bcfbb3..b4d92e6fa5ce 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -286,6 +286,36 @@ static int ovl_sync_fs(struct super_block *sb, int wait)
return ret;
}
+int ovl_syncfs(struct file *file)
+{
+ struct super_block *sb = file->f_path.dentry->d_sb;
+ struct ovl_fs *ofs = sb->s_fs_info;
+ struct super_block *upper_sb;
+ int ret;
+
+ ret = 0;
+ down_read(&sb->s_umount);
+ if (sb_rdonly(sb))
+ goto out;
+
+ if (!ovl_upper_mnt(ofs))
+ goto out;
+
+ if (!ovl_should_sync(ofs))
+ goto out;
+
+ upper_sb = ovl_upper_mnt(ofs)->mnt_sb;
+
+ down_read(&upper_sb->s_umount);
+ ret = sync_filesystem(upper_sb);
+ up_read(&upper_sb->s_umount);
+
+
+out:
+ up_read(&sb->s_umount);
+ return ret;
+}
+
/**
* ovl_statfs
* @sb: The overlayfs super block
--
2.25.4
next prev parent reply other threads:[~2020-12-16 23:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 23:31 [RFC PATCH 0/3] vfs, overlayfs: Fix syncfs() to return error Vivek Goyal
2020-12-16 23:31 ` [PATCH 1/3] vfs: add new f_op->syncfs vector Vivek Goyal
2020-12-17 0:49 ` Al Viro
2020-12-17 9:57 ` Jan Kara
2020-12-17 16:15 ` Vivek Goyal
2020-12-17 15:00 ` Vivek Goyal
2020-12-17 19:49 ` Jeff Layton
2020-12-16 23:31 ` Vivek Goyal [this message]
2020-12-16 23:31 ` [PATCH 3/3] overlayfs: Check writeback errors w.r.t upper in ->syncfs() Vivek Goyal
2020-12-17 20:08 ` Jeffrey Layton
2020-12-18 14:44 ` Vivek Goyal
2020-12-18 15:02 ` Jeff Layton
2020-12-18 16:28 ` Vivek Goyal
2020-12-18 16:55 ` Jeffrey Layton
2020-12-18 20:25 ` NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201216233149.39025-3-vgoyal@redhat.com \
--to=vgoyal@redhat.com \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neilb@suse.com \
--cc=sargun@sargun.me \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).