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: Yang Dongsheng X-Patchwork-Id: 7182361 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 BBAD19F380 for ; Tue, 15 Sep 2015 09:32:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7935205F1 for ; Tue, 15 Sep 2015 09:32:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF9E5205E9 for ; Tue, 15 Sep 2015 09:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754351AbbIOJJi (ORCPT ); Tue, 15 Sep 2015 05:09:38 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:19552 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754337AbbIOJJh (ORCPT ); Tue, 15 Sep 2015 05:09:37 -0400 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: , , , CC: , , Dongsheng Yang 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] Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 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;