From patchwork Wed Apr 12 10:24:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9676959 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 A92E060325 for ; Wed, 12 Apr 2017 10:25:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7FD285D6 for ; Wed, 12 Apr 2017 10:25:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F950285E8; Wed, 12 Apr 2017 10:25:12 +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 54449285D6 for ; Wed, 12 Apr 2017 10:25:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbdDLKZJ (ORCPT ); Wed, 12 Apr 2017 06:25:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:40150 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751997AbdDLKZE (ORCPT ); Wed, 12 Apr 2017 06:25:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 128E6AEAD; Wed, 12 Apr 2017 10:25:03 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id A19041E313F; Wed, 12 Apr 2017 12:25:02 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , , Jan Kara Subject: [PATCH 02/25] block: Unregister bdi on last reference drop Date: Wed, 12 Apr 2017 12:24:26 +0200 Message-Id: <20170412102449.16901-3-jack@suse.cz> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170412102449.16901-1-jack@suse.cz> References: <20170412102449.16901-1-jack@suse.cz> 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 Most users will want to unregister bdi when dropping last reference to a bdi. Only a few users (like block devices) want to play more complex tricks with bdi registration and unregistration. So unregister bdi when the last reference to bdi is dropped and just make sure we don't unregister the bdi the second time if it is already unregistered. Reviewed-by: Christoph Hellwig Signed-off-by: Jan Kara --- mm/backing-dev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/backing-dev.c b/mm/backing-dev.c index e5e0972bdd6f..164ccc93690f 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -961,6 +961,8 @@ static void release_bdi(struct kref *ref) struct backing_dev_info *bdi = container_of(ref, struct backing_dev_info, refcnt); + if (test_bit(WB_registered, &bdi->wb.state)) + bdi_unregister(bdi); bdi_exit(bdi); kfree(bdi); }