file.c (01b944fe1cd4e21a2a9ed51adbdbafe2d5e905ba) | file.c (5955102c9984fa081b2d570cfac75c97eecf8f3b) |
---|---|
1/* 2 * File operations for Coda. 3 * Original version: (C) 1996 Peter Braam 4 * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University 5 * 6 * Carnegie Mellon encourages users of this code to contribute improvements 7 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>. 8 */ --- 57 unchanged lines hidden (view full) --- 66 struct coda_file_info *cfi = CODA_FTOC(coda_file); 67 struct file *host_file; 68 ssize_t ret; 69 70 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 71 72 host_file = cfi->cfi_container; 73 file_start_write(host_file); | 1/* 2 * File operations for Coda. 3 * Original version: (C) 1996 Peter Braam 4 * Rewritten for Linux 2.1: (C) 1997 Carnegie Mellon University 5 * 6 * Carnegie Mellon encourages users of this code to contribute improvements 7 * to the Coda project. Contact Peter Braam <coda@cs.cmu.edu>. 8 */ --- 57 unchanged lines hidden (view full) --- 66 struct coda_file_info *cfi = CODA_FTOC(coda_file); 67 struct file *host_file; 68 ssize_t ret; 69 70 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 71 72 host_file = cfi->cfi_container; 73 file_start_write(host_file); |
74 mutex_lock(&coda_inode->i_mutex); | 74 inode_lock(coda_inode); |
75 ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos); 76 coda_inode->i_size = file_inode(host_file)->i_size; 77 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; 78 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC; | 75 ret = vfs_iter_write(cfi->cfi_container, to, &iocb->ki_pos); 76 coda_inode->i_size = file_inode(host_file)->i_size; 77 coda_inode->i_blocks = (coda_inode->i_size + 511) >> 9; 78 coda_inode->i_mtime = coda_inode->i_ctime = CURRENT_TIME_SEC; |
79 mutex_unlock(&coda_inode->i_mutex); | 79 inode_unlock(coda_inode); |
80 file_end_write(host_file); 81 return ret; 82} 83 84static int 85coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) 86{ 87 struct coda_file_info *cfi; --- 110 unchanged lines hidden (view full) --- 198 199 if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || 200 S_ISLNK(coda_inode->i_mode))) 201 return -EINVAL; 202 203 err = filemap_write_and_wait_range(coda_inode->i_mapping, start, end); 204 if (err) 205 return err; | 80 file_end_write(host_file); 81 return ret; 82} 83 84static int 85coda_file_mmap(struct file *coda_file, struct vm_area_struct *vma) 86{ 87 struct coda_file_info *cfi; --- 110 unchanged lines hidden (view full) --- 198 199 if (!(S_ISREG(coda_inode->i_mode) || S_ISDIR(coda_inode->i_mode) || 200 S_ISLNK(coda_inode->i_mode))) 201 return -EINVAL; 202 203 err = filemap_write_and_wait_range(coda_inode->i_mapping, start, end); 204 if (err) 205 return err; |
206 mutex_lock(&coda_inode->i_mutex); | 206 inode_lock(coda_inode); |
207 208 cfi = CODA_FTOC(coda_file); 209 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 210 host_file = cfi->cfi_container; 211 212 err = vfs_fsync(host_file, datasync); 213 if (!err && !datasync) 214 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); | 207 208 cfi = CODA_FTOC(coda_file); 209 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 210 host_file = cfi->cfi_container; 211 212 err = vfs_fsync(host_file, datasync); 213 if (!err && !datasync) 214 err = venus_fsync(coda_inode->i_sb, coda_i2f(coda_inode)); |
215 mutex_unlock(&coda_inode->i_mutex); | 215 inode_unlock(coda_inode); |
216 217 return err; 218} 219 220const struct file_operations coda_file_operations = { 221 .llseek = generic_file_llseek, 222 .read_iter = coda_file_read_iter, 223 .write_iter = coda_file_write_iter, 224 .mmap = coda_file_mmap, 225 .open = coda_open, 226 .release = coda_release, 227 .fsync = coda_fsync, 228 .splice_read = coda_file_splice_read, 229}; 230 | 216 217 return err; 218} 219 220const struct file_operations coda_file_operations = { 221 .llseek = generic_file_llseek, 222 .read_iter = coda_file_read_iter, 223 .write_iter = coda_file_write_iter, 224 .mmap = coda_file_mmap, 225 .open = coda_open, 226 .release = coda_release, 227 .fsync = coda_fsync, 228 .splice_read = coda_file_splice_read, 229}; 230 |