]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
gfs2_atomic_open(): fix O_EXCL|O_CREAT handling on cold dcache
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 10 Mar 2020 13:31:41 +0000 (09:31 -0400)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 7 Apr 2020 08:51:55 +0000 (10:51 +0200)
BugLink: https://bugs.launchpad.net/bugs/1869732
commit 21039132650281de06a169cbe8a0f7e5c578fd8b upstream.

with the way fs/namei.c:do_last() had been done, ->atomic_open()
instances needed to recognize the case when existing file got
found with O_EXCL|O_CREAT, either by falling back to finish_no_open()
or failing themselves.  gfs2 one didn't.

Fixes: 6d4ade986f9c (GFS2: Add atomic_open support)
Cc: stable@kernel.org # v3.11
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/gfs2/inode.c

index a6ed5f4e2869d9a7f751fc3077dd5a04bd407537..3006a3e28e00bc0064a9ea5993d1b39b821311da 100644 (file)
@@ -1256,7 +1256,7 @@ static int gfs2_atomic_open(struct inode *dir, struct dentry *dentry,
                if (!(*opened & FILE_OPENED))
                        return finish_no_open(file, d);
                dput(d);
-               return 0;
+               return excl && (flags & O_CREAT) ? -EEXIST : 0;
        }
 
        BUG_ON(d != NULL);