diff options
Diffstat (limited to 'fs/ocfs2/file.c')
| -rw-r--r-- | fs/ocfs2/file.c | 33 | 
1 files changed, 17 insertions, 16 deletions
| diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 558ce0312421..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); | 
| @@ -993,10 +997,9 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 993 | } | 997 | } | 
| 994 | 998 | ||
| 995 | if (size_change && attr->ia_size != i_size_read(inode)) { | 999 | if (size_change && attr->ia_size != i_size_read(inode)) { | 
| 996 | if (attr->ia_size > sb->s_maxbytes) { | 1000 | status = inode_newsize_ok(inode, attr->ia_size); | 
| 997 | status = -EFBIG; | 1001 | if (status) | 
| 998 | goto bail_unlock; | 1002 | goto bail_unlock; | 
| 999 | } | ||
| 1000 | 1003 | ||
| 1001 | if (i_size_read(inode) > attr->ia_size) { | 1004 | if (i_size_read(inode) > attr->ia_size) { | 
| 1002 | if (ocfs2_should_order_data(inode)) { | 1005 | if (ocfs2_should_order_data(inode)) { | 
| @@ -1021,7 +1024,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 1021 | /* | 1024 | /* | 
| 1022 | * Gather pointers to quota structures so that allocation / | 1025 | * Gather pointers to quota structures so that allocation / | 
| 1023 | * freeing of quota structures happens here and not inside | 1026 | * freeing of quota structures happens here and not inside | 
| 1024 | * vfs_dq_transfer() where we have problems with lock ordering | 1027 | * dquot_transfer() where we have problems with lock ordering | 
| 1025 | */ | 1028 | */ | 
| 1026 | 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 | 
| 1027 | && OCFS2_HAS_RO_COMPAT_FEATURE(sb, | 1030 | && OCFS2_HAS_RO_COMPAT_FEATURE(sb, | 
| @@ -1054,7 +1057,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
| 1054 | mlog_errno(status); | 1057 | mlog_errno(status); | 
| 1055 | goto bail_unlock; | 1058 | goto bail_unlock; | 
| 1056 | } | 1059 | } | 
| 1057 | status = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; | 1060 | status = dquot_transfer(inode, attr); | 
| 1058 | if (status < 0) | 1061 | if (status < 0) | 
| 1059 | goto bail_commit; | 1062 | goto bail_commit; | 
| 1060 | } else { | 1063 | } else { | 
| @@ -1836,6 +1839,8 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry, | |||
| 1836 | &meta_level); | 1839 | &meta_level); | 
| 1837 | if (has_refcount) | 1840 | if (has_refcount) | 
| 1838 | *has_refcount = 1; | 1841 | *has_refcount = 1; | 
| 1842 | if (direct_io) | ||
| 1843 | *direct_io = 0; | ||
| 1839 | } | 1844 | } | 
| 1840 | 1845 | ||
| 1841 | if (ret < 0) { | 1846 | if (ret < 0) { | 
| @@ -1859,10 +1864,6 @@ static int ocfs2_prepare_inode_for_write(struct dentry *dentry, | |||
| 1859 | break; | 1864 | break; | 
| 1860 | } | 1865 | } | 
| 1861 | 1866 | ||
| 1862 | if (has_refcount && *has_refcount == 1) { | ||
| 1863 | *direct_io = 0; | ||
| 1864 | break; | ||
| 1865 | } | ||
| 1866 | /* | 1867 | /* | 
| 1867 | * Allowing concurrent direct writes means | 1868 | * Allowing concurrent direct writes means | 
| 1868 | * i_size changes wouldn't be synchronized, so | 1869 | * i_size changes wouldn't be synchronized, so | 
| @@ -2043,7 +2044,7 @@ out_dio: | |||
| 2043 | * async dio is going to do it in the future or an end_io after an | 2044 | * async dio is going to do it in the future or an end_io after an | 
| 2044 | * error has already done it. | 2045 | * error has already done it. | 
| 2045 | */ | 2046 | */ | 
| 2046 | if (ret == -EIOCBQUEUED || !ocfs2_iocb_is_rw_locked(iocb)) { | 2047 | if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) { | 
| 2047 | rw_level = -1; | 2048 | rw_level = -1; | 
| 2048 | have_alloc_sem = 0; | 2049 | have_alloc_sem = 0; | 
| 2049 | } | 2050 | } | 
