From patchwork Tue Jul 21 08:37:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6833431 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 2A8EC9F358 for ; Tue, 21 Jul 2015 08:47:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 453C120690 for ; Tue, 21 Jul 2015 08:47:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C4DA20678 for ; Tue, 21 Jul 2015 08:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754428AbbGUIra (ORCPT ); Tue, 21 Jul 2015 04:47:30 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:7296 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753852AbbGUInk (ORCPT ); Tue, 21 Jul 2015 04:43:40 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98671200" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Jul 2015 16:47:16 +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 t6L8fj6W005007; Tue, 21 Jul 2015 16:41:46 +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; Tue, 21 Jul 2015 16:43:33 +0800 From: Dongsheng Yang To: , , CC: , , Dongsheng Yang Subject: [PATCH 07/25] fs: quota: make quota support fs which is running on char dev Date: Tue, 21 Jul 2015 16:37:38 +0800 Message-ID: <1437467876-22106-8-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1437467876-22106-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1437467876-22106-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.1 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 So far, we have done all preparation. Then let's add some code to support char dev fs in quotactl. Signed-off-by: Dongsheng Yang --- fs/quota/quota.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/fs/quota/quota.c b/fs/quota/quota.c index 86ded73..3f9acea 100644 --- a/fs/quota/quota.c +++ b/fs/quota/quota.c @@ -17,6 +17,7 @@ #include #include #include +#include static int check_quotactl_permission(struct super_block *sb, int type, int cmd, qid_t id) @@ -726,29 +727,40 @@ static int quotactl_cmd_write(int cmd) */ static struct super_block *quotactl_block(const char __user *special, int cmd) { + struct super_block *sb = NULL; + struct filename *tmp = getname(special); + struct cdev *cdev = NULL; + #ifdef CONFIG_BLOCK struct block_device *bdev; - struct super_block *sb; - struct filename *tmp = getname(special); if (IS_ERR(tmp)) return ERR_CAST(tmp); bdev = lookup_bdev(tmp->name); - putname(tmp); if (IS_ERR(bdev)) - return ERR_CAST(bdev); + goto not_block; if (quotactl_cmd_write(cmd)) sb = get_super_thawed(bdev); else sb = get_super(bdev); bdput(bdev); - if (!sb) - return ERR_PTR(-ENODEV); + goto out; - return sb; -#else - return ERR_PTR(-ENODEV); +not_block: #endif + cdev = lookup_cdev(tmp->name); + if (IS_ERR(cdev)) + goto out; + if (quotactl_cmd_write(cmd)) + sb = get_super_cdev_thawed(cdev); + else + sb = get_super_cdev(cdev); + cdev_put(cdev); +out: + putname(tmp); + if (sb) + return sb; + return ERR_PTR(-ENODEV); } /*