Sage Weil [Sat, 29 Sep 2012 08:27:33 +0000 (01:27 -0700)]
mds: simplify get_dirfrag()
Avoid useless have_inode() call.
CID 716996: Dereference null return value (NULL_RETURNS)
At (13): Dereferencing a pointer that might be null "this->get_inode(df.ino, snapid_t(18446744073709551614UL))" when calling "CInode::get_dirfrag(frag_t)". [hide details]
Sage Weil [Sat, 29 Sep 2012 08:17:21 +0000 (01:17 -0700)]
mds: add assert to lock path
This makes coverity happy:
CID 716916: Explicit null dereferenced (FORWARD_NULL)
At (28): Passing null pointer "in" to function "MDSCacheObject::state_test(unsigned int) const", which dereferences it. [hide details]
Sage Weil [Sat, 29 Sep 2012 08:16:16 +0000 (01:16 -0700)]
mds: fix uninit Dumper fields in ctor
CID 717234: Uninitialized pointer field (UNINIT_CTOR)
At (8): Non-static class member "rank" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Sat, 29 Sep 2012 08:12:53 +0000 (01:12 -0700)]
mds: fix uninit Capability::last_issue
CID 717233: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "last_issue" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Sat, 29 Sep 2012 08:11:41 +0000 (01:11 -0700)]
mds: fix uninit field in CInode
CID 717231: Uninitialized scalar field (UNINIT_CTOR)
At (3): Non-static class member "auth_pin_freeze_allowance" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Sat, 29 Sep 2012 08:09:43 +0000 (01:09 -0700)]
mds: fix typo in rsubdirs warning
CID 716879: Copy-paste error (COPY_PASTE_ERROR)
At (2): "rfiles" in "pi->rstat.rfiles" looks like a copy-paste error. Should it say "rsubdirs" instead?
Sage Weil [Sat, 29 Sep 2012 08:08:30 +0000 (01:08 -0700)]
mds: init CDir fields
CID 717230: Uninitialized scalar field (UNINIT_CTOR)
At (8): Non-static class member "num_dentries_auth_subtree_nested" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Sat, 29 Sep 2012 08:06:38 +0000 (01:06 -0700)]
mds: avoid useless have_inode() call
CID 716989: Dereference null return value (NULL_RETURNS)
At (83): Dereferencing a pointer that might be null "in" when calling "operator <<(std::ostream &, CInode &)". [hide details]
Sage Weil [Sat, 29 Sep 2012 07:59:54 +0000 (00:59 -0700)]
osd: pass by value
CID 717054: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter recovery_info of type ObjectRecoveryInfo (size 640 bytes) by value.
Sage Weil [Sat, 29 Sep 2012 07:57:40 +0000 (00:57 -0700)]
osd: fix coverity NULL warning
Session is alwasy set on requests.
CID 717008: Dereference null return value (NULL_RETURNS)
At (34): Dereferencing a pointer that might be null "session" when calling "OSD::Session::del_notif(void *)". [hide details]
Sage Weil [Sat, 29 Sep 2012 07:50:57 +0000 (00:50 -0700)]
osd: init all vars in PG::NamedState
CID 717341: Uninitialized pointer field (UNINIT_CTOR)
At (2): Non-static class member "state_name" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Sat, 29 Sep 2012 01:16:49 +0000 (18:16 -0700)]
mon: fix uninit var warning in session startup
This is a false positive; just init the var.
CID 717198: Uninitialized scalar variable (UNINIT)
At (18): Using uninitialized value "auid" when calling "MonCaps::set_auid(uint64_t)". [hide details]
Sage Weil [Sat, 29 Sep 2012 00:56:34 +0000 (17:56 -0700)]
mds: dentry always has dir
CID 716912: Dereference after null check (FORWARD_NULL)
At (3): Passing null pointer "this->dir" to function "CDir::ino() const", which dereferences it. [hide details]
Sage Weil [Sat, 29 Sep 2012 00:54:34 +0000 (17:54 -0700)]
librbd: init value in CopyProgressCtx ctor
CID 717227: Uninitialized pointer field (UNINIT_CTOR)
At (4): Non-static class member "src_size" is not initialized in this constructor nor in any functions that it calls.
Samuel Just [Fri, 28 Sep 2012 23:19:56 +0000 (16:19 -0700)]
FileStore: use fresh vector for calls for listing collection
In collection_list_range, use an empty vector to pass into
collection_list_partial. collection_list_partial stops
listing when the output vector exceeds the specified max.
If this happens before we hit the end of the range,
collection_list_range will spin forever.
Signed-off-by: Samuel Just <sam.just@inktank.com> Reviewed-by: Mike Ryan <mike.ryan@inktank.com> Reviewed-by: Greg Farnum <greg@inktank.com>
Sage Weil [Fri, 28 Sep 2012 17:31:29 +0000 (10:31 -0700)]
osdmap: restore stream format
CID 727986: Not restoring ostream format (STREAM_FORMAT_STATE)
At (20): Changing format state of stream "out" for category precision without later restoring it.
Sage Weil [Fri, 28 Sep 2012 15:06:19 +0000 (08:06 -0700)]
cls_refcount: fix uninit vals in ctor
CID 727989: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "implicit_ref" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:55:45 +0000 (07:55 -0700)]
osdmaptool: fix pg_t::parse() return value check
CID 716876: Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
At (1): pgid.parse(test_map_pg.c_str()) < 0 is always false regardless of the values of its operands. This occurs as the logical operand of if.
Sage Weil [Fri, 28 Sep 2012 14:55:08 +0000 (07:55 -0700)]
osdmaptool: check return values
CID 716864: Unchecked return value (CHECKED_RETURN)
At (155): Calling function "ceph::buffer::list::read_file(char const *, std::string *)" without checking return value (as is done elsewhere 14 out of 16 times).
Sage Weil [Fri, 28 Sep 2012 14:53:04 +0000 (07:53 -0700)]
objecter: fix dereference after null check
CID 716933: Dereference after null check (FORWARD_NULL)
At (4): Passing null pointer "extra_ops->ops" to function "std::vector<OSDOp, std::allocator<OSDOp> >::operator [](std::vector<OSDOp, std::allocator<OSDOp> >::size_type)", which dereferences it. [hide details]
All callers pass 1, but this was also hard-coded into the helper logic.
Fix code (and doxygen desc) to allow other values.
Sage Weil [Fri, 28 Sep 2012 14:45:49 +0000 (07:45 -0700)]
objectcacher: fix uninit var in ctor
CID 717351: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "tid" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:44:18 +0000 (07:44 -0700)]
objectcacher: fix uninit it ctor
CID 717350: Uninitialized scalar field (UNINIT_CTOR)
At (4): Non-static class member field "ex.length" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:42:20 +0000 (07:42 -0700)]
objectcacher: avoid confusing coverity
CID 716932: Explicit null dereferenced (FORWARD_NULL)
At (21): Passing null pointer "final" to function "ObjectCacher::BufferHead::end() const", which dereferences it. [hide details]
Sage Weil [Fri, 28 Sep 2012 14:36:27 +0000 (07:36 -0700)]
journaler: uninit var in ctor
CID 717349: Uninitialized scalar field (UNINIT_CTOR)
At (14): Non-static class member field "layout.fl_pg_pool" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:35:39 +0000 (07:35 -0700)]
journaler: uninit var in ctor
CID 717348: Uninitialized scalar field (UNINIT_CTOR)
At (14): Non-static class member field "layout.fl_pg_pool" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:35:20 +0000 (07:35 -0700)]
filer: fix overflow
CID 717017: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "layout->fl_stripe_count.operator unsigned int() * layout->fl_object_size.operator unsigned int()" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic before being used in a context which expects an expression of type "uint64_t" (64 bits, unsigned). To avoid overflow, cast either operand to "uint64_t" before performing the multiplication.
Sage Weil [Fri, 28 Sep 2012 14:29:16 +0000 (07:29 -0700)]
messages: uninit values
CID 717259: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "global_id" is not initialized in this constructor nor in any functions that it calls.
CID 728086: Uninitialized scalar field (UNINIT_CTOR)
At (4): Non-static class member "type" is not initialized in this constructor nor in any functions that it calls.
CID 717260: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "from" is not initialized in this constructor nor in any functions that it calls.
CID 717261: Uninitialized scalar field (UNINIT_CTOR)
At (51): Non-static class member field "head.time_warp_seq" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:15:07 +0000 (07:15 -0700)]
msg/Accepter: check getsockbyname() return value
CID 717442: Other violation (CHECKED_RETURN)
At (10): Calling function "getsockname(this->listen_sd, (sockaddr *)listen_addr.ss_addr(), &llen)" without checking return value. This library function may fail and return an error code.
At (11): No check of the return value of "getsockname(this->listen_sd, (sockaddr *)listen_addr.ss_addr(), &llen)".
Sage Weil [Fri, 28 Sep 2012 14:12:39 +0000 (07:12 -0700)]
LogEntry: fix uninit in ctor
At (2): Non-static class member "m_thread" is not initialized in this constructor nor in any functions that it calls.
At (4): Non-static class member "m_prio" is not initialized in this constructor nor in any functions that it calls.
At (6): Non-static class member "m_subsys" is not initialized in this constructor nor in any functions that it calls.
CID 717229: Uninitialized scalar field (UNINIT_CTOR)
At (8): Non-static class member "m_static_buf" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 14:10:05 +0000 (07:10 -0700)]
utime: restore ostream state
CID 717130: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.
CID 717131: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.
Sage Weil [Fri, 28 Sep 2012 13:57:58 +0000 (06:57 -0700)]
crushtester: avoid divide by zero
CID 716906: Division or modulo by zero (DIVIDE_BY_ZERO)
At (214): In expression "(float)weight[i] / (float)total_weight", division by expression "total_weight" which may be zero has undefined behavior.
Sage Weil [Fri, 28 Sep 2012 13:56:20 +0000 (06:56 -0700)]
crushtester: avoid divide by zero
CID 716904: Division or modulo by zero (DIVIDE_BY_ZERO)
At (4): In expression "(float)weight[i] / (float)total_weight", division by expression "total_weight" which may be zero has undefined behavior.
At (8): On this path, function call "this->crush->get_max_devices()" has return value of 0
CID 716905: Division or modulo by zero (DIVIDE_BY_ZERO)
At (9): In expression "lrand48() % this->crush->get_max_devices()" modulo by expression "this->crush->get_max_devices()" which may be zero has undefined behavior.
Sage Weil [Fri, 28 Sep 2012 13:45:06 +0000 (06:45 -0700)]
PrebufferedStream: avoid dereferencing end()
This appeared to work, but probably isn't a good idea.
CID 716940: Using invalid iterator (INVALIDATE_ITERATOR)
At (4): Dereferencing iterator "this->m_overflow.end()" though it is already past the end of its container.
Sage Weil [Fri, 28 Sep 2012 04:03:02 +0000 (21:03 -0700)]
perfcounters: remove unused members
Avoids coverity warning
CID 717214: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "m_shutdown_fd" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 01:17:08 +0000 (18:17 -0700)]
ipaddr: fix buffer overrun on ipv6 prefix of 128
CID 717020: Out-of-bounds read (OVERRUN)
At (3): Overrunning array "addr->__in6_u.__u6_addr8" of 16 bytes at byte offset 16 using index "prefix_len / 8U" (which evaluates to 16).
Sage Weil [Fri, 28 Sep 2012 01:13:24 +0000 (18:13 -0700)]
buffer: init data val in ctor
CID 717213: Uninitialized pointer field (UNINIT_CTOR)
At (2): Non-static class member "data" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 01:12:20 +0000 (18:12 -0700)]
buffer: restore stream state after hexdump()
CID 717129: Not restoring ostream format (STREAM_FORMAT_STATE)
At (51): Changing format state of stream "out" for category fill without later restoring it.
Sage Weil [Fri, 28 Sep 2012 01:11:51 +0000 (18:11 -0700)]
adminsocket: init vars in ctor
At (2): Non-static class member "m_version_hook" is not initialized in this constructor nor in any functions that it calls.
CID 717212: Uninitialized pointer field (UNINIT_CTOR)
At (4): Non-static class member "m_help_hook" is not initialized in this constructor nor in any functions that it calls.
Sage Weil [Fri, 28 Sep 2012 01:02:10 +0000 (18:02 -0700)]
adminsocket: check return value
CID 716847: Other violation (CHECKED_RETURN)
At (5): Calling function "fcntl(sock_fd, 2, 1)" without checking return value. This library function may fail and return an error code.
At (6): No check of the return value of "fcntl(sock_fd, 2, 1)".
Sage Weil [Fri, 28 Sep 2012 00:55:28 +0000 (17:55 -0700)]
workqueue: reset heartbeat timeout under lock
This makes coverity happier:
CID 727967: Value not atomically updated (ATOMICITY)
At (44): Using an unreliable value of "hb" inside the second locked section. If the data that "hb" depends on was changed by another thread, this use might be incorrect.
Sage Weil [Fri, 28 Sep 2012 00:49:44 +0000 (17:49 -0700)]
MemoryModel: init in ctor
CID 717211: Uninitialized scalar field (UNINIT_CTOR)
At (18): Non-static class member field "last.mmap" is not initialized in this constructor nor in any functions that it calls.
Samuel Just [Mon, 24 Sep 2012 21:33:17 +0000 (14:33 -0700)]
PG: explicitely delay ops on backfill_pos
Previously, we considered backfill_pos degraded in order to delay
ops since a write to backfill_pos could generate a snap before
backfill_pos, and we assume that (0, backfill_pos) is fully
backfilled. This is a problem since it's possible that
backfill_pos is a valid object, but not one that currently exists.
For example, it might have been deleted since last_backfill was
last changed. Instead, we will explicitly delay ops on
backfill_pos in waiting_for_backfill_pos.
This error resulted in #2691 since wait_for_degraded_object also
attempts to recover the object. At this point, the primary would
attempt to recover the object, find that it isn't there, and put
it in the missing set with need=0,0. Eventually, recover_primary
attempts to recover that object, finds that it has been deleted
in the log, and asserts.