Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Howells and committed by
Al Viro
f25801ee 4ef51e8b

+4 -10
+4 -10
fs/overlayfs/inode.c
··· 343 343 int err; 344 344 struct path realpath; 345 345 enum ovl_path_type type; 346 - bool want_write = false; 347 346 348 347 type = ovl_path_real(dentry, &realpath); 349 348 if (ovl_open_need_copy_up(file->f_flags, type, realpath.dentry)) { 350 - want_write = true; 351 349 err = ovl_want_write(dentry); 352 350 if (err) 353 - goto out; 351 + return err; 354 352 355 353 if (file->f_flags & O_TRUNC) 356 354 err = ovl_copy_up_last(dentry, NULL, true); 357 355 else 358 356 err = ovl_copy_up(dentry); 357 + ovl_drop_write(dentry); 359 358 if (err) 360 - goto out_drop_write; 359 + return err; 361 360 362 361 ovl_path_upper(dentry, &realpath); 363 362 } 364 363 365 - err = vfs_open(&realpath, file, cred); 366 - out_drop_write: 367 - if (want_write) 368 - ovl_drop_write(dentry); 369 - out: 370 - return err; 364 + return vfs_open(&realpath, file, cred); 371 365 } 372 366 373 367 static const struct inode_operations ovl_file_inode_operations = {