Skip to content

Commit 6109c85

Browse files
Jeff LaytonJeff Layton
authored andcommitted
locks: add a dedicated spinlock to protect i_flctx lists
We can now add a dedicated spinlock without expanding struct inode. Change to using that to protect the various i_flctx lists. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Acked-by: Christoph Hellwig <hch@lst.de>
1 parent a7231a9 commit 6109c85

9 files changed

Lines changed: 71 additions & 69 deletions

File tree

‎fs/ceph/locks.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
255255

256256
ctx = inode->i_flctx;
257257
if (ctx) {
258-
spin_lock(&inode->i_lock);
258+
spin_lock(&ctx->flc_lock);
259259
list_for_each_entry(lock, &ctx->flc_posix, fl_list)
260260
++(*fcntl_count);
261261
list_for_each_entry(lock, &ctx->flc_flock, fl_list)
262262
++(*flock_count);
263-
spin_unlock(&inode->i_lock);
263+
spin_unlock(&ctx->flc_lock);
264264
}
265265
dout("counted %d flock locks and %d fcntl locks",
266266
*flock_count, *fcntl_count);
@@ -288,7 +288,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
288288
if (!ctx)
289289
return 0;
290290

291-
spin_lock(&inode->i_lock);
291+
spin_lock(&ctx->flc_lock);
292292
list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
293293
++seen_fcntl;
294294
if (seen_fcntl > num_fcntl_locks) {
@@ -312,7 +312,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
312312
++l;
313313
}
314314
fail:
315-
spin_unlock(&inode->i_lock);
315+
spin_unlock(&ctx->flc_lock);
316316
return err;
317317
}
318318

‎fs/cifs/file.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,11 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
11361136
if (!flctx)
11371137
goto out;
11381138

1139-
spin_lock(&inode->i_lock);
1139+
spin_lock(&flctx->flc_lock);
11401140
list_for_each(el, &flctx->flc_posix) {
11411141
count++;
11421142
}
1143-
spin_unlock(&inode->i_lock);
1143+
spin_unlock(&flctx->flc_lock);
11441144

11451145
INIT_LIST_HEAD(&locks_to_send);
11461146

@@ -1159,7 +1159,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
11591159
}
11601160

11611161
el = locks_to_send.next;
1162-
spin_lock(&inode->i_lock);
1162+
spin_lock(&flctx->flc_lock);
11631163
list_for_each_entry(flock, &flctx->flc_posix, fl_list) {
11641164
if (el == &locks_to_send) {
11651165
/*
@@ -1181,7 +1181,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
11811181
lck->type = type;
11821182
lck->offset = flock->fl_start;
11831183
}
1184-
spin_unlock(&inode->i_lock);
1184+
spin_unlock(&flctx->flc_lock);
11851185

11861186
list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
11871187
int stored_rc;

‎fs/lockd/svcsubs.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
171171
return 0;
172172
again:
173173
file->f_locks = 0;
174-
spin_lock(&inode->i_lock);
174+
spin_lock(&flctx->flc_lock);
175175
list_for_each_entry(fl, &flctx->flc_posix, fl_list) {
176176
if (fl->fl_lmops != &nlmsvc_lock_operations)
177177
continue;
@@ -183,7 +183,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
183183
if (match(lockhost, host)) {
184184
struct file_lock lock = *fl;
185185

186-
spin_unlock(&inode->i_lock);
186+
spin_unlock(&flctx->flc_lock);
187187
lock.fl_type = F_UNLCK;
188188
lock.fl_start = 0;
189189
lock.fl_end = OFFSET_MAX;
@@ -195,7 +195,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
195195
goto again;
196196
}
197197
}
198-
spin_unlock(&inode->i_lock);
198+
spin_unlock(&flctx->flc_lock);
199199

200200
return 0;
201201
}
@@ -232,14 +232,14 @@ nlm_file_inuse(struct nlm_file *file)
232232
return 1;
233233

234234
if (flctx && !list_empty_careful(&flctx->flc_posix)) {
235-
spin_lock(&inode->i_lock);
235+
spin_lock(&flctx->flc_lock);
236236
list_for_each_entry(fl, &flctx->flc_posix, fl_list) {
237237
if (fl->fl_lmops == &nlmsvc_lock_operations) {
238-
spin_unlock(&inode->i_lock);
238+
spin_unlock(&flctx->flc_lock);
239239
return 1;
240240
}
241241
}
242-
spin_unlock(&inode->i_lock);
242+
spin_unlock(&flctx->flc_lock);
243243
}
244244
file->f_locks = 0;
245245
return 0;

0 commit comments

Comments
 (0)