From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-15?Q?Luk=E1=A8_Czerner?= Subject: Re: truncate head of file? Date: Wed, 20 Aug 2014 09:31:52 +0200 (CEST) Message-ID: References: <53F435EC.4030601@symas.com> <53F447A8.8020804@symas.com> Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1352426231-1408519915=:2268" Cc: linux-fsdevel To: Howard Chu Return-path: Received: from mx1.redhat.com ([209.132.183.28]:11758 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751721AbaHTHcD (ORCPT ); Wed, 20 Aug 2014 03:32:03 -0400 In-Reply-To: <53F447A8.8020804@symas.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1352426231-1408519915=:2268 Content-Type: TEXT/PLAIN; charset=windows-1252 Content-Transfer-Encoding: 8BIT On Wed, 20 Aug 2014, Howard Chu wrote: > Date: Wed, 20 Aug 2014 00:00:56 -0700 > From: Howard Chu > To: Lukáš Czerner > Cc: linux-fsdevel > 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 > > > To: linux-fsdevel > > > 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 --8323328-1352426231-1408519915=:2268--