From: Eric Dumazet <dada1@cosmosbay.com>
To: Shuduo Sang <sangshuduo@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>,
Lars Noschinski <lklml@ml.noschinski.de>,
linux-kernel@vger.kernel.org
Subject: Re: How does ext2 implement sparse files?
Date: Fri, 01 Feb 2008 12:08:10 +0100 [thread overview]
Message-ID: <47A2FD9A.8020809@cosmosbay.com> (raw)
In-Reply-To: <ee101c360802010234m4a7199e7g4cc9131484529b1c@mail.gmail.com>
Shuduo Sang a écrit :
> On Feb 1, 2008 2:14 AM, Andi Kleen <andi@firstfloor.org> wrote:
>
>> Lars Noschinski <lklml@ml.noschinski.de> writes:
>>
>>
>>> For an university project, we had to write a toy filesystem (ext2-like),
>>> for which I would like to implement sparse file support. For this, I
>>> digged through the ext2 source code; but I could not find the point,
>>> where ext2 detects holes.
>>>
>>> As far as I can see from fs/buffer.c, an hole is a buffer_head which is
>>> not mapped, but uptodate. But I cannot find a relevant source line,
>>> where ext2 makes usage of this information.
>>>
>> It does not explicitely detect holes; holey data is just never written
>> so no space for it is allocated.
>>
>>
>
> does anybody know how to make a hole in a large file which already has
> real content from user space application?
> In my project I need this function to delete a piece of content from
> an exist large effectively.
> thanks.
>
>
Some OSes use fcntl() F_FREESP/F_FREESP64 to be able to free allocated
space in files (ie make holes if supported by underlying fs)
AFAIK, linux can generically do this only at the end of a file
(ftruncate()) , not at random points.
XFS has special support for FREESP (it comes from IRIX), implemented as
an ioctl()
Check for XFS_IOC_FREESP and XFS_IOC_UNRESVSP in fs/xfs/xfs_fs.h
next prev parent reply other threads:[~2008-02-01 11:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-31 15:28 How does ext2 implement sparse files? Lars Noschinski
2008-01-31 16:51 ` Lennart Sorensen
2008-01-31 17:18 ` Chris Snook
2008-01-31 18:14 ` Andi Kleen
2008-02-01 10:34 ` Shuduo Sang
2008-02-01 11:08 ` Eric Dumazet [this message]
2008-02-01 11:55 ` Lars Noschinski
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=47A2FD9A.8020809@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lklml@ml.noschinski.de \
--cc=sangshuduo@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.