From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Moyer Subject: Re: [PATCH 1/2] fs: truncate blocks outside i_size after generic_file_direct_write error Date: Mon, 20 Oct 2008 08:47:22 -0400 Message-ID: References: <1224424981-5144-1-git-send-email-dmonakhov@openvz.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Dmitri Monakhov Return-path: In-Reply-To: <1224424981-5144-1-git-send-email-dmonakhov@openvz.org> (Dmitri Monakhov's message of "Sun, 19 Oct 2008 18:03:00 +0400") Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Dmitri Monakhov writes: > We need to remove block that was allocated in generic_file_direct_write() > if we fail. We have to do it *regardless* to blocksize. At least ext2, > ext3 and reiserfs interpret (i_size < biggest block) condition as error. > Fsck will complain about wrong i_size. Then fsck will fix the error > by changing i_size according to the biggest block. This is bad because > this blocks contain gurbage from previous write attempt. And result in > data corruption. > > In order to call vmtruncate() we have to hold host->i_mutex. This is true > for generic_file_aio_write(). In fact occasionally it is also true for all > generic_file_aio_write_nolock() callers except blockdev. But this situation > may change someday. This patch fix only generic_write_aio_write() case. > BTW: update generic_file_direct_write's comment with currently outdated. Do you have a test case for this, by any chance? Cheers, Jeff