Relocate fh_getattr()
Subsystems (2)
Chuck Lever
maintainercover Relocate fh_getattr()
From: Chuck Lever <[email protected]>
Tucked away in Mike's LOCALIO branch is a patch that, among other changes, moves fh_getattr() to fs/nfsd/vfs.c. My feeling is that either:
- fh_getattr() remains as part of the NFSD FH API, thus it belongs in fs/nfsd/nfsfh.c; or
- if it is to be relocated to fs/nfsd/vfs.c, then it should adopt the naming convention used for the public functions in that source file.
This patch series tries on the first approach, for size.
It's a nit, I know.
Chuck Lever (2):
NFSD: Relocate the fh_want_write() and fh_drop_write() helpers
NFSD: Move the fh_getattr() helper
fs/nfsd/nfsfh.c | 23 +++++++++++++++++++++++ fs/nfsd/nfsfh.h | 38 ++++++++++++++++++++++++++++++++++++++ fs/nfsd/vfs.h | 33 --------------------------------- 3 files changed, 61 insertions(+), 33 deletions(-)
Signature · 1 line
2.50.0
Chuck Lever
maintainerRFC PATCH 1/2 NFSD: Relocate the fh_want_write() and fh_drop_write() helpers
From: Chuck Lever <[email protected]>
Clean up: These helpers are part of the NFSD file handle API. Relocate them to fs/nfsd/nfsfh.h.
--- fs/nfsd/nfsfh.h | 37 +++++++++++++++++++++++++++++++++++++ fs/nfsd/vfs.h | 20 -------------------- 2 files changed, 37 insertions(+), 20 deletions(-)
fs/nfsd/nfsfh.h +37 -0
@@ -14,6 +14,8 @@#include <linux/exportfs.h> #include <linux/nfs4.h> +#include "export.h" +/* * The file handle starts with a sequence of four-byte words. * The first word contains a version number (1) and three descriptor bytes
@@ -271,6 +273,41 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,return true; } +/** +* fh_want_write - Get write access to an export +* @fhp: File handle of file to be written +* +* Caller must invoke fh_drop_write() when its write operation +* is complete. +* +* Returns 0 if the file handle's export can be written to. Otherwise +* the export is not prepared for updates, and the returned negative +* errno value reflects the reason for the failure. +*/ +static inline int fh_want_write (struct svc_fh *fhp) +{ +int ret; + +if (fhp->fh_want_write) +return 0 ; + ret =mnt_want_write (fhp->fh_export->ex_path.mnt); +if (!ret) + fhp->fh_want_write = true; +return ret; +} + +/** +* fh_drop_write - Release write access on an export +* @fhp: File handle of file on which fh_want_write() was previously called +*/ +static inline void fh_drop_write (struct svc_fh *fhp) +{ +if (fhp->fh_want_write) { + fhp->fh_want_write = false; +mnt_drop_write (fhp->fh_export->ex_path.mnt); + } +} +/** * knfsd_fh_hash - calculate the crc32 hash for the filehandle * @fh - pointer to filehandle
fs/nfsd/vfs.h +0 -20
@@ -160,26 +160,6 @@ __be32 nfsd_permission(struct svc_cred *cred, struct svc_export *exp,void nfsd_filp_close (struct file *fp); -static inline int fh_want_write (struct svc_fh *fh) -{ -int ret; - -if (fh->fh_want_write) -return 0 ; - ret =mnt_want_write (fh->fh_export->ex_path.mnt); -if (!ret) - fh->fh_want_write = true; -return ret; -} - -static inline void fh_drop_write (struct svc_fh *fh) -{ -if (fh->fh_want_write) { - fh->fh_want_write = false; -mnt_drop_write (fh->fh_export->ex_path.mnt); - } -} -static inline __be32 fh_getattr (const struct svc_fh *fh,struct kstat *stat) {u32 request_mask =STATX_BASIC_STATS ;
Signature · 1 line
2.50.0
Chuck Lever
maintainerRFC PATCH 2/2 NFSD: Move the fh_getattr() helper
In reply to Chuck LeverFrom: Chuck Lever <[email protected]>
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).
--- fs/nfsd/nfsfh.c | 23 +++++++++++++++++++++++ fs/nfsd/nfsfh.h | 1 + fs/nfsd/vfs.h | 13 ------------- 3 files changed, 24 insertions(+), 13 deletions(-)
fs/nfsd/nfsfh.c +23 -0
@@ -662,6 +662,29 @@ fh_update(struct svc_fh *fhp)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
fs/nfsd/nfsfh.h +1 -0
@@ -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 *);
fs/nfsd/vfs.h +0 -13
@@ -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 */
Signature · 1 line
2.50.0