Skip to content

Commit

Permalink
osd: add is_unmanaged_snaps_mode() to pg_pool_t; use more consistently
Browse files Browse the repository at this point in the history
Create an is_unmanaged_snaps_mode() function to parallel
is_pool_snaps_mode(), and replace all the checks directly referencing
removed_snaps or snaps with calls to these functions.
Fixes ceph#2345.

Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo authored and liewegas committed May 1, 2012
1 parent 22bd5df commit 18790b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/mon/OSDMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2466,15 +2466,15 @@ bool OSDMonitor::prepare_pool_op(MPoolOp *m)
switch (m->op) {
case POOL_OP_CREATE_SNAP:
case POOL_OP_DELETE_SNAP:
if (!pp.removed_snaps.empty()) {
if (pp.is_unmanaged_snaps_mode()) {
ret = -EINVAL;
goto out;
}
break;

case POOL_OP_CREATE_UNMANAGED_SNAP:
case POOL_OP_DELETE_UNMANAGED_SNAP:
if (!pp.snaps.empty()) {
if (pp.is_pool_snaps_mode()) {
ret = -EINVAL;
goto out;
}
Expand Down
11 changes: 8 additions & 3 deletions src/osd/osd_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ bool pg_pool_t::is_pool_snaps_mode() const
return removed_snaps.empty() && get_snap_seq() > 0;
}

bool pg_pool_t::is_unmanaged_snaps_mode() const
{
return removed_snaps.size() && get_snap_seq() > 0;
}

bool pg_pool_t::is_removed_snap(snapid_t s) const
{
if (is_pool_snaps_mode())
Expand Down Expand Up @@ -540,7 +545,7 @@ snapid_t pg_pool_t::snap_exists(const char *s) const

void pg_pool_t::add_snap(const char *n, utime_t stamp)
{
assert(removed_snaps.empty());
assert(!is_unmanaged_snaps_mode());
snapid_t s = get_snap_seq() + 1;
snap_seq = s;
snaps[s].snapid = s;
Expand All @@ -551,7 +556,7 @@ void pg_pool_t::add_snap(const char *n, utime_t stamp)
void pg_pool_t::add_unmanaged_snap(uint64_t& snapid)
{
if (removed_snaps.empty()) {
assert(snaps.empty());
assert(!is_pool_snaps_mode());
removed_snaps.insert(snapid_t(1));
snap_seq = 1;
}
Expand All @@ -567,7 +572,7 @@ void pg_pool_t::remove_snap(snapid_t s)

void pg_pool_t::remove_unmanaged_snap(snapid_t s)
{
assert(snaps.empty());
assert(is_unmanaged_snaps_mode());
removed_snaps.insert(s);
snap_seq = snap_seq + 1;
removed_snaps.insert(get_snap_seq());
Expand Down
2 changes: 2 additions & 0 deletions src/osd/osd_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,10 @@ struct pg_pool_t {
* - removal governed by removed_snaps
*
* we know which mode we're using based on whether removed_snaps is empty.
* If nothing has been created, both functions report false.
*/
bool is_pool_snaps_mode() const;
bool is_unmanaged_snaps_mode() const;
bool is_removed_snap(snapid_t s) const;

/*
Expand Down

0 comments on commit 18790b1

Please sign in to comment.