Whamcloud - gitweb
LU-14949 llite: Always do lookup on ENOENT in open
When there is no valid dentry found for a file we want to
open, we perform a full lookup, which goes to the server
and looks up the file by name. When we find an existing
dentry in cache *but the file is not open on the node*, we
do not do a full lookup. We move directly to opening the
file.
When we open files, we use the FID of the file. The
problem occurs when a new file is renamed *over* the file
we were trying to open. This removes the FID we are
trying to open, but the file *name* userspace called open()
on is still present. In this case, we will return ENOENT,
even though there is a file matching the name used in the
open() call.
The solution is when we get an ENOENT on open (indicating
our open raced with an unlink), we always send ESTALE back
to the VFS, which restarts the open and forces a lookup to
the server (by forcing Lustre to consider the dentry
invalid, see comments in ll_intent_file_open and code in
ll_revalidate_dentry).
This causes a lookup by name, which will correctly handle
the rename, allowing the open to proceed normally.
This should only generate extra retries in the case where a
positive dentry exists on the client but the file has been
removed on the server, ie, open racing with unlink.
This should hopefully be rare.
Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Signed-off-by: Oleg Drokin <green@whamcloud.com>
Change-Id: If9157cac901c81d6ad3f15997d419d3907fe88b8
Reviewed-on: https://review.whamcloud.com/44675
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>