Skip to content

Commit aef9583

Browse files
kinglongmeeJeff Layton
authored andcommitted
NFSD: Get reference of lockowner when coping file_lock
v5: using nfs4_get_stateowner() instead of an inline function v3: Update based on Jeff's comments v2: Fix bad using of struct file_lock_operations for handle the owner Acked-by: Jeff Layton <jlayton@primarydata.com> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com> Signed-off-by: Jeff Layton <jlayton@primarydata.com>
1 parent b5971af commit aef9583

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎fs/nfsd/nfs4state.c‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4876,9 +4876,25 @@ nfs4_transform_lock_offset(struct file_lock *lock)
48764876
lock->fl_end = OFFSET_MAX;
48774877
}
48784878

4879-
/* Hack!: For now, we're defining this just so we can use a pointer to it
4880-
* as a unique cookie to identify our (NFSv4's) posix locks. */
4879+
static void nfsd4_fl_get_owner(struct file_lock *dst, struct file_lock *src)
4880+
{
4881+
struct nfs4_lockowner *lo = (struct nfs4_lockowner *)src->fl_owner;
4882+
dst->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lo->lo_owner));
4883+
}
4884+
4885+
static void nfsd4_fl_put_owner(struct file_lock *fl)
4886+
{
4887+
struct nfs4_lockowner *lo = (struct nfs4_lockowner *)fl->fl_owner;
4888+
4889+
if (lo) {
4890+
nfs4_put_stateowner(&lo->lo_owner);
4891+
fl->fl_owner = NULL;
4892+
}
4893+
}
4894+
48814895
static const struct lock_manager_operations nfsd_posix_mng_ops = {
4896+
.lm_get_owner = nfsd4_fl_get_owner,
4897+
.lm_put_owner = nfsd4_fl_put_owner,
48824898
};
48834899

48844900
static inline void
@@ -5243,7 +5259,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
52435259
status = nfserr_openmode;
52445260
goto out;
52455261
}
5246-
file_lock->fl_owner = (fl_owner_t)lock_sop;
5262+
5263+
file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner));
52475264
file_lock->fl_pid = current->tgid;
52485265
file_lock->fl_file = filp;
52495266
file_lock->fl_flags = FL_POSIX;
@@ -5439,7 +5456,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
54395456
}
54405457

54415458
file_lock->fl_type = F_UNLCK;
5442-
file_lock->fl_owner = (fl_owner_t)lockowner(stp->st_stateowner);
5459+
file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner));
54435460
file_lock->fl_pid = current->tgid;
54445461
file_lock->fl_file = filp;
54455462
file_lock->fl_flags = FL_POSIX;

0 commit comments

Comments
 (0)