Skip to content

Commit 4f65636

Browse files
bcodding-rhJeff Layton
authored and
Jeff Layton
committed
Move locks API users to locks_lock_inode_wait()
Instead of having users check for FL_POSIX or FL_FLOCK to call the correct locks API function, use the check within locks_lock_inode_wait(). This allows for some later cleanup. Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
1 parent e55c34a commit 4f65636

File tree

12 files changed

+22
-59
lines changed

12 files changed

+22
-59
lines changed

drivers/staging/lustre/lustre/llite/file.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,13 +2763,9 @@ ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
27632763
rc = md_enqueue(sbi->ll_md_exp, &einfo, NULL,
27642764
op_data, &lockh, &flock, 0, NULL /* req */, flags);
27652765

2766-
if ((file_lock->fl_flags & FL_FLOCK) &&
2767-
(rc == 0 || file_lock->fl_type == F_UNLCK))
2768-
rc2 = flock_lock_file_wait(file, file_lock);
2769-
if ((file_lock->fl_flags & FL_POSIX) &&
2770-
(rc == 0 || file_lock->fl_type == F_UNLCK) &&
2766+
if ((rc == 0 || file_lock->fl_type == F_UNLCK) &&
27712767
!(flags & LDLM_FL_TEST_LOCK))
2772-
rc2 = posix_lock_file_wait(file, file_lock);
2768+
rc2 = locks_lock_file_wait(file, file_lock);
27732769

27742770
if (rc2 && file_lock->fl_type != F_UNLCK) {
27752771
einfo.ei_mode = LCK_NL;

fs/9p/vfs_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
161161
if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
162162
BUG();
163163

164-
res = posix_lock_file_wait(filp, fl);
164+
res = locks_lock_file_wait(filp, fl);
165165
if (res < 0)
166166
goto out;
167167

@@ -231,7 +231,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
231231
if (res < 0 && fl->fl_type != F_UNLCK) {
232232
fl_type = fl->fl_type;
233233
fl->fl_type = F_UNLCK;
234-
res = posix_lock_file_wait(filp, fl);
234+
res = locks_lock_file_wait(filp, fl);
235235
fl->fl_type = fl_type;
236236
}
237237
out:

fs/ceph/locks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,12 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
228228
err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK,
229229
file, lock_cmd, wait, fl);
230230
if (!err) {
231-
err = flock_lock_file_wait(file, fl);
231+
err = locks_lock_file_wait(file, fl);
232232
if (err) {
233233
ceph_lock_message(CEPH_LOCK_FLOCK,
234234
CEPH_MDS_OP_SETFILELOCK,
235235
file, CEPH_LOCK_UNLOCK, 0, fl);
236-
dout("got %d on flock_lock_file_wait, undid lock", err);
236+
dout("got %d on locks_lock_file_wait, undid lock", err);
237237
}
238238
}
239239
return err;

fs/cifs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type,
15531553

15541554
out:
15551555
if (flock->fl_flags & FL_POSIX && !rc)
1556-
rc = posix_lock_file_wait(file, flock);
1556+
rc = locks_lock_file_wait(file, flock);
15571557
return rc;
15581558
}
15591559

fs/dlm/plock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
172172
rv = op->info.rv;
173173

174174
if (!rv) {
175-
if (posix_lock_file_wait(file, fl) < 0)
175+
if (locks_lock_file_wait(file, fl) < 0)
176176
log_error(ls, "dlm_posix_lock: vfs lock error %llx",
177177
(unsigned long long)number);
178178
}
@@ -262,7 +262,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
262262
/* cause the vfs unlock to return ENOENT if lock is not found */
263263
fl->fl_flags |= FL_EXISTS;
264264

265-
rv = posix_lock_file_wait(file, fl);
265+
rv = locks_lock_file_wait(file, fl);
266266
if (rv == -ENOENT) {
267267
rv = 0;
268268
goto out_free;

fs/fuse/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl)
21892189
int err;
21902190

