From patchwork Sat Aug 13 16:02:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tao Ma X-Patchwork-Id: 109941 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 181CFB6F67 for ; Sun, 14 Aug 2011 02:09:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751083Ab1HMQJZ (ORCPT ); Sat, 13 Aug 2011 12:09:25 -0400 Received: from oproxy1-pub.bluehost.com ([66.147.249.253]:46189 "HELO oproxy1-pub.bluehost.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750956Ab1HMQJY (ORCPT ); Sat, 13 Aug 2011 12:09:24 -0400 Received: (qmail 15057 invoked by uid 0); 13 Aug 2011 16:09:24 -0000 Received: from unknown (HELO box585.bluehost.com) (66.147.242.185) by oproxy1.bluehost.com with SMTP; 13 Aug 2011 16:09:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tao.ma; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=BnY0F+A2ldXo4UmbTf3hYG7qIH+lMfo6sH3eMjJc+AY=; b=fwuy977hzW3tyBDaDKy7ylfcgGnOW2fTZs3lLVkjztBzHco/6+xi7TjY/9oW5Z390G6Vh1qYCxJeKdxNctg4+qGMklG7L5cX8dwwt2oIgAKg0LDz/zAQeP2Wp7k8f19S; Received: from [114.245.227.234] (helo=localhost.localdomain) by box585.bluehost.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1QsGm2-0007JI-9O; Sat, 13 Aug 2011 10:09:24 -0600 From: Tao Ma To: linux-ext4@vger.kernel.org Cc: mjt@tls.msk.ru, sandeen@redhat.com Subject: Re: DIO process stuck apparently due to dioread_nolock (3.0) Date: Sun, 14 Aug 2011 00:02:51 +0800 Message-Id: <1313251371-3672-1-git-send-email-tm@tao.ma> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <4E456436.8070107@msgid.tls.msk.ru> References: <4E456436.8070107@msgid.tls.msk.ru> X-Identified-User: {1390:box585.bluehost.com:colyli:tao.ma} {sentby:smtp auth 114.245.227.234 authed with tm@tao.ma} Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Tao Ma Hi Michael, could you please check whether this patch work for you? Subject: [PATCH] ext4: Set unwritten flag and increase i_aiodio_unwritten simultaneously. From 4f1d797973da8b5cf79f58cc1e4d22efb9d46d19 Mon Sep 17 00:00:00 2001 From: Tao Ma Date: Sat, 13 Aug 2011 23:50:28 +0800 Subject: [PATCH] ext4: Set unwritten flag and increase i_aiodio_unwritten simultaneously. EXT4_IO_END_UNWRITTEN flag set and the increase of i_aiodio_unwritten should be done simultaneously since ext4_end_io_nolock always clear the flag and decrease the counter in the same time. We don't increase i_aiodio_unwritten when setting EXT4_IO_END_UNWRITTEN so it will go nagative and causes some process to wait forever. Part of the patch came from Eric in his e-mail. http://marc.info/?l=linux-ext4&m=131316851417460&w=2 Reported-by: Michael Tokarev Signed-off-by: Eric Sandeen Signed-off-by: Tao Ma --- fs/ext4/inode.c | 9 ++++++++- fs/ext4/page-io.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index d47264c..40c0b10 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2668,8 +2668,15 @@ static void ext4_end_io_buffer_write(struct buffer_head *bh, int uptodate) goto out; } - io_end->flag = EXT4_IO_END_UNWRITTEN; + /* + * It may be over-defensive here to check EXT4_IO_END_UNWRITTEN now, + * but being more careful is always safe for the future change. + */ inode = io_end->inode; + if (!(io_end->flag & EXT4_IO_END_UNWRITTEN)) { + io_end->flag |= EXT4_IO_END_UNWRITTEN; + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); + } /* Add the io_end to per-inode completed io list*/ spin_lock_irqsave(&EXT4_I(inode)->i_completed_io_lock, flags); diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 430c401..78839af 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -334,8 +334,10 @@ submit_and_retry: if ((io_end->num_io_pages >= MAX_IO_PAGES) && (io_end->pages[io_end->num_io_pages-1] != io_page)) goto submit_and_retry; - if (buffer_uninit(bh)) - io->io_end->flag |= EXT4_IO_END_UNWRITTEN; + if (buffer_uninit(bh) && !(io_end->flag & EXT4_IO_END_UNWRITTEN)) { + io_end->flag |= EXT4_IO_END_UNWRITTEN; + atomic_inc(&EXT4_I(inode)->i_aiodio_unwritten); + } io->io_end->size += bh->b_size; io->io_next_block++; ret = bio_add_page(io->io_bio, bh->b_page, bh->b_size, bh_offset(bh));