Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373467
b: refs/heads/master
c: 5679c59
h: refs/heads/master
i:
  373465: 8ddea7b
  373463: 3a4c30f
v: v3
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent 3ae55f3 commit cf5623a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 57acbaa7fb00b6e1a74d29aaaaf273ed8cb4dabc
refs/heads/master: 5679c59f608f2fedff313e59b374257f1c945234
37 changes: 37 additions & 0 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ enum obj_request_type {
enum obj_req_flags {
OBJ_REQ_DONE, /* completion flag: not done = 0, done = 1 */
OBJ_REQ_IMG_DATA, /* object usage: standalone = 0, image = 1 */
OBJ_REQ_KNOWN, /* EXISTS flag valid: no = 0, yes = 1 */
OBJ_REQ_EXISTS, /* target exists: no = 0, yes = 1 */
};

struct rbd_obj_request {
Expand Down Expand Up @@ -1129,6 +1131,37 @@ static bool obj_request_done_test(struct rbd_obj_request *obj_request)
return test_bit(OBJ_REQ_DONE, &obj_request->flags) != 0;
}

/*
* This sets the KNOWN flag after (possibly) setting the EXISTS
* flag. The latter is set based on the "exists" value provided.
*
* Note that for our purposes once an object exists it never goes
* away again. It's possible that the response from two existence
* checks are separated by the creation of the target object, and
* the first ("doesn't exist") response arrives *after* the second
* ("does exist"). In that case we ignore the second one.
*/
static void obj_request_existence_set(struct rbd_obj_request *obj_request,
bool exists)
{
if (exists)
set_bit(OBJ_REQ_EXISTS, &obj_request->flags);
set_bit(OBJ_REQ_KNOWN, &obj_request->flags);
smp_mb();
}

static bool obj_request_known_test(struct rbd_obj_request *obj_request)
{
smp_mb();
return test_bit(OBJ_REQ_KNOWN, &obj_request->flags) != 0;
}

static bool obj_request_exists_test(struct rbd_obj_request *obj_request)
{
smp_mb();
return test_bit(OBJ_REQ_EXISTS, &obj_request->flags) != 0;
}

static void rbd_obj_request_get(struct rbd_obj_request *obj_request)
{
dout("%s: obj %p (was %d)\n", __func__, obj_request,
Expand Down Expand Up @@ -1623,6 +1656,10 @@ static struct rbd_img_request *rbd_img_request_create(
INIT_LIST_HEAD(&img_request->obj_requests);
kref_init(&img_request->kref);

(void) obj_request_existence_set;
(void) obj_request_known_test;
(void) obj_request_exists_test;

rbd_img_request_get(img_request); /* Avoid a warning */
rbd_img_request_put(img_request); /* TEMPORARY */

Expand Down

0 comments on commit cf5623a

Please sign in to comment.