Skip to content

Commit be65559

Browse files
committed
ceph: use i_ceph_lock instead of i_lock
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>
1 parent 5170330 commit be65559

11 files changed

Lines changed: 212 additions & 207 deletions

File tree

‎fs/ceph/addr.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int ceph_set_page_dirty(struct page *page)
8787
snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
8888

8989
/* dirty the head */
90-
spin_lock(&inode->i_lock);
90+
spin_lock(&ci->i_ceph_lock);
9191
if (ci->i_head_snapc == NULL)
9292
ci->i_head_snapc = ceph_get_snap_context(snapc);
9393
++ci->i_wrbuffer_ref_head;
@@ -100,7 +100,7 @@ static int ceph_set_page_dirty(struct page *page)
100100
ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1,
101101
ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
102102
snapc, snapc->seq, snapc->num_snaps);
103-
spin_unlock(&inode->i_lock);
103+
spin_unlock(&ci->i_ceph_lock);
104104

105105
/* now adjust page */
106106
spin_lock_irq(&mapping->tree_lock);
@@ -391,7 +391,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
391391
struct ceph_snap_context *snapc = NULL;
392392
struct ceph_cap_snap *capsnap = NULL;
393393

394-
spin_lock(&inode->i_lock);
394+
spin_lock(&ci->i_ceph_lock);
395395
list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
396396
dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap,
397397
capsnap->context, capsnap->dirty_pages);
@@ -407,7 +407,7 @@ static struct ceph_snap_context *get_oldest_context(struct inode *inode,
407407
dout(" head snapc %p has %d dirty pages\n",
408408
snapc, ci->i_wrbuffer_ref_head);
409409
}
410-
spin_unlock(&inode->i_lock);
410+
spin_unlock(&ci->i_ceph_lock);
411411
return snapc;
412412
}
413413

0 commit comments

Comments
 (0)