From patchwork Fri May 21 17:03:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 101520 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4LH7iQd031408 for ; Fri, 21 May 2010 17:07:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934476Ab0EURG3 (ORCPT ); Fri, 21 May 2010 13:06:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50649 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934429Ab0EURGW (ORCPT ); Fri, 21 May 2010 13:06:22 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4LH5oBO030363 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 May 2010 13:05:50 -0400 Received: from localhost.localdomain (test1244.test.redhat.com [10.10.10.244]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4LH5luA001618; Fri, 21 May 2010 13:05:49 -0400 From: Josef Bacik To: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@infradead.org, akpm@linux-foundation.org Subject: [PATCH 3/6] direct-io: do not merge logically non-contiguous requests Date: Fri, 21 May 2010 13:03:39 -0400 Message-Id: <1274461422-18433-3-git-send-email-josef@redhat.com> In-Reply-To: <1274461422-18433-1-git-send-email-josef@redhat.com> References: <1274461422-18433-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 21 May 2010 17:07:44 +0000 (UTC) diff --git a/fs/direct-io.c b/fs/direct-io.c index 5949947..da111aa 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -632,10 +632,26 @@ static int dio_send_cur_page(struct dio *dio) int ret = 0; if (dio->bio) { + loff_t cur_offset = dio->block_in_file << dio->blkbits; + loff_t bio_next_offset = dio->logical_offset_in_bio + + dio->bio->bi_size; + /* - * See whether this new request is contiguous with the old + * See whether this new request is contiguous with the old. + * + * Btrfs cannot handl having logically non-contiguous requests + * submitted. For exmple if you have + * + * Logical: [0-4095][HOLE][8192-12287] + * Phyiscal: [0-4095] [4096-8181] + * + * We cannot submit those pages together as one BIO. So if our + * current logical offset in the file does not equal what would + * be the next logical offset in the bio, submit the bio we + * have. */ - if (dio->final_block_in_bio != dio->cur_page_block) + if (dio->final_block_in_bio != dio->cur_page_block || + cur_offset != bio_next_offset) dio_bio_submit(dio); /* * Submit now if the underlying fs is about to perform a