From patchwork Tue Jul 21 08:37:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 6833321 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 90E80C05AC for ; Tue, 21 Jul 2015 08:44:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC23E20690 for ; Tue, 21 Jul 2015 08:44:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B678420678 for ; Tue, 21 Jul 2015 08:44:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbbGUIoA (ORCPT ); Tue, 21 Jul 2015 04:44:00 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:57008 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754189AbbGUIn4 (ORCPT ); Tue, 21 Jul 2015 04:43:56 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98671232" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Jul 2015 16:47:34 +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 t6L8g3cF005072; Tue, 21 Jul 2015 16:42:03 +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:51 +0800 From: Dongsheng Yang To: , , CC: , , Dongsheng Yang Subject: [PATCH 24/25] ubifs: implement ubifs_qctl_operations for quotactl Date: Tue, 21 Jul 2015 16:37:55 +0800 Message-ID: <1437467876-22106-25-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 To make ubifs support quota, we have to provide a qctl_operations to quotactl. But we can not use the default operations. The problem is quota_off function. We have to do a budget at first before disabling quota. Signed-off-by: Dongsheng Yang --- fs/ubifs/super.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 60deed2..00451b0 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2278,6 +2278,62 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi) return c; } +#ifdef CONFIG_QUOTA +static int ubifs_quota_off(struct super_block *sb, int type) +{ + struct ubifs_budget_req req = {}; + struct ubifs_info *c = sb->s_fs_info; + struct quota_info *dqopt = sb_dqopt(sb); + struct inode *inodes[MAXQUOTAS] = {}; + struct inode *tmp = NULL; + struct ubifs_inode *ui = NULL; + int ret = 0; + int cnt = 0; + + if (type == -1) { + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { + if (!sb_has_quota_loaded(sb, cnt)) + continue; + req.dirtied_ino += 1; + inodes[cnt] = dqopt->files[cnt]; + } + } else { + if (sb_has_quota_loaded(sb, type)) { + req.dirtied_ino = 1; + inodes[cnt] = dqopt->files[type]; + } + } + + if (req.dirtied_ino) { + ret = ubifs_budget_space(c, &req); + if (ret) + return ret; + } + + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { + tmp = inodes[cnt]; + if (!tmp) + break; + ui = ubifs_inode(tmp); + mutex_lock(&ui->ui_mutex); + ui->budgeted = 1; + mutex_unlock(&ui->ui_mutex); + } + + return dquot_disable(sb, type, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); +} + +static const struct quotactl_ops ubifs_qctl_operations = { + .quota_on = dquot_quota_on, + .quota_off = ubifs_quota_off, + .quota_sync = dquot_quota_sync, + .get_state = dquot_get_state, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk +}; +#endif + static int ubifs_fill_super(struct super_block *sb, void *data, int silent) { struct ubifs_info *c = sb->s_fs_info;