[PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder

Jeff Layton posted 3 patches 3 weeks, 2 days ago
There is a newer version of this series
fs/inode.c          | 17 +++++++++++----
fs/nfsd/nfs4proc.c  | 63 +++++++++++++++++++++++++++++++++++++++++++----------
fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++---------------
fs/nfsd/state.h     |  8 -------
4 files changed, 95 insertions(+), 42 deletions(-)
[PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder
Posted by Jeff Layton 3 weeks, 2 days ago
The main problem is that an attribute delegation has strict rules about
updates can be done, and that prevents applications that backdate
timestamps on files after writing them, (e.g. tar -x, cp -p, etc.) from
setting them properly.

We could fix this on the client by making it always issue an RPC for the
SETATTR, but that would harm performance in these common use-cases.
This set allows the server to accept some of these backdated mtime
updates, by changing how the ctime is handled.

It'd be nice to see this in v7.4.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Changes in v2:
- Split the change into three patches
- Stamp now in inode_set_ctime_deleg() for a stale update, so nfsd need
  not compare
- Drop a SETATTR report that matches the inode, so an untouched file
  keeps its change attribute
- Set dl_setattr only on the branch that carries a c/mtime update
- Compare against the inode, not the grant-time snapshots (Chuck)
- Set the ctime whenever a CB_GETATTR moves the mtime
- Take i_rwsem before the CB_GETATTR comparison
- Drop the unused dl_atime, dl_mtime and dl_ctime, and make
  nfsd4_vet_deleg_time() static
- Link to v1: https://lore.kernel.org/r/20260901-delegts-v1-1-9937f7ee4370@kernel.org

---
Jeff Layton (3):
      fs: stamp the current time for a stale delegated ctime update
      nfsd: accept a backdated timestamp from a delegation holder
      nfsd: compare CB_GETATTR times against the inode

 fs/inode.c          | 17 +++++++++++----
 fs/nfsd/nfs4proc.c  | 63 +++++++++++++++++++++++++++++++++++++++++++----------
 fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++---------------
 fs/nfsd/state.h     |  8 -------
 4 files changed, 95 insertions(+), 42 deletions(-)
---
base-commit: ac579868af0c900d8fd9c8cfe9e10db46ccc5a75
change-id: 20260901-delegts-e91a648f1427

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder
Posted by Christian Brauner 3 weeks ago
> The main problem is that an attribute delegation has strict rules about
> updates can be done, and that prevents applications that backdate
> timestamps on files after writing them, (e.g. tar -x, cp -p, etc.) from
> setting them properly.
> 
> We could fix this on the client by making it always issue an RPC for the
> SETATTR, but that would harm performance in these common use-cases.
> This set allows the server to accept some of these backdated mtime
> updates, by changing how the ctime is handled.
> 
> It'd be nice to see this in v7.4.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---

There's a bunch of Sashiko comments outstanding, Jeff. Let me know, if I
can ignore them.

--
Re: [PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder
Posted by Jeff Layton 3 weeks ago
On Fri, 2026-09-04 at 12:50 +0200, Christian Brauner wrote:
> > The main problem is that an attribute delegation has strict rules about
> > updates can be done, and that prevents applications that backdate
> > timestamps on files after writing them, (e.g. tar -x, cp -p, etc.) from
> > setting them properly.
> > 
> > We could fix this on the client by making it always issue an RPC for the
> > SETATTR, but that would harm performance in these common use-cases.
> > This set allows the server to accept some of these backdated mtime
> > updates, by changing how the ctime is handled.
> > 
> > It'd be nice to see this in v7.4.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> 
> There's a bunch of Sashiko comments outstanding, Jeff. Let me know, if I
> can ignore them.


At least one of them looks valid. I'll plan to send a v3.

Thanks,
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder
Posted by Chuck Lever 3 weeks, 2 days ago

On Wed, Sep 2, 2026, at 2:54 PM, Jeff Layton wrote:
> The main problem is that an attribute delegation has strict rules about
> updates can be done, and that prevents applications that backdate
> timestamps on files after writing them, (e.g. tar -x, cp -p, etc.) from
> setting them properly.
>
> We could fix this on the client by making it always issue an RPC for the
> SETATTR, but that would harm performance in these common use-cases.
> This set allows the server to accept some of these backdated mtime
> updates, by changing how the ctime is handled.
>
> It'd be nice to see this in v7.4.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> Changes in v2:
> - Split the change into three patches
> - Stamp now in inode_set_ctime_deleg() for a stale update, so nfsd need
>   not compare
> - Drop a SETATTR report that matches the inode, so an untouched file
>   keeps its change attribute
> - Set dl_setattr only on the branch that carries a c/mtime update
> - Compare against the inode, not the grant-time snapshots (Chuck)
> - Set the ctime whenever a CB_GETATTR moves the mtime
> - Take i_rwsem before the CB_GETATTR comparison
> - Drop the unused dl_atime, dl_mtime and dl_ctime, and make
>   nfsd4_vet_deleg_time() static
> - Link to v1: 
> https://lore.kernel.org/r/20260901-delegts-v1-1-9937f7ee4370@kernel.org
>
> ---
> Jeff Layton (3):
>       fs: stamp the current time for a stale delegated ctime update
>       nfsd: accept a backdated timestamp from a delegation holder
>       nfsd: compare CB_GETATTR times against the inode
>
>  fs/inode.c          | 17 +++++++++++----
>  fs/nfsd/nfs4proc.c  | 63 +++++++++++++++++++++++++++++++++++++++++++----------
>  fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++---------------
>  fs/nfsd/state.h     |  8 -------
>  4 files changed, 95 insertions(+), 42 deletions(-)
> ---
> base-commit: ac579868af0c900d8fd9c8cfe9e10db46ccc5a75
> change-id: 20260901-delegts-e91a648f1427
>
> Best regards,
> -- 
> Jeff Layton <jlayton@kernel.org>

Since the series modifies fs/inode.c, Christian will want to take it
through the VFS tree.

Acked-by: Chuck Lever <cel@kernel.org>


-- 
Chuck Lever (Come to NFS bake-a-thon! https://nfsv4bat.org)
Re: [PATCH v2 0/3] fs/nfsd: accept a backdated timestamp from a delegation holder
Posted by Christian Brauner 3 weeks ago
On Wed, Sep 02, 2026 at 08:03:53PM -0400, Chuck Lever wrote:
> 
> 
> On Wed, Sep 2, 2026, at 2:54 PM, Jeff Layton wrote:
> > The main problem is that an attribute delegation has strict rules about
> > updates can be done, and that prevents applications that backdate
> > timestamps on files after writing them, (e.g. tar -x, cp -p, etc.) from
> > setting them properly.
> >
> > We could fix this on the client by making it always issue an RPC for the
> > SETATTR, but that would harm performance in these common use-cases.
> > This set allows the server to accept some of these backdated mtime
> > updates, by changing how the ctime is handled.
> >
> > It'd be nice to see this in v7.4.
> >
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> > Changes in v2:
> > - Split the change into three patches
> > - Stamp now in inode_set_ctime_deleg() for a stale update, so nfsd need
> >   not compare
> > - Drop a SETATTR report that matches the inode, so an untouched file
> >   keeps its change attribute
> > - Set dl_setattr only on the branch that carries a c/mtime update
> > - Compare against the inode, not the grant-time snapshots (Chuck)
> > - Set the ctime whenever a CB_GETATTR moves the mtime
> > - Take i_rwsem before the CB_GETATTR comparison
> > - Drop the unused dl_atime, dl_mtime and dl_ctime, and make
> >   nfsd4_vet_deleg_time() static
> > - Link to v1: 
> > https://lore.kernel.org/r/20260901-delegts-v1-1-9937f7ee4370@kernel.org
> >
> > ---
> > Jeff Layton (3):
> >       fs: stamp the current time for a stale delegated ctime update
> >       nfsd: accept a backdated timestamp from a delegation holder
> >       nfsd: compare CB_GETATTR times against the inode
> >
> >  fs/inode.c          | 17 +++++++++++----
> >  fs/nfsd/nfs4proc.c  | 63 +++++++++++++++++++++++++++++++++++++++++++----------
> >  fs/nfsd/nfs4state.c | 49 ++++++++++++++++++++++++++---------------
> >  fs/nfsd/state.h     |  8 -------
> >  4 files changed, 95 insertions(+), 42 deletions(-)
> > ---
> > base-commit: ac579868af0c900d8fd9c8cfe9e10db46ccc5a75
> > change-id: 20260901-delegts-e91a648f1427
> >
> > Best regards,
> > -- 
> > Jeff Layton <jlayton@kernel.org>
> 
> Since the series modifies fs/inode.c, Christian will want to take it
> through the VFS tree.
> 
> Acked-by: Chuck Lever <cel@kernel.org>

Thanks!