reserve a few feature bits

Make sure we have a bit of warning before we reach the end times.

Signed-off-by: Sage Weil <sage@redhat.com>
mon: use pre-encoded OSDMap for build_latest_full() MOSDMap message

Do not reencode; use our existing encoded bufferlist.

Signed-off-by: Sage Weil <sage@redhat.com>
osd: warn if reencoding and OSDMap with fewer features than the mon

It is very dangerous to reencode and OSDMap with fewer features than the
mon intended as we may be introducing a different variation of the same
OSDMap epoch into the wild.  Add a build warning here as well as this is
a potentially serious problem.

Signed-off-by: Sage Weil <sage@redhat.com>
osd: use encoded osdmap bl instead of reencoding

We have a good one on disk; there is no reason to do this.

Signed-off-by: Sage Weil <sage@redhat.com>
prevent random people from encoding the OSDMap

This is a safety check: nobody should be encoding OSDMaps except:

 - the mons
 - MOSDMap, when encoding old OSDMaps with legacy encodings
 - ceph-dencoder
 - the OSD

More importantly, nobody should be encoding OSDMap::Incremental except

 - the leader mon

We use a reserved feature bit to indicate that the encoder is enlightened.
Note that we skip this check for legacy encodings, so we don't touch
MOSDMap in this patch.

Signed-off-by: Sage Weil <sage@redhat.com>
add MMonGetOSDMap message

This message lets you explicitly request a range of full or incremental
maps from someone (the monitor, presumably), independent of any other
session state.

Signed-off-by: Sage Weil <sage@redhat.com>
mon/OSDMonitor: handle MMonGetOSDMap

Respond to MMonGetOSDMap with an MOSDMap filled with what we have.

Signed-off-by: Sage Weil <sage@redhat.com>
buffer: add iterator::get_bl()

Signed-off-by: Sage Weil <sage@redhat.com>
osd/OSDMap: encode crc

Note that we include the logic in OSDMap::encode to add data that comes
after the crc, although we do not use it yet.

Also note that we do not yet verify the crc on decode.

Signed-off-by: Sage Weil <sage@redhat.com>
mon/OSDMonitor: populate Incremental::full_crc

When we encode an Incremental, put in the expected crc for the resulting
full OSDMap.

Signed-off-by: Sage Weil <sage@redhat.com>
osd/OSDMap: verify CRC on decode

Signed-off-by: Sage Weil <sage@redhat.com>
PG: always clear_primary_state when leaving Primary

Otherwise, entries from the log collection process might leak into the next
epoch, where we might end up choosing a different authoritative log.  In this
case, it resulted in us not rolling back to log entries on one of the replicas
prior to trying to recover from an affected object due to the peer_missing not
being cleared.

Fixes: #10059
Backport: giant, firefly, dumpling
Signed-off-by: Samuel Just <sjust@redhat.com>
PG: always clear_primary_state on new interval, but only clear pg temp if not primary

Signed-off-by: Samuel Just <sjust@redhat.com>
rgw: support swift storage policy api

Fixes: #9932

When creating a bucket, set the placement rule according to the
provided X-Storage-Policy http header.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
PGLog: include rollback_info_trimmed_to in (read|write)_log

Fixes: #10157
Backport: firefly, giant
Signed-off-by: Samuel Just <sjust@redhat.com>
safe_io: do not set ending \0 in safe_read_file()

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
mds: disallow write operations when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: don't trim log when MDS is readonly

When MDS is readonly, keep metadata objects (not include the journal) of
cephfs unchanged. This allows us to submit new entries to the log while
MDS is readonly. (Log entries submitted after MDS becomes readonly can
be safely dropped)

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: keep locks in sync state when MDS is readonly

when transit locks to sync state, we may submit new entries to the log.
This should be safe as long as we don't trim old log segments.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
mds: disallow slave requests when MDS is readonly

Signed-off-by: Yan, Zheng <zyan@redhat.com>