diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/hpfs/file.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'fs/hpfs/file.c')
-rw-r--r-- | fs/hpfs/file.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index c0340887c7ea..89c500ee5213 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c | |||
@@ -6,23 +6,22 @@ | |||
6 | * file VFS functions | 6 | * file VFS functions |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/smp_lock.h> | ||
10 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
11 | 10 | ||
12 | #define BLOCKS(size) (((size) + 511) >> 9) | 11 | #define BLOCKS(size) (((size) + 511) >> 9) |
13 | 12 | ||
14 | static int hpfs_file_release(struct inode *inode, struct file *file) | 13 | static int hpfs_file_release(struct inode *inode, struct file *file) |
15 | { | 14 | { |
16 | lock_kernel(); | 15 | hpfs_lock(inode->i_sb); |
17 | hpfs_write_if_changed(inode); | 16 | hpfs_write_if_changed(inode); |
18 | unlock_kernel(); | 17 | hpfs_unlock(inode->i_sb); |
19 | return 0; | 18 | return 0; |
20 | } | 19 | } |
21 | 20 | ||
22 | int hpfs_file_fsync(struct file *file, int datasync) | 21 | int hpfs_file_fsync(struct file *file, int datasync) |
23 | { | 22 | { |
24 | /*return file_fsync(file, datasync);*/ | 23 | struct inode *inode = file->f_mapping->host; |
25 | return 0; /* Don't fsync :-) */ | 24 | return sync_blockdev(inode->i_sb->s_bdev); |
26 | } | 25 | } |
27 | 26 | ||
28 | /* | 27 | /* |
@@ -49,38 +48,46 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno) | |||
49 | static void hpfs_truncate(struct inode *i) | 48 | static void hpfs_truncate(struct inode *i) |
50 | { | 49 | { |
51 | if (IS_IMMUTABLE(i)) return /*-EPERM*/; | 50 | if (IS_IMMUTABLE(i)) return /*-EPERM*/; |
52 | lock_kernel(); | 51 | hpfs_lock_assert(i->i_sb); |
52 | |||
53 | hpfs_i(i)->i_n_secs = 0; | 53 | hpfs_i(i)->i_n_secs = 0; |
54 | i->i_blocks = 1 + ((i->i_size + 511) >> 9); | 54 | i->i_blocks = 1 + ((i->i_size + 511) >> 9); |
55 | hpfs_i(i)->mmu_private = i->i_size; | 55 | hpfs_i(i)->mmu_private = i->i_size; |
56 | hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); | 56 | hpfs_truncate_btree(i->i_sb, i->i_ino, 1, ((i->i_size + 511) >> 9)); |
57 | hpfs_write_inode(i); | 57 | hpfs_write_inode(i); |
58 | hpfs_i(i)->i_n_secs = 0; | 58 | hpfs_i(i)->i_n_secs = 0; |
59 | unlock_kernel(); | ||
60 | } | 59 | } |
61 | 60 | ||
62 | static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) | 61 | static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) |
63 | { | 62 | { |
63 | int r; | ||
64 | secno s; | 64 | secno s; |
65 | hpfs_lock(inode->i_sb); | ||
65 | s = hpfs_bmap(inode, iblock); | 66 | s = hpfs_bmap(inode, iblock); |
66 | if (s) { | 67 | if (s) { |
67 | map_bh(bh_result, inode->i_sb, s); | 68 | map_bh(bh_result, inode->i_sb, s); |
68 | return 0; | 69 | goto ret_0; |
69 | } | 70 | } |
70 | if (!create) return 0; | 71 | if (!create) goto ret_0; |
71 | if (iblock<<9 != hpfs_i(inode)->mmu_private) { | 72 | if (iblock<<9 != hpfs_i(inode)->mmu_private) { |
72 | BUG(); | 73 | BUG(); |
73 | return -EIO; | 74 | r = -EIO; |
75 | goto ret_r; | ||
74 | } | 76 | } |
75 | if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) { | 77 | if ((s = hpfs_add_sector_to_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1)) == -1) { |
76 | hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1); | 78 | hpfs_truncate_btree(inode->i_sb, inode->i_ino, 1, inode->i_blocks - 1); |
77 | return -ENOSPC; | 79 | r = -ENOSPC; |
80 | goto ret_r; | ||
78 | } | 81 | } |
79 | inode->i_blocks++; | 82 | inode->i_blocks++; |
80 | hpfs_i(inode)->mmu_private += 512; | 83 | hpfs_i(inode)->mmu_private += 512; |
81 | set_buffer_new(bh_result); | 84 | set_buffer_new(bh_result); |
82 | map_bh(bh_result, inode->i_sb, s); | 85 | map_bh(bh_result, inode->i_sb, s); |
83 | return 0; | 86 | ret_0: |
87 | r = 0; | ||
88 | ret_r: | ||
89 | hpfs_unlock(inode->i_sb); | ||
90 | return r; | ||
84 | } | 91 | } |
85 | 92 | ||
86 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) | 93 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) |
@@ -120,7 +127,6 @@ static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block) | |||
120 | const struct address_space_operations hpfs_aops = { | 127 | const struct address_space_operations hpfs_aops = { |
121 | .readpage = hpfs_readpage, | 128 | .readpage = hpfs_readpage, |
122 | .writepage = hpfs_writepage, | 129 | .writepage = hpfs_writepage, |
123 | .sync_page = block_sync_page, | ||
124 | .write_begin = hpfs_write_begin, | 130 | .write_begin = hpfs_write_begin, |
125 | .write_end = generic_write_end, | 131 | .write_end = generic_write_end, |
126 | .bmap = _hpfs_bmap | 132 | .bmap = _hpfs_bmap |
@@ -132,8 +138,11 @@ static ssize_t hpfs_file_write(struct file *file, const char __user *buf, | |||
132 | ssize_t retval; | 138 | ssize_t retval; |
133 | 139 | ||
134 | retval = do_sync_write(file, buf, count, ppos); | 140 | retval = do_sync_write(file, buf, count, ppos); |
135 | if (retval > 0) | 141 | if (retval > 0) { |
142 | hpfs_lock(file->f_path.dentry->d_sb); | ||
136 | hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1; | 143 | hpfs_i(file->f_path.dentry->d_inode)->i_dirty = 1; |
144 | hpfs_unlock(file->f_path.dentry->d_sb); | ||
145 | } | ||
137 | return retval; | 146 | return retval; |
138 | } | 147 | } |
139 | 148 | ||