From patchwork Mon Feb 1 14:51:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 8180221 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6E475BEEE5 for ; Mon, 1 Feb 2016 14:52:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F7C320434 for ; Mon, 1 Feb 2016 14:52:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27CED203C2 for ; Mon, 1 Feb 2016 14:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933111AbcBAOwW (ORCPT ); Mon, 1 Feb 2016 09:52:22 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:36899 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933131AbcBAOwU (ORCPT ); Mon, 1 Feb 2016 09:52:20 -0500 Received: by mail-wm0-f41.google.com with SMTP id l66so74991996wml.0 for ; Mon, 01 Feb 2016 06:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QtD3cR/TVNHmTVaXHzcOsGCpjv15Rr7teEEqxMUKskQ=; b=g4/NIzGVw9Q9k7EC5CjW0gwC8uDTxOO1N5EqGGdBuZx08ntyyLnIQTyBdkUqeGqo8G 3gQ/2UP8oqa6b5a0txJ+kVeKhiqgympZAaTFnpNI3rWNZz9fFlzpVYHabzbdOEnvopfc Dcz0BEgrK9l5QYN+Of2rxL0asG/rn9bmD4vvzRH6wq0oZ7NMymS3B3Ao3NiGl+UzdBRe Jqw9ZOpdOHvODZbPLgKuiJXBRvMYuc6d/msVLIfQKva11Mm36qoSOEj9x6n+TYFkLwff lkXePCxX3wq8i6DGELvPoHJEuBaOZNhRpW4+5WOoyCs5xs/FtauO1wRrRX/jjfAmph7H 2Cog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QtD3cR/TVNHmTVaXHzcOsGCpjv15Rr7teEEqxMUKskQ=; b=k8015DA8NdWdNgZUCgotd6YtydDfEXBX63KLA1eps8DHRsYEtO654MhNxf2GTt8vMY 6F6HWVuMU9mOSl0hheNlG8PjBVPBRV5pJLkKfpJtxFHGvXLSytXO+C/ymoXcLbEW1KKH 7kygpVzF6x61I0wFeFgdZO4CcKg/sRs/Ldy2pOJp/HKidW1brIPH6zt2gW5kJdEt/tJp AH3/rqgA2yL9Pb6kuSMmrUVJ1nua0+FXwV+pkrQOsC6RNmqdSM55ACJtzLo7sEB43rmP fM8WD/Sougop4GgEAPtXWUPlbA7cJJFy75EUJQCK0jl650zQXUJMswoIUB3RXR4Cy6ld 5kVQ== X-Gm-Message-State: AG10YOQFQxAF1BgGiR5m2biYnglqcOAQ9u5m7bMz4caAKVhU7fdaxooe94rfFV6PtN0JvCcL X-Received: by 10.28.156.73 with SMTP id f70mr5451611wme.52.1454338339231; Mon, 01 Feb 2016 06:52:19 -0800 (PST) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id g3sm29496312wjw.31.2016.02.01.06.52.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 06:52:18 -0800 (PST) From: Roman Pen Cc: Roman Pen , Gi-Oh Kim , Tejun Heo , Jens Axboe , Alexander Viro , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 3/4] block,fs: switch to a new put_gendisk() call Date: Mon, 1 Feb 2016 15:51:54 +0100 Message-Id: <1454338315-13465-4-git-send-email-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1454338315-13465-1-git-send-email-roman.penyaev@profitbricks.com> References: <1454338315-13465-1-git-send-email-roman.penyaev@profitbricks.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In previous patch a new put_gendisk() call was introduced, which puts the disk and the disk owner module references. This new call should help not to forget about required module_put() after receiving a disk pointer using get_disk() or get_gendisk() calls. In this patch disk_put(),module_put() sequences are replaced with a single put_gendisk() call. Signed-off-by: Roman Pen Cc: Gi-Oh Kim Cc: Tejun Heo Cc: Jens Axboe Cc: Alexander Viro Cc: linux-block@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org --- block/blk-cgroup.c | 15 +++------------ fs/block_dev.c | 24 +++++++----------------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 66e6f1a..2ed9636 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -788,7 +788,6 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, { struct gendisk *disk; struct blkcg_gq *blkg; - struct module *owner; unsigned int major, minor; int key_len, part, ret; char *body; @@ -805,9 +804,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, if (!disk) return -ENODEV; if (part) { - owner = disk->fops->owner; - put_disk(disk); - module_put(owner); + put_gendisk(disk); return -ENODEV; } @@ -823,9 +820,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, ret = PTR_ERR(blkg); rcu_read_unlock(); spin_unlock_irq(disk->queue->queue_lock); - owner = disk->fops->owner; - put_disk(disk); - module_put(owner); + put_gendisk(disk); /* * If queue was bypassing, we should retry. Do so after a * short msleep(). It isn't strictly necessary but queue @@ -856,13 +851,9 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep); void blkg_conf_finish(struct blkg_conf_ctx *ctx) __releases(ctx->disk->queue->queue_lock) __releases(rcu) { - struct module *owner; - spin_unlock_irq(ctx->disk->queue->queue_lock); rcu_read_unlock(); - owner = ctx->disk->fops->owner; - put_disk(ctx->disk); - module_put(owner); + put_gendisk(ctx->disk); } EXPORT_SYMBOL_GPL(blkg_conf_finish); diff --git a/fs/block_dev.c b/fs/block_dev.c index 7b9cd49..dc2ea76 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -870,8 +869,7 @@ static struct block_device *bd_start_claiming(struct block_device *bdev, else whole = bdgrab(bdev); - module_put(disk->fops->owner); - put_disk(disk); + put_gendisk(disk); if (!whole) return ERR_PTR(-ENOMEM); @@ -1167,7 +1165,6 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part); static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) { struct gendisk *disk; - struct module *owner; int ret; int partno; int perm = 0; @@ -1193,7 +1190,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) disk = get_gendisk(bdev->bd_dev, &partno); if (!disk) goto out; - owner = disk->fops->owner; disk_block_events(disk); mutex_lock_nested(&bdev->bd_mutex, for_part); @@ -1222,8 +1218,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) bdev->bd_queue = NULL; mutex_unlock(&bdev->bd_mutex); disk_unblock_events(disk); - put_disk(disk); - module_put(owner); + put_gendisk(disk); goto restart; } } @@ -1285,9 +1280,8 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) if (ret) goto out_unlock_bdev; } - /* only one opener holds refs to the module and disk */ - put_disk(disk); - module_put(owner); + /* only one opener holds refs to the disk */ + put_gendisk(disk); } bdev->bd_openers++; if (for_part) @@ -1307,8 +1301,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) out_unlock_bdev: mutex_unlock(&bdev->bd_mutex); disk_unblock_events(disk); - put_disk(disk); - module_put(owner); + put_gendisk(disk); out: bdput(bdev); @@ -1525,7 +1518,7 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) /* * Detaching bdev inode from its wb in __destroy_inode() * is too late: the queue which embeds its bdi (along with - * root wb) can be gone as soon as we put_disk() below. + * root wb) can be gone as soon as we put_gendisk() below. */ inode_detach_wb(bdev->bd_inode); } @@ -1534,8 +1527,6 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) disk->fops->release(disk, mode); } if (!bdev->bd_openers) { - struct module *owner = disk->fops->owner; - disk_put_part(bdev->bd_part); bdev->bd_part = NULL; bdev->bd_disk = NULL; @@ -1543,8 +1534,7 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) victim = bdev->bd_contains; bdev->bd_contains = NULL; - put_disk(disk); - module_put(owner); + put_gendisk(disk); } mutex_unlock(&bdev->bd_mutex); bdput(bdev);