xref: /freebsd/tests/sys/fs/fusefs/io.cc (revision dff3a6b4109964418dd88e3aa0d931924b54d149)
1a87e0831SAlan Somers /*-
2a87e0831SAlan Somers  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3a87e0831SAlan Somers  *
4a87e0831SAlan Somers  * Copyright (c) 2019 The FreeBSD Foundation
5a87e0831SAlan Somers  *
6a87e0831SAlan Somers  * This software was developed by BFF Storage Systems, LLC under sponsorship
7a87e0831SAlan Somers  * from the FreeBSD Foundation.
8a87e0831SAlan Somers  *
9a87e0831SAlan Somers  * Redistribution and use in source and binary forms, with or without
10a87e0831SAlan Somers  * modification, are permitted provided that the following conditions
11a87e0831SAlan Somers  * are met:
12a87e0831SAlan Somers  * 1. Redistributions of source code must retain the above copyright
13a87e0831SAlan Somers  *    notice, this list of conditions and the following disclaimer.
14a87e0831SAlan Somers  * 2. Redistributions in binary form must reproduce the above copyright
15a87e0831SAlan Somers  *    notice, this list of conditions and the following disclaimer in the
16a87e0831SAlan Somers  *    documentation and/or other materials provided with the distribution.
17a87e0831SAlan Somers  *
18a87e0831SAlan Somers  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19a87e0831SAlan Somers  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20a87e0831SAlan Somers  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21a87e0831SAlan Somers  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22a87e0831SAlan Somers  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23a87e0831SAlan Somers  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24a87e0831SAlan Somers  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25a87e0831SAlan Somers  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26a87e0831SAlan Somers  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27a87e0831SAlan Somers  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28a87e0831SAlan Somers  * SUCH DAMAGE.
29a87e0831SAlan Somers  */
30a87e0831SAlan Somers 
31a87e0831SAlan Somers extern "C" {
32a87e0831SAlan Somers #include <fcntl.h>
33a87e0831SAlan Somers #include <stdlib.h>
34a87e0831SAlan Somers #include <unistd.h>
35a87e0831SAlan Somers }
36a87e0831SAlan Somers 
37a87e0831SAlan Somers #include "mockfs.hh"
38a87e0831SAlan Somers #include "utils.hh"
39a87e0831SAlan Somers 
40a87e0831SAlan Somers /*
41a87e0831SAlan Somers  * For testing I/O like fsx does, but deterministically and without a real
42a87e0831SAlan Somers  * underlying file system
43a87e0831SAlan Somers  *
44a87e0831SAlan Somers  * TODO: after fusefs gains the options to select cache mode for each mount
45a87e0831SAlan Somers  * point, run each of these tests for all cache modes.
46a87e0831SAlan Somers  */
47a87e0831SAlan Somers 
48a87e0831SAlan Somers using namespace testing;
49a87e0831SAlan Somers 
50a87e0831SAlan Somers const char FULLPATH[] = "mountpoint/some_file.txt";
51a87e0831SAlan Somers const char RELPATH[] = "some_file.txt";
52a87e0831SAlan Somers const uint64_t ino = 42;
53a87e0831SAlan Somers 
54*dff3a6b4SAlan Somers static void compare(const void *tbuf, const void *controlbuf, off_t baseofs,
55*dff3a6b4SAlan Somers 	ssize_t size)
56*dff3a6b4SAlan Somers {
57*dff3a6b4SAlan Somers 	int i;
58*dff3a6b4SAlan Somers 
59*dff3a6b4SAlan Somers 	for (i = 0; i < size; i++) {
60*dff3a6b4SAlan Somers 		if (((const char*)tbuf)[i] != ((const char*)controlbuf)[i]) {
61*dff3a6b4SAlan Somers 			off_t ofs = baseofs + i;
62*dff3a6b4SAlan Somers 			FAIL() << "miscompare at offset "
63*dff3a6b4SAlan Somers 			       << std::hex
64*dff3a6b4SAlan Somers 			       << std::showbase
65*dff3a6b4SAlan Somers 			       << ofs
66*dff3a6b4SAlan Somers 			       << ".  expected = "
67*dff3a6b4SAlan Somers 			       << std::setw(2)
68*dff3a6b4SAlan Somers 			       << (unsigned)((const uint8_t*)controlbuf)[i]
69*dff3a6b4SAlan Somers 			       << " got = "
70*dff3a6b4SAlan Somers 			       << (unsigned)((const uint8_t*)tbuf)[i];
71*dff3a6b4SAlan Somers 		}
72*dff3a6b4SAlan Somers 	}
73*dff3a6b4SAlan Somers }
74*dff3a6b4SAlan Somers 
75a87e0831SAlan Somers class Io: public FuseTest {
76a87e0831SAlan Somers public:
77a87e0831SAlan Somers int m_backing_fd, m_control_fd, m_test_fd;
78a87e0831SAlan Somers 
79a87e0831SAlan Somers Io(): m_backing_fd(-1), m_control_fd(-1) {};
80a87e0831SAlan Somers 
81a87e0831SAlan Somers void SetUp()
82a87e0831SAlan Somers {
8393c0c1d4SAlan Somers 	m_backing_fd = open("backing_file", O_RDWR | O_CREAT | O_TRUNC, 0644);
84a87e0831SAlan Somers 	if (m_backing_fd < 0)
85a87e0831SAlan Somers 		FAIL() << strerror(errno);
8693c0c1d4SAlan Somers 	m_control_fd = open("control", O_RDWR | O_CREAT | O_TRUNC, 0644);
87a87e0831SAlan Somers 	if (m_control_fd < 0)
88a87e0831SAlan Somers 		FAIL() << strerror(errno);
89a87e0831SAlan Somers 	srandom(22'9'1982);	// Seed with my birthday
90a87e0831SAlan Somers 	FuseTest::SetUp();
91a87e0831SAlan Somers 	if (IsSkipped())
92a87e0831SAlan Somers 		return;
93a87e0831SAlan Somers 
94a87e0831SAlan Somers 	expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1);
95a87e0831SAlan Somers 	expect_open(ino, 0, 1);
96a87e0831SAlan Somers 	EXPECT_CALL(*m_mock, process(
97a87e0831SAlan Somers 		ResultOf([=](auto in) {
98a87e0831SAlan Somers 			return (in.header.opcode == FUSE_WRITE &&
99a87e0831SAlan Somers 				in.header.nodeid == ino);
100a87e0831SAlan Somers 		}, Eq(true)),
101a87e0831SAlan Somers 		_)
102a87e0831SAlan Somers 	).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto& out) {
103a87e0831SAlan Somers 		const char *buf = (const char*)in.body.bytes +
104a87e0831SAlan Somers 			sizeof(struct fuse_write_in);
105a87e0831SAlan Somers 		ssize_t isize = in.body.write.size;
106a87e0831SAlan Somers 		off_t iofs = in.body.write.offset;
107a87e0831SAlan Somers 
108a87e0831SAlan Somers 		ASSERT_EQ(isize, pwrite(m_backing_fd, buf, isize, iofs))
109a87e0831SAlan Somers 			<< strerror(errno);
110a87e0831SAlan Somers 		SET_OUT_HEADER_LEN(out, write);
111a87e0831SAlan Somers 		out.body.write.size = isize;
112a87e0831SAlan Somers 	})));
113a87e0831SAlan Somers 	EXPECT_CALL(*m_mock, process(
114a87e0831SAlan Somers 		ResultOf([=](auto in) {
115a87e0831SAlan Somers 			return (in.header.opcode == FUSE_READ &&
116a87e0831SAlan Somers 				in.header.nodeid == ino);
117a87e0831SAlan Somers 		}, Eq(true)),
118a87e0831SAlan Somers 		_)
119a87e0831SAlan Somers 	).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto& out) {
120a87e0831SAlan Somers 		ssize_t isize = in.body.write.size;
121a87e0831SAlan Somers 		off_t iofs = in.body.write.offset;
122a87e0831SAlan Somers 		void *buf = out.body.bytes;
123a87e0831SAlan Somers 
124a87e0831SAlan Somers 		ASSERT_LE(0, pread(m_backing_fd, buf, isize, iofs))
125a87e0831SAlan Somers 			<< strerror(errno);
126a87e0831SAlan Somers 		out.header.len = sizeof(struct fuse_out_header) + isize;
127a87e0831SAlan Somers 	})));
128a87e0831SAlan Somers 	EXPECT_CALL(*m_mock, process(
129a87e0831SAlan Somers 		ResultOf([=](auto in) {
130a87e0831SAlan Somers 			uint32_t valid = FATTR_SIZE | FATTR_FH;
131a87e0831SAlan Somers 			return (in.header.opcode == FUSE_SETATTR &&
132a87e0831SAlan Somers 				in.header.nodeid == ino &&
133a87e0831SAlan Somers 				in.body.setattr.valid == valid);
134a87e0831SAlan Somers 		}, Eq(true)),
135a87e0831SAlan Somers 		_)
136a87e0831SAlan Somers 	).WillRepeatedly(Invoke(ReturnImmediate([=](auto in, auto& out) {
137a87e0831SAlan Somers 		ASSERT_EQ(0, ftruncate(m_backing_fd, in.body.setattr.size))
138a87e0831SAlan Somers 			<< strerror(errno);
139a87e0831SAlan Somers 		SET_OUT_HEADER_LEN(out, attr);
140a87e0831SAlan Somers 		out.body.attr.attr.ino = ino;
141a87e0831SAlan Somers 		out.body.attr.attr.mode = S_IFREG | 0755;
142a87e0831SAlan Somers 		out.body.attr.attr.size = in.body.setattr.size;
143a87e0831SAlan Somers 		out.body.attr.attr_valid = UINT64_MAX;
144a87e0831SAlan Somers 	})));
145a87e0831SAlan Somers 	/* Any test that close()s will send FUSE_FLUSH and FUSE_RELEASE */
146a87e0831SAlan Somers 	EXPECT_CALL(*m_mock, process(
147a87e0831SAlan Somers 		ResultOf([=](auto in) {
148a87e0831SAlan Somers 			return (in.header.opcode == FUSE_FLUSH &&
149a87e0831SAlan Somers 				in.header.nodeid == ino);
150a87e0831SAlan Somers 		}, Eq(true)),
151a87e0831SAlan Somers 		_)
152a87e0831SAlan Somers 	).WillRepeatedly(Invoke(ReturnErrno(0)));
153a87e0831SAlan Somers 	EXPECT_CALL(*m_mock, process(
154a87e0831SAlan Somers 		ResultOf([=](auto in) {
155a87e0831SAlan Somers 			return (in.header.opcode == FUSE_RELEASE &&
156a87e0831SAlan Somers 				in.header.nodeid == ino);
157a87e0831SAlan Somers 		}, Eq(true)),
158a87e0831SAlan Somers 		_)
159a87e0831SAlan Somers 	).WillRepeatedly(Invoke(ReturnErrno(0)));
160a87e0831SAlan Somers 
161a87e0831SAlan Somers 	m_test_fd = open(FULLPATH, O_RDWR );
162a87e0831SAlan Somers 	EXPECT_LE(0, m_test_fd) << strerror(errno);
163a87e0831SAlan Somers }
164a87e0831SAlan Somers 
165a87e0831SAlan Somers void TearDown()
166a87e0831SAlan Somers {
167a87e0831SAlan Somers 	if (m_backing_fd >= 0)
168a87e0831SAlan Somers 		close(m_backing_fd);
169a87e0831SAlan Somers 	if (m_control_fd >= 0)
170a87e0831SAlan Somers 		close(m_control_fd);
171a87e0831SAlan Somers 	FuseTest::TearDown();
172a87e0831SAlan Somers 	/* Deliberately leak test_fd */
173a87e0831SAlan Somers }
174a87e0831SAlan Somers 
175a87e0831SAlan Somers void do_ftruncate(off_t offs)
176a87e0831SAlan Somers {
177a87e0831SAlan Somers 	ASSERT_EQ(0, ftruncate(m_test_fd, offs)) << strerror(errno);
178a87e0831SAlan Somers 	ASSERT_EQ(0, ftruncate(m_control_fd, offs)) << strerror(errno);
179a87e0831SAlan Somers }
180a87e0831SAlan Somers 
181a87e0831SAlan Somers void do_read(ssize_t size, off_t offs)
182a87e0831SAlan Somers {
183a87e0831SAlan Somers 	void *test_buf, *control_buf;
184a87e0831SAlan Somers 
185a87e0831SAlan Somers 	test_buf = malloc(size);
186a87e0831SAlan Somers 	ASSERT_NE(NULL, test_buf) << strerror(errno);
187a87e0831SAlan Somers 	control_buf = malloc(size);
188a87e0831SAlan Somers 	ASSERT_NE(NULL, control_buf) << strerror(errno);
189a87e0831SAlan Somers 
190a87e0831SAlan Somers 	ASSERT_EQ(size, pread(m_test_fd, test_buf, size, offs))
191a87e0831SAlan Somers 		<< strerror(errno);
192a87e0831SAlan Somers 	ASSERT_EQ(size, pread(m_control_fd, control_buf, size, offs))
193a87e0831SAlan Somers 		<< strerror(errno);
194a87e0831SAlan Somers 
195*dff3a6b4SAlan Somers 	compare(test_buf, control_buf, offs, size);
196a87e0831SAlan Somers 
197a87e0831SAlan Somers 	free(control_buf);
198a87e0831SAlan Somers 	free(test_buf);
199a87e0831SAlan Somers }
200a87e0831SAlan Somers 
201a87e0831SAlan Somers void do_write(ssize_t size, off_t offs)
202a87e0831SAlan Somers {
203a87e0831SAlan Somers 	char *buf;
204a87e0831SAlan Somers 	long i;
205a87e0831SAlan Somers 
206a87e0831SAlan Somers 	buf = (char*)malloc(size);
207a87e0831SAlan Somers 	ASSERT_NE(NULL, buf) << strerror(errno);
208a87e0831SAlan Somers 	for (i=0; i < size; i++)
209a87e0831SAlan Somers 		buf[i] = random();
210a87e0831SAlan Somers 
211a87e0831SAlan Somers 	ASSERT_EQ(size, pwrite(m_test_fd, buf, size, offs ))
212a87e0831SAlan Somers 		<< strerror(errno);
213a87e0831SAlan Somers 	ASSERT_EQ(size, pwrite(m_control_fd, buf, size, offs))
214a87e0831SAlan Somers 		<< strerror(errno);
215a87e0831SAlan Somers }
216a87e0831SAlan Somers 
217a87e0831SAlan Somers };
218a87e0831SAlan Somers 
219a87e0831SAlan Somers /*
220a87e0831SAlan Somers  * Extend a file with dirty data in the last page of the last block.
221a87e0831SAlan Somers  *
222a87e0831SAlan Somers  * fsx -WR -P /tmp -S8 -N3 fsx.bin
223a87e0831SAlan Somers  */
224a87e0831SAlan Somers TEST_F(Io, extend_from_dirty_page)
225a87e0831SAlan Somers {
226a87e0831SAlan Somers 	off_t wofs = 0x21a0;
227a87e0831SAlan Somers 	ssize_t wsize = 0xf0a8;
228a87e0831SAlan Somers 	off_t rofs = 0xb284;
229a87e0831SAlan Somers 	ssize_t rsize = 0x9b22;
230a87e0831SAlan Somers 	off_t truncsize = 0x28702;
231a87e0831SAlan Somers 
232a87e0831SAlan Somers 	do_write(wsize, wofs);
233a87e0831SAlan Somers 	do_ftruncate(truncsize);
234a87e0831SAlan Somers 	do_read(rsize, rofs);
235a87e0831SAlan Somers }
236a87e0831SAlan Somers 
237a87e0831SAlan Somers /*
238a87e0831SAlan Somers  * When writing the last page of a file, it must be written synchronously.
239a87e0831SAlan Somers  * Otherwise the cached page can become invalid by a subsequent extend
240a87e0831SAlan Somers  * operation.
241a87e0831SAlan Somers  *
242a87e0831SAlan Somers  * fsx -WR -P /tmp -S642 -N3 fsx.bin
243a87e0831SAlan Somers  */
244a87e0831SAlan Somers TEST_F(Io, last_page)
245a87e0831SAlan Somers {
246a87e0831SAlan Somers 	off_t wofs0 = 0x1134f;
247a87e0831SAlan Somers 	ssize_t wsize0 = 0xcc77;
248a87e0831SAlan Somers 	off_t wofs1 = 0x2096a;
249a87e0831SAlan Somers 	ssize_t wsize1 = 0xdfa7;
250a87e0831SAlan Somers 	off_t rofs = 0x1a3aa;
251a87e0831SAlan Somers 	ssize_t rsize = 0xb5b7;
252a87e0831SAlan Somers 
253a87e0831SAlan Somers 	do_write(wsize0, wofs0);
254a87e0831SAlan Somers 	do_write(wsize1, wofs1);
255a87e0831SAlan Somers 	do_read(rsize, rofs);
256a87e0831SAlan Somers }
257a87e0831SAlan Somers 
258a87e0831SAlan Somers /*
259a87e0831SAlan Somers  * Read a hole from a block that contains some cached data.
260a87e0831SAlan Somers  *
261a87e0831SAlan Somers  * fsx -WR -P /tmp -S55  fsx.bin
262a87e0831SAlan Somers  */
263a87e0831SAlan Somers TEST_F(Io, read_hole_from_cached_block)
264a87e0831SAlan Somers {
265a87e0831SAlan Somers 	off_t wofs = 0x160c5;
266a87e0831SAlan Somers 	ssize_t wsize = 0xa996;
267a87e0831SAlan Somers 	off_t rofs = 0x472e;
268a87e0831SAlan Somers 	ssize_t rsize = 0xd8d5;
269a87e0831SAlan Somers 
270a87e0831SAlan Somers 	do_write(wsize, wofs);
271a87e0831SAlan Somers 	do_read(rsize, rofs);
272a87e0831SAlan Somers }
273a87e0831SAlan Somers 
274a87e0831SAlan Somers /*
27593c0c1d4SAlan Somers  * Truncating a file into a dirty buffer should not causing anything untoward
27693c0c1d4SAlan Somers  * to happen when that buffer is eventually flushed.
277a87e0831SAlan Somers  *
278a87e0831SAlan Somers  * fsx -WR -P /tmp -S839 -d -N6 fsx.bin
279a87e0831SAlan Somers  */
28093c0c1d4SAlan Somers TEST_F(Io, truncate_into_dirty_buffer)
281a87e0831SAlan Somers {
282a87e0831SAlan Somers 	off_t wofs0 = 0x3bad7;
283a87e0831SAlan Somers 	ssize_t wsize0 = 0x4529;
284a87e0831SAlan Somers 	off_t wofs1 = 0xc30d;
285a87e0831SAlan Somers 	ssize_t wsize1 = 0x5f77;
286a87e0831SAlan Somers 	off_t truncsize0 = 0x10916;
287a87e0831SAlan Somers 	off_t rofs = 0xdf17;
288a87e0831SAlan Somers 	ssize_t rsize = 0x29ff;
289a87e0831SAlan Somers 	off_t truncsize1 = 0x152b4;
290a87e0831SAlan Somers 
291a87e0831SAlan Somers 	do_write(wsize0, wofs0);
292a87e0831SAlan Somers 	do_write(wsize1, wofs1);
293a87e0831SAlan Somers 	do_ftruncate(truncsize0);
294a87e0831SAlan Somers 	do_read(rsize, rofs);
295a87e0831SAlan Somers 	do_ftruncate(truncsize1);
296a87e0831SAlan Somers 	close(m_test_fd);
297a87e0831SAlan Somers }
29893c0c1d4SAlan Somers 
29993c0c1d4SAlan Somers /*
30093c0c1d4SAlan Somers  * Truncating a file into a dirty buffer should not causing anything untoward
30193c0c1d4SAlan Somers  * to happen when that buffer is eventually flushed, even when the buffer's
30293c0c1d4SAlan Somers  * dirty_off is > 0.
30393c0c1d4SAlan Somers  *
30493c0c1d4SAlan Somers  * Based on this command with a few steps removed:
30593c0c1d4SAlan Somers  * fsx -WR -P /tmp -S677 -d -N8 fsx.bin
30693c0c1d4SAlan Somers  */
30793c0c1d4SAlan Somers TEST_F(Io, truncate_into_dirty_buffer2)
30893c0c1d4SAlan Somers {
30993c0c1d4SAlan Somers 	off_t truncsize0 = 0x344f3;
31093c0c1d4SAlan Somers 	off_t wofs = 0x2790c;
31193c0c1d4SAlan Somers 	ssize_t wsize = 0xd86a;
31293c0c1d4SAlan Somers 	off_t truncsize1 = 0x2de38;
31393c0c1d4SAlan Somers 	off_t rofs2 = 0x1fd7a;
31493c0c1d4SAlan Somers 	ssize_t rsize2 = 0xc594;
31593c0c1d4SAlan Somers 	off_t truncsize2 = 0x31e71;
31693c0c1d4SAlan Somers 
31793c0c1d4SAlan Somers 	/* Sets the file size to something larger than the next write */
31893c0c1d4SAlan Somers 	do_ftruncate(truncsize0);
31993c0c1d4SAlan Somers 	/*
32093c0c1d4SAlan Somers 	 * Creates a dirty buffer.  The part in lbn 2 doesn't flush
32193c0c1d4SAlan Somers 	 * synchronously.
32293c0c1d4SAlan Somers 	 */
32393c0c1d4SAlan Somers 	do_write(wsize, wofs);
32493c0c1d4SAlan Somers 	/* Truncates part of the dirty buffer created in step 2 */
32593c0c1d4SAlan Somers 	do_ftruncate(truncsize1);
32693c0c1d4SAlan Somers 	/* XXX ?I don't know why this is necessary? */
32793c0c1d4SAlan Somers 	do_read(rsize2, rofs2);
32893c0c1d4SAlan Somers 	/* Truncates the dirty buffer */
32993c0c1d4SAlan Somers 	do_ftruncate(truncsize2);
33093c0c1d4SAlan Somers 	close(m_test_fd);
33193c0c1d4SAlan Somers }
332*dff3a6b4SAlan Somers 
333*dff3a6b4SAlan Somers /*
334*dff3a6b4SAlan Somers  * Regression test for a bug introduced in r348931
335*dff3a6b4SAlan Somers  *
336*dff3a6b4SAlan Somers  * Sequence of operations:
337*dff3a6b4SAlan Somers  * 1) The first write reads lbn so it can modify it
338*dff3a6b4SAlan Somers  * 2) The first write flushes lbn 3 immediately because it's the end of file
339*dff3a6b4SAlan Somers  * 3) The first write then flushes lbn 4 because it's the end of the file
340*dff3a6b4SAlan Somers  * 4) The second write modifies the cached versions of lbn 3 and 4
341*dff3a6b4SAlan Somers  * 5) The third write's getblkx invalidates lbn 4's B_CACHE because it's
342*dff3a6b4SAlan Somers  *    extending the buffer.  Then it flushes lbn 4 because B_DELWRI was set but
343*dff3a6b4SAlan Somers  *    B_CACHE was clear.
344*dff3a6b4SAlan Somers  * 6) fuse_write_biobackend erroneously called vfs_bio_clrbuf, putting the
345*dff3a6b4SAlan Somers  *    buffer into a weird write-only state.  All read operations would return
346*dff3a6b4SAlan Somers  *    0.  Writes were apparently still processed, because the buffer's contents
347*dff3a6b4SAlan Somers  *    were correct when examined in a core dump.
348*dff3a6b4SAlan Somers  * 7) The third write reads lbn 4 because cache is clear
349*dff3a6b4SAlan Somers  * 9) uiomove dutifully copies new data into the buffer
350*dff3a6b4SAlan Somers  * 10) The buffer's dirty is flushed to lbn 4
351*dff3a6b4SAlan Somers  * 11) The read returns all zeros because of step 6.
352*dff3a6b4SAlan Somers  *
353*dff3a6b4SAlan Somers  * Based on:
354*dff3a6b4SAlan Somers  * fsx -WR -l 524388 -o 131072 -P /tmp -S6456 -q  fsx.bin
355*dff3a6b4SAlan Somers  */
356*dff3a6b4SAlan Somers TEST_F(Io, resize_a_valid_buffer_while_extending)
357*dff3a6b4SAlan Somers {
358*dff3a6b4SAlan Somers 	do_write(0x14530, 0x36ee6);	/* [0x36ee6, 0x4b415] */
359*dff3a6b4SAlan Somers 	do_write(0x1507c, 0x33256);	/* [0x33256, 0x482d1] */
360*dff3a6b4SAlan Somers 	do_write(0x175c, 0x4c03d);	/* [0x4c03d, 0x4d798] */
361*dff3a6b4SAlan Somers 	do_read(0xe277, 0x3599c);	/* [0x3599c, 0x43c12] */
362*dff3a6b4SAlan Somers 	close(m_test_fd);
363*dff3a6b4SAlan Somers }
364