diff options
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 5b52547d6299..17947dc8341e 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -107,6 +107,9 @@ static int ocfs2_file_open(struct inode *inode, struct file *file) | |||
107 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, | 107 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, |
108 | file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name); | 108 | file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name); |
109 | 109 | ||
110 | if (file->f_mode & FMODE_WRITE) | ||
111 | dquot_initialize(inode); | ||
112 | |||
110 | spin_lock(&oi->ip_lock); | 113 | spin_lock(&oi->ip_lock); |
111 | 114 | ||
112 | /* Check that the inode hasn't been wiped from disk by another | 115 | /* Check that the inode hasn't been wiped from disk by another |
@@ -629,11 +632,10 @@ restart_all: | |||
629 | } | 632 | } |
630 | 633 | ||
631 | restarted_transaction: | 634 | restarted_transaction: |
632 | if (vfs_dq_alloc_space_nodirty(inode, ocfs2_clusters_to_bytes(osb->sb, | 635 | status = dquot_alloc_space_nodirty(inode, |
633 | clusters_to_add))) { | 636 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); |
634 | status = -EDQUOT; | 637 | if (status) |
635 | goto leave; | 638 | goto leave; |
636 | } | ||
637 | did_quota = 1; | 639 | did_quota = 1; |
638 | 640 | ||
639 | /* reserve a write to the file entry early on - that we if we | 641 | /* reserve a write to the file entry early on - that we if we |
@@ -674,7 +676,7 @@ restarted_transaction: | |||
674 | clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); | 676 | clusters_to_add -= (OCFS2_I(inode)->ip_clusters - prev_clusters); |
675 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 677 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
676 | /* Release unused quota reservation */ | 678 | /* Release unused quota reservation */ |
677 | vfs_dq_free_space(inode, | 679 | dquot_free_space(inode, |
678 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); | 680 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); |
679 | did_quota = 0; | 681 | did_quota = 0; |
680 | 682 | ||
@@ -710,7 +712,7 @@ restarted_transaction: | |||
710 | 712 | ||
711 | leave: | 713 | leave: |
712 | if (status < 0 && did_quota) | 714 | if (status < 0 && did_quota) |
713 | vfs_dq_free_space(inode, | 715 | dquot_free_space(inode, |
714 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); | 716 | ocfs2_clusters_to_bytes(osb->sb, clusters_to_add)); |
715 | if (handle) { | 717 | if (handle) { |
716 | ocfs2_commit_trans(osb, handle); | 718 | ocfs2_commit_trans(osb, handle); |
@@ -978,6 +980,8 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
978 | 980 | ||
979 | size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE; | 981 | size_change = S_ISREG(inode->i_mode) && attr->ia_valid & ATTR_SIZE; |
980 | if (size_change) { | 982 | if (size_change) { |
983 | dquot_initialize(inode); | ||
984 | |||
981 | status = ocfs2_rw_lock(inode, 1); | 985 | status = ocfs2_rw_lock(inode, 1); |
982 | if (status < 0) { | 986 | if (status < 0) { |
983 | mlog_errno(status); | 987 | mlog_errno(status); |
@@ -1020,7 +1024,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
1020 | /* | 1024 | /* |
1021 | * Gather pointers to quota structures so that allocation / | 1025 | * Gather pointers to quota structures so that allocation / |
1022 | * freeing of quota structures happens here and not inside | 1026 | * freeing of quota structures happens here and not inside |
1023 | * vfs_dq_transfer() where we have problems with lock ordering | 1027 | * dquot_transfer() where we have problems with lock ordering |
1024 | */ | 1028 | */ |
1025 | if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid | 1029 | if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid |
1026 | && OCFS2_HAS_RO_COMPAT_FEATURE(sb, | 1030 | && OCFS2_HAS_RO_COMPAT_FEATURE(sb, |
@@ -1053,7 +1057,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
1053 | mlog_errno(status); | 1057 | mlog_errno(status); |
1054 | goto bail_unlock; | 1058 | goto bail_unlock; |
1055 | } | 1059 | } |
1056 | status = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; | 1060 | status = dquot_transfer(inode, attr); |
1057 | if (status < 0) | 1061 | if (status < 0) |
1058 | goto bail_commit; | 1062 | goto bail_commit; |
1059 | } else { | 1063 | } else { |