From patchwork Fri Jun 24 19:50:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Peterson X-Patchwork-Id: 9198115 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AF19A6075F for ; Fri, 24 Jun 2016 19:51:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DD9C284D1 for ; Fri, 24 Jun 2016 19:51:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92D7A284D3; Fri, 24 Jun 2016 19:51:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4131F284D1 for ; Fri, 24 Jun 2016 19:51:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751700AbcFXTvD (ORCPT ); Fri, 24 Jun 2016 15:51:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46086 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbcFXTuO (ORCPT ); Fri, 24 Jun 2016 15:50:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2790980088; Fri, 24 Jun 2016 19:50:14 +0000 (UTC) Received: from loki.redhat.com (ovpn-116-105.phx2.redhat.com [10.3.116.105]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5OJoBQ3008063; Fri, 24 Jun 2016 15:50:13 -0400 From: Bob Peterson To: cluster-devel@redhat.com, , Dave Chinner Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH 2/2] GFS2: Add a gfs2-specific prune_icache_sb Date: Fri, 24 Jun 2016 14:50:11 -0500 Message-Id: <1466797811-5873-3-git-send-email-rpeterso@redhat.com> In-Reply-To: <1466797811-5873-1-git-send-email-rpeterso@redhat.com> References: <1466797811-5873-1-git-send-email-rpeterso@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 24 Jun 2016 19:50:14 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a new prune_icache_sb function for the VFS slab shrinker to call. Trying to directly free the inodes from memory might deadlock because it evicts inodes, which calls into DLM to acquire the glock. The DLM, in turn, may block on a pending fence operation, which may already be blocked on memory allocation that caused the slab shrinker to be called in the first place. Signed-off-by: Bob Peterson --- fs/gfs2/incore.h | 2 ++ fs/gfs2/ops_fstype.c | 1 + fs/gfs2/quota.c | 25 +++++++++++++++++++++++++ fs/gfs2/super.c | 13 +++++++++++++ 4 files changed, 41 insertions(+) diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index a6a3389..a367459 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h @@ -757,6 +757,8 @@ struct gfs2_sbd { struct task_struct *sd_logd_process; struct task_struct *sd_quotad_process; + int sd_iprune; /* inodes to prune */ + spinlock_t sd_shrinkspin; /* Quota stuff */ diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 4546360..65a69be 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -95,6 +95,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) spin_lock_init(&sdp->sd_jindex_spin); mutex_init(&sdp->sd_jindex_mutex); init_completion(&sdp->sd_journal_ready); + spin_lock_init(&sdp->sd_shrinkspin); INIT_LIST_HEAD(&sdp->sd_quota_list); mutex_init(&sdp->sd_quota_mutex); diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index ce7d69a..5810a2c 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -1528,14 +1528,39 @@ void gfs2_wake_up_statfs(struct gfs2_sbd *sdp) { int gfs2_quotad(void *data) { struct gfs2_sbd *sdp = data; + struct super_block *sb = sdp->sd_vfs; struct gfs2_tune *tune = &sdp->sd_tune; unsigned long statfs_timeo = 0; unsigned long quotad_timeo = 0; unsigned long t = 0; DEFINE_WAIT(wait); int empty; + int rc; + struct shrink_control sc = {.gfp_mask = GFP_KERNEL, }; while (!kthread_should_stop()) { + /* TODO: Deal with shrinking of dcache */ + /* Prune any inode cache intended by the shrinker. */ + spin_lock(&sdp->sd_shrinkspin); + if (sdp->sd_iprune > 0) { + sc.nr_to_scan = sdp->sd_iprune; + if (sc.nr_to_scan > 1024) + sc.nr_to_scan = 1024; + sdp->sd_iprune -= sc.nr_to_scan; + spin_unlock(&sdp->sd_shrinkspin); + rc = prune_icache_sb(sb, &sc); + if (rc < 0) { + spin_lock(&sdp->sd_shrinkspin); + sdp->sd_iprune = 0; + spin_unlock(&sdp->sd_shrinkspin); + } + if (sdp->sd_iprune) { + cond_resched(); + continue; + } + } else { + spin_unlock(&sdp->sd_shrinkspin); + } /* Update the master statfs file */ if (sdp->sd_statfs_force_sync) { diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 9b2ff353..75e8a85 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1667,6 +1667,18 @@ static void gfs2_destroy_inode(struct inode *inode) call_rcu(&inode->i_rcu, gfs2_i_callback); } +static long gfs2_prune_icache_sb(struct super_block *sb, + struct shrink_control *sc) +{ + struct gfs2_sbd *sdp; + + sdp = sb->s_fs_info; + spin_lock(&sdp->sd_shrinkspin); + sdp->sd_iprune = sc->nr_to_scan + 1; + spin_unlock(&sdp->sd_shrinkspin); + return 0; +} + const struct super_operations gfs2_super_ops = { .alloc_inode = gfs2_alloc_inode, .destroy_inode = gfs2_destroy_inode, @@ -1681,5 +1693,6 @@ const struct super_operations gfs2_super_ops = { .remount_fs = gfs2_remount_fs, .drop_inode = gfs2_drop_inode, .show_options = gfs2_show_options, + .prune_icache_sb = gfs2_prune_icache_sb, };