Whamcloud - gitweb
LU-14949 llite: Always do lookup on ENOENT in open
authorPatrick Farrell <pfarrell@whamcloud.com>
Mon, 23 Aug 2021 17:32:07 +0000 (13:32 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 17 Sep 2021 23:47:43 +0000 (23:47 +0000)
commit204d19c3f378486ec4f01dc42a5fe769e996f7a5
tree276521723170bc128b5183fa919024c3f4180666
parent8fcf14abf89974dd7c31a69c25b43258b8afd840
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.

Lustre-change: https://review.whamcloud.com/44675
Lustre-commit: 72c1f7095203cc1badadf581c66f9546476438ab

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ice19f4bdbea9a2cbeb337336f7e7098afa6b4be3
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-on: https://review.whamcloud.com/44949
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/obd_support.h
lustre/llite/file.c
lustre/tests/sanity.sh
lustre/tests/sanityn.sh