diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2010-02-16 00:31:50 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:26 -0500 |
commit | 8ddd69d6df4758bf0cab981481af24cc84419567 (patch) | |
tree | 126eb5877e092963b7ed1cf143e3ce0bac6a7c85 /fs/quota | |
parent | ad1e6e8da9fe8cb7ecfde8eabacedc3b50fceae4 (diff) |
quota: generalize quota transfer interface
Current quota transfer interface support only uid/gid.
This patch extend interface in order to support various quotas types
The goal is accomplished without changes in most frequently used
vfs_dq_transfer() func.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota')
-rw-r--r-- | fs/quota/dquot.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 5a831dc5ab28..4d2041fddefc 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -1695,15 +1695,13 @@ EXPORT_SYMBOL(dquot_free_inode); | |||
1695 | * This operation can block, but only after everything is updated | 1695 | * This operation can block, but only after everything is updated |
1696 | * A transaction must be started when entering this function. | 1696 | * A transaction must be started when entering this function. |
1697 | */ | 1697 | */ |
1698 | int dquot_transfer(struct inode *inode, struct iattr *iattr) | 1698 | int dquot_transfer(struct inode *inode, qid_t *chid, unsigned long mask) |
1699 | { | 1699 | { |
1700 | qsize_t space, cur_space; | 1700 | qsize_t space, cur_space; |
1701 | qsize_t rsv_space = 0; | 1701 | qsize_t rsv_space = 0; |
1702 | struct dquot *transfer_from[MAXQUOTAS]; | 1702 | struct dquot *transfer_from[MAXQUOTAS]; |
1703 | struct dquot *transfer_to[MAXQUOTAS]; | 1703 | struct dquot *transfer_to[MAXQUOTAS]; |
1704 | int cnt, ret = QUOTA_OK; | 1704 | int cnt, ret = QUOTA_OK; |
1705 | int chuid = iattr->ia_valid & ATTR_UID && inode->i_uid != iattr->ia_uid, | ||
1706 | chgid = iattr->ia_valid & ATTR_GID && inode->i_gid != iattr->ia_gid; | ||
1707 | char warntype_to[MAXQUOTAS]; | 1705 | char warntype_to[MAXQUOTAS]; |
1708 | char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS]; | 1706 | char warntype_from_inodes[MAXQUOTAS], warntype_from_space[MAXQUOTAS]; |
1709 | 1707 | ||
@@ -1717,13 +1715,10 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
1717 | transfer_to[cnt] = NULL; | 1715 | transfer_to[cnt] = NULL; |
1718 | warntype_to[cnt] = QUOTA_NL_NOWARN; | 1716 | warntype_to[cnt] = QUOTA_NL_NOWARN; |
1719 | } | 1717 | } |
1720 | if (chuid) | 1718 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
1721 | transfer_to[USRQUOTA] = dqget(inode->i_sb, iattr->ia_uid, | 1719 | if (mask & (1 << cnt)) |
1722 | USRQUOTA); | 1720 | transfer_to[cnt] = dqget(inode->i_sb, chid[cnt], cnt); |
1723 | if (chgid) | 1721 | } |
1724 | transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid, | ||
1725 | GRPQUOTA); | ||
1726 | |||
1727 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1722 | down_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
1728 | if (IS_NOQUOTA(inode)) { /* File without quota accounting? */ | 1723 | if (IS_NOQUOTA(inode)) { /* File without quota accounting? */ |
1729 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); | 1724 | up_write(&sb_dqopt(inode->i_sb)->dqptr_sem); |
@@ -1799,12 +1794,25 @@ over_quota: | |||
1799 | } | 1794 | } |
1800 | EXPORT_SYMBOL(dquot_transfer); | 1795 | EXPORT_SYMBOL(dquot_transfer); |
1801 | 1796 | ||
1802 | /* Wrapper for transferring ownership of an inode */ | 1797 | /* Wrapper for transferring ownership of an inode for uid/gid only |
1798 | * Called from FSXXX_setattr() | ||
1799 | */ | ||
1803 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) | 1800 | int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) |
1804 | { | 1801 | { |
1802 | qid_t chid[MAXQUOTAS]; | ||
1803 | unsigned long mask = 0; | ||
1804 | |||
1805 | if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) { | ||
1806 | mask |= 1 << USRQUOTA; | ||
1807 | chid[USRQUOTA] = iattr->ia_uid; | ||
1808 | } | ||
1809 | if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) { | ||
1810 | mask |= 1 << GRPQUOTA; | ||
1811 | chid[GRPQUOTA] = iattr->ia_gid; | ||
1812 | } | ||
1805 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) { | 1813 | if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode)) { |
1806 | vfs_dq_init(inode); | 1814 | vfs_dq_init(inode); |
1807 | if (inode->i_sb->dq_op->transfer(inode, iattr) == NO_QUOTA) | 1815 | if (inode->i_sb->dq_op->transfer(inode, chid, mask) == NO_QUOTA) |
1808 | return 1; | 1816 | return 1; |
1809 | } | 1817 | } |
1810 | return 0; | 1818 | return 0; |