From mboxrd@z Thu Jan 1 00:00:00 1970 From: Howard Chu Subject: Re: truncate head of file? Date: Wed, 20 Aug 2014 00:00:56 -0700 Message-ID: <53F447A8.8020804@symas.com> References: <53F435EC.4030601@symas.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-fsdevel To: =?windows-1252?Q?Luk=E1=9A_Czerner?= Return-path: Received: from zill.ext.symas.net ([69.43.206.106]:54518 "EHLO zill.ext.symas.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbaHTHA7 (ORCPT ); Wed, 20 Aug 2014 03:00:59 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Luk=E1=9A 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 tha= t deletes >> pages from the head of a file. This could be leveraged to make logfi= les 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 ? =46or example - we have a logfile (opened O_APPEND) that grows continuo= usly. We=20 want to delete some old log info from the head of the file. We could us= e "hole=20 punching" to cause a specific range of data to be freed, but that just = leaves=20 a sparse file. If we were to cat this file the read() would have to adv= ance=20 thru all of that empty space before arriving at actual log data. We wan= t both=20 the data to be freed and for the logical beginning of the file to be mo= ved=20 forward, to match the location of where the remaining data begins. =46reeing the space would be simplest if we just deallocate X pages fro= m the=20 file, and then the beginning of the file becomes the beginning of the f= irst=20 remaining page of the file. --=20 -- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html