From: NeilBrown <neilb@ownmail.net>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH 6/7] nfsd: nfsd_check_obj_isreg() to use nfs error codes.
Date: Thu, 10 Sep 2026 10:20:52 +1000 [thread overview]
Message-ID: <20260910002934.192979-7-neilb@ownmail.net> (raw)
In-Reply-To: <20260910002934.192979-1-neilb@ownmail.net>
From: NeilBrown <neil@brown.name>
There is no longer any value in having nfsd_check_obj_isreg() return
over-loaded error codes which are converted to nfs error codes.
So revert to directly returning the required nfs error code.
Also take the opportunity to avoid dereferencing the inode and determine
the type directly from the dentry.
We can now remove ELOOP from nfs_errtbl[] as it doesn't *really* mean
the same as nfserr_symlink. We probably don't need EFTYPE either, but
there is a very good match of meaning, so let's leave it.
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/nfsd/nfs4proc.c | 36 ++++++++++++++++--------------------
fs/nfsd/vfs.c | 1 -
2 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 0fd5a6411ed3..a6ba7618a307 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -223,20 +223,17 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
return fh_verify(rqstp, current_fh, S_IFREG, accmode);
}
-static int nfsd_check_obj_isreg(struct dentry *child)
+static __be32 nfsd_check_obj_isreg(struct dentry *child)
{
- umode_t mode;
-
- if (!child || !d_inode(child))
- return -EFTYPE;
- mode = d_inode(child)->i_mode;
- if (S_ISREG(mode))
+ if (!child)
+ return nfserr_wrong_type;
+ if (d_is_reg(child))
return 0;
- if (S_ISDIR(mode))
- return -EISDIR;
- if (S_ISLNK(mode))
- return -ELOOP;
- return -EFTYPE;
+ if (d_is_dir(child))
+ return nfserr_isdir;
+ if (d_is_symlink(child))
+ return nfserr_symlink;
+ return nfserr_wrong_type;
}
static void nfsd4_set_open_owner_reply_cache(struct nfsd4_compound_state *cstate, struct nfsd4_open *open, struct svc_fh *resfh)
@@ -388,18 +385,17 @@ nfsd4_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
oflags,
open->op_iattr.ia_mode & S_IALLUGO);
if (IS_ERR(open->op_filp)) {
- int hosterr = PTR_ERR(open->op_filp);
-
- if (hosterr == -EFTYPE) {
+ status = nfserrno(PTR_ERR(open->op_filp));
+ if (status == nfserr_wrong_type) {
if (nfsd4_create_is_exclusive(open->op_createmode))
- hosterr = -EEXIST;
+ status = nfserr_exist;
else
- hosterr = nfsd_check_obj_isreg(parent.dentry);
+ status = nfsd_check_obj_isreg(parent.dentry);
}
- status = nfserrno(hosterr);
- open->op_filp = NULL;
if (status == nfserr_noent && create_status)
status = create_status;
+
+ open->op_filp = NULL;
dput(parent.dentry);
goto out;
}
@@ -558,7 +554,7 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru
}
if (status)
goto out;
- status = nfserrno(nfsd_check_obj_isreg((*resfh)->fh_dentry));
+ status = nfsd_check_obj_isreg((*resfh)->fh_dentry);
if (status)
goto out;
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f9131827d391..8def58e92a8e 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -106,7 +106,6 @@ nfserrno(int errno)
{ nfserr_perm, -ENOKEY },
{ nfserr_no_grace, -ENOGRACE},
{ nfserr_io, -EBADMSG },
- { nfserr_symlink, -ELOOP },
{ nfserr_wrong_type, -EFTYPE },
};
int i;
--
2.50.0.107.gf914562f5916.dirty
next prev parent reply other threads:[~2026-09-10 0:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 0:20 [PATCH 0/7 RFC] fixes for vfs_lookup_open, and integration with nfsd NeilBrown
2026-09-10 0:20 ` [PATCH 1/7] vfs: add some allowed open flags to vfs_lookup_open() NeilBrown
2026-09-10 0:20 ` [PATCH 2/7] vfs: O_NONBLOCK|O_CREAT open shouldn't wait for directory delegation NeilBrown
2026-09-10 0:20 ` [PATCH 3/7] vfs: vfs_lookup_open() should only return -EFTYPE for non-regular files NeilBrown
2026-09-10 0:20 ` [PATCH 4/7] vfs: change vfs_lookup_open() to return found dentry in path.dentry NeilBrown
2026-09-10 0:39 ` NeilBrown
2026-09-10 15:13 ` Chuck Lever
2026-09-10 0:20 ` [PATCH 5/7] nfsd: switch NFS4 OPEN to use vfs_lookup_open() NeilBrown
2026-09-10 15:41 ` Chuck Lever
2026-09-10 0:20 ` NeilBrown [this message]
2026-09-10 0:20 ` [PATCH 7/7] nfsd: use vfs_lookup_open() for non-creating open requests too NeilBrown
2026-09-10 15:47 ` Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260910002934.192979-7-neilb@ownmail.net \
--to=neilb@ownmail.net \
--cc=brauner@kernel.org \
--cc=cel@kernel.org \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.