Skip to content

Commit

Permalink
ceph: use i_ceph_lock instead of i_lock
Browse files Browse the repository at this point in the history
We have been using i_lock to protect all kinds of data structures in the
ceph_inode_info struct, including lists of inodes that we need to iterate
over while avoiding races with inode destruction.  That requires grabbing
a reference to the inode with the list lock protected, but igrab() now
takes i_lock to check the inode flags.

Changing the list lock ordering would be a painful process.

However, using a ceph-specific i_ceph_lock in the ceph inode instead of
i_lock is a simple mechanical change and avoids the ordering constraints
imposed by igrab().

Reported-by: Amon Ott <a.ott@m-privacy.de>
Signed-off-by: Sage Weil <sage@newdream.net>
  • Loading branch information
Sage Weil committed Dec 7, 2011
1 parent 5170330 commit be65559
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 207 deletions.
8 changes: 4 additions & 4 deletions fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static int ceph_set_page_dirty(struct page *page)
snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);

/* dirty the head */
spin_lock(&inode->i_lock);
spin_lock(&ci->i_ceph_lock);
if (ci->i_head_snapc == NULL)
ci->i_head_snapc = ceph_get_snap_context(snapc);
++ci->i_wrbuffer_ref_head;
Expand All @@ -100,7 +100,7 @@ static int ceph_set_page_dirty(struct page *page)
ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1,
ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
snapc, snapc->seq, snapc->num_snaps);
spin_unlock(&inode->i_lock);
spin_unlock(&ci->i_ceph_lock);

/* now adjust page */
spin_lock_irq(&mapping->tree_lock);
Expand Down Expand Up @@ -391,7 +391,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
struct ceph_snap_context *snapc = NULL;
struct ceph_cap_snap *capsnap = NULL;

spin_lock(&inode->i_lock);
spin_lock(&ci->i_ceph_lock);
list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap,
capsnap->context, capsnap->dirty_pages);
Expand All @@ -407,7 +407,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
dout(" head snapc %p has %d dirty pages\n",
snapc, ci->i_wrbuffer_ref_head);
}
spin_unlock(&inode->i_lock);
spin_unlock(&ci->i_ceph_lock);
return snapc;
}

Expand Down
Loading

0 comments on commit be65559

Please sign in to comment.