Skip to content

Commit

Permalink
Merge pull request ceph#3979 from ceph/wip-rbd-map-options
Browse files Browse the repository at this point in the history
rbd: default map options, new options, misc

Reviewed-by: Josh Durgin <jdurgin@redhat.com>
  • Loading branch information
jdurgin committed Mar 12, 2015
2 parents b6d1eff + 6d9fbbe commit 6e56438
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 36 deletions.
11 changes: 11 additions & 0 deletions doc/man/8/rbd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,17 @@ the running kernel.

* nocrc - Disable CRC32C checksumming for data writes.

* cephx_require_signatures - Require cephx message signing, i.e. MSG_AUTH
feature bit (since 3.19, default).

* nocephx_require_signatures - Don't require cephx message signing (since
3.19).

* tcp_nodelay - Disable Nagle's algorithm on client sockets (since 4.0,
default).

* notcp_nodelay - Enable Nagle's algorithm on client sockets (since 4.0).

* osdkeepalive=x - OSD keepalive timeout (default is 5 seconds).

* osd_idle_ttl=x - OSD idle TTL (default is 60 seconds).
Expand Down
72 changes: 55 additions & 17 deletions man/rbd.8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "RBD" "8" "January 12, 2014" "dev" "Ceph"
.TH "RBD" "8" "March 12, 2015" "dev" "Ceph"
.SH NAME
rbd \- manage rados block device (RBD) images
.
Expand Down Expand Up @@ -187,6 +187,25 @@ See map options section below for more details.
.B \-\-read\-only
Map the image read\-only. Equivalent to \-o ro.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-image\-features features
Specifies which RBD format 2 features are to be enabled when creating
an image. The numbers from the desired features below should be added
to compute the parameter value:
.sp
+1: layering support
+2: striping v2 support
+4: exclusive locking support
+8: object map support
.UNINDENT
.INDENT 0.0
.TP
.B \-\-image\-shared
Specifies that the image will be used concurrently by multiple clients.
This will disable features that are dependent upon exclusive ownership
of the image.
.UNINDENT
.SH COMMANDS
.INDENT 0.0
.TP
Expand All @@ -207,7 +226,8 @@ Will create a new rbd image. You must also specify the size via \-\-size. The
.B \fBclone\fP [\fIparent\-snapname\fP] [\fIimage\-name\fP]
Will create a clone (copy\-on\-write child) of the parent snapshot.
Object order will be identical to that of the parent image unless
specified. Size will be the same as the parent snapshot.
specified. Size will be the same as the parent snapshot. The \-\-stripe\-unit
and \-\-stripe\-count arguments are optional, but must be used together.
.sp
The parent snapshot must be protected (see \fIrbd snap protect\fP).
This requires image format 2.
Expand Down Expand Up @@ -242,6 +262,9 @@ Creates a new image and imports its data from path (use \- for
stdin). The import operation will try to create sparse rbd images
if possible. For import from stdin, the sparsification unit is
the data block size of the destination image (1 << order).
.sp
The \-\-stripe\-unit and \-\-stripe\-count arguments are optional, but must be
used together.
.TP
.B \fBexport\-diff\fP [\fIimage\-name\fP] [\fIdest\-path\fP] [\-\-from\-snap \fIsnapname\fP]
Exports an incremental diff for an image to dest path (use \- for stdout). If
Expand All @@ -251,6 +274,14 @@ using the standard \-\-snap option or @snap syntax (see below). The image diff
metadata about image size changes, and the start and end snapshots. It efficiently represents
discarded or \(aqzero\(aq regions of the image.
.TP
.B \fBmerge\-diff\fP [\fIfirst\-diff\-path\fP] [\fIsecond\-diff\-path\fP] [\fImerged\-diff\-path\fP]
Merge two continuous incremental diffs of an image into one single diff. The
first diff\(aqs end snapshot must be equal with the second diff\(aqs start snapshot.
The first diff could be \- for stdin, and merged diff could be \- for stdout, which
enables multiple diff files to be merged using something like
\(aqrbd merge\-diff first second \- | rbd merge\-diff \- third result\(aq. Note this command
currently only support the source incremental diff with stripe_count == 1
.TP
.B \fBimport\-diff\fP [\fIsrc\-path\fP] [\fIimage\-name\fP]
Imports an incremental diff of an image and applies it to the current image. If the diff
was generated relative to a start snapshot, we verify that snapshot already exists before
Expand Down Expand Up @@ -311,6 +342,9 @@ Unmaps the block device that was mapped via the rbd kernel module.
.B \fBshowmapped\fP
Show the rbd images that are mapped via the rbd kernel module.
.TP
.B \fBstatus\fP [\fIimage\-name\fP]
Show the status of the image, including which clients have it open.
.TP
.B \fBlock\fP list [\fIimage\-name\fP]
Show locks held on the image. The first column is the locker
to use with the \fIlock remove\fP command.
Expand Down Expand Up @@ -361,28 +395,21 @@ The striping is controlled by three parameters:
.INDENT 0.0
.TP
.B order
.TP
.B The size of objects we stripe over is a power of two, specifially 2^[*order*] bytes. The default
.TP
.B is 22, or 4 MB.
The size of objects we stripe over is a power of two, specifically 2^[\fIorder\fP] bytes. The default
is 22, or 4 MB.
.UNINDENT
.INDENT 0.0
.TP
.B stripe_unit
.TP
.B Each [*stripe_unit*] contiguous bytes are stored adjacently in the same object, before we move on
.TP
.B to the next object.
Each [\fIstripe_unit\fP] contiguous bytes are stored adjacently in the same object, before we move on
to the next object.
.UNINDENT
.INDENT 0.0
.TP
.B stripe_count
.TP
.B After we write [*stripe_unit*] bytes to [*stripe_count*] objects, we loop back to the initial object
.TP
.B and write another stripe, until the object reaches its maximum size (as specified by [*order*]. At that
.TP
.B point, we move on to the next [*stripe_count*] objects.
After we write [\fIstripe_unit\fP] bytes to [\fIstripe_count\fP] objects, we loop back to the initial object
and write another stripe, until the object reaches its maximum size (as specified by [\fIorder\fP]. At that
point, we move on to the next [\fIstripe_count\fP] objects.
.UNINDENT
.sp
By default, [\fIstripe_unit\fP] is the same as the object size and [\fIstripe_count\fP] is 1. Specifying a different
Expand All @@ -408,6 +435,17 @@ crc \- Enable CRC32C checksumming for data writes (default).
.IP \(bu 2
nocrc \- Disable CRC32C checksumming for data writes.
.IP \(bu 2
cephx_require_signatures \- Require cephx message signing, i.e. MSG_AUTH
feature bit (since 3.19, default).
.IP \(bu 2
nocephx_require_signatures \- Don\(aqt require cephx message signing (since
3.19).
.IP \(bu 2
tcp_nodelay \- Disable Nagle\(aqs algorithm on client sockets (since 4.0,
default).
.IP \(bu 2
notcp_nodelay \- Enable Nagle\(aqs algorithm on client sockets (since 4.0).
.IP \(bu 2
osdkeepalive=x \- OSD keepalive timeout (default is 5 seconds).
.IP \(bu 2
osd_idle_ttl=x \- OSD idle TTL (default is 60 seconds).
Expand Down Expand Up @@ -604,7 +642,7 @@ rbd lock remove mypool/myimage mylockid client.2485
.UNINDENT
.SH AVAILABILITY
.sp
\fBrbd\fP is part of Ceph, a massively scalable, open-source, distributed storage system. Please refer to
\fBrbd\fP is part of Ceph, a massively scalable, open\-source, distributed storage system. Please refer to
the Ceph documentation at \fI\%http://ceph.com/docs\fP for more information.
.SH SEE ALSO
.sp
Expand Down
2 changes: 2 additions & 0 deletions src/common/config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,8 @@ OPTION(rbd_default_features, OPT_INT, 3) // only applies to format 2 images
// +1 for layering, +2 for stripingv2,
// +4 for exclusive lock, +8 for object map

OPTION(rbd_default_map_options, OPT_STR, "") // default rbd map -o / --options

OPTION(nss_db_path, OPT_STR, "") // path to nss db


Expand Down
51 changes: 32 additions & 19 deletions src/rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2267,18 +2267,19 @@ static int do_kernel_map(const char *poolname, const char *imgname,
if (r < 0)
return r;

for (map<string, string>::const_iterator it = map_options.begin();
it != map_options.end();
++it) {
for (map<string, string>::iterator it = map_options.begin();
it != map_options.end(); ) {
// for compatibility with < 3.7 kernels, assume that rw is on by
// default and omit it even if it was specified by the user
// (see ceph.git commit fb0f1986449b)
if (it->first == "rw" && it->second == "rw")
continue;

if (it != map_options.begin())
oss << ",";
oss << it->second;
if (it->first == "rw" && it->second == "rw") {
map_options.erase(it++);
} else {
if (it != map_options.begin())
oss << ",";
oss << it->second;
++it;
}
}

r = krbd_map(krbd, poolname, imgname, snapname, oss.str().c_str(), &devnode);
Expand Down Expand Up @@ -2356,11 +2357,6 @@ static string map_option_int_cb(const char *value_char)

static void put_map_option(const string key, string val)
{
map<string, string>::const_iterator it = map_options.find(key);
if (it != map_options.end()) {
cerr << "rbd: warning: redefining map option " << key << ": '"
<< it->second << "' -> '" << val << "'" << std::endl;
}
map_options[key] = val;
}

Expand Down Expand Up @@ -2403,6 +2399,12 @@ static int parse_map_options(char *options)
put_map_option("share", this_char);
} else if (!strcmp(this_char, "crc") || !strcmp(this_char, "nocrc")) {
put_map_option("crc", this_char);
} else if (!strcmp(this_char, "cephx_require_signatures") ||
!strcmp(this_char, "nocephx_require_signatures")) {
put_map_option("cephx_require_signatures", this_char);
} else if (!strcmp(this_char, "tcp_nodelay") ||
!strcmp(this_char, "notcp_nodelay")) {
put_map_option("tcp_nodelay", this_char);
} else if (!strcmp(this_char, "mount_timeout")) {
if (put_map_option_value("mount_timeout", value_char, map_option_int_cb))
return 1;
Expand Down Expand Up @@ -2595,6 +2597,7 @@ int main(int argc, const char **argv)
*lock_tag = NULL, *output_format = "plain",
*fromsnapname = NULL,
*first_diff = NULL, *second_diff = NULL;
char *cli_map_options = NULL;
bool lflag = false;
int pretty_format = 0;
long long stripe_unit = 0, stripe_count = 0;
Expand Down Expand Up @@ -2679,11 +2682,7 @@ int main(int argc, const char **argv)
} else if (ceph_argparse_flag(args, i, "--no-settle", (char *)NULL)) {
cerr << "rbd: --no-settle is deprecated" << std::endl;
} else if (ceph_argparse_witharg(args, i, &val, "-o", "--options", (char*)NULL)) {
char *map_options = strdup(val.c_str());
if (parse_map_options(map_options)) {
cerr << "rbd: couldn't parse map options" << std::endl;
return EXIT_FAILURE;
}
cli_map_options = strdup(val.c_str());
} else if (ceph_argparse_flag(args, i, "--read-only", (char *)NULL)) {
// --read-only is equivalent to -o ro
put_map_option("rw", "ro");
Expand Down Expand Up @@ -2915,6 +2914,20 @@ if (!set_conf_param(v, p1, p2, p3)) { \
return EXIT_FAILURE;
}

if (opt_cmd == OPT_MAP) {
char *default_map_options = strdup(g_conf->rbd_default_map_options.c_str());

// parse default options first so they can be overwritten by cli options
if (parse_map_options(default_map_options)) {
cerr << "rbd: couldn't parse default map options" << std::endl;
return EXIT_FAILURE;
}
if (cli_map_options && parse_map_options(cli_map_options)) {
cerr << "rbd: couldn't parse map options" << std::endl;
return EXIT_FAILURE;
}
}

if (opt_cmd == OPT_UNMAP && !devpath) {
cerr << "rbd: device path was not specified" << std::endl;
return EXIT_FAILURE;
Expand Down

0 comments on commit 6e56438

Please sign in to comment.