From patchwork Thu Sep 13 15:01:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Monakhov X-Patchwork-Id: 183646 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 326542C0092 for ; Fri, 14 Sep 2012 01:01:34 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758097Ab2IMPBb (ORCPT ); Thu, 13 Sep 2012 11:01:31 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:51413 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758099Ab2IMPB3 (ORCPT ); Thu, 13 Sep 2012 11:01:29 -0400 Received: by mail-lb0-f174.google.com with SMTP id gj3so2024059lbb.19 for ; Thu, 13 Sep 2012 08:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=rlvvTI79g2V0z35uD4ogGBVqeuHrwIx7SpZr/MhzR+s=; b=T67Fi1zAKk5n7M4J/QbHSxhqs0+T7ObOyxFW4cd79Or3PdnYGykCVchzBzE7A6D1m7 B1nq3IPkfV3dSh1TADVWud6hYZz9wO23xe5BTxo7g7xcAS0xLizFmB2LdWP5weigfJNQ 8yQmx4aMjNa69La70BDr6IAiV8nQPFW0lSQuMHXHJD99SKhtzopZ1d7dJpL+iBcufO8d ZDQab5AXEOn3ZyVQGGClzrZrm4WEinnQX7+JgNIOpe9tg71T8VSVblQ7QqHtl1MFAX60 zZjQGrtoaqOou4MVkantmgM/izHOt9YQQNoJlDqU9dtwdTVNgh5NxNQZkXfVSyusRojO VNQQ== Received: by 10.112.101.194 with SMTP id fi2mr1014939lbb.104.1347548488374; Thu, 13 Sep 2012 08:01:28 -0700 (PDT) Received: from smtp.gmail.com (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id lx11sm23567767lab.4.2012.09.13.08.01.27 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Sep 2012 08:01:27 -0700 (PDT) From: Dmitry Monakhov To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, jack@suse.cz, wenqing.lz@taobao.com, Dmitry Monakhov Subject: [PATCH 6/9] ext4: endless truncate due to nonlocked dio readers V2 Date: Thu, 13 Sep 2012 19:01:11 +0400 Message-Id: <1347548474-31897-7-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1347548474-31897-1-git-send-email-dmonakhov@openvz.org> References: <1347548474-31897-1-git-send-email-dmonakhov@openvz.org> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org If we have enough aggressive DIO readers, truncate and other dio waiters will wait forever inside inode_dio_wait(). It is reasonable to disable nonlock DIO read optimization during truncate. Signed-off-by: Dmitry Monakhov --- fs/ext4/inode.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 658f649..a295b3a 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4333,9 +4333,13 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (attr->ia_valid & ATTR_SIZE) { if (attr->ia_size != inode->i_size) { truncate_setsize(inode, attr->ia_size); - /* Inode size will be reduced, wait for dio in flight */ - if (orphan) + /* Inode size will be reduced, wait for dio in flight. + * Temproraly disable unlocked DIO to prevent livelock */ + if (orphan) { + ext4_inode_block_unlocked_dio(inode); inode_dio_wait(inode); + ext4_inode_resume_unlocked_dio(inode); + } } ext4_truncate(inode); }