diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2010-06-06 09:50:39 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:48:04 -0400 |
| commit | 9df2f85128def59185f8a1c584f8af41df17405a (patch) | |
| tree | 42a861708d9180d3dd838491af6a6be5de526614 /fs/bfs | |
| parent | ac14a95b5239d37b6082c3791b88d7ab4e8e444c (diff) | |
switch bfs to ->evict_inode(), clean up
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/bfs')
| -rw-r--r-- | fs/bfs/inode.c | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index f22a7d3dc362..0499822b1568 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
| @@ -99,6 +99,24 @@ error: | |||
| 99 | return ERR_PTR(-EIO); | 99 | return ERR_PTR(-EIO); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | static struct bfs_inode *find_inode(struct super_block *sb, u16 ino, struct buffer_head **p) | ||
| 103 | { | ||
| 104 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(sb)->si_lasti)) { | ||
| 105 | printf("Bad inode number %s:%08x\n", sb->s_id, ino); | ||
| 106 | return ERR_PTR(-EIO); | ||
| 107 | } | ||
| 108 | |||
| 109 | ino -= BFS_ROOT_INO; | ||
| 110 | |||
| 111 | *p = sb_bread(sb, 1 + ino / BFS_INODES_PER_BLOCK); | ||
| 112 | if (!*p) { | ||
| 113 | printf("Unable to read inode %s:%08x\n", sb->s_id, ino); | ||
| 114 | return ERR_PTR(-EIO); | ||
| 115 | } | ||
| 116 | |||
| 117 | return (struct bfs_inode *)(*p)->b_data + ino % BFS_INODES_PER_BLOCK; | ||
| 118 | } | ||
| 119 | |||
| 102 | static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc) | 120 | static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc) |
| 103 | { | 121 | { |
| 104 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); | 122 | struct bfs_sb_info *info = BFS_SB(inode->i_sb); |
| @@ -106,28 +124,15 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 106 | unsigned long i_sblock; | 124 | unsigned long i_sblock; |
| 107 | struct bfs_inode *di; | 125 | struct bfs_inode *di; |
| 108 | struct buffer_head *bh; | 126 | struct buffer_head *bh; |
| 109 | int block, off; | ||
| 110 | int err = 0; | 127 | int err = 0; |
| 111 | 128 | ||
| 112 | dprintf("ino=%08x\n", ino); | 129 | dprintf("ino=%08x\n", ino); |
| 113 | 130 | ||
| 114 | if ((ino < BFS_ROOT_INO) || (ino > BFS_SB(inode->i_sb)->si_lasti)) { | 131 | di = find_inode(inode->i_sb, ino, &bh); |
| 115 | printf("Bad inode number %s:%08x\n", inode->i_sb->s_id, ino); | 132 | if (IS_ERR(di)) |
| 116 | return -EIO; | 133 | return PTR_ERR(di); |
| 117 | } | ||
| 118 | 134 | ||
| 119 | mutex_lock(&info->bfs_lock); | 135 | mutex_lock(&info->bfs_lock); |
| 120 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | ||
| 121 | bh = sb_bread(inode->i_sb, block); | ||
| 122 | if (!bh) { | ||
| 123 | printf("Unable to read inode %s:%08x\n", | ||
| 124 | inode->i_sb->s_id, ino); | ||
| 125 | mutex_unlock(&info->bfs_lock); | ||
| 126 | return -EIO; | ||
| 127 | } | ||
| 128 | |||
| 129 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | ||
| 130 | di = (struct bfs_inode *)bh->b_data + off; | ||
| 131 | 136 | ||
| 132 | if (ino == BFS_ROOT_INO) | 137 | if (ino == BFS_ROOT_INO) |
| 133 | di->i_vtype = cpu_to_le32(BFS_VDIR); | 138 | di->i_vtype = cpu_to_le32(BFS_VDIR); |
| @@ -158,12 +163,11 @@ static int bfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 158 | return err; | 163 | return err; |
| 159 | } | 164 | } |
| 160 | 165 | ||
| 161 | static void bfs_delete_inode(struct inode *inode) | 166 | static void bfs_evict_inode(struct inode *inode) |
| 162 | { | 167 | { |
| 163 | unsigned long ino = inode->i_ino; | 168 | unsigned long ino = inode->i_ino; |
| 164 | struct bfs_inode *di; | 169 | struct bfs_inode *di; |
| 165 | struct buffer_head *bh; | 170 | struct buffer_head *bh; |
| 166 | int block, off; | ||
| 167 | struct super_block *s = inode->i_sb; | 171 | struct super_block *s = inode->i_sb; |
| 168 | struct bfs_sb_info *info = BFS_SB(s); | 172 | struct bfs_sb_info *info = BFS_SB(s); |
| 169 | struct bfs_inode_info *bi = BFS_I(inode); | 173 | struct bfs_inode_info *bi = BFS_I(inode); |
| @@ -171,28 +175,19 @@ static void bfs_delete_inode(struct inode *inode) | |||
| 171 | dprintf("ino=%08lx\n", ino); | 175 | dprintf("ino=%08lx\n", ino); |
| 172 | 176 | ||
| 173 | truncate_inode_pages(&inode->i_data, 0); | 177 | truncate_inode_pages(&inode->i_data, 0); |
| 178 | invalidate_inode_buffers(inode); | ||
| 179 | end_writeback(inode); | ||
| 174 | 180 | ||
| 175 | if ((ino < BFS_ROOT_INO) || (ino > info->si_lasti)) { | 181 | if (inode->i_nlink) |
| 176 | printf("invalid ino=%08lx\n", ino); | ||
| 177 | return; | 182 | return; |
| 178 | } | ||
| 179 | |||
| 180 | inode->i_size = 0; | ||
| 181 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC; | ||
| 182 | mutex_lock(&info->bfs_lock); | ||
| 183 | mark_inode_dirty(inode); | ||
| 184 | 183 | ||
| 185 | block = (ino - BFS_ROOT_INO) / BFS_INODES_PER_BLOCK + 1; | 184 | di = find_inode(s, inode->i_ino, &bh); |
| 186 | bh = sb_bread(s, block); | 185 | if (IS_ERR(di)) |
| 187 | if (!bh) { | ||
| 188 | printf("Unable to read inode %s:%08lx\n", | ||
| 189 | inode->i_sb->s_id, ino); | ||
| 190 | mutex_unlock(&info->bfs_lock); | ||
| 191 | return; | 186 | return; |
| 192 | } | 187 | |
| 193 | off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK; | 188 | mutex_lock(&info->bfs_lock); |
| 194 | di = (struct bfs_inode *)bh->b_data + off; | 189 | /* clear on-disk inode */ |
| 195 | memset((void *)di, 0, sizeof(struct bfs_inode)); | 190 | memset(di, 0, sizeof(struct bfs_inode)); |
| 196 | mark_buffer_dirty(bh); | 191 | mark_buffer_dirty(bh); |
| 197 | brelse(bh); | 192 | brelse(bh); |
| 198 | 193 | ||
| @@ -214,7 +209,6 @@ static void bfs_delete_inode(struct inode *inode) | |||
| 214 | mark_buffer_dirty(info->si_sbh); | 209 | mark_buffer_dirty(info->si_sbh); |
| 215 | } | 210 | } |
| 216 | mutex_unlock(&info->bfs_lock); | 211 | mutex_unlock(&info->bfs_lock); |
| 217 | clear_inode(inode); | ||
| 218 | } | 212 | } |
| 219 | 213 | ||
| 220 | static int bfs_sync_fs(struct super_block *sb, int wait) | 214 | static int bfs_sync_fs(struct super_block *sb, int wait) |
| @@ -319,7 +313,7 @@ static const struct super_operations bfs_sops = { | |||
| 319 | .alloc_inode = bfs_alloc_inode, | 313 | .alloc_inode = bfs_alloc_inode, |
| 320 | .destroy_inode = bfs_destroy_inode, | 314 | .destroy_inode = bfs_destroy_inode, |
| 321 | .write_inode = bfs_write_inode, | 315 | .write_inode = bfs_write_inode, |
| 322 | .delete_inode = bfs_delete_inode, | 316 | .evict_inode = bfs_evict_inode, |
| 323 | .put_super = bfs_put_super, | 317 | .put_super = bfs_put_super, |
| 324 | .write_super = bfs_write_super, | 318 | .write_super = bfs_write_super, |
| 325 | .sync_fs = bfs_sync_fs, | 319 | .sync_fs = bfs_sync_fs, |
