xfs
[Top] [All Lists]

Re: Review: fix truncate vs null files issues

To: David Chinner <dgc@xxxxxxx>
Subject: Re: Review: fix truncate vs null files issues
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Wed, 11 Jul 2007 09:57:21 +0100
Cc: xfs-dev <xfs-dev@xxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
In-reply-to: <20070709073826.GO31489@xxxxxxx>
References: <20070709073826.GO31489@xxxxxxx>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.2.3i
On Mon, Jul 09, 2007 at 05:38:26PM +1000, David Chinner wrote:
> 
> When we change the file size via xfs_setattr(), we log the
> new, in-memory file size in the transaction. We do this without
> having flushed any dirty data so if we have previously extended
> the file we change the on disk file size without having written
> the data first.
> 
> This is a problem for both growing the file and truncating the
> file. The truncate case is partially hidden by the VTRUNCATE
> code, but if the file has not been closed before a crash has
> occurred we can still get NULLs appearing in files. 
> 
> The following patch fixes this problem by flushing the range
> between the on-disk filesize and the new file size as long
> as the new file size is larger than the on disk file size.
> 
> Comments?

Looks good.

> +                 (ip->i_size != ip->i_d.di_size) &&
> +                 (vap->va_size > ip->i_d.di_size)) {

And if I'd really want to get picky I'd say please remove all the superflous
braces here..


<Prev in Thread] Current Thread [Next in Thread>