Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331645
b: refs/heads/master
c: cc0538b
h: refs/heads/master
i:
  331643: da6c607
v: v3
  • Loading branch information
Alex Elder committed Oct 1, 2012
1 parent 1141d18 commit 06942e9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f8c3892911145db7cf895cc26f53ad73dd4e7b1f
refs/heads/master: cc0538b62c839c2df7b9f8378bb37e3b35faa608
28 changes: 24 additions & 4 deletions trunk/drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
#define DEV_NAME_LEN 32
#define MAX_INT_FORMAT_WIDTH ((5 * sizeof (int)) / 2 + 1)

#define RBD_NOTIFY_TIMEOUT_DEFAULT 10
#define RBD_NOTIFY_TIMEOUT_DEFAULT 10
#define RBD_READ_ONLY_DEFAULT false

/*
* block device image metadata (in-memory version)
Expand All @@ -91,6 +92,7 @@ struct rbd_image_header {

struct rbd_options {
int notify_timeout;
bool read_only;
};

/*
Expand Down Expand Up @@ -176,7 +178,7 @@ struct rbd_device {
u64 snap_id; /* current snapshot id */
/* whether the snap_id this device reads from still exists */
bool snap_exists;
int read_only;
bool read_only;

struct list_head node;

Expand Down Expand Up @@ -351,12 +353,21 @@ enum {
/* int args above */
Opt_last_string,
/* string args above */
Opt_read_only,
Opt_read_write,
/* Boolean args above */
Opt_last_bool,
};

static match_table_t rbd_opts_tokens = {
{Opt_notify_timeout, "notify_timeout=%d"},
/* int args above */
/* string args above */
{Opt_read_only, "read_only"},
{Opt_read_only, "ro"}, /* Alternate spelling */
{Opt_read_write, "read_write"},
{Opt_read_write, "rw"}, /* Alternate spelling */
/* Boolean args above */
{-1, NULL}
};

Expand All @@ -381,6 +392,8 @@ static int parse_rbd_opts_token(char *c, void *private)
} else if (token > Opt_last_int && token < Opt_last_string) {
dout("got string token %d val %s\n", token,
argstr[0].from);
} else if (token > Opt_last_string && token < Opt_last_bool) {
dout("got Boolean token %d\n", token);
} else {
dout("got token %d\n", token);
}
Expand All @@ -389,6 +402,12 @@ static int parse_rbd_opts_token(char *c, void *private)
case Opt_notify_timeout:
rbd_opts->notify_timeout = intval;
break;
case Opt_read_only:
rbd_opts->read_only = true;
break;
case Opt_read_write:
rbd_opts->read_only = false;
break;
default:
BUG_ON(token);
}
Expand All @@ -407,6 +426,7 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
struct rbd_client *rbdc;

rbd_opts->notify_timeout = RBD_NOTIFY_TIMEOUT_DEFAULT;
rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;

ceph_opts = ceph_parse_options(options, mon_addr,
mon_addr + mon_addr_len,
Expand Down Expand Up @@ -620,7 +640,7 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
sizeof (RBD_SNAP_HEAD_NAME))) {
rbd_dev->snap_id = CEPH_NOSNAP;
rbd_dev->snap_exists = false;
rbd_dev->read_only = 0;
rbd_dev->read_only = rbd_dev->rbd_opts.read_only;
if (size)
*size = rbd_dev->header.image_size;
} else {
Expand All @@ -632,7 +652,7 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, u64 *size)
goto done;
rbd_dev->snap_id = snap_id;
rbd_dev->snap_exists = true;
rbd_dev->read_only = 1;
rbd_dev->read_only = true; /* No choice for snapshots */
}

ret = 0;
Expand Down

0 comments on commit 06942e9

Please sign in to comment.