From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Mason Subject: [PATCH] Properly init address_space->writeback_index Date: Thu, 14 Aug 2008 14:13:40 -0400 Message-ID: <1218737620.15342.386.camel@think.oraclecorp.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit To: linux-fsdevel , Andrew Morton Return-path: Received: from rgminet01.oracle.com ([148.87.113.118]:24269 "EHLO rgminet01.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752105AbYHNSOj (ORCPT ); Thu, 14 Aug 2008 14:14:39 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: write_cache_pages uses i_mapping->writeback_index to pick up where it left off the last time a given inode was found by pdflush or balance_dirty_pages (or anyone else who sets wbc->range_cyclic) alloc_inode should set it to a sane value so that writeback doesn't start in the middle of a file. It is somewhat difficult to notice the bug since write_cache_pages will loop around to the start of the file and the elevator helps hide the resulting seeks. For whatever reason, Btrfs hits this often. Unpatched, untarring 30 copies of the linux kernel in series runs at 47MB/s on a single sata drive. With this fix, it jumps to 62MB/s. Signed-off-by: Chris Mason diff -r 67160ae21a58 fs/inode.c --- a/fs/inode.c Wed Aug 06 19:26:20 2008 -0700 +++ b/fs/inode.c Thu Aug 14 10:15:49 2008 -0400 @@ -166,6 +166,7 @@ static struct inode *alloc_inode(struct mapping_set_gfp_mask(mapping, GFP_HIGHUSER_PAGECACHE); mapping->assoc_mapping = NULL; mapping->backing_dev_info = &default_backing_dev_info; + mapping->writeback_index = 0; /* * If the block_device provides a backing_dev_info for client