From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josef Bacik Subject: Re: ext3 writing of data before metadata in ordered mode Date: Mon, 26 Oct 2009 09:19:39 -0400 Message-ID: <20091026131939.GA20565@localhost.localdomain> References: <9ff7a3bc0910251433k2c719989n981e3652162cafdf@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, kernelnewbies To: Joel Fernandes Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46303 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754516AbZJZNTq (ORCPT ); Mon, 26 Oct 2009 09:19:46 -0400 Content-Disposition: inline In-Reply-To: <9ff7a3bc0910251433k2c719989n981e3652162cafdf@mail.gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, Oct 25, 2009 at 02:33:59PM -0700, Joel Fernandes wrote: > In data=ordered mode the ext3_ordered_commit_write function marks the > buffers as dirty, how then does the JBD ensure that the data is > written before the metadata? Once the data buffers are marked as > dirty, JBD doesn't have control anymore over when the data is written > is actually written to disk right? Because the actually writing of the > data is handled by the page wtriteback mechanism (pdflush) right? > > I might be missing something here, thanks for your time and patience. > ordered mode means we don't care when the data gets flushed out, just so long as it happens before we do metadata. So we mark the buffer as dirty, which is appropriate, so that if pdflush decides that it needs to start flushing dirty data it can. We also add the buffer to the transactions t_sync_datalist list so we know all of the data buffers that were modified in this transaction. So when we go to commit the transaction we go through this list writing out all of the dirty buffers on that list. If we hit a buffer that is not dirty we know its already been written out and we can move on to the next one. Then after all this is done we go through the list of metadata that was modified in that transaction, write out the journal entries, and then mark the metadata as dirty so it can be written out at some point in the future. Let me know if that makes sense. Thanks, Josef