[PATCH 05/10] ovl: make sure fsync is never called on the lowerfilesystem.

From: NeilBrown
Date: Sun Sep 05 2010 - 20:51:50 EST


If we open a directory O_RDONLY, ->realfile could be on the lower
filesystem.
While fsync is not likely to be called on such a file, we should make
sure never to pass the fsync down as we are treating the lower
filesystem as read-only.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---
fs/overlayfs/overlayfs.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/fs/overlayfs/overlayfs.c b/fs/overlayfs/overlayfs.c
index de854e1..f9eea96 100644
--- a/fs/overlayfs/overlayfs.c
+++ b/fs/overlayfs/overlayfs.c
@@ -329,8 +329,15 @@ static loff_t ovl_dir_llseek(struct file *file, loff_t offset, int origin)
static int ovl_dir_fsync(struct file *file, int datasync)
{
struct ovl_dir_file *od = file->private_data;
+ struct ovl_entry *ue = file->f_path.dentry->d_fsdata;

- return vfs_fsync(od->realfile, datasync);
+ /* realfile could be on lowerdir, but only if this was a read-only open,
+ * in which case we can ignore the fsync.
+ */
+ if (file->f_path.dentry == ue->upperpath.dentry)
+ return vfs_fsync(od->realfile, datasync);
+ else
+ return 0;
}

static int ovl_dir_release(struct inode *inode, struct file *file)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/