Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Tue, 17 Apr 2001 09:15:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Tue, 17 Apr 2001 09:15:32 -0400 Received: from nat-pool.corp.redhat.com ([199.183.24.200]:57143 "EHLO devserv.devel.redhat.com") by vger.kernel.org with ESMTP id ; Tue, 17 Apr 2001 09:15:20 -0400 Date: Tue, 17 Apr 2001 14:09:28 +0100 From: "Stephen C. Tweedie" To: Marcelo Tosatti Cc: Linus Torvalds , "Stephen C. Tweedie" , Alexander Viro , lkml Subject: Re: generic_osync_inode/ext2_fsync_inode still not safe Message-ID: <20010417140928.C2505@redhat.com> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from marcelo@conectiva.com.br on Sat, Apr 14, 2001 at 07:24:42AM -0300 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sat, Apr 14, 2001 at 07:24:42AM -0300, Marcelo Tosatti wrote: > > As described earlier, code which wants to write an inode cannot rely on > the I_DIRTY bits (on inode->i_state) being clean to guarantee that the > inode and its dirty pages, if any, are safely synced on disk. Indeed --- for all such structures, including pages, buffer_heads and inodes, you can only assume that the object is safely on disk if you have checked both the dirty bit AND the locked bit. If you find it locked but clean, then a writeout may be in progress, so you need to do a wait_on_* to be really sure that the write has completed. > The reason for that is sync_one() --- it cleans the I_DIRTY bits of an > inode, sets the I_LOCK and starts a writeout. As long as it is setting the I_LOCK bit, then that's fine. > The easy and safe fix is to simply remove the I_DIRTY_* checks from > generic_osync_inode and ext2_fsync_inode. Easy but slow. Another fix would > be to make sync_one() unconditionally synchronous... slow. Just make the *sync functions look for the locked bit and do a wait on the inode if it is locked. Cheers, Stephen - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/