* Spurious -EEXIST from NFSv3
@ 2025-11-19 10:52 Michael Stoler
2025-11-19 13:48 ` Trond Myklebust
0 siblings, 1 reply; 9+ messages in thread
From: Michael Stoler @ 2025-11-19 10:52 UTC (permalink / raw)
To: linux-nfs; +Cc: Dan Aloni
[-- Attachment #1.1: Type: text/plain, Size: 576 bytes --]
I’m having an issue with an NFS driver based on Linux 5.15.147. The
function nfs_verifier_is_delegated() spuriously returns true for NFSv3 file
inside nfs_do_lookup_revalidate(). This causes the d_revalidate method to
return true for a removed file, which in turn leads to an -EEXIST error
during exclusive creation of a non-existent file.
It appears that the root cause is an initialization races or an
uninitialized d_time value. The attached patch resolves the issue, but is
there a more graceful or proper solution?
Regards,
Michael Stoler
[-- Attachment #1.2: Type: text/html, Size: 2444 bytes --]
[-- Attachment #2: revalidate.patch --]
[-- Type: application/octet-stream, Size: 437 bytes --]
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1602,7 +1602,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
goto out_bad;
}
- if (nfs_verifier_is_delegated(dentry))
+ if (nfs_verifier_is_delegated(dentry) && NFS_PROTO(inode)->version > 3)
return nfs_lookup_revalidate_delegated(dir, dentry, inode);
/* Force a full look up iff the parent directory has changed */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Spurious -EEXIST from NFSv3
2025-11-19 10:52 Spurious -EEXIST from NFSv3 Michael Stoler
@ 2025-11-19 13:48 ` Trond Myklebust
2025-11-19 13:58 ` [PATCH 0/3] Fix verifier initialisation races for dentries Trond Myklebust
0 siblings, 1 reply; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 13:48 UTC (permalink / raw)
To: Michael Stoler, linux-nfs; +Cc: Dan Aloni
On Wed, 2025-11-19 at 12:52 +0200, Michael Stoler wrote:
>
>
> You don't often get email from michael.stoler@vastdata.com.
> Learn why this is important
>
>
>
>
>
>
> I’m having an issue with an NFS driver based on Linux 5.15.147.
> The function nfs_verifier_is_delegated() spuriously returns true for
> NFSv3 file inside nfs_do_lookup_revalidate(). This causes the
> d_revalidate method to return true for a removed file, which in turn
> leads to an -EEXIST error during exclusive creation of a non-existent
> file.
>
> It appears that the root cause is an initialization races or an
> uninitialized d_time value. The attached patch resolves the issue,
> but is there a more graceful or proper solution?
>
That patch is incorrect. The verifier must be initialised for all
visible dentries, irrespective of the NFS version. Let me see if I can
come up with something.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/3] Fix verifier initialisation races for dentries
2025-11-19 13:48 ` Trond Myklebust
@ 2025-11-19 13:58 ` Trond Myklebust
2025-11-19 13:58 ` [PATCH 1/3] NFS: Initialise verifiers for visible dentries in readdir and lookup Trond Myklebust
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 13:58 UTC (permalink / raw)
To: Michael Stoler; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Michael Stoler reports seeing an issue in which an uninitialised
verifier on a dentry is causing an incorrect revalidation. This again is
causing him to see a removed file as being still present during an
exclusive create.
The fix should be to ensure that all verifiers are initialised before
calling d_splice_alias().
Trond Myklebust (3):
NFS: Initialise verifiers for visible dentries in readdir and lookup
NFS: Initialise verifiers for visible dentries in nfs_atomic_open()
NFS: Initialise verifiers for visible dentries in
_nfs4_open_and_get_state
fs/nfs/dir.c | 8 +++++---
fs/nfs/nfs4proc.c | 27 ++++++++++++++-------------
2 files changed, 19 insertions(+), 16 deletions(-)
--
2.51.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] NFS: Initialise verifiers for visible dentries in readdir and lookup
2025-11-19 13:58 ` [PATCH 0/3] Fix verifier initialisation races for dentries Trond Myklebust
@ 2025-11-19 13:58 ` Trond Myklebust
2025-11-19 13:58 ` [PATCH 2/3] NFS: Initialise verifiers for visible dentries in nfs_atomic_open() Trond Myklebust
2025-11-19 13:58 ` [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state Trond Myklebust
2 siblings, 0 replies; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 13:58 UTC (permalink / raw)
To: Michael Stoler; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Ensure that the verifiers are initialised before calling
d_splice_alias() in both nfs_prime_dcache() and nfs_lookup().
Reported-by: Michael Stoler <michael.stoler@vastdata.com>
Fixes: a1147b8281bd ("NFS: Fix up directory verifier races")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index d557b0443e8b..2eead7e85be5 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -789,16 +789,17 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry,
goto out;
}
+ nfs_set_verifier(dentry, dir_verifier);
inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr);
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
if (alias) {
if (IS_ERR(alias))
goto out;
+ nfs_set_verifier(alias, dir_verifier);
dput(dentry);
dentry = alias;
}
- nfs_set_verifier(dentry, dir_verifier);
trace_nfs_readdir_lookup(d_inode(parent), dentry, 0);
out:
dput(dentry);
@@ -1994,13 +1995,14 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
nfs_lookup_advise_force_readdirplus(dir, flags);
no_entry:
+ nfs_set_verifier(dentry, dir_verifier);
res = d_splice_alias(inode, dentry);
if (res != NULL) {
if (IS_ERR(res))
goto out;
+ nfs_set_verifier(res, dir_verifier);
dentry = res;
}
- nfs_set_verifier(dentry, dir_verifier);
out:
trace_nfs_lookup_exit(dir, dentry, flags, PTR_ERR_OR_ZERO(res));
nfs_free_fattr(fattr);
--
2.51.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] NFS: Initialise verifiers for visible dentries in nfs_atomic_open()
2025-11-19 13:58 ` [PATCH 0/3] Fix verifier initialisation races for dentries Trond Myklebust
2025-11-19 13:58 ` [PATCH 1/3] NFS: Initialise verifiers for visible dentries in readdir and lookup Trond Myklebust
@ 2025-11-19 13:58 ` Trond Myklebust
2025-11-19 13:58 ` [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state Trond Myklebust
2 siblings, 0 replies; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 13:58 UTC (permalink / raw)
To: Michael Stoler; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Ensure that the verifiers are initialised before calling
d_splice_alias() in nfs_atomic_open().
Reported-by: Michael Stoler <michael.stoler@vastdata.com>
Fixes: 809fd143de88 ("NFSv4: Ensure nfs_atomic_open set the dentry verifier on ENOENT")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 2eead7e85be5..3b8250ee0141 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2144,12 +2144,12 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
d_drop(dentry);
switch (err) {
case -ENOENT:
- d_splice_alias(NULL, dentry);
if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE))
dir_verifier = inode_peek_iversion_raw(dir);
else
dir_verifier = nfs_save_change_attribute(dir);
nfs_set_verifier(dentry, dir_verifier);
+ d_splice_alias(NULL, dentry);
break;
case -EISDIR:
case -ENOTDIR:
--
2.51.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
2025-11-19 13:58 ` [PATCH 0/3] Fix verifier initialisation races for dentries Trond Myklebust
2025-11-19 13:58 ` [PATCH 1/3] NFS: Initialise verifiers for visible dentries in readdir and lookup Trond Myklebust
2025-11-19 13:58 ` [PATCH 2/3] NFS: Initialise verifiers for visible dentries in nfs_atomic_open() Trond Myklebust
@ 2025-11-19 13:58 ` Trond Myklebust
2025-11-19 16:14 ` Anna Schumaker
2025-11-20 10:47 ` kernel test robot
2 siblings, 2 replies; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 13:58 UTC (permalink / raw)
To: Michael Stoler; +Cc: linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Ensure that the verifiers are initialised before calling
d_splice_alias() in _nfs4_open_and_get_state().
Reported-by: Michael Stoler <michael.stoler@vastdata.com>
Fixes: cf5b4059ba71 ("NFSv4: Fix races between open and dentry revalidation")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/nfs4proc.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 93c6ce04332b..54595983525d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3174,18 +3174,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
- dentry = opendata->dentry;
- if (d_really_is_negative(dentry)) {
- struct dentry *alias;
- d_drop(dentry);
- alias = d_splice_alias(igrab(state->inode), dentry);
- /* d_splice_alias() can't fail here - it's a non-directory */
- if (alias) {
- dput(ctx->dentry);
- ctx->dentry = dentry = alias;
- }
- }
-
switch(opendata->o_arg.claim) {
default:
break;
@@ -3196,7 +3184,20 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
break;
if (opendata->o_res.delegation.type != 0)
dir_verifier = nfs_save_change_attribute(dir);
- nfs_set_verifier(dentry, dir_verifier);
+ }
+ nfs_set_verifier(dentry, dir_verifier);
+
+ dentry = opendata->dentry;
+ if (d_really_is_negative(dentry)) {
+ struct dentry *alias;
+ d_drop(dentry);
+ alias = d_splice_alias(igrab(state->inode), dentry);
+ /* d_splice_alias() can't fail here - it's a non-directory */
+ if (alias) {
+ dput(ctx->dentry);
+ nfs_set_verifier(alias, dir_verifier);
+ ctx->dentry = dentry = alias;
+ }
}
/* Parse layoutget results before we check for access */
--
2.51.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
2025-11-19 13:58 ` [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state Trond Myklebust
@ 2025-11-19 16:14 ` Anna Schumaker
2025-11-19 16:50 ` Trond Myklebust
2025-11-20 10:47 ` kernel test robot
1 sibling, 1 reply; 9+ messages in thread
From: Anna Schumaker @ 2025-11-19 16:14 UTC (permalink / raw)
To: Trond Myklebust, Michael Stoler; +Cc: linux-nfs
Hi Trond,
On 11/19/25 8:58 AM, Trond Myklebust wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> Ensure that the verifiers are initialised before calling
> d_splice_alias() in _nfs4_open_and_get_state().
>
> Reported-by: Michael Stoler <michael.stoler@vastdata.com>
> Fixes: cf5b4059ba71 ("NFSv4: Fix races between open and dentry revalidation")
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
> fs/nfs/nfs4proc.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 93c6ce04332b..54595983525d 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -3174,18 +3174,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
> if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
> set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
>
> - dentry = opendata->dentry;
> - if (d_really_is_negative(dentry)) {
> - struct dentry *alias;
> - d_drop(dentry);
> - alias = d_splice_alias(igrab(state->inode), dentry);
> - /* d_splice_alias() can't fail here - it's a non-directory */
> - if (alias) {
> - dput(ctx->dentry);
> - ctx->dentry = dentry = alias;
> - }
> - }
> -
> switch(opendata->o_arg.claim) {
> default:
> break;
> @@ -3196,7 +3184,20 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
> break;
> if (opendata->o_res.delegation.type != 0)
> dir_verifier = nfs_save_change_attribute(dir);
> - nfs_set_verifier(dentry, dir_verifier);
> + }
> + nfs_set_verifier(dentry, dir_verifier);
Isn't 'dentry' uninitialized here? As far as I can tell, it gets set for the first time
in the very next statement.
Thanks,
Anna
> +
> + dentry = opendata->dentry;
> + if (d_really_is_negative(dentry)) {
> + struct dentry *alias;
> + d_drop(dentry);
> + alias = d_splice_alias(igrab(state->inode), dentry);
> + /* d_splice_alias() can't fail here - it's a non-directory */
> + if (alias) {
> + dput(ctx->dentry);
> + nfs_set_verifier(alias, dir_verifier);
> + ctx->dentry = dentry = alias;
> + }
> }
>
> /* Parse layoutget results before we check for access */
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
2025-11-19 16:14 ` Anna Schumaker
@ 2025-11-19 16:50 ` Trond Myklebust
0 siblings, 0 replies; 9+ messages in thread
From: Trond Myklebust @ 2025-11-19 16:50 UTC (permalink / raw)
To: Anna Schumaker, Michael Stoler; +Cc: linux-nfs
On Wed, 2025-11-19 at 11:14 -0500, Anna Schumaker wrote:
> Hi Trond,
>
> On 11/19/25 8:58 AM, Trond Myklebust wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> >
> > Ensure that the verifiers are initialised before calling
> > d_splice_alias() in _nfs4_open_and_get_state().
> >
> > Reported-by: Michael Stoler <michael.stoler@vastdata.com>
> > Fixes: cf5b4059ba71 ("NFSv4: Fix races between open and dentry
> > revalidation")
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> > fs/nfs/nfs4proc.c | 27 ++++++++++++++-------------
> > 1 file changed, 14 insertions(+), 13 deletions(-)
> >
> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > index 93c6ce04332b..54595983525d 100644
> > --- a/fs/nfs/nfs4proc.c
> > +++ b/fs/nfs/nfs4proc.c
> > @@ -3174,18 +3174,6 @@ static int _nfs4_open_and_get_state(struct
> > nfs4_opendata *opendata,
> > if (opendata->o_res.rflags &
> > NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
> > set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state-
> > >inode)->flags);
> >
> > - dentry = opendata->dentry;
> > - if (d_really_is_negative(dentry)) {
> > - struct dentry *alias;
> > - d_drop(dentry);
> > - alias = d_splice_alias(igrab(state->inode),
> > dentry);
> > - /* d_splice_alias() can't fail here - it's a non-
> > directory */
> > - if (alias) {
> > - dput(ctx->dentry);
> > - ctx->dentry = dentry = alias;
> > - }
> > - }
> > -
> > switch(opendata->o_arg.claim) {
> > default:
> > break;
> > @@ -3196,7 +3184,20 @@ static int _nfs4_open_and_get_state(struct
> > nfs4_opendata *opendata,
> > break;
> > if (opendata->o_res.delegation.type != 0)
> > dir_verifier =
> > nfs_save_change_attribute(dir);
> > - nfs_set_verifier(dentry, dir_verifier);
> > + }
> > + nfs_set_verifier(dentry, dir_verifier);
>
> Isn't 'dentry' uninitialized here? As far as I can tell, it gets set
> for the first time
> in the very next statement.
D'oh! I wonder why the compiler let that pass?
Anyhow, yes, the nfs_set_verifier() call needs to be moved one line
down.
>
> Thanks,
> Anna
>
> > +
> > + dentry = opendata->dentry;
> > + if (d_really_is_negative(dentry)) {
> > + struct dentry *alias;
> > + d_drop(dentry);
> > + alias = d_splice_alias(igrab(state->inode),
> > dentry);
> > + /* d_splice_alias() can't fail here - it's a non-
> > directory */
> > + if (alias) {
> > + dput(ctx->dentry);
> > + nfs_set_verifier(alias, dir_verifier);
> > + ctx->dentry = dentry = alias;
> > + }
> > }
> >
> > /* Parse layoutget results before we check for access */
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trondmy@kernel.org, trond.myklebust@hammerspace.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
2025-11-19 13:58 ` [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state Trond Myklebust
2025-11-19 16:14 ` Anna Schumaker
@ 2025-11-20 10:47 ` kernel test robot
1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2025-11-20 10:47 UTC (permalink / raw)
To: Trond Myklebust, Michael Stoler; +Cc: llvm, oe-kbuild-all, linux-nfs
Hi Trond,
kernel test robot noticed the following build warnings:
[auto build test WARNING on trondmy-nfs/linux-next]
[also build test WARNING on linus/master v6.18-rc6 next-20251119]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Trond-Myklebust/NFS-Initialise-verifiers-for-visible-dentries-in-readdir-and-lookup/20251119-222523
base: git://git.linux-nfs.org/projects/trondmy/linux-nfs.git linux-next
patch link: https://lore.kernel.org/r/4c4b51c67f7b38e4df4cb389007058e37ade0d14.1763560328.git.trond.myklebust%40hammerspace.com
patch subject: [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state
config: hexagon-randconfig-6002-20251120 (https://download.01.org/0day-ci/archive/20251120/202511201835.LXbDRKN5-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9e9fe08b16ea2c4d9867fb4974edf2a3776d6ece)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251120/202511201835.LXbDRKN5-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202511201835.LXbDRKN5-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/nfs/nfs4proc.c:3188:19: warning: variable 'dentry' is uninitialized when used here [-Wuninitialized]
3188 | nfs_set_verifier(dentry, dir_verifier);
| ^~~~~~
fs/nfs/nfs4proc.c:3152:23: note: initialize the variable 'dentry' to silence this warning
3152 | struct dentry *dentry;
| ^
| = NULL
1 warning generated.
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for OF_GPIO
Depends on [n]: GPIOLIB [=y] && OF [=n] && HAS_IOMEM [=y]
Selected by [y]:
- GPIO_TB10X [=y] && GPIOLIB [=y] && HAS_IOMEM [=y] && (ARC_PLAT_TB10X || COMPILE_TEST [=y])
WARNING: unmet direct dependencies detected for MFD_STMFX
Depends on [n]: HAS_IOMEM [=y] && I2C [=y] && OF [=n]
Selected by [y]:
- PINCTRL_STMFX [=y] && PINCTRL [=y] && I2C [=y] && OF_GPIO [=y] && HAS_IOMEM [=y]
WARNING: unmet direct dependencies detected for GPIO_SYSCON
Depends on [n]: GPIOLIB [=y] && HAS_IOMEM [=y] && MFD_SYSCON [=y] && OF [=n]
Selected by [y]:
- GPIO_SAMA5D2_PIOBU [=y] && GPIOLIB [=y] && HAS_IOMEM [=y] && MFD_SYSCON [=y] && OF_GPIO [=y] && (ARCH_AT91 || COMPILE_TEST [=y])
vim +/dentry +3188 fs/nfs/nfs4proc.c
aa53ed541a1fec Jeff Layton 2007-06-05 3146
c21443c2c792cd Trond Myklebust 2013-02-07 3147 static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
d564d2c4c2445c ChenXiaoSong 2022-09-23 3148 struct nfs_open_context *ctx)
c21443c2c792cd Trond Myklebust 2013-02-07 3149 {
c21443c2c792cd Trond Myklebust 2013-02-07 3150 struct nfs4_state_owner *sp = opendata->owner;
c21443c2c792cd Trond Myklebust 2013-02-07 3151 struct nfs_server *server = sp->so_server;
275bb307865a31 Trond Myklebust 2013-05-29 3152 struct dentry *dentry;
c21443c2c792cd Trond Myklebust 2013-02-07 3153 struct nfs4_state *state;
1bf85d8c987564 Trond Myklebust 2019-06-27 3154 fmode_t acc_mode = _nfs4_ctx_to_accessmode(ctx);
cf5b4059ba7197 Trond Myklebust 2020-02-05 3155 struct inode *dir = d_inode(opendata->dir);
cf5b4059ba7197 Trond Myklebust 2020-02-05 3156 unsigned long dir_verifier;
c21443c2c792cd Trond Myklebust 2013-02-07 3157 int ret;
c21443c2c792cd Trond Myklebust 2013-02-07 3158
cf5b4059ba7197 Trond Myklebust 2020-02-05 3159 dir_verifier = nfs_save_change_attribute(dir);
c21443c2c792cd Trond Myklebust 2013-02-07 3160
3b65a30df9b3f1 Fred Isaman 2016-09-19 3161 ret = _nfs4_proc_open(opendata, ctx);
dca780016dab84 Trond Myklebust 2014-10-23 3162 if (ret != 0)
c21443c2c792cd Trond Myklebust 2013-02-07 3163 goto out;
c21443c2c792cd Trond Myklebust 2013-02-07 3164
ae55e59da0e401 Trond Myklebust 2018-05-22 3165 state = _nfs4_opendata_to_nfs4_state(opendata);
c21443c2c792cd Trond Myklebust 2013-02-07 3166 ret = PTR_ERR(state);
c21443c2c792cd Trond Myklebust 2013-02-07 3167 if (IS_ERR(state))
c21443c2c792cd Trond Myklebust 2013-02-07 3168 goto out;
a974deee477af8 Trond Myklebust 2017-02-08 3169 ctx->state = state;
c21443c2c792cd Trond Myklebust 2013-02-07 3170 if (server->caps & NFS_CAP_POSIX_LOCK)
c21443c2c792cd Trond Myklebust 2013-02-07 3171 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
a8ce377a5db8d3 Jeff Layton 2016-09-17 3172 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK)
a8ce377a5db8d3 Jeff Layton 2016-09-17 3173 set_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags);
43245eca6e670e Olga Kornievskaia 2022-02-02 3174 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_PRESERVE_UNLINKED)
43245eca6e670e Olga Kornievskaia 2022-02-02 3175 set_bit(NFS_INO_PRESERVE_UNLINKED, &NFS_I(state->inode)->flags);
c21443c2c792cd Trond Myklebust 2013-02-07 3176
cf5b4059ba7197 Trond Myklebust 2020-02-05 3177 switch(opendata->o_arg.claim) {
cf5b4059ba7197 Trond Myklebust 2020-02-05 3178 default:
cf5b4059ba7197 Trond Myklebust 2020-02-05 3179 break;
cf5b4059ba7197 Trond Myklebust 2020-02-05 3180 case NFS4_OPEN_CLAIM_NULL:
cf5b4059ba7197 Trond Myklebust 2020-02-05 3181 case NFS4_OPEN_CLAIM_DELEGATE_CUR:
cf5b4059ba7197 Trond Myklebust 2020-02-05 3182 case NFS4_OPEN_CLAIM_DELEGATE_PREV:
cf5b4059ba7197 Trond Myklebust 2020-02-05 3183 if (!opendata->rpc_done)
cf5b4059ba7197 Trond Myklebust 2020-02-05 3184 break;
820620516993c1 Trond Myklebust 2024-06-16 3185 if (opendata->o_res.delegation.type != 0)
cf5b4059ba7197 Trond Myklebust 2020-02-05 3186 dir_verifier = nfs_save_change_attribute(dir);
26573137bc0af6 Trond Myklebust 2025-11-19 3187 }
cf5b4059ba7197 Trond Myklebust 2020-02-05 @3188 nfs_set_verifier(dentry, dir_verifier);
26573137bc0af6 Trond Myklebust 2025-11-19 3189
26573137bc0af6 Trond Myklebust 2025-11-19 3190 dentry = opendata->dentry;
26573137bc0af6 Trond Myklebust 2025-11-19 3191 if (d_really_is_negative(dentry)) {
26573137bc0af6 Trond Myklebust 2025-11-19 3192 struct dentry *alias;
26573137bc0af6 Trond Myklebust 2025-11-19 3193 d_drop(dentry);
26573137bc0af6 Trond Myklebust 2025-11-19 3194 alias = d_splice_alias(igrab(state->inode), dentry);
26573137bc0af6 Trond Myklebust 2025-11-19 3195 /* d_splice_alias() can't fail here - it's a non-directory */
26573137bc0af6 Trond Myklebust 2025-11-19 3196 if (alias) {
26573137bc0af6 Trond Myklebust 2025-11-19 3197 dput(ctx->dentry);
26573137bc0af6 Trond Myklebust 2025-11-19 3198 nfs_set_verifier(alias, dir_verifier);
26573137bc0af6 Trond Myklebust 2025-11-19 3199 ctx->dentry = dentry = alias;
26573137bc0af6 Trond Myklebust 2025-11-19 3200 }
275bb307865a31 Trond Myklebust 2013-05-29 3201 }
275bb307865a31 Trond Myklebust 2013-05-29 3202
af9b6d7570ca9a Trond Myklebust 2018-06-29 3203 /* Parse layoutget results before we check for access */
af9b6d7570ca9a Trond Myklebust 2018-06-29 3204 pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
af9b6d7570ca9a Trond Myklebust 2018-06-29 3205
d564d2c4c2445c ChenXiaoSong 2022-09-23 3206 ret = nfs4_opendata_access(sp->so_cred, opendata, state, acc_mode);
c21443c2c792cd Trond Myklebust 2013-02-07 3207 if (ret != 0)
c21443c2c792cd Trond Myklebust 2013-02-07 3208 goto out;
c21443c2c792cd Trond Myklebust 2013-02-07 3209
0460253913e50a Trond Myklebust 2024-02-24 3210 if (d_inode(dentry) == state->inode)
c45ffdd2696130 Trond Myklebust 2013-05-29 3211 nfs_inode_attach_open_context(ctx);
2409a976a2990e Fred Isaman 2016-10-06 3212
c21443c2c792cd Trond Myklebust 2013-02-07 3213 out:
2135e5d56278ff Trond Myklebust 2022-08-02 3214 if (!opendata->cancelled) {
6949493884fe88 Trond Myklebust 2022-05-14 3215 if (opendata->lgp) {
6949493884fe88 Trond Myklebust 2022-05-14 3216 nfs4_lgopen_release(opendata->lgp);
6949493884fe88 Trond Myklebust 2022-05-14 3217 opendata->lgp = NULL;
6949493884fe88 Trond Myklebust 2022-05-14 3218 }
ae55e59da0e401 Trond Myklebust 2018-05-22 3219 nfs4_sequence_free_slot(&opendata->o_res.seq_res);
2135e5d56278ff Trond Myklebust 2022-08-02 3220 }
c21443c2c792cd Trond Myklebust 2013-02-07 3221 return ret;
c21443c2c792cd Trond Myklebust 2013-02-07 3222 }
c21443c2c792cd Trond Myklebust 2013-02-07 3223
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-11-20 10:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 10:52 Spurious -EEXIST from NFSv3 Michael Stoler
2025-11-19 13:48 ` Trond Myklebust
2025-11-19 13:58 ` [PATCH 0/3] Fix verifier initialisation races for dentries Trond Myklebust
2025-11-19 13:58 ` [PATCH 1/3] NFS: Initialise verifiers for visible dentries in readdir and lookup Trond Myklebust
2025-11-19 13:58 ` [PATCH 2/3] NFS: Initialise verifiers for visible dentries in nfs_atomic_open() Trond Myklebust
2025-11-19 13:58 ` [PATCH 3/3] NFS: Initialise verifiers for visible dentries in _nfs4_open_and_get_state Trond Myklebust
2025-11-19 16:14 ` Anna Schumaker
2025-11-19 16:50 ` Trond Myklebust
2025-11-20 10:47 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox