From patchwork Tue Sep 15 09:02:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 517774 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2D54A140082 for ; Tue, 15 Sep 2015 19:26:28 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbmTn-0004HU-BG; Tue, 15 Sep 2015 09:24:47 +0000 Received: from [59.151.112.132] (helo=heian.cn.fujitsu.com) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbmFD-0002nf-Fc for linux-mtd@lists.infradead.org; Tue, 15 Sep 2015 09:09:47 +0000 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100730409" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 15 Sep 2015 17:12:27 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t8F99KGQ008118; Tue, 15 Sep 2015 17:09:20 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 15 Sep 2015 17:09:34 +0800 From: Dongsheng Yang To: , , , Subject: [PATCH v3 37/39] ubifs: implement ubifs_restore_iflags for quotactl_operations Date: Tue, 15 Sep 2015 17:02:32 +0800 Message-ID: <1442307754-13233-38-git-send-email-yangds.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1442307754-13233-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <1442307754-13233-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150915_020943_964117_43ECCED3 X-CRM114-Status: GOOD ( 12.74 ) X-Spam-Score: -1.1 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Dongsheng Yang , linux-mtd@lists.infradead.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We have to implement a ubifs_restore_iflags for quotactl_operations, because we don't allow dquot mark_inode_dirty() without a budget. So we need to do it by ourselves in ubifs_restore_iflags. Signed-off-by: Dongsheng Yang --- fs/ubifs/super.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index d3213a2..01aaa88 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2192,6 +2192,67 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi) return c; } +#ifdef CONFIG_QUOTA +static int ubifs_restore_iflags(struct super_block *sb, struct inode **toputinode, + unsigned int *old_flags) +{ + int cnt = 0; + int err = 0; + struct quota_info *dqopt = sb_dqopt(sb); + struct ubifs_info *c = sb->s_fs_info; + + for (cnt = 0; cnt < MAXQUOTAS; cnt++) + if (toputinode[cnt]) { + struct ubifs_inode *ui = ubifs_inode(toputinode[cnt]); + struct ubifs_budget_req req = { .dirtied_ino = 1, + .dirtied_ino_d = ALIGN(ui->data_len, 8) }; + int release = 0; + + /* budget for the inode which need to update */ + err = ubifs_budget_space(c, &req); + if (err) + return err; + + mutex_lock(&dqopt->dqonoff_mutex); + /* If quota was reenabled in the meantime, we have + * nothing to do */ + if (!sb_has_quota_loaded(sb, cnt)) { + mutex_lock(&toputinode[cnt]->i_mutex); + toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | + S_NOATIME | S_NOQUOTA); + toputinode[cnt]->i_flags |= old_flags[cnt]; + truncate_inode_pages(&toputinode[cnt]->i_data, + 0); + mutex_unlock(&toputinode[cnt]->i_mutex); + + mutex_lock(&ui->ui_mutex); + release = ui->dirty; + mark_inode_dirty_sync(toputinode[cnt]); + mutex_unlock(&ui->ui_mutex); + } else { + release = 1; + } + mutex_unlock(&dqopt->dqonoff_mutex); + /* Release the budget if we don't need to update the inode */ + if (release) + ubifs_release_budget(c, &req); + } + + return 0; +} + +static const struct quotactl_ops ubifs_quotactl_ops = { + .quota_on = dquot_quota_on, + .quota_off = dquot_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, + .restore_iflags = ubifs_restore_iflags +}; +#endif + static int ubifs_fill_super(struct super_block *sb, void *data, int silent) { struct ubifs_info *c = sb->s_fs_info;