Skip to content

Avoid returning NFS4ERR_FILE_OPEN when not appropriate

[email protected] linux-nfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 1 replyIn review
  2. v24 patches 0 repliesSuperseded
  3. v1 RFC4 patches 9 repliesSuperseded

Changes in v3 from the cover letter

- Fix crash when renaming to a non-existent object

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4NFSD: nfsd_unlink() clobbers non-zero status returned from fh_fill_pre_attrs()fs/nfsd/vfs.c+1 -30 replies
2/4NFSD: Never return NFS4ERR_FILE_OPEN when removing a directoryfs/nfsd/vfs.c+18 -60 replies
3/4NFSD: Return NFS4ERR_FILE_OPEN only when renaming over an open filefs/nfsd/vfs.c+29 -40 replies
4/4NFSD: Return NFS4ERR_FILE_OPEN only when linking an open filefs/nfsd/vfs.c+31 -130 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJeff Layton
SeriesR-b
1/4
2/4
3/4
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/4] Avoid returning NFS4ERR_FILE_OPEN when not appropriate

From: Chuck Lever <[email protected]>

This short series aims to prevent NFSD from returning NFS4ERR_FILE_OPEN when an NFSv4 LINK, RENAME, or REMOVE operation targets a directory. The only time the protocol spec permits a server to return FILE_OPEN is when the target of the operation is an object that is open and cannot be closed immediately to satisfy the request.

I would have preferred these fixes go into NFSv4-specific sections of NFSD, but the current structure of the code prevents doing that while maintaining operational efficiency. Plus, these small patches should be able to apply cleanly to LTS kernels.

We can defer deeper restructuring for later. For example, fh_verify() could be made to return an errno instead of a generic NFS status code; then the VFS utility functions in fs/nfsd/vfs.c could be made to do the same, making their callers responsible for the proper NFS version-specific translation of the errno into a status code.

This series has passed git regression and xfstests. I'm interested in review and comment about this approach, but please do test these if you have the ability to trigger -EBUSY easily.

NFSv4 OPEN is also affected, but because of its complexity will require careful audit (ie, a separate patch set). Please send a copy of the output of WARN_ONCE so we can see where to start digging in that area.

Changes since v2:
- Fix crash when renaming to a non-existent object

Changes since RFC:
- Address a minor code odor
- Clarify some code comments

Chuck Lever (4):
NFSD: nfsd_unlink() clobbers non-zero status returned from

    fh_fill_pre_attrs()

NFSD: Never return NFS4ERR_FILE_OPEN when removing a directory
NFSD: Return NFS4ERR_FILE_OPEN only when renaming over an open file
NFSD: Return NFS4ERR_FILE_OPEN only when linking an open file

 fs/nfsd/vfs.c | 105 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 79 insertions(+), 26 deletions(-)
Signature · 1 line
2.47.0