public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [BUG] fallocate behavior when crossing end-of-file
@ 2009-05-06 13:03 Raskin Michael
  2009-05-06 14:59 ` Edward Shishkin
  0 siblings, 1 reply; 6+ messages in thread
From: Raskin Michael @ 2009-05-06 13:03 UTC (permalink / raw)
  To: linux-btrfs

		Hello.
	I found the following bug in BtrFS:

	1. Create and open an empty file
	2. fallocate (fd, 0, 1)
	
Desired: something (probably, one block) is allocated/reserved for the
file. File length is set to 1 byte.

Actual: A block is allocated. File length is set to 1 block (4096
bytes). The rest of the file is filled with zeros.

	last_byte = min(extent_map_end(em), alloc_end);
	last_byte = (last_byte + mask) & ~mask;
	if (em->block_start == EXTENT_MAP_HOLE) {
		ret = prealloc_file_range(trans, inode, cur_offset,
				last_byte, locked_end + 1,
				alloc_hint, mode);

That part seems strange to me. You make an effort for block size to
divide last_byte. But last_byte should be
max(i_size_read(inode), offset+len)
- without any rounding.

Michael Raskin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-06 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-06 13:03 [BUG] fallocate behavior when crossing end-of-file Raskin Michael
2009-05-06 14:59 ` Edward Shishkin
2009-05-06 15:10   ` Chris Mason
2009-05-06 15:12   ` Michael Raskin
2009-05-06 15:36     ` Edward Shishkin
2009-05-06 21:07       ` Michael Raskin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox