public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Mason <chris.mason@oracle.com>
To: Edward Shishkin <edward.shishkin@gmail.com>
Cc: Raskin Michael <raskin@mccme.ru>, linux-btrfs@vger.kernel.org
Subject: Re: [BUG] fallocate behavior when crossing end-of-file
Date: Wed, 06 May 2009 11:10:23 -0400	[thread overview]
Message-ID: <1241622623.17493.0.camel@localhost.localdomain> (raw)
In-Reply-To: <4A01A5DF.5050406@gmail.com>

On Wed, 2009-05-06 at 16:59 +0200, Edward Shishkin wrote:
> Raskin Michael wrote:
> > 		Hello.
> >   
> 
> 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.
> >   
>              
> Where is it documented?
> 
> IMHO we should only guarantee that writes
> to [0, 1] won't fail because of lack of disk space.
> Other things (including file size) are up to implementation.
> 

This one looks like a pretty simple bug in the fallocate call.  It is
rounding up the size to a block boundary.

-chris

> > 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
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> >   
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2009-05-06 15:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-05-06 15:12   ` Michael Raskin
2009-05-06 15:36     ` Edward Shishkin
2009-05-06 21:07       ` Michael Raskin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1241622623.17493.0.camel@localhost.localdomain \
    --to=chris.mason@oracle.com \
    --cc=edward.shishkin@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=raskin@mccme.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox