[PATCH 4/6] libceph: make sure redirect does not change namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Yan, Zheng <zyan@xxxxxxxxxx>
---
 net/ceph/osd_client.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 0eb27ad..1d13605 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1725,10 +1725,23 @@ static int ceph_oloc_decode(void **p, void *end,
 	}
 
 	if (struct_v >= 5) {
+		bool changed = false;
 		u32 ns_len = ceph_decode_32(p);
 		if (ns_len > 0) {
 			ceph_decode_need(p, end, ns_len, e_inval);
+			if (oloc->pool != -1 &&
+			    (!oloc->pool_ns ||
+			     ceph_compare_pool_ns(oloc->pool_ns, *p, ns_len)))
+				changed = true;
 			*p += ns_len;
+		} else {
+			if (oloc->pool != -1 && oloc->pool_ns)
+				changed = true;
+		}
+		if (changed) {
+			/* redirect changes namespace */
+			pr_warn("ceph_object_locator::nspace is changed\n");
+			goto e_inval;
 		}
 	}
 
@@ -1901,7 +1914,9 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg)
 	}
 
 	if (decode_redir) {
+		redir.oloc.pool_ns = req->r_target_oloc.pool_ns;
 		err = ceph_redirect_decode(&p, end, &redir);
+		redir.oloc.pool_ns = NULL;
 		if (err)
 			goto bad_put;
 	} else {
-- 
2.5.0

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



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux