Skip to content

Commit

Permalink
mon: require pgnum in 'ceph osd pool create <poolname> <pgnum> [<pgp_…
Browse files Browse the repository at this point in the history
…num>]' command

The default of 8 is virtually never the right answer.  Require the initial
pg count to be explicitly provided.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Nov 12, 2012
1 parent cda9e51 commit efa03ce
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion doc/cluster-ops/control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Creates/deletes a snapshot of a pool. ::

Creates/deletes/renames a storage pool. ::

ceph osd pool create {pool-name} [pg_num [pgp_num]]
ceph osd pool create {pool-name} pg_num [pgp_num]
ceph osd pool delete {pool-name}
ceph osd pool rename {old-name} {new-name}

Expand Down
2 changes: 1 addition & 1 deletion doc/cluster-ops/pools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Create a Pool

To create a pool, execute::

ceph osd pool create {pool-name} [{pg-num}] [{pgp-num}]
ceph osd pool create {pool-name} {pg-num} [{pgp-num}]

Where:

Expand Down
4 changes: 2 additions & 2 deletions doc/rbd/rbd-openstack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ By default, Ceph block devices use the ``rbd`` pool. You may use any available
pool. We recommend creating a pool for Nova/Cinder and a pool for Glance. Ensure
your Ceph cluster is running, then create the pools. ::

ceph osd pool create volumes
ceph osd pool create images
ceph osd pool create volumes 128
ceph osd pool create images 128

See `Create a Pool`_ for detail on specifying the number of placement groups for
your pools, and `Placement Groups`_ for details on the number of placement
Expand Down
2 changes: 1 addition & 1 deletion qa/workunits/kclient/file_layout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sudo ls /sys/kernel/debug/ceph
sudo ls /sys/kernel/debug/ceph/\* || true
sudo bash -c 'ls /sys/kernel/debug/ceph/*' || true
sudo bash -c 'cat /sys/kernel/debug/ceph/*/mdsmap' > temp
ceph osd pool create newpool || true
ceph osd pool create newpool 2 || true
ceph mds add_data_pool 3 || true
sudo bash -c 'cat /sys/kernel/debug/ceph/*/mdsmap' > temp2
while diff -q temp2 temp
Expand Down
4 changes: 1 addition & 3 deletions qa/workunits/mon/pool_ops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ set -e

ceph osd pool create foo 123 123
ceph osd pool create fooo 123
ceph osd pool create foooo

ceph osd pool create foo # idempotent
ceph osd pool create foo 123 # idempotent

ceph osd pool delete foo
ceph osd pool delete foo
ceph osd pool delete fuggg

ceph osd pool delete fooo
ceph osd pool delete foooo

echo OK

Expand Down
41 changes: 22 additions & 19 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2561,27 +2561,30 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
}
}
}
else if (m->cmd[2] == "create" && m->cmd.size() >= 4) {
else if (m->cmd[2] == "create" && m->cmd.size() >= 3) {
if (m->cmd.size() < 5) {
ss << "usage: osd pool create <poolname> <pg_num> [pgp_num]";
err = -EINVAL;
goto out;
}
int pg_num = 0;
int pgp_num = 0;
if (m->cmd.size() > 4) { // try to parse out pg_num and pgp_num
const char *start = m->cmd[4].c_str();
char *end = (char*)start;
pgp_num = pg_num = strtol(start, &end, 10);
if (*end != '\0') { // failed to parse
err = -EINVAL;
ss << "usage: osd pool create <poolname> [pg_num [pgp_num]]";
goto out;
} else if (m->cmd.size() > 5) { // check for pgp_num too
start = m->cmd[5].c_str();
end = (char *)start;
pgp_num = strtol(start, &end, 10);
if (*end != '\0') { // failed to parse
err = -EINVAL;
ss << "usage: osd pool create <poolname> [pg_num [pgp_num]]";
goto out;
}
}
const char *start = m->cmd[4].c_str();
char *end = (char*)start;
pgp_num = pg_num = strtol(start, &end, 10);
if (*end != '\0') { // failed to parse
err = -EINVAL;
ss << "usage: osd pool create <poolname> <pg_num> [pgp_num]";
goto out;
} else if (m->cmd.size() > 5) { // check for pgp_num too
start = m->cmd[5].c_str();
end = (char *)start;
pgp_num = strtol(start, &end, 10);
if (*end != '\0') { // failed to parse
err = -EINVAL;
ss << "usage: osd pool create <poolname> <pg_num> [pgp_num]";
goto out;
}
}

if (osdmap.name_pool.count(m->cmd[3])) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/cli/ceph/help.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
ceph osd blacklist rm <address>[:source_port]
ceph osd pool mksnap <pool> <snapname>
ceph osd pool rmsnap <pool> <snapname>
ceph osd pool create <pool> [<pg_num> [<pgp_num>]]
ceph osd pool create <pool> <pg_num> [<pgp_num>]
ceph osd pool delete <pool>
ceph osd pool rename <pool> <new pool name>
ceph osd pool set <pool> <field> <value>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/ceph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static void usage()
cout << " ceph osd blacklist rm <address>[:source_port]\n";
cout << " ceph osd pool mksnap <pool> <snapname>\n";
cout << " ceph osd pool rmsnap <pool> <snapname>\n";
cout << " ceph osd pool create <pool> [<pg_num> [<pgp_num>]]\n";
cout << " ceph osd pool create <pool> <pg_num> [<pgp_num>]\n";
cout << " ceph osd pool delete <pool>\n";
cout << " ceph osd pool rename <pool> <new pool name>\n";
cout << " ceph osd pool set <pool> <field> <value>\n";
Expand Down

0 comments on commit efa03ce

Please sign in to comment.