]> www.infradead.org Git - users/hch/misc.git/commitdiff
NFSD: Move the fh_getattr() helper
authorChuck Lever <chuck.lever@oracle.com>
Wed, 2 Jul 2025 23:33:45 +0000 (19:33 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 21 Sep 2025 23:24:50 +0000 (19:24 -0400)
Clean up: The fh_getattr() function is part of NFSD's file handle
API, so relocate it.

I've made it an un-inlined function so that trace points and new
functionality can easily be introduced. That increases the size of
nfsd.ko by about a page on my x86_64 system (out of 26MB; compiled
with -O2).

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsfh.c
fs/nfsd/nfsfh.h
fs/nfsd/vfs.h

index 74cf1f4de17410eab4d8edea867fb114823f809a..f4c2fb3dd5d05f7f8fef0d9af74e0b3fe4009873 100644 (file)
@@ -662,6 +662,29 @@ out_negative:
        return nfserr_serverfault;
 }
 
+/**
+ * fh_getattr - Retrieve attributes on a local file
+ * @fhp: File handle of target file
+ * @stat: Caller-supplied kstat buffer to be filled in
+ *
+ * Returns nfs_ok on success, otherwise an NFS status code is
+ * returned.
+ */
+__be32 fh_getattr(const struct svc_fh *fhp, struct kstat *stat)
+{
+       struct path p = {
+               .mnt            = fhp->fh_export->ex_path.mnt,
+               .dentry         = fhp->fh_dentry,
+       };
+       u32 request_mask = STATX_BASIC_STATS;
+
+       if (fhp->fh_maxsize == NFS4_FHSIZE)
+               request_mask |= (STATX_BTIME | STATX_CHANGE_COOKIE);
+
+       return nfserrno(vfs_getattr(&p, stat, request_mask,
+                                   AT_STATX_SYNC_AS_STAT));
+}
+
 /**
  * fh_fill_pre_attrs - Fill in pre-op attributes
  * @fhp: file handle to be updated
index 6f5255d1c1903fc7e5d30ae00c649885d054d2d7..5ef7191f8ad8113e3bfc530c0376411edeb8a939 100644 (file)
@@ -222,6 +222,7 @@ extern char * SVCFH_fmt(struct svc_fh *fhp);
 __be32 fh_verify(struct svc_rqst *, struct svc_fh *, umode_t, int);
 __be32 fh_verify_local(struct net *, struct svc_cred *, struct auth_domain *,
                        struct svc_fh *, umode_t, int);
+__be32 fh_getattr(const struct svc_fh *fhp, struct kstat *stat);
 __be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
 __be32 fh_update(struct svc_fh *);
 void   fh_put(struct svc_fh *);
index 4007dcbbbfefa412032268e1e51d477607064a6f..0c0292611c6de3daf6f3ed51e2c61c0ad2751de4 100644 (file)
@@ -160,17 +160,4 @@ __be32             nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
 
 void           nfsd_filp_close(struct file *fp);
 
-static inline __be32 fh_getattr(const struct svc_fh *fh, struct kstat *stat)
-{
-       u32 request_mask = STATX_BASIC_STATS;
-       struct path p = {.mnt = fh->fh_export->ex_path.mnt,
-                        .dentry = fh->fh_dentry};
-
-       if (fh->fh_maxsize == NFS4_FHSIZE)
-               request_mask |= (STATX_BTIME | STATX_CHANGE_COOKIE);
-
-       return nfserrno(vfs_getattr(&p, stat, request_mask,
-                                   AT_STATX_SYNC_AS_STAT));
-}
-
 #endif /* LINUX_NFSD_VFS_H */