21912191
if (fc->no_flock) {
2192-
err = flock_lock_file_wait(file, fl);
2192+
err = locks_lock_file_wait(file, fl);
21932193
} else {
21942194
struct fuse_file *ff = file->private_data;
21952195

fs/gfs2/file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
10001000
}
10011001
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) {
10021002
if (fl->fl_type == F_UNLCK)
1003-
posix_lock_file_wait(file, fl);
1003+
locks_lock_file_wait(file, fl);
10041004
return -EIO;
10051005
}
10061006
if (IS_GETLK(cmd))
@@ -1031,7 +1031,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
10311031
if (gl) {
10321032
if (fl_gh->gh_state == state)
10331033
goto out;
1034-
flock_lock_file_wait(file,
1034+
locks_lock_file_wait(file,
10351035
&(struct file_lock){.fl_type = F_UNLCK});
10361036
gfs2_glock_dq(fl_gh);
10371037
gfs2_holder_reinit(state, flags, fl_gh);
@@ -1056,7 +1056,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
10561056
if (error == GLR_TRYFAILED)
10571057
error = -EAGAIN;
10581058
} else {
1059-
error = flock_lock_file_wait(file, fl);
1059+
error = locks_lock_file_wait(file, fl);
10601060
gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
10611061
}
10621062

@@ -1071,7 +1071,7 @@ static void do_unflock(struct file *file, struct file_lock *fl)
10711071
struct gfs2_holder *fl_gh = &fp->f_fl_gh;
10721072

10731073
mutex_lock(&fp->f_fl_mutex);
1074-
flock_lock_file_wait(file, fl);
1074+
locks_lock_file_wait(file, fl);
10751075
if (fl_gh->gh_gl) {
10761076
gfs2_glock_dq(fl_gh);
10771077
gfs2_holder_uninit(fl_gh);

fs/lockd/clntproc.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,7 @@ static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *ho
474474

475475
static int do_vfs_lock(struct file_lock *fl)
476476
{
477-
int res = 0;
478-
switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
479-
case FL_POSIX:
480-
res = posix_lock_file_wait(fl->fl_file, fl);
481-
break;
482-
case FL_FLOCK:
483-
res = flock_lock_file_wait(fl->fl_file, fl);
484-
break;
485-
default:
486-
BUG();
487-
}
488-
return res;
477+
return locks_lock_file_wait(fl->fl_file, fl);
489478
}
490479

491480
/*

fs/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
19611961
(can_sleep) ? F_SETLKW : F_SETLK,
19621962
lock);
19631963
else
1964-
error = flock_lock_file_wait(f.file, lock);
1964+
error = locks_lock_file_wait(f.file, lock);
19651965

19661966
out_free:
19671967
locks_free_lock(lock);

fs/nfs/file.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -738,18 +738,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
738738

739739
static int do_vfs_lock(struct file *file, struct file_lock *fl)
740740
{
741-
int res = 0;
742-
switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
743-
case FL_POSIX:
744-
res = posix_lock_file_wait(file, fl);
745-
break;
746-
case FL_FLOCK:
747-
res = flock_lock_file_wait(file, fl);
748-
break;
749-
default:
750-
BUG();
751-
}
752-
return res;
741+
return locks_lock_file_wait(file, fl);
753742
}
754743

755744
static int

fs/nfs/nfs4proc.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5472,18 +5472,7 @@ static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *
54725472

54735473
static int do_vfs_lock(struct inode *inode, struct file_lock *fl)
54745474
{
5475-
int res = 0;
5476-
switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
5477-
case FL_POSIX:
5478-
res = posix_lock_inode_wait(inode, fl);
5479-
break;
5480-
case FL_FLOCK:
5481-
res = flock_lock_inode_wait(inode, fl);
5482-
break;
5483-
default:
5484-
BUG();
5485-
}
5486-
return res;
5475+
return locks_lock_inode_wait(inode, fl);
54875476
}
54885477

54895478
struct nfs4_unlockdata {

fs/ocfs2/locks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode,
6666
* level.
6767
*/
6868

69-
flock_lock_file_wait(file,
69+
locks_lock_file_wait(file,
7070
&(struct file_lock){.fl_type = F_UNLCK});
7171

7272
ocfs2_file_unlock(file);
@@ -81,7 +81,7 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode,
8181
goto out;
8282
}
8383

84-
ret = flock_lock_file_wait(file, fl);
84+
ret = locks_lock_file_wait(file, fl);
8585
if (ret)
8686
ocfs2_file_unlock(file);
8787

@@ -98,7 +98,7 @@ static int ocfs2_do_funlock(struct file *file, int cmd, struct file_lock *fl)
9898

9999
mutex_lock(&fp->fp_mutex);
100100
ocfs2_file_unlock(file);
101-
ret = flock_lock_file_wait(file, fl);
101+
ret = locks_lock_file_wait(file, fl);
102102
mutex_unlock(&fp->fp_mutex);
103103

104104
return ret;
@@ -119,7 +119,7 @@ int ocfs2_flock(struct file *file, int cmd, struct file_lock *fl)
119119

120120
if ((osb->s_mount_opt & OCFS2_MOUNT_LOCALFLOCKS) ||
121121
ocfs2_mount_local(osb))
122-
return flock_lock_file_wait(file, fl);
122+
return locks_lock_file_wait(file, fl);
123123

124124
if (fl->fl_type == F_UNLCK)
125125
return ocfs2_do_funlock(file, cmd, fl);

0 commit comments

Comments
 (0)