[sheepdog] [PATCH] sheep/gateway: fix a PANIC by wrong passing policy

Liu Yuan namei.unix at gmail.com
Thu Dec 26 11:25:19 CET 2013


We should use get_vdi_copy_policy() to get the policy if req->rq.obj.policy == 0
or we will panic the sheep daemon

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/gateway.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sheep/gateway.c b/sheep/gateway.c
index c8a1e9d..f0f716a 100644
--- a/sheep/gateway.c
+++ b/sheep/gateway.c
@@ -518,9 +518,11 @@ static int gateway_forward_request(struct request *req)
 	 */
 	nr_reqs = nr_to_send;
 	if (nr_to_send > nr_copies) {
+		uint8_t policy = req->rq.obj.copy_policy ?:
+			get_vdi_copy_policy(oid_to_vid(req->rq.obj.oid));
 		int ds;
 		/* Only for erasure code, nr_to_send might > nr_copies */
-		ec_policy_to_dp(req->rq.obj.copy_policy, &ds, NULL);
+		ec_policy_to_dp(policy, &ds, NULL);
 		if (nr_copies < ds) {
 			sd_err("There isn't enough copies(%d) to send out (%d)",
 			       nr_copies, nr_to_send);
-- 
1.8.1.2




More information about the sheepdog mailing list