diff options
Diffstat (limited to 'fs/coda/file.c')
-rw-r--r-- | fs/coda/file.c | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/fs/coda/file.c b/fs/coda/file.c index ad3cd2abeeb4..0433057be330 100644 --- a/fs/coda/file.c +++ b/fs/coda/file.c | |||
@@ -15,16 +15,15 @@ | |||
15 | #include <linux/stat.h> | 15 | #include <linux/stat.h> |
16 | #include <linux/cred.h> | 16 | #include <linux/cred.h> |
17 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
18 | #include <linux/smp_lock.h> | 18 | #include <linux/spinlock.h> |
19 | #include <linux/string.h> | 19 | #include <linux/string.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
22 | 22 | ||
23 | #include <linux/coda.h> | 23 | #include <linux/coda.h> |
24 | #include <linux/coda_linux.h> | ||
25 | #include <linux/coda_fs_i.h> | ||
26 | #include <linux/coda_psdev.h> | 24 | #include <linux/coda_psdev.h> |
27 | 25 | ||
26 | #include "coda_linux.h" | ||
28 | #include "coda_int.h" | 27 | #include "coda_int.h" |
29 | 28 | ||
30 | static ssize_t | 29 | static ssize_t |
@@ -109,19 +108,24 @@ coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) | |||
109 | 108 | ||
110 | coda_inode = coda_file->f_path.dentry->d_inode; | 109 | coda_inode = coda_file->f_path.dentry->d_inode; |
111 | host_inode = host_file->f_path.dentry->d_inode; | 110 | host_inode = host_file->f_path.dentry->d_inode; |
111 | |||
112 | cii = ITOC(coda_inode); | ||
113 | spin_lock(&cii->c_lock); | ||
112 | coda_file->f_mapping = host_file->f_mapping; | 114 | coda_file->f_mapping = host_file->f_mapping; |
113 | if (coda_inode->i_mapping == &coda_inode->i_data) | 115 | if (coda_inode->i_mapping == &coda_inode->i_data) |
114 | coda_inode->i_mapping = host_inode->i_mapping; | 116 | coda_inode->i_mapping = host_inode->i_mapping; |
115 | 117 | ||
116 | /* only allow additional mmaps as long as userspace isn't changing | 118 | /* only allow additional mmaps as long as userspace isn't changing |
117 | * the container file on us! */ | 119 | * the container file on us! */ |
118 | else if (coda_inode->i_mapping != host_inode->i_mapping) | 120 | else if (coda_inode->i_mapping != host_inode->i_mapping) { |
121 | spin_unlock(&cii->c_lock); | ||
119 | return -EBUSY; | 122 | return -EBUSY; |
123 | } | ||
120 | 124 | ||
121 | /* keep track of how often the coda_inode/host_file has been mmapped */ | 125 | /* keep track of how often the coda_inode/host_file has been mmapped */ |
122 | cii = ITOC(coda_inode); | ||
123 | cii->c_mapcount++; | 126 | cii->c_mapcount++; |
124 | cfi->cfi_mapcount++; | 127 | cfi->cfi_mapcount++; |
128 | spin_unlock(&cii->c_lock); | ||
125 | 129 | ||
126 | return host_file->f_op->mmap(host_file, vma); | 130 | return host_file->f_op->mmap(host_file, vma); |
127 | } | 131 | } |
@@ -138,8 +142,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
138 | if (!cfi) | 142 | if (!cfi) |
139 | return -ENOMEM; | 143 | return -ENOMEM; |
140 | 144 | ||
141 | lock_kernel(); | ||
142 | |||
143 | error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, | 145 | error = venus_open(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, |
144 | &host_file); | 146 | &host_file); |
145 | if (!host_file) | 147 | if (!host_file) |
@@ -147,7 +149,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
147 | 149 | ||
148 | if (error) { | 150 | if (error) { |
149 | kfree(cfi); | 151 | kfree(cfi); |
150 | unlock_kernel(); | ||
151 | return error; | 152 | return error; |
152 | } | 153 | } |
153 | 154 | ||
@@ -159,8 +160,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) | |||
159 | 160 | ||
160 | BUG_ON(coda_file->private_data != NULL); | 161 | BUG_ON(coda_file->private_data != NULL); |
161 | coda_file->private_data = cfi; | 162 | coda_file->private_data = cfi; |
162 | |||
163 | unlock_kernel(); | ||
164 | return 0; | 163 | return 0; |
165 | } | 164 | } |
166 | 165 | ||
@@ -171,9 +170,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) | |||
171 | struct coda_file_info *cfi; | 170 | struct coda_file_info *cfi; |
172 | struct coda_inode_info *cii; | 171 | struct coda_inode_info *cii; |
173 | struct inode *host_inode; | 172 | struct inode *host_inode; |
174 | int err = 0; | 173 | int err; |
175 | |||
176 | lock_kernel(); | ||
177 | 174 | ||
178 | cfi = CODA_FTOC(coda_file); | 175 | cfi = CODA_FTOC(coda_file); |
179 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); | 176 | BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); |
@@ -185,18 +182,18 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) | |||
185 | cii = ITOC(coda_inode); | 182 | cii = ITOC(coda_inode); |
186 | 183 | ||
187 | /* did we mmap this file? */ | 184 | /* did we mmap this file? */ |
185 | spin_lock(&cii->c_lock); | ||
188 | if (coda_inode->i_mapping == &host_inode->i_data) { | 186 | if (coda_inode->i_mapping == &host_inode->i_data) { |
189 | cii->c_mapcount -= cfi->cfi_mapcount; | 187 | cii->c_mapcount -= cfi->cfi_mapcount; |
190 | if (!cii->c_mapcount) | 188 | if (!cii->c_mapcount) |
191 | coda_inode->i_mapping = &coda_inode->i_data; | 189 | coda_inode->i_mapping = &coda_inode->i_data; |
192 | } | 190 | } |
191 | spin_unlock(&cii->c_lock); | ||
193 | 192 | ||
194 | fput(cfi->cfi_container); | 193 | fput(cfi->cfi_container); |
195 | kfree(coda_file->private_data); | 194 | kfree(coda_file->private_data); |
196 | coda_file->private_data = NULL; | 195 | coda_file->private_data = NULL; |
197 | 196 | ||
198 | unlock_kernel(); | ||
199 | |||
200 | /* VFS fput ignores the return value from file_operations->release, so | 197 | /* VFS fput ignores the return value from file_operations->release, so |
201 | * there is no use returning an error here */ | 198 | * there is no use returning an error here */ |
202 | return 0; | 199 | return 0; |
@@ -207,7 +204,7 @@ int coda_fsync(struct file *coda_file, int datasync) | |||
207 | struct file *host_file; | 204 | struct file *host_file; |
208 | struct inode *coda_inode = coda_file->f_path.dentry->d_inode; | 205 | struct inode *coda_inode = coda_file->f_path.dentry->d_inode; |
209 | struct coda_file_info *cfi; | 206 | struct coda_file_info *cfi; |
210 | int err = 0; | 207 | int err; |
211 | 208 | ||
212 | if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || | 209 | if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || |
213 | S_ISLNK(coda_inode->i_mode))) | 210 | S_ISLNK(coda_inode->i_mode))) |
@@ -218,11 +215,8 @@ int coda_fsync(struct file *coda_file, int datasync) | |||
218 | host_file = cfi->cfi_container; | 215 | host_file = cfi->cfi_container; |
219 | 216 | ||
220 | err = vfs_fsync(host_file, datasync); | 217 | err = vfs_fsync(host_file, datasync); |
221 | if ( !err && !datasync ) { | 218 | if (!err && !datasync) |
222 | lock_kernel(); | ||
223 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); | 219 | err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); |
224 | unlock_kernel(); | ||
225 | } | ||
226 | 220 | ||
227 | return err; | 221 | return err; |
228 | } | 222 | } |