crush: return CRUSH_ITEM_UNDEF for failed placements with indep
authorIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 24 Dec 2013 19:19:25 +0000 (21:19 +0200)
committerIlya Dryomov <ilya.dryomov@inktank.com>
Tue, 31 Dec 2013 18:32:15 +0000 (20:32 +0200)
For firstn mode, if we fail to make a valid placement choice, we just
continue and return a short result to the caller.  For indep mode, however,
we need to make the position stable, and return an undefined value on
failed placements to avoid shifting later results to the left.

Reflects ceph.git commit b1d4dd4eb044875874a1d01c01c7d766db5d0a80.

Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
include/linux/crush/crush.h
net/ceph/crush/mapper.c

index 83543c504b5a215ed36e9439147e0b7fb08b0437..3d6a12928560166db3ba9dec65bbb073f9221881 100644 (file)
 
 #define CRUSH_MAGIC 0x00010000ul   /* for detecting algorithm revisions */
 
-
 #define CRUSH_MAX_DEPTH 10  /* max crush hierarchy depth */
 
 
+#define CRUSH_ITEM_UNDEF  0x7fffffff  /* undefined result */
+
 /*
  * CRUSH uses user-defined "rules" to describe how inputs should be
  * mapped to devices.  A rule consists of sequence of steps to perform
index dcf48bc504ea46137d4e89b9a31cfd0bc82c331b..a8605245d1905408e40bebef19dcc5e6663287da 100644 (file)
@@ -455,8 +455,12 @@ reject:
                } while (retry_descent);
 
                if (skip_rep) {
-                       dprintk("skip rep\n");
-                       continue;
+                       if (firstn) {
+                               dprintk("skip rep\n");
+                               continue;
+                       }
+                       dprintk("undef rep, continuing\n");
+                       item = CRUSH_ITEM_UNDEF;
                }
 
                dprintk("CHOOSE got %d\n", item);