From: "Lukáš Czerner" <lczerner@redhat.com>
To: Howard Chu <hyc@symas.com>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: truncate head of file?
Date: Wed, 20 Aug 2014 09:31:52 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1408200926110.2268@localhost.localdomain> (raw)
In-Reply-To: <53F447A8.8020804@symas.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2154 bytes --]
On Wed, 20 Aug 2014, Howard Chu wrote:
> Date: Wed, 20 Aug 2014 00:00:56 -0700
> From: Howard Chu <hyc@symas.com>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>
> Subject: Re: truncate head of file?
>
> Lukáš Czerner wrote:
> > On Tue, 19 Aug 2014, Howard Chu wrote:
> >
> > > Date: Tue, 19 Aug 2014 22:45:16 -0700
> > > From: Howard Chu <hyc@symas.com>
> > > To: linux-fsdevel <linux-fsdevel@vger.kernel.org>
> > > Subject: truncate head of file?
> > >
> > > Was thinking it would be very handy to have a truncate() variant that
> > > deletes
> > > pages from the head of a file. This could be leveraged to make logfiles
> > > easier
> > > to maintain, as an example. Anyone else interested, think this would be
> > > nice
> > > to have?
> > >
> > > (Note - not the same as just punching holes in the beginning of the file -
> > > we
> > > want the beginning of the file to advance as well, past the deleted
> > > pages.)
> >
> > I am not really sure I understand the behaviour you'd like to see.
> > Can you please explain the behaviour including more concrete use
> > case ?
>
> For example - we have a logfile (opened O_APPEND) that grows continuously. We
> want to delete some old log info from the head of the file. We could use "hole
> punching" to cause a specific range of data to be freed, but that just leaves
> a sparse file. If we were to cat this file the read() would have to advance
> thru all of that empty space before arriving at actual log data. We want both
> the data to be freed and for the logical beginning of the file to be moved
> forward, to match the location of where the remaining data begins.
>
> Freeing the space would be simplest if we just deallocate X pages from the
> file, and then the beginning of the file becomes the beginning of the first
> remaining page of the file.
Ok, now I understand. It is exactly what FALLOC_FL_COLLAPSE_RANGE is
for. It has been merged into mainline with commit v3.14-rc1-1-g00f5e61
However it will not work with O_APPEND nor does any other fallocate
flag except pure fallocate, so not even punch hole would have
worked.
-Lukas
next prev parent reply other threads:[~2014-08-20 7:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-20 5:45 truncate head of file? Howard Chu
2014-08-20 6:26 ` Randy Dunlap
2014-08-20 6:39 ` Lukáš Czerner
2014-08-20 7:00 ` Howard Chu
2014-08-20 7:31 ` Lukáš Czerner [this message]
2014-08-20 8:33 ` Howard Chu
2014-08-20 11:44 ` Ashish Sangwan
2014-08-20 22:02 ` Howard Chu
2014-08-21 18:17 ` Andreas Dilger
2014-08-21 18:59 ` Howard Chu
2014-08-22 23:22 ` Randy Dunlap
2014-08-29 5:06 ` Howard Chu
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=alpine.LFD.2.00.1408200926110.2268@localhost.localdomain \
--to=lczerner@redhat.com \
--cc=hyc@symas.com \
--cc=linux-fsdevel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).