From: Howard Chu <hyc@symas.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: "Lukáš Czerner" <lczerner@redhat.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: truncate head of file?
Date: Thu, 21 Aug 2014 11:59:50 -0700 [thread overview]
Message-ID: <53F641A6.90100@symas.com> (raw)
In-Reply-To: <CDD37D55-4442-446D-832A-E959795A7F3F@dilger.ca>
Andreas Dilger wrote:
>
> On Aug 20, 2014, at 1:00 AM, Howard Chu <hyc@symas.com> wrote:
>> 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.
>
> It would also be possible to use fallocate(FALLOC_FL_PUNCH_HOLE)
> to punch out the processed records, and seek(SEEK_DATA) to find
> the first record that has not been processed. That would avoid
> problems with the file size changing and O_APPEND.
That would be OK, except that we want the file size to decrease. Otherwise the
logical size grows without bound and eventually we'd have to recreate the file
anyway.
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/
next prev parent reply other threads:[~2014-08-21 18:59 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
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 [this message]
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=53F641A6.90100@symas.com \
--to=hyc@symas.com \
--cc=adilger@dilger.ca \
--cc=lczerner@redhat.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).