Skip to content

Commit

Permalink
overlayfs: don't hold ->i_mutex over opening the real directory
Browse files Browse the repository at this point in the history
just use it to serialize the assignment

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Oct 25, 2014
1 parent 1be47b3 commit 3d268c9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions fs/overlayfs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,20 +458,27 @@ static int ovl_dir_fsync(struct file *file, loff_t start, loff_t end,
if (!od->is_upper && ovl_path_type(dentry) == OVL_PATH_MERGE) {
struct inode *inode = file_inode(file);

mutex_lock(&inode->i_mutex);
realfile = od->upperfile;
if (!realfile) {
struct path upperpath;

ovl_path_upper(dentry, &upperpath);
realfile = ovl_path_open(&upperpath, O_RDONLY);
if (IS_ERR(realfile)) {
mutex_unlock(&inode->i_mutex);
return PTR_ERR(realfile);
mutex_lock(&inode->i_mutex);
if (!od->upperfile) {
if (IS_ERR(realfile)) {
mutex_unlock(&inode->i_mutex);
return PTR_ERR(realfile);
}
od->upperfile = realfile;
} else {
/* somebody has beaten us to it */
if (!IS_ERR(realfile))
fput(realfile);
realfile = od->upperfile;
}
od->upperfile = realfile;
mutex_unlock(&inode->i_mutex);
}
mutex_unlock(&inode->i_mutex);
}

return vfs_fsync_range(realfile, start, end, datasync);
Expand Down

0 comments on commit 3d268c9

Please sign in to comment.