Skip to content

Commit

Permalink
locks: add a dedicated spinlock to protect i_flctx lists
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Christoph Hellwig <[email protected]>
  • Loading branch information
Jeff Layton authored and Jeff Layton committed Jan 16, 2015
1 parent a7231a9 commit 6109c85
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 69 deletions.
8 changes: 4 additions & 4 deletions fs/ceph/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)

ctx = inode->i_flctx;
if (ctx) {
spin_lock(&inode->i_lock);
spin_lock(&ctx->flc_lock);
list_for_each_entry(lock, &ctx->flc_posix, fl_list)
++(*fcntl_count);
list_for_each_entry(lock, &ctx->flc_flock, fl_list)
++(*flock_count);
spin_unlock(&inode->i_lock);
spin_unlock(&ctx->flc_lock);
}
dout("counted %d flock locks and %d fcntl locks",
*flock_count, *fcntl_count);
Expand Down Expand Up @@ -288,7 +288,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
if (!ctx)
return 0;

spin_lock(&inode->i_lock);
spin_lock(&ctx->flc_lock);
list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
++seen_fcntl;
if (seen_fcntl > num_fcntl_locks) {
Expand All @@ -312,7 +312,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
++l;
}
fail:
spin_unlock(&inode->i_lock);
spin_unlock(&ctx->flc_lock);
return err;
}

Expand Down
8 changes: 4 additions & 4 deletions fs/cifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,11 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
if (!flctx)
goto out;

spin_lock(&inode->i_lock);
spin_lock(&flctx->flc_lock);
list_for_each(el, &flctx->flc_posix) {
count++;
}
spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);

INIT_LIST_HEAD(&locks_to_send);

Expand All @@ -1159,7 +1159,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
}

el = locks_to_send.next;
spin_lock(&inode->i_lock);
spin_lock(&flctx->flc_lock);
list_for_each_entry(flock, &flctx->flc_posix, fl_list) {
if (el == &locks_to_send) {
/*
Expand All @@ -1181,7 +1181,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile)
lck->type = type;
lck->offset = flock->fl_start;
}
spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);

list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) {
int stored_rc;
Expand Down
12 changes: 6 additions & 6 deletions fs/lockd/svcsubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
return 0;
again:
file->f_locks = 0;
spin_lock(&inode->i_lock);
spin_lock(&flctx->flc_lock);
list_for_each_entry(fl, &flctx->flc_posix, fl_list) {
if (fl->fl_lmops != &nlmsvc_lock_operations)
continue;
Expand All @@ -183,7 +183,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
if (match(lockhost, host)) {
struct file_lock lock = *fl;

spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);
lock.fl_type = F_UNLCK;
lock.fl_start = 0;
lock.fl_end = OFFSET_MAX;
Expand All @@ -195,7 +195,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
goto again;
}
}
spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);

return 0;
}
Expand Down Expand Up @@ -232,14 +232,14 @@ nlm_file_inuse(struct nlm_file *file)
return 1;

if (flctx && !list_empty_careful(&flctx->flc_posix)) {
spin_lock(&inode->i_lock);
spin_lock(&flctx->flc_lock);
list_for_each_entry(fl, &flctx->flc_posix, fl_list) {
if (fl->fl_lmops == &nlmsvc_lock_operations) {
spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);
return 1;
}
}
spin_unlock(&inode->i_lock);
spin_unlock(&flctx->flc_lock);
}
file->f_locks = 0;
return 0;
Expand Down
Loading

0 comments on commit 6109c85

Please sign in to comment.