Skip to contentSkip to conversation

ceph:Fix error handling in the function down_reply

PATCH Yan, Zheng 2 participants 2 messages Nov 9, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Yan, Zheng

author Applied
#1 lore raw
Quoted 31 lines · Nicholas Krause

This fixes error handling in the function down_reply in order to properly check and jump to the goto label, out_err for this particular function if a error code is returned by any function called in down_reply and therefore make checking be included for the call to ceph_update_snap_trace in order to comply with these error handling checks/paths.

---
fs/ceph/mds_client.c | 11 +++++++----

1 file changed, 7 insertions(+), 4 deletions(-)
fs/ceph/mds_client.c +4 -4
index 51cb02d..0b01f94 100644
@@ -2495,14 +2495,17 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
 	realm = NULL;
 	if (rinfo->snapblob_len) {
 		down_write(&mdsc->snap_rwsem);
-		ceph_update_snap_trace(mdsc, rinfo->snapblob,
-				rinfo->snapblob + rinfo->snapblob_len,
-				le32_to_cpu(head->op) == CEPH_MDS_OP_RMSNAP,
-				&realm);
+		err = ceph_update_snap_trace(mdsc, rinfo->snapblob,
+					     rinfo->snapblob + rinfo->snapblob_len,
+					     le32_to_cpu(head->op) == CEPH_MDS_OP_RMSNAP,
+					     &realm);

fs/ceph/mds_client.c static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) · line 2511

Quoted 10 lines
fs/ceph/mds_client.c +3 -0
 		downgrade_write(&mdsc->snap_rwsem);
 	} else {
 		down_read(&mdsc->snap_rwsem);
 	}
+
+	if (err)
+		goto out_err;
 
 	/* insert trace into our cache */
 	mutex_lock(&req->r_fill_mutex);

Applied, thanks

Yan, Zheng

Quoted 3 lines
Signature · 1 line
2.5.0
#2 lore raw
Quoted 39 lines · Zheng
Quoted 39 lines · Nicholas Krause

This fixes error handling in the function down_reply in order to properly check and jump to the goto label, out_err for this particular function if a error code is returned by any function called in down_reply and therefore make checking be included for the call to ceph_update_snap_trace in order to comply with these error handling checks/paths.

---
fs/ceph/mds_client.c | 11 +++++++----

1 file changed, 7 insertions(+), 4 deletions(-)
fs/ceph/mds_client.c +7 -4
index 51cb02d..0b01f94 100644
@@ -2495,14 +2495,17 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg)
      realm = NULL;
      if (rinfo->snapblob_len) {
              down_write(&mdsc->snap_rwsem);
-             ceph_update_snap_trace(mdsc, rinfo->snapblob,
-                             rinfo->snapblob + rinfo->snapblob_len,
-                             le32_to_cpu(head->op) == CEPH_MDS_OP_RMSNAP,
-                             &realm);
+             err = ceph_update_snap_trace(mdsc, rinfo->snapblob,
+                                          rinfo->snapblob + rinfo->snapblob_len,
+                                          le32_to_cpu(head->op) == CEPH_MDS_OP_RMSNAP,
+                                          &realm);
              downgrade_write(&mdsc->snap_rwsem);
      } else {
              down_read(&mdsc->snap_rwsem);
      }
+
+     if (err)
+             goto out_err;
 
Quoted 4 lines

fs/ceph/mds_client.c static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) · line 2511

Quoted 2 lines
fs/ceph/mds_client.c +0 -0
      /* insert trace into our cache */
      mutex_lock(&req->r_fill_mutex);

Applied, thanks

This looks to me like it'd leave snap_rwsem locked for read? Also, the name of the function in question is handle_reply(), not down_reply().

I'll revert testing.

Thanks,

Ilya