From patchwork Tue Aug 10 09:29:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Bader X-Patchwork-Id: 61362 X-Patchwork-Delegate: stefan.bader@canonical.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id C58DAB7103 for ; Tue, 10 Aug 2010 19:29:39 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Oil9K-0005Su-A3; Tue, 10 Aug 2010 10:29:34 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.69) (envelope-from ) id 1Oil90-00059N-T0 for kernel-team@lists.ubuntu.com; Tue, 10 Aug 2010 10:29:15 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1Oil90-0001Di-RF; Tue, 10 Aug 2010 10:29:14 +0100 Received: from p5b2e54bf.dip.t-dialin.net ([91.46.84.191] helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1Oil90-00053W-Cm; Tue, 10 Aug 2010 10:29:14 +0100 From: Stefan Bader To: kernel-team@lists.ubuntu.com, stable@kernel.org Subject: [PATCH 12/16] writeback: fix pin_sb_for_writeback Date: Tue, 10 Aug 2010 11:29:00 +0200 Message-Id: <1281432544-20831-13-git-send-email-stefan.bader@canonical.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1281432544-20831-1-git-send-email-stefan.bader@canonical.com> References: <1281432544-20831-1-git-send-email-stefan.bader@canonical.com> Cc: axboe@kernel.dk X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Christoph Hellwig BugLink: http://bugs.launchpad.net/bugs/585092 commit 29cb48594b873f6193d6327097e504bd3e2314de upstream We need to check for s_instances to make sure we don't bother working against a filesystem that is beeing unmounted, and we need to call put_super to make sure a superblock is freed when we race against umount. Also no need to keep sb_lock after we got a reference on it. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Stefan Bader --- fs/fs-writeback.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 58a8de2..51372bc 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -522,19 +522,21 @@ select_queue: static bool pin_sb_for_writeback(struct super_block *sb) { spin_lock(&sb_lock); + if (list_empty(&sb->s_instances)) { + spin_unlock(&sb_lock); + return false; + } + sb->s_count++; + spin_unlock(&sb_lock); + if (down_read_trylock(&sb->s_umount)) { - if (sb->s_root) { - spin_unlock(&sb_lock); + if (sb->s_root) return true; - } - /* - * umounted, drop rwsem again and fall through to failure - */ up_read(&sb->s_umount); } - sb->s_count--; - spin_unlock(&sb_lock); + + put_super(sb); return false; }