diff options
author | David Howells <dhowells@redhat.com> | 2015-06-18 09:32:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-19 03:19:31 -0400 |
commit | f25801ee4680ef1db21e15c112e6e5fe3ffe8da5 (patch) | |
tree | f8e57a57d9d21f34eaf567525358da4cf0d92736 | |
parent | 4ef51e8b7aaa67493ad5b36a0e5874bf6ff8b956 (diff) |
overlay: Call ovl_drop_write() earlier in ovl_dentry_open()
Call ovl_drop_write() earlier in ovl_dentry_open() before we call vfs_open()
as we've done the copy up for which we needed the freeze-write lock by that
point.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/overlayfs/inode.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 308379b2d0b2..21079d1ca2aa 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -343,31 +343,25 @@ static int ovl_dentry_open(struct dentry *dentry, struct file *file, | |||
343 | int err; | 343 | int err; |
344 | struct path realpath; | 344 | struct path realpath; |
345 | enum ovl_path_type type; | 345 | enum ovl_path_type type; |
346 | bool want_write = false; | ||
347 | 346 | ||
348 | type = ovl_path_real(dentry, &realpath); | 347 | type = ovl_path_real(dentry, &realpath); |
349 | if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) { | 348 | if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) { |
350 | want_write = true; | ||
351 | err = ovl_want_write(dentry); | 349 | err = ovl_want_write(dentry); |
352 | if (err) | 350 | if (err) |
353 | goto out; | 351 | return err; |
354 | 352 | ||
355 | if (file->f_flags & O_TRUNC) | 353 | if (file->f_flags & O_TRUNC) |
356 | err = ovl_copy_up_last(dentry, NULL, true); | 354 | err = ovl_copy_up_last(dentry, NULL, true); |
357 | else | 355 | else |
358 | err = ovl_copy_up(dentry); | 356 | err = ovl_copy_up(dentry); |
357 | ovl_drop_write(dentry); | ||
359 | if (err) | 358 | if (err) |
360 | goto out_drop_write; | 359 | return err; |
361 | 360 | ||
362 | ovl_path_upper(dentry, &realpath); | 361 | ovl_path_upper(dentry, &realpath); |
363 | } | 362 | } |
364 | 363 | ||
365 | err = vfs_open(&realpath, file, cred); | 364 | return vfs_open(&realpath, file, cred); |
366 | out_drop_write: | ||
367 | if (want_write) | ||
368 | ovl_drop_write(dentry); | ||
369 | out: | ||
370 | return err; | ||
371 | } | 365 | } |
372 | 366 | ||
373 | static const struct inode_operations ovl_file_inode_operations = { | 367 | static const struct inode_operations ovl_file_inode_operations = { |