|
Lines 73-79
static void compare(const void *tbuf, const void *controlbuf, off_t baseofs,
Link Here
|
| 73 |
} |
73 |
} |
| 74 |
} |
74 |
} |
| 75 |
|
75 |
|
| 76 |
typedef tuple<bool, uint32_t, cache_mode> IoParam; |
76 |
typedef tuple<bool, uint32_t, cache_mode, uint32_t> IoParam; |
| 77 |
|
77 |
|
| 78 |
class Io: public FuseTest, public WithParamInterface<IoParam> { |
78 |
class Io: public FuseTest, public WithParamInterface<IoParam> { |
| 79 |
public: |
79 |
public: |
|
Lines 112-117
void SetUp()
Link Here
|
| 112 |
default: |
112 |
default: |
| 113 |
FAIL() << "Unknown cache mode"; |
113 |
FAIL() << "Unknown cache mode"; |
| 114 |
} |
114 |
} |
|
|
115 |
m_kernel_minor_version = get<3>(GetParam()); |
| 115 |
m_noatime = true; // To prevent SETATTR for atime on close |
116 |
m_noatime = true; // To prevent SETATTR for atime on close |
| 116 |
|
117 |
|
| 117 |
FuseTest::SetUp(); |
118 |
FuseTest::SetUp(); |
|
Lines 195-200
void SetUp()
Link Here
|
| 195 |
}, Eq(true)), |
196 |
}, Eq(true)), |
| 196 |
_) |
197 |
_) |
| 197 |
).WillRepeatedly(Invoke(ReturnErrno(0))); |
198 |
).WillRepeatedly(Invoke(ReturnErrno(0))); |
|
|
199 |
EXPECT_CALL(*m_mock, process( |
| 200 |
ResultOf([=](auto in) { |
| 201 |
return (in.header.opcode == FUSE_FALLOCATE && |
| 202 |
in.body.fallocate.mode == (FUSE_FALLOC_FL_PUNCH_HOLE | FUSE_FALLOC_FL_KEEP_SIZE)); |
| 203 |
}, Eq(true)), |
| 204 |
_) |
| 205 |
).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto& out) { |
| 206 |
const struct spacectl_range rqsr = { |
| 207 |
.r_offset = (off_t)in.body.fallocate.offset, |
| 208 |
.r_len = (off_t)in.body.fallocate.length |
| 209 |
}; |
| 210 |
struct spacectl_range rmsr; |
| 211 |
int r; |
| 212 |
|
| 213 |
r = fspacectl(m_backing_fd, SPACECTL_DEALLOC, &rqsr, 0, &rmsr); |
| 214 |
ASSERT_EQ(0, r); |
| 215 |
ASSERT_EQ(0, rmsr.r_len); |
| 216 |
out.header.len = sizeof(out.header); |
| 217 |
}))); |
| 198 |
|
218 |
|
| 199 |
m_test_fd = open(FULLPATH, O_RDWR ); |
219 |
m_test_fd = open(FULLPATH, O_RDWR ); |
| 200 |
EXPECT_LE(0, m_test_fd) << strerror(errno); |
220 |
EXPECT_LE(0, m_test_fd) << strerror(errno); |
|
Lines 223-228
void do_closeopen()
Link Here
|
| 223 |
ASSERT_LE(0, m_control_fd) << strerror(errno); |
243 |
ASSERT_LE(0, m_control_fd) << strerror(errno); |
| 224 |
} |
244 |
} |
| 225 |
|
245 |
|
|
|
246 |
void do_fspacectl(off_t offs, off_t len) |
| 247 |
{ |
| 248 |
struct spacectl_range rqsr, test_rmsr, control_rmsr; |
| 249 |
int r; |
| 250 |
|
| 251 |
rqsr.r_offset = offs; |
| 252 |
rqsr.r_len = len; |
| 253 |
r = fspacectl(m_test_fd, SPACECTL_DEALLOC, &rqsr, 0, &test_rmsr); |
| 254 |
ASSERT_EQ(0, r) << strerror(errno); |
| 255 |
r = fspacectl(m_control_fd, SPACECTL_DEALLOC, &rqsr, 0, &control_rmsr); |
| 256 |
ASSERT_EQ(0, r) << strerror(errno); |
| 257 |
} |
| 258 |
|
| 226 |
void do_ftruncate(off_t offs) |
259 |
void do_ftruncate(off_t offs) |
| 227 |
{ |
260 |
{ |
| 228 |
ASSERT_EQ(0, ftruncate(m_test_fd, offs)) << strerror(errno); |
261 |
ASSERT_EQ(0, ftruncate(m_test_fd, offs)) << strerror(errno); |
|
Lines 345-350
virtual void SetUp() {
Link Here
|
| 345 |
} |
378 |
} |
| 346 |
}; |
379 |
}; |
| 347 |
|
380 |
|
|
|
381 |
class IoFspaceCtl: public Io { |
| 382 |
public: |
| 383 |
virtual void SetUp() { |
| 384 |
Io::SetUp(); |
| 385 |
} |
| 386 |
}; |
| 387 |
|
| 348 |
/* |
388 |
/* |
| 349 |
* Extend a file with dirty data in the last page of the last block. |
389 |
* Extend a file with dirty data in the last page of the last block. |
| 350 |
* |
390 |
* |
|
Lines 507-522
TEST_P(Io, resize_a_valid_buffer_while_extending)
Link Here
|
| 507 |
close(m_test_fd); |
547 |
close(m_test_fd); |
| 508 |
} |
548 |
} |
| 509 |
|
549 |
|
|
|
550 |
/* |
| 551 |
* fspacectl that overlaps with mmap write and normal read. Regression test for |
| 552 |
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276191 |
| 553 |
*/ |
| 554 |
TEST_P(IoFspaceCtl, fspacectl_after_mmap_write) |
| 555 |
{ |
| 556 |
do_mapwrite(0x1c6e5, 0x61d4); |
| 557 |
do_fspacectl(0x4f40c, 0x7c97); |
| 558 |
do_read(0x10afc, 0x4108); |
| 559 |
close(m_test_fd); |
| 560 |
} |
| 561 |
|
| 510 |
INSTANTIATE_TEST_SUITE_P(Io, Io, |
562 |
INSTANTIATE_TEST_SUITE_P(Io, Io, |
| 511 |
Combine(Bool(), /* async read */ |
563 |
Combine(Bool(), /* async read */ |
| 512 |
Values(0x1000, 0x10000, 0x20000), /* m_maxwrite */ |
564 |
Values(0x1000, 0x10000, 0x20000), /* m_maxwrite */ |
| 513 |
Values(Uncached, Writethrough, Writeback, WritebackAsync) |
565 |
Values(Uncached, Writethrough, Writeback, WritebackAsync), |
|
|
566 |
Values(28) |
| 514 |
) |
567 |
) |
| 515 |
); |
568 |
); |
| 516 |
|
569 |
|
| 517 |
INSTANTIATE_TEST_SUITE_P(Io, IoCacheable, |
570 |
INSTANTIATE_TEST_SUITE_P(Io, IoCacheable, |
| 518 |
Combine(Bool(), /* async read */ |
571 |
Combine(Bool(), /* async read */ |
| 519 |
Values(0x1000, 0x10000, 0x20000), /* m_maxwrite */ |
572 |
Values(0x1000, 0x10000, 0x20000), /* m_maxwrite */ |
| 520 |
Values(Writethrough, Writeback, WritebackAsync) |
573 |
Values(Writethrough, Writeback, WritebackAsync), |
|
|
574 |
Values(28) |
| 575 |
) |
| 576 |
); |
| 577 |
|
| 578 |
INSTANTIATE_TEST_SUITE_P(Io, IoFspaceCtl, |
| 579 |
Combine(Values(true), /* async read */ |
| 580 |
Values(0x10000), /* m_maxwrite */ |
| 581 |
Values(Uncached, Writethrough, Writeback, WritebackAsync), |
| 582 |
Values(18, 28) /* kernel_minor_vers */ |
| 521 |
) |
583 |
) |
| 522 |
); |
584 |
); |
| 523 |
- |
|
|