]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
new primitive: discard_new_inode()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 28 Jun 2018 19:53:17 +0000 (15:53 -0400)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:52:47 +0000 (19:52 -0600)
commita5b1d6edcceaccbad1f964641992f820794fdfae
treeb01819e25bd78de126881f87a2edad1d4b4cf3f5
parentd662cb6259195bb85df79c056d2866951d4c3fd3
new primitive: discard_new_inode()

BugLink: https://bugs.launchpad.net/bugs/1836426
commit c2b6d621c4ffe9936adf7a55c8b1c769672c306f upstream.

We don't want open-by-handle picking half-set-up in-core
struct inode from e.g. mkdir() having failed halfway through.
In other words, we don't want such inodes returned by iget_locked()
on their way to extinction.  However, we can't just have them
unhashed - otherwise open-by-handle immediately *after* that would've
ended up creating a new in-core inode over the on-disk one that
is in process of being freed right under us.

Solution: new flag (I_CREATING) set by insert_inode_locked() and
removed by unlock_new_inode() and a new primitive (discard_new_inode())
to be used by such halfway-through-setup failure exits instead of
unlock_new_inode() / iput() combinations.  That primitive unlocks new
inode, but leaves I_CREATING in place.

iget_locked() treats finding an I_CREATING inode as failure
(-ESTALE, once we sort out the error propagation).
insert_inode_locked() treats the same as instant -EBUSY.
ilookup() treats those as icache miss.

[Fix by Dan Carpenter <dan.carpenter@oracle.com> folded in]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Miklos Szeredi <mszeredi@redhat.com>
Cc: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/dcache.c
fs/inode.c
include/linux/fs.h