Skip to contentSkip to conversation

ceph: print debug message before put mds session

PATCH Applied Henry C Chang 2 participants 4 messages May 11, 2011 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ceph: print debug message before put mds session

The mds session, s, could be freed during ceph_put_mds_session. Move dout before ceph_put_mds_session.

---
 fs/ceph/mds_client.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ceph/mds_client.c +1 -1
index f60b07b..d0fae4c 100644
@@ -3304,8 +3304,8 @@ static void con_put(struct ceph_connection *con)
 {
 	struct ceph_mds_session *s = con->private;
 
+	dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref) - 1);
 	ceph_put_mds_session(s);
-	dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref));
 }
 
 /*
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 2/3 ceph: fix list_add in ceph_put_snap_realm

---
 fs/ceph/snap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ceph/snap.c +1 -1
index e86ec11..24067d6 100644
@@ -206,7 +206,7 @@ void ceph_put_snap_realm(struct ceph_mds_client *mdsc,
 		up_write(&mdsc->snap_rwsem);
 	} else {
 		spin_lock(&mdsc->snap_empty_lock);
-		list_add(&mdsc->snap_empty, &realm->empty_item);
+		list_add(&realm->empty_item, &mdsc->snap_empty);
 		spin_unlock(&mdsc->snap_empty_lock);
 	}
 }
Signature · 1 line
1.7.2.3
#2 lore raw

PATCH 3/3 ceph: do not use i_wrbuffer_ref as refcount for Fb cap

In reply to Henry C Chang

We increments i_wrbuffer_ref when taking the Fb cap. This breaks the dirty page accounting and causes looping in __ceph_do_pending_vmtruncate, and ceph client hangs.

This bug can be reproduced occasionally by running blogbench.

Add a new field i_wb_ref to inode and dedicate it to Fb reference counting.

---
 fs/ceph/caps.c  |   16 ++++++++--------
 fs/ceph/inode.c |    1 +
 fs/ceph/super.h |    2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)
fs/ceph/caps.c +8 -8
index 9fa0866..2a5404c 100644
@@ -819,7 +819,7 @@ int __ceph_caps_used(struct ceph_inode_info *ci)
 		used |= CEPH_CAP_FILE_CACHE;
 	if (ci->i_wr_ref)
 		used |= CEPH_CAP_FILE_WR;
-	if (ci->i_wrbuffer_ref)
+	if (ci->i_wb_ref || ci->i_wrbuffer_ref)
 		used |= CEPH_CAP_FILE_BUFFER;
 	return used;
 }
@@ -1990,11 +1990,11 @@ static void __take_cap_refs(struct ceph_inode_info *ci, int got)
 	if (got & CEPH_CAP_FILE_WR)
 		ci->i_wr_ref++;
 	if (got & CEPH_CAP_FILE_BUFFER) {
-		if (ci->i_wrbuffer_ref == 0)
+		if (ci->i_wb_ref == 0)
 			ihold(&ci->vfs_inode);
-		ci->i_wrbuffer_ref++;
-		dout("__take_cap_refs %p wrbuffer %d -> %d (?)\n",
-		     &ci->vfs_inode, ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref);
+		ci->i_wb_ref++;
+		dout("__take_cap_refs %p wb %d -> %d (?)\n",
+		     &ci->vfs_inode, ci->i_wb_ref-1, ci->i_wb_ref);
 	}
 }
 
@@ -2169,12 +2169,12 @@ void ceph_put_cap_refs(struct ceph_inode_info *ci, int had)
 		if (--ci->i_rdcache_ref == 0)
 			last++;
 	if (had & CEPH_CAP_FILE_BUFFER) {
-		if (--ci->i_wrbuffer_ref == 0) {
+		if (--ci->i_wb_ref == 0) {
 			last++;
 			put++;
 		}
-		dout("put_cap_refs %p wrbuffer %d -> %d (?)\n",
-		     inode, ci->i_wrbuffer_ref+1, ci->i_wrbuffer_ref);
+		dout("put_cap_refs %p wb %d -> %d (?)\n",
+		     inode, ci->i_wb_ref+1, ci->i_wb_ref);
 	}
 	if (had & CEPH_CAP_FILE_WR)
 		if (--ci->i_wr_ref == 0) {
fs/ceph/inode.c +1 -0
index 03d6daf..70b6a48 100644
@@ -355,6 +355,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
 	ci->i_rd_ref = 0;
 	ci->i_rdcache_ref = 0;
 	ci->i_wr_ref = 0;
+	ci->i_wb_ref = 0;
 	ci->i_wrbuffer_ref = 0;
 	ci->i_wrbuffer_ref_head = 0;
 	ci->i_shared_gen = 0;
fs/ceph/super.h +1 -1
index b1f1b8b..f5cabef 100644
@@ -293,7 +293,7 @@ struct ceph_inode_info {
 
 	/* held references to caps */
 	int i_pin_ref;
-	int i_rd_ref, i_rdcache_ref, i_wr_ref;
+	int i_rd_ref, i_rdcache_ref, i_wr_ref, i_wb_ref;
 	int i_wrbuffer_ref, i_wrbuffer_ref_head;
 	u32 i_shared_gen;       /* increment each time we get FILE_SHARED */
 	u32 i_rdcache_gen;      /* incremented each time we get FILE_CACHE. */
Signature · 1 line
1.7.2.3
Applied
#3 lore raw
In reply to Henry C Chang

Applied all three of these. Thanks, Henry! I'll send them to Linus today or tomorrow so they'll make 2.6.39.

sage

Quoted 31 lines · Henry C Chang

The mds session, s, could be freed during ceph_put_mds_session. Move dout before ceph_put_mds_session.

---
 fs/ceph/mds_client.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ceph/mds_client.c +1 -1
index f60b07b..d0fae4c 100644
@@ -3304,8 +3304,8 @@ static void con_put(struct ceph_connection *con)
 {
 	struct ceph_mds_session *s = con->private;
 
+	dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref) - 1);
 	ceph_put_mds_session(s);
-	dout("mdsc con_put %p (%d)\n", s, atomic_read(&s->s_ref));
 }
 
 /*
Signature · 6 lines
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html