Merge pull request #42308 from jtlayton/wip-51644

osd: don't assert on zero-length OP_ZERO request

Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Kefu Chai 2021-07-30 19:03:19 +08:00 committed by GitHub
commit 13c2a0e948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -6811,8 +6811,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
if (result < 0)
break;
ceph_assert(op.extent.length);
if (obs.exists && !oi.is_whiteout()) {
if (op.extent.length && obs.exists && !oi.is_whiteout()) {
t->zero(soid, op.extent.offset, op.extent.length);
interval_set<uint64_t> ch;
ch.insert(op.extent.offset, op.extent.length);

View File

@ -163,6 +163,14 @@ TEST_F(LibRadosIo, AppendRoundTrip) {
ASSERT_EQ(0, memcmp(buf3 + sizeof(buf), buf2, sizeof(buf2)));
}
TEST_F(LibRadosIo, ZeroLenZero) {
rados_write_op_t op = rados_create_write_op();
ASSERT_TRUE(op);
rados_write_op_zero(op, 0, 0);
ASSERT_EQ(0, rados_write_op_operate(op, ioctx, "foo", NULL, 0));
rados_release_write_op(op);
}
TEST_F(LibRadosIo, TruncTest) {
char buf[128];
char buf2[sizeof(buf)];