From patchwork Thu Jul 30 05:48:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6898321 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 8716FC05AC for ; Thu, 30 Jul 2015 05:54:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 94D482054D for ; Thu, 30 Jul 2015 05:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A816420546 for ; Thu, 30 Jul 2015 05:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752024AbbG3FyQ (ORCPT ); Thu, 30 Jul 2015 01:54:16 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:60081 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750926AbbG3FyN (ORCPT ); Thu, 30 Jul 2015 01:54:13 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="99064467" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Jul 2015 13:57:46 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t6U5qL5q028253; Thu, 30 Jul 2015 13:52:21 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 30 Jul 2015 13:54:12 +0800 From: Dongsheng Yang To: , , , CC: , , Dongsheng Yang Subject: [PATCH v2 05/35] fs: super: introduce a get_super_cdev to get super by a cdev reference Date: Thu, 30 Jul 2015 13:48:01 +0800 Message-ID: <1438235311-23788-6-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1438235311-23788-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1438235311-23788-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 As we have cdev in superblock now, we can provide get_super_cdev to get super_block by a cdev reference, similar with get_super which is working only for block_device. Signed-off-by: Dongsheng Yang Reviewed-by: Jan Kara --- fs/super.c | 15 +++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 16 insertions(+) diff --git a/fs/super.c b/fs/super.c index 46fd1f1..4c56dff 100644 --- a/fs/super.c +++ b/fs/super.c @@ -613,6 +613,21 @@ struct super_block *get_super(struct block_device *bdev) } EXPORT_SYMBOL(get_super); +static int cdev_compare(struct super_block *sb, void *key) +{ + return (sb->s_cdev == (struct cdev *)key); +} + +/** + * get_super_cdev - get the superblock of a cdev + * @cdev: char device to get the superblock for + */ +struct super_block *get_super_cdev(struct cdev *cdev) +{ + return __get_super(cdev_compare, cdev); +} +EXPORT_SYMBOL(get_super_cdev); + /** * get_super_thawed - get thawed superblock of a device * @bdev: device to get the superblock for diff --git a/include/linux/fs.h b/include/linux/fs.h index 2f1d9499..e5ea425a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2744,6 +2744,7 @@ extern void get_filesystem(struct file_system_type *fs); extern void put_filesystem(struct file_system_type *fs); extern struct file_system_type *get_fs_type(const char *name); extern struct super_block *get_super(struct block_device *); +extern struct super_block *get_super_cdev(struct cdev *); extern struct super_block *get_super_thawed(struct block_device *); extern struct super_block *get_active_super(struct block_device *bdev); extern void drop_super(struct super_block *sb);