Andreas Dilger wrote:
On Aug 20, 2014, at 1:00 AM, Howard Chu <hyc@xxxxxxxxx> 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/
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html