Skip to content

Commit c1f203e

Browse files
committed
NFSD: Move the fh_getattr() helper
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>
1 parent c926f02 commit c1f203e

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

fs/nfsd/nfsfh.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,29 @@ fh_update(struct svc_fh *fhp)
662662
return nfserr_serverfault;
663663
}
664664

665+
/**
666+
* fh_getattr - Retrieve attributes on a local file
667+
* @fhp: File handle of target file
668+
* @stat: Caller-supplied kstat buffer to be filled in
669+
*
670+
* Returns nfs_ok on success, otherwise an NFS status code is
671+
* returned.
672+
*/
673+
__be32 fh_getattr(const struct svc_fh *fhp, struct kstat *stat)
674+
{
675+
struct path p = {
676+
.mnt = fhp->fh_export->ex_path.mnt,
677+
.dentry = fhp->fh_dentry,
678+
};
679+
u32 request_mask = STATX_BASIC_STATS;
680+
681+
if (fhp->fh_maxsize == NFS4_FHSIZE)
682+
request_mask |= (STATX_BTIME | STATX_CHANGE_COOKIE);
683+
684+
return nfserrno(vfs_getattr(&p, stat, request_mask,
685+
AT_STATX_SYNC_AS_STAT));
686+
}
687+
665688
/**
666689
* fh_fill_pre_attrs - Fill in pre-op attributes
667690
* @fhp: file handle to be updated

fs/nfsd/nfsfh.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ extern char * SVCFH_fmt(struct svc_fh *fhp);
222222
__be32 fh_verify(struct svc_rqst *, struct svc_fh *, umode_t, int);
223223
__be32 fh_verify_local(struct net *, struct svc_cred *, struct auth_domain *,
224224
struct svc_fh *, umode_t, int);
225+
__be32 fh_getattr(const struct svc_fh *fhp, struct kstat *stat);
225226
__be32 fh_compose(struct svc_fh *, struct svc_export *, struct dentry *, struct svc_fh *);
226227
__be32 fh_update(struct svc_fh *);
227228
void fh_put(struct svc_fh *);

fs/nfsd/vfs.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,4 @@ __be32 nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
160160

161161
void nfsd_filp_close(struct file *fp);
162162

163-
static inline __be32 fh_getattr(const struct svc_fh *fh, struct kstat *stat)
164-
{
165-
u32 request_mask = STATX_BASIC_STATS;
166-
struct path p = {.mnt = fh->fh_export->ex_path.mnt,
167-
.dentry = fh->fh_dentry};
168-
169-
if (fh->fh_maxsize == NFS4_FHSIZE)
170-
request_mask |= (STATX_BTIME | STATX_CHANGE_COOKIE);
171-
172-
return nfserrno(vfs_getattr(&p, stat, request_mask,
173-
AT_STATX_SYNC_AS_STAT));
174-
}
175-
176163
#endif /* LINUX_NFSD_VFS_H */

0 commit comments

Comments
 (0)