From patchwork Fri Nov 20 21:18:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 7671341 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CC8079F392 for ; Fri, 20 Nov 2015 21:18:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECE28203FB for ; Fri, 20 Nov 2015 21:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11755203F7 for ; Fri, 20 Nov 2015 21:18:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760032AbbKTVSz (ORCPT ); Fri, 20 Nov 2015 16:18:55 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:35850 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755238AbbKTVSy (ORCPT ); Fri, 20 Nov 2015 16:18:54 -0500 Received: by wmww144 with SMTP id w144so34307604wmw.1 for ; Fri, 20 Nov 2015 13:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=37JPJIW72lYRJ1n2JzNQVqlvrtBd+yCk19PopakTJpI=; b=k6gzz6QCCdxYiXrr5RyiudDHvBu3tzH1zsq6X71wy8P7FrcpOKINmQyDDq57ReDD22 H1gZ2D/H7mdxgtcm/eFsC7yc2YTEshxAeycrMpUxoA69RZwn4Eot9+Wr26JkTUugqd4p gBjQ5+YEF8y8iTR4Fe+AMPP6xkOsXGv1C785/nYBjqyzDvRZyzv5lPFFx5oXplVr8F5s otgAaNp5xPm2UwYvdIbBX9iw7bTslFyZD61Pojb0LNkJ+fCo0AKjJCZL2OjWxBsKaiCW QtfhCxrx+nL0d1WpVm2bWSGrHpqOzn7MBxEQCRc02pFF9ehTm1QzKIDxs3XSjMwcr1cm YAYg== X-Received: by 10.28.128.210 with SMTP id b201mr4455294wmd.69.1448054333223; Fri, 20 Nov 2015 13:18:53 -0800 (PST) Received: from localhost.localdomain.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id u4sm1238327wjz.4.2015.11.20.13.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2015 13:18:52 -0800 (PST) From: Ilya Dryomov To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH] block: use bd{grab,put}() instead of open-coding Date: Fri, 20 Nov 2015 22:18:43 +0100 Message-Id: <1448054323-23921-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 - bd_acquire() and bd_forget() open-code bdgrab() and bdput() - raw driver uses igrab() but never checks its return value and always holds another ref from bind_set() while calling it, so it's equivalent to bdgrab() Signed-off-by: Ilya Dryomov --- drivers/char/raw.c | 2 +- fs/block_dev.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 60316fbaf295..9b9809b709a5 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c @@ -71,7 +71,7 @@ static int raw_open(struct inode *inode, struct file *filp) err = -ENODEV; if (!bdev) goto out; - igrab(bdev->bd_inode); + bdgrab(bdev); err = blkdev_get(bdev, filp->f_mode | FMODE_EXCL, raw_open); if (err) goto out; diff --git a/fs/block_dev.c b/fs/block_dev.c index 6f8dd407c533..42ebf7b675c0 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -682,7 +682,7 @@ static struct block_device *bd_acquire(struct inode *inode) spin_lock(&bdev_lock); bdev = inode->i_bdev; if (bdev) { - ihold(bdev->bd_inode); + bdgrab(bdev); spin_unlock(&bdev_lock); return bdev; } @@ -698,7 +698,7 @@ static struct block_device *bd_acquire(struct inode *inode) * So, we can access it via ->i_mapping always * without igrab(). */ - ihold(bdev->bd_inode); + bdgrab(bdev); inode->i_bdev = bdev; inode->i_mapping = bdev->bd_inode->i_mapping; list_add(&inode->i_devices, &bdev->bd_inodes); @@ -721,7 +721,7 @@ void bd_forget(struct inode *inode) spin_unlock(&bdev_lock); if (bdev) - iput(bdev->bd_inode); + bdput(bdev); } /**