diff options
author | Alex Elder <elder@inktank.com> | 2012-07-13 21:35:11 -0400 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-07-30 21:15:47 -0400 |
commit | aa711ee3402ad10ffd5b70ce0417fadc9a95cccf (patch) | |
tree | 2400f84b9bc87fbd989844c4e2462809f69e9a96 /fs/ceph | |
parent | bd919d45aa61c19d9ed82548d6deb06bcae31153 (diff) |
ceph: define snap counts as u32 everywhere
There are two structures in which a count of snapshots are
maintained:
struct ceph_snap_context {
...
u32 num_snaps;
...
}
and
struct ceph_snap_realm {
...
u32 num_prior_parent_snaps; /* had prior to parent_since */
...
u32 num_snaps;
...
}
These fields never take on negative values (e.g., to hold special
meaning), and so are really inherently unsigned. Furthermore they
take their value from over-the-wire or on-disk formatted 32-bit
values.
So change their definition to have type u32, and change some spots
elsewhere in the code to account for this change.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/snap.c | 18 | ||||
-rw-r--r-- | fs/ceph/super.h | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index e5206fc76562..cbb2f54a3019 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c | |||
@@ -296,8 +296,7 @@ static int build_snap_context(struct ceph_snap_realm *realm) | |||
296 | struct ceph_snap_realm *parent = realm->parent; | 296 | struct ceph_snap_realm *parent = realm->parent; |
297 | struct ceph_snap_context *snapc; | 297 | struct ceph_snap_context *snapc; |
298 | int err = 0; | 298 | int err = 0; |
299 | int i; | 299 | u32 num = realm->num_prior_parent_snaps + realm->num_snaps; |
300 | int num = realm->num_prior_parent_snaps + realm->num_snaps; | ||
301 | 300 | ||
302 | /* | 301 | /* |
303 | * build parent context, if it hasn't been built. | 302 | * build parent context, if it hasn't been built. |
@@ -321,11 +320,11 @@ static int build_snap_context(struct ceph_snap_realm *realm) | |||
321 | realm->cached_context->seq == realm->seq && | 320 | realm->cached_context->seq == realm->seq && |
322 | (!parent || | 321 | (!parent || |
323 | realm->cached_context->seq >= parent->cached_context->seq)) { | 322 | realm->cached_context->seq >= parent->cached_context->seq)) { |
324 | dout("build_snap_context %llx %p: %p seq %lld (%d snaps)" | 323 | dout("build_snap_context %llx %p: %p seq %lld (%u snaps)" |
325 | " (unchanged)\n", | 324 | " (unchanged)\n", |
326 | realm->ino, realm, realm->cached_context, | 325 | realm->ino, realm, realm->cached_context, |
327 | realm->cached_context->seq, | 326 | realm->cached_context->seq, |
328 | realm->cached_context->num_snaps); | 327 | (unsigned int) realm->cached_context->num_snaps); |
329 | return 0; | 328 | return 0; |
330 | } | 329 | } |
331 | 330 | ||
@@ -342,6 +341,8 @@ static int build_snap_context(struct ceph_snap_realm *realm) | |||
342 | num = 0; | 341 | num = 0; |
343 | snapc->seq = realm->seq; | 342 | snapc->seq = realm->seq; |
344 | if (parent) { | 343 | if (parent) { |
344 | u32 i; | ||
345 | |||
345 | /* include any of parent's snaps occurring _after_ my | 346 | /* include any of parent's snaps occurring _after_ my |
346 | parent became my parent */ | 347 | parent became my parent */ |
347 | for (i = 0; i < parent->cached_context->num_snaps; i++) | 348 | for (i = 0; i < parent->cached_context->num_snaps; i++) |
@@ -361,8 +362,9 @@ static int build_snap_context(struct ceph_snap_realm *realm) | |||
361 | 362 | ||
362 | sort(snapc->snaps, num, sizeof(u64), cmpu64_rev, NULL); | 363 | sort(snapc->snaps, num, sizeof(u64), cmpu64_rev, NULL); |
363 | snapc->num_snaps = num; | 364 | snapc->num_snaps = num; |
364 | dout("build_snap_context %llx %p: %p seq %lld (%d snaps)\n", | 365 | dout("build_snap_context %llx %p: %p seq %lld (%u snaps)\n", |
365 | realm->ino, realm, snapc, snapc->seq, snapc->num_snaps); | 366 | realm->ino, realm, snapc, snapc->seq, |
367 | (unsigned int) snapc->num_snaps); | ||
366 | 368 | ||
367 | if (realm->cached_context) | 369 | if (realm->cached_context) |
368 | ceph_put_snap_context(realm->cached_context); | 370 | ceph_put_snap_context(realm->cached_context); |
@@ -402,9 +404,9 @@ static void rebuild_snap_realms(struct ceph_snap_realm *realm) | |||
402 | * helper to allocate and decode an array of snapids. free prior | 404 | * helper to allocate and decode an array of snapids. free prior |
403 | * instance, if any. | 405 | * instance, if any. |
404 | */ | 406 | */ |
405 | static int dup_array(u64 **dst, __le64 *src, int num) | 407 | static int dup_array(u64 **dst, __le64 *src, u32 num) |
406 | { | 408 | { |
407 | int i; | 409 | u32 i; |
408 | 410 | ||
409 | kfree(*dst); | 411 | kfree(*dst); |
410 | if (num) { | 412 | if (num) { |
diff --git a/fs/ceph/super.h b/fs/ceph/super.h index fc35036d258d..3ea48b7b98b3 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h | |||
@@ -612,9 +612,9 @@ struct ceph_snap_realm { | |||
612 | u64 parent_since; /* snapid when our current parent became so */ | 612 | u64 parent_since; /* snapid when our current parent became so */ |
613 | 613 | ||
614 | u64 *prior_parent_snaps; /* snaps inherited from any parents we */ | 614 | u64 *prior_parent_snaps; /* snaps inherited from any parents we */ |
615 | int num_prior_parent_snaps; /* had prior to parent_since */ | 615 | u32 num_prior_parent_snaps; /* had prior to parent_since */ |
616 | u64 *snaps; /* snaps specific to this realm */ | 616 | u64 *snaps; /* snaps specific to this realm */ |
617 | int num_snaps; | 617 | u32 num_snaps; |
618 | 618 | ||
619 | struct ceph_snap_realm *parent; | 619 | struct ceph_snap_realm *parent; |
620 | struct list_head children; /* list of child realms */ | 620 | struct list_head children; /* list of child realms */ |