Skip to content

Commit c926f02

Browse files
committed
NFSD: Relocate the fh_want_write() and fh_drop_write() helpers
Clean up: these helpers are part of the NFSD file handle API. Relocate them to fs/nfsd/nfsfh.h. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 6df164e commit c926f02

2 files changed

Lines changed: 37 additions & 20 deletions

File tree

fs/nfsd/nfsfh.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/exportfs.h>
1515
#include <linux/nfs4.h>
1616

17+
#include "export.h"
18+
1719
/*
1820
* The file handle starts with a sequence of four-byte words.
1921
* 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,
271273
return true;
272274
}
273275

276+
/**
277+
* fh_want_write - Get write access to an export
278+
* @fhp: File handle of file to be written
279+
*
280+
* Caller must invoke fh_drop_write() when its write operation
281+
* is complete.
282+
*
283+
* Returns 0 if the file handle's export can be written to. Otherwise
284+
* the export is not prepared for updates, and the returned negative
285+
* errno value reflects the reason for the failure.
286+
*/
287+
static inline int fh_want_write(struct svc_fh *fhp)
288+
{
289+
int ret;
290+
291+
if (fhp->fh_want_write)
292+
return 0;
293+
ret = mnt_want_write(fhp->fh_export->ex_path.mnt);
294+
if (!ret)
295+
fhp->fh_want_write = true;
296+
return ret;
297+
}
298+
299+
/**
300+
* fh_drop_write - Release write access on an export
301+
* @fhp: File handle of file on which fh_want_write() was previously called
302+
*/
303+
static inline void fh_drop_write(struct svc_fh *fhp)
304+
{
305+
if (fhp->fh_want_write) {
306+
fhp->fh_want_write = false;
307+
mnt_drop_write(fhp->fh_export->ex_path.mnt);
308+
}
309+
}
310+
274311
/**
275312
* knfsd_fh_hash - calculate the crc32 hash for the filehandle
276313
* @fh - pointer to filehandle

fs/nfsd/vfs.h

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

161161
void nfsd_filp_close(struct file *fp);
162162

163-
static inline int fh_want_write(struct svc_fh *fh)
164-
{
165-
int ret;
166-
167-
if (fh->fh_want_write)
168-
return 0;
169-
ret = mnt_want_write(fh->fh_export->ex_path.mnt);
170-
if (!ret)
171-
fh->fh_want_write = true;
172-
return ret;
173-
}
174-
175-
static inline void fh_drop_write(struct svc_fh *fh)
176-
{
177-
if (fh->fh_want_write) {
178-
fh->fh_want_write = false;
179-
mnt_drop_write(fh->fh_export->ex_path.mnt);
180-
}
181-
}
182-
183163
static inline __be32 fh_getattr(const struct svc_fh *fh, struct kstat *stat)
184164
{
185165
u32 request_mask = STATX_BASIC_STATS;

0 commit comments

Comments
 (0)