public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Smit Shah <getsmit@gmail.com>
Cc: linux-xfs@oss.sgi.com
Subject: Re: XFS Preallocate using ALLOCSP
Date: Tue, 16 Jun 2009 10:16:20 -0500	[thread overview]
Message-ID: <4A37B744.9030301@sandeen.net> (raw)
In-Reply-To: <8770d98c0906152344p185533a9rc144a5667d13d2de@mail.gmail.com>

Smit Shah wrote:

> Even the man page of fallocate says that it allocates and initializes
> to zero the disk space allocated

Bleah, so it does:

       FALLOC_FL_KEEP_SIZE
              This flag allocates and initializes to zero the disk space

well, that's misleading and/or wrong.

> but when i saw the code i did found out that it does not zero it out.
> Hence was a kindof confused. So posix_allocate is similar to ALLOCSP
> when falloc is not supported by the underlying filesystem  that is to
> ftruncate the file  and zero it out. So all of them try to allocate
> contiguous blocks but the only difference is when we use the
> fallocate in ext4/xfs it does not zero out the preallocated space. Am
> i right ?

fallocate / sys_fallocate marks the region as uninitialized so that you
get back 0s when you read.  It's implemented on xfs, ext4, ocfs2, and btrfs.

posix_fallocate manages to reach sys_fallocate when all the stars align:
kernel,  glibc, and filesystgem.  Otherwise it writes 0s.

> But  when i fallocate in ext4 i can see the write performance 
> improvement but not in xfs

Testing how?

> and reason i found out in one of your previous comments is  because
> of the unwritten flag set in xfs. So how do we see if the unwritten
> flag is set or not ? I did use xfs_info but it didnt show any such
> information.

ext4 & xfs are doing the same basic thing, they must maintain the
unwritten state on the preallocated extents, and manage that as it
changes when portions are written with real data.

xfs_bmap -v -v -p on a file will show you extent state for xfs.

> I guess i am not right here ftruncate simply does a lseek and wirtes

ftruncate simply sets i_size, it does no data IO.

> to it which might not be contiguous whereas fallocate tries to
> allocate contiguous block so as to reduce fragmentation

Actually fallocate's only official job is to reserve blocks so you don't
get ENOSPC later.  Because the request comes in all at once, you are
very likely to get an optimal allocation, and that's a nice side effect,
but it's not actually required by the interface.

> and hence i
> thought to reduce fragmentation and for security reasons 

None of these normal interfaces poses any security risk.  If you build
xfs without the unwritten extent feature you could allocate w/o flagging
uninitialized and expose stale data, but that's not a normal mode of
operation.

> its better
> to use ALLOCSP rather than something like ftruncate /posix_fallocate
> or RSEVSP which kindof performs bad for writes with unwritten flag
> set and now there being a no direct way while creating the fs to
> disable unwritten.

In the end, there are only 2 ways to preallocate blocks: explicitly
write 0s, or flag regions as unwritten (as xfs/ext4/... can do).  (Ok,
or a 3rd sorta-way, which is to reserve w/o flagging, maybe that's what
you're looking for, but that's deprecated or not really available at
this point).

Maybe I should ask what the end goal is here.  :)

-Eric

> Thanks, Smit

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2009-06-16 15:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16  0:18 XFS Preallocate using ALLOCSP Smit Shah
2009-06-16  2:00 ` Smit Shah
2009-06-16  3:34 ` Eric Sandeen
2009-06-16  6:44   ` Smit Shah
2009-06-16  7:34     ` Smit Shah
2009-06-16 15:16     ` Eric Sandeen [this message]
2009-06-16 16:42       ` Felix Blyakher
2009-06-16 17:28         ` Smit Shah
2009-06-16 17:32           ` Eric Sandeen
2009-06-16 21:38             ` Smit Shah
2009-06-17  1:04               ` Michael Monnerie
2009-06-16 17:41           ` Felix Blyakher
2009-06-16 21:42             ` Smit Shah
2009-06-16 22:05               ` Eric Sandeen
2009-06-16 22:32                 ` Felix Blyakher
2009-06-16 22:19               ` Smit Shah
2009-06-16 22:26               ` Felix Blyakher

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=4A37B744.9030301@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=getsmit@gmail.com \
    --cc=linux-xfs@oss.sgi.com \
    /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