diff options
author | Alex Elder <elder@inktank.com> | 2013-02-11 13:33:24 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-02 00:19:03 -0400 |
commit | 5679c59f608f2fedff313e59b374257f1c945234 (patch) | |
tree | 59aa459d73a8a6b757dfb915b7de926c9e3023f3 | |
parent | 57acbaa7fb00b6e1a74d29aaaaf273ed8cb4dabc (diff) |
rbd: add target object existence flags
This creates two new flags for object requests to indicate what is
known about the existence of the object to which a request is to be
sent. The KNOWN flag will be true if the the EXISTS flag is
meaningful. That is:
KNOWN EXISTS
----- ------
0 0 don't know whether the object exists
0 1 (not used/invalid)
1 0 object is known to not exist
1 0 object is known to exist
This will be used in determining how to handle write requests for
data objects for layered rbd images.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r-- | drivers/block/rbd.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 211baa7f4f0b..b1b8ef864d58 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -173,6 +173,8 @@ enum obj_request_type { | |||
173 | enum obj_req_flags { | 173 | enum obj_req_flags { |
174 | OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */ | 174 | OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */ |
175 | OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */ | 175 | OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */ |
176 | OBJ_REQ_KNOWN, /* EXISTS flag valid: no = 0, yes = 1 */ | ||
177 | OBJ_REQ_EXISTS, /* target exists: no = 0, yes = 1 */ | ||
176 | }; | 178 | }; |
177 | 179 | ||
178 | struct rbd_obj_request { | 180 | struct rbd_obj_request { |
@@ -1129,6 +1131,37 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request) | |||
1129 | return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0; | 1131 | return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0; |
1130 | } | 1132 | } |
1131 | 1133 | ||
1134 | /* | ||
1135 | * This sets the KNOWN flag after (possibly) setting the EXISTS | ||
1136 | * flag. The latter is set based on the "exists" value provided. | ||
1137 | * | ||
1138 | * Note that for our purposes once an object exists it never goes | ||
1139 | * away again. It's possible that the response from two existence | ||
1140 | * checks are separated by the creation of the target object, and | ||
1141 | * the first ("doesn't exist") response arrives *after* the second | ||
1142 | * ("does exist"). In that case we ignore the second one. | ||
1143 | */ | ||
1144 | static void obj_request_existence_set(struct rbd_obj_request *obj_request, | ||
1145 | bool exists) | ||
1146 | { | ||
1147 | if (exists) | ||
1148 | set_bit(OBJ_REQ_EXISTS, &obj_request->flags); | ||
1149 | set_bit(OBJ_REQ_KNOWN, &obj_request->flags); | ||
1150 | smp_mb(); | ||
1151 | } | ||
1152 | |||
1153 | static bool obj_request_known_test(struct rbd_obj_request *obj_request) | ||
1154 | { | ||
1155 | smp_mb(); | ||
1156 | return test_bit(OBJ_REQ_KNOWN, &obj_request->flags) != 0; | ||
1157 | } | ||
1158 | |||
1159 | static bool obj_request_exists_test(struct rbd_obj_request *obj_request) | ||
1160 | { | ||
1161 | smp_mb(); | ||
1162 | return test_bit(OBJ_REQ_EXISTS, &obj_request->flags) != 0; | ||
1163 | } | ||
1164 | |||
1132 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) | 1165 | static void rbd_obj_request_get(struct rbd_obj_request *obj_request) |
1133 | { | 1166 | { |
1134 | dout("%s: obj %p (was %d)\n", __func__, obj_request, | 1167 | dout("%s: obj %p (was %d)\n", __func__, obj_request, |
@@ -1623,6 +1656,10 @@ static struct rbd_img_request *rbd_img_request_create( | |||
1623 | INIT_LIST_HEAD(&img_request->obj_requests); | 1656 | INIT_LIST_HEAD(&img_request->obj_requests); |
1624 | kref_init(&img_request->kref); | 1657 | kref_init(&img_request->kref); |
1625 | 1658 | ||
1659 | (void) obj_request_existence_set; | ||
1660 | (void) obj_request_known_test; | ||
1661 | (void) obj_request_exists_test; | ||
1662 | |||
1626 | rbd_img_request_get(img_request); /* Avoid a warning */ | 1663 | rbd_img_request_get(img_request); /* Avoid a warning */ |
1627 | rbd_img_request_put(img_request); /* TEMPORARY */ | 1664 | rbd_img_request_put(img_request); /* TEMPORARY */ |
1628 | 1665 | ||