Skip to content

Commit dd8dd40

Browse files
neilbrownchucklever
authored andcommitted
NFSD: discard fh_locked flag and fh_lock/fh_unlock
As all inode locking is now fully balanced, fh_put() does not need to call fh_unlock(). fh_lock() and fh_unlock() are no longer used, so discard them. These are the only real users of ->fh_locked, so discard that too. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent bb4d53d commit dd8dd40

File tree

3 files changed

+6
-70
lines changed

3 files changed

+6
-70
lines changed

fs/nfsd/nfsfh.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
549549
if (ref_fh == fhp)
550550
fh_put(ref_fh);
551551

552-
if (fhp->fh_locked || fhp->fh_dentry) {
552+
if (fhp->fh_dentry) {
553553
printk(KERN_ERR "fh_compose: fh %pd2 not initialized!\n",
554554
dentry);
555555
}
@@ -700,7 +700,6 @@ fh_put(struct svc_fh *fhp)
700700
struct dentry * dentry = fhp->fh_dentry;
701701
struct svc_export * exp = fhp->fh_export;
702702
if (dentry) {
703-
fh_unlock(fhp);
704703
fhp->fh_dentry = NULL;
705704
dput(dentry);
706705
fh_clear_pre_post_attrs(fhp);

fs/nfsd/nfsfh.h

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ typedef struct svc_fh {
8181
struct dentry * fh_dentry; /* validated dentry */
8282
struct svc_export * fh_export; /* export pointer */
8383

84-
bool fh_locked; /* inode locked by us */
8584
bool fh_want_write; /* remount protection taken */
8685
bool fh_no_wcc; /* no wcc data needed */
8786
bool fh_no_atomic_attr;
@@ -93,7 +92,7 @@ typedef struct svc_fh {
9392
bool fh_post_saved; /* post-op attrs saved */
9493
bool fh_pre_saved; /* pre-op attrs saved */
9594

96-
/* Pre-op attributes saved during fh_lock */
95+
/* Pre-op attributes saved when inode is locked */
9796
__u64 fh_pre_size; /* size before operation */
9897
struct timespec64 fh_pre_mtime; /* mtime before oper */
9998
struct timespec64 fh_pre_ctime; /* ctime before oper */
@@ -103,7 +102,7 @@ typedef struct svc_fh {
103102
*/
104103
u64 fh_pre_change;
105104

106-
/* Post-op attributes saved in fh_unlock */
105+
/* Post-op attributes saved in fh_fill_post_attrs() */
107106
struct kstat fh_post_attr; /* full attrs after operation */
108107
u64 fh_post_change; /* nfsv4 change; see above */
109108
} svc_fh;
@@ -223,8 +222,8 @@ void fh_put(struct svc_fh *);
223222
static __inline__ struct svc_fh *
224223
fh_copy(struct svc_fh *dst, struct svc_fh *src)
225224
{
226-
WARN_ON(src->fh_dentry || src->fh_locked);
227-
225+
WARN_ON(src->fh_dentry);
226+
228227
*dst = *src;
229228
return dst;
230229
}
@@ -323,51 +322,4 @@ static inline u64 nfsd4_change_attribute(struct kstat *stat,
323322
extern void fh_fill_pre_attrs(struct svc_fh *fhp);
324323
extern void fh_fill_post_attrs(struct svc_fh *fhp);
325324
extern void fh_fill_both_attrs(struct svc_fh *fhp);
326-
327-
/*
328-
* Lock a file handle/inode
329-
* NOTE: both fh_lock and fh_unlock are done "by hand" in
330-
* vfs.c:nfsd_rename as it needs to grab 2 i_mutex's at once
331-
* so, any changes here should be reflected there.
332-
*/
333-
334-
static inline void
335-
fh_lock_nested(struct svc_fh *fhp, unsigned int subclass)
336-
{
337-
struct dentry *dentry = fhp->fh_dentry;
338-
struct inode *inode;
339-
340-
BUG_ON(!dentry);
341-
342-
if (fhp->fh_locked) {
343-
printk(KERN_WARNING "fh_lock: %pd2 already locked!\n",
344-
dentry);
345-
return;
346-
}
347-
348-
inode = d_inode(dentry);
349-
inode_lock_nested(inode, subclass);
350-
fh_fill_pre_attrs(fhp);
351-
fhp->fh_locked = true;
352-
}
353-
354-
static inline void
355-
fh_lock(struct svc_fh *fhp)
356-
{
357-
fh_lock_nested(fhp, I_MUTEX_NORMAL);
358-
}
359-
360-
/*
361-
* Unlock a file handle/inode
362-
*/
363-
static inline void
364-
fh_unlock(struct svc_fh *fhp)
365-
{
366-
if (fhp->fh_locked) {
367-
fh_fill_post_attrs(fhp);
368-
inode_unlock(d_inode(fhp->fh_dentry));
369-
fhp->fh_locked = false;
370-
}
371-
}
372-
373325
#endif /* _LINUX_NFSD_NFSFH_H */

fs/nfsd/vfs.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,13 +1265,6 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
12651265
dirp = d_inode(dentry);
12661266

12671267
dchild = dget(resfhp->fh_dentry);
1268-
if (!fhp->fh_locked) {
1269-
WARN_ONCE(1, "nfsd_create: parent %pd2 not locked!\n",
1270-
dentry);
1271-
err = nfserr_io;
1272-
goto out;
1273-
}
1274-
12751268
err = nfsd_permission(rqstp, fhp->fh_export, dentry, NFSD_MAY_CREATE);
12761269
if (err)
12771270
goto out;
@@ -1634,10 +1627,7 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
16341627
goto out;
16351628
}
16361629

1637-
/* cannot use fh_lock as we need deadlock protective ordering
1638-
* so do it by hand */
16391630
trap = lock_rename(tdentry, fdentry);
1640-
ffhp->fh_locked = tfhp->fh_locked = true;
16411631
fh_fill_pre_attrs(ffhp);
16421632
fh_fill_pre_attrs(tfhp);
16431633

@@ -1693,17 +1683,12 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
16931683
dput(odentry);
16941684
out_nfserr:
16951685
err = nfserrno(host_err);
1696-
/*
1697-
* We cannot rely on fh_unlock on the two filehandles,
1698-
* as that would do the wrong thing if the two directories
1699-
* were the same, so again we do it by hand.
1700-
*/
1686+
17011687
if (!close_cached) {
17021688
fh_fill_post_attrs(ffhp);
17031689
fh_fill_post_attrs(tfhp);
17041690
}
17051691
unlock_rename(tdentry, fdentry);
1706-
ffhp->fh_locked = tfhp->fh_locked = false;
17071692
fh_drop_write(ffhp);
17081693

17091694
/*

0 commit comments

Comments
 (0)