mds/Server.cc: check straydn before dereference

ID 1019554 (#1 of 1): Dereference after null check (FORWARD_NULL)
 13. var_deref_model: Passing null pointer "straydn" to function
 "MDSCacheObject::is_auth() const", which dereferences it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
RGWPutCORS_ObjStore_S3::get_params: check data before dereference

CID 1063697 (#1 of 1): Explicit null dereferenced (FORWARD_NULL)
 5. var_deref_model: Passing null pointer "data" to function
 "RGWXMLParser::parse(char const *, int, int)", which dereferences it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
AdminSocket: initialize m_getdescs_hook in the constructor

CID 717212 (#1 of 1): Uninitialized pointer field (UNINIT_CTOR)
 2. uninit_member: Non-static class member "m_getdescs_hook" is not
 initialized in this constructor nor in any functions that it calls.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ReplicatedPG::already_(complete|ack) should skip temp object ops

We clearly won't get dup ops on these repops, and they don't
have meaningful versions since they don't carry log
entries.

Fixes: #7682
Signed-off-by: Samuel Just <sam.just@inktank.com>
AbstractWrite: initialize m_snap_seq with 0

CID 717223 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
 2. uninit_member: Non-static class member "m_snap_seq" is not initialized
 in this constructor nor in any functions that it calls.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
RGWListBucketMultiparts: init max_uploads/default_max with 0

CID 717377 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
 2. uninit_member: Non-static class member "max_uploads" is not initialized
    in this constructor nor in any functions that it calls.
 4. uninit_member: Non-static class member "default_max" is not initialized
    in this constructor nor in any functions that it calls.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Merge pull request #1439 from ceph/wip-7682

ReplicatedPG::already_(complete|ack) should skip temp object ops

Reviewed-by: Sage Weil <sage@inktank.com>
test/system/st_rados_watch: expect ENOENT for watch on non-existent object

Signed-off-by: Samuel Just <sam.just@inktank.com>
test/librados/watch_notify: create foo before watching

Signed-off-by: Samuel Just <sam.just@inktank.com>
Merge pull request #1441 from ceph/wip-7671

Wip 7671

Reviewed-by: Sage Weil <sage@inktank.com>
Merge pull request #1440 from ceph/wip-7649

Wip 7649

Reviewed-by: Sage Weil <sage@inktank.com>
doc/release-notes: note that WATCH can get ENOENT now

Signed-off-by: Sage Weil <sage@inktank.com>
mailmap: Danny Al-Gaaf name normalization

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_librbd.cc: add missing va_end() to test_ls_pp

CID 1054877 (#1 of 1): Missing varargs init or cleanup (VARARGS)
 17. missing_va_end: va_end was not called for "ap".

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
libcephfs/test.cc: shutdown cmount

CID 743410 (#17 of 17): Resource leak (RESOURCE_LEAK)
 65. leaked_storage: Variable "cmount" going out of scope leaks the storage
 it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
libcephfs/test.cc: shutdown cmount at end of MountNonExist

CID 966624 (#5 of 5): Resource leak (RESOURCE_LEAK)
 17. leaked_storage: Variable "cmount" going out of scope leaks the
 storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
doc: fix formatting on PG recommendation

Previous commit (047287afbe0ddfaaafd05e9dbf25c1c7dea9a1be) broke
formatting on the formula, and also made mixed formula and text oddly,
which on second thought didn't look too good.

Add the note about the power of two to the following paragraph
instead, in prose.

Signed-off-by: Florian Haas <florian@hastexo.com>
Make the configuration "filestore merge threshold" can be negative which prevent it from merging, this could help:
  1. We are trying to create the PG folder up to several levels with a standalone tool to prevent it from runtime splitting, we need a configuration which prevent it from merging even there is no file within the folder.
  2. As runtime split / merge could bring latency issues, customer can use a negative merge threshold to prevent merging but only splitting.
This change is backward compatbile.
Signed-off-by: Guang Yang (yguang@yahoo-inc.com)
Work around race condition in libnss

This change prevents a segfault in ceph::crypto::init when using NSS and
calling rados_connect from multiple threads simultaneously on different
rados_t objects (and updates the documentation for rados_connect to
reflect the fix).

It's pretty simple, just one static mutex wrapping the
NSS definition of ceph::crypto::init. More details regarding the race
condition are in this[0] commit (and pull request #1424).

To reproduce the race condition in the existing codebase, the below[1]
C program will work (depending on number of cores and probably other
things, the number of threads needed to reliably reproduce varies, but
the more the better - in my environment five is sufficient, with four
cores.

[0]: 377c919088423bafcae92759f8d578438717705c

[1]:

```c

void *init(void *p) {
	int err;
	rados_t cluster;
	err = rados_create(&cluster, NULL);
	if (err < 0) {
		fprintf(stderr, "cannot create cluster handle: %s\n", strerror(-err));
		return NULL;
	}
	err = rados_conf_read_file(cluster, "./ceph.conf");
	if (err < 0) {
		fprintf(stderr, "error reading config file: %s\n", strerror(-err));
		return NULL;
	}
	rados_connect(cluster);
	return NULL;
}

int main() {
	pthread_t ts[NTHREAD];
	int i;
	for (i = 0; i < NTHREAD; i++) {
		pthread_create(&ts[i], NULL, init, NULL);
	}
	for (i = 0; i < NTHREAD; i++) {
		int k;
		void *p = (void*)&k;
		pthread_join(ts[i], p);
	}

	return 0;
}
```

Signed-off-by: Sharif Olorin <sio@tesser.org>
Add unit test for race condition in libnss

This isn't in test/crypto.cc because common_init_finish is called prior
to running any tests. Will not build the test function if Ceph hasn't
been configured with NSS.

Signed-off-by: Sharif Olorin <sio@tesser.org>