diff options
Diffstat (limited to 'fs/logfs/inode.c')
-rw-r--r-- | fs/logfs/inode.c | 66 |
1 files changed, 23 insertions, 43 deletions
diff --git a/fs/logfs/inode.c b/fs/logfs/inode.c index 14ed27274da2..d8c71ece098f 100644 --- a/fs/logfs/inode.c +++ b/fs/logfs/inode.c | |||
@@ -193,6 +193,7 @@ static void logfs_init_inode(struct super_block *sb, struct inode *inode) | |||
193 | inode->i_ctime = CURRENT_TIME; | 193 | inode->i_ctime = CURRENT_TIME; |
194 | inode->i_mtime = CURRENT_TIME; | 194 | inode->i_mtime = CURRENT_TIME; |
195 | inode->i_nlink = 1; | 195 | inode->i_nlink = 1; |
196 | li->li_refcount = 1; | ||
196 | INIT_LIST_HEAD(&li->li_freeing_list); | 197 | INIT_LIST_HEAD(&li->li_freeing_list); |
197 | 198 | ||
198 | for (i = 0; i < LOGFS_EMBEDDED_FIELDS; i++) | 199 | for (i = 0; i < LOGFS_EMBEDDED_FIELDS; i++) |
@@ -234,33 +235,21 @@ static struct inode *logfs_alloc_inode(struct super_block *sb) | |||
234 | * purpose is to create a new inode that will not trigger the warning if such | 235 | * purpose is to create a new inode that will not trigger the warning if such |
235 | * an inode is still in use. An ugly hack, no doubt. Suggections for | 236 | * an inode is still in use. An ugly hack, no doubt. Suggections for |
236 | * improvement are welcome. | 237 | * improvement are welcome. |
238 | * | ||
239 | * AV: that's what ->put_super() is for... | ||
237 | */ | 240 | */ |
238 | struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino) | 241 | struct inode *logfs_new_meta_inode(struct super_block *sb, u64 ino) |
239 | { | 242 | { |
240 | struct inode *inode; | 243 | struct inode *inode; |
241 | 244 | ||
242 | inode = logfs_alloc_inode(sb); | 245 | inode = new_inode(sb); |
243 | if (!inode) | 246 | if (!inode) |
244 | return ERR_PTR(-ENOMEM); | 247 | return ERR_PTR(-ENOMEM); |
245 | 248 | ||
246 | inode->i_mode = S_IFREG; | 249 | inode->i_mode = S_IFREG; |
247 | inode->i_ino = ino; | 250 | inode->i_ino = ino; |
248 | inode->i_sb = sb; | 251 | inode->i_data.a_ops = &logfs_reg_aops; |
249 | 252 | mapping_set_gfp_mask(&inode->i_data, GFP_NOFS); | |
250 | /* This is a blatant copy of alloc_inode code. We'd need alloc_inode | ||
251 | * to be nonstatic, alas. */ | ||
252 | { | ||
253 | struct address_space * const mapping = &inode->i_data; | ||
254 | |||
255 | mapping->a_ops = &logfs_reg_aops; | ||
256 | mapping->host = inode; | ||
257 | mapping->flags = 0; | ||
258 | mapping_set_gfp_mask(mapping, GFP_NOFS); | ||
259 | mapping->assoc_mapping = NULL; | ||
260 | mapping->backing_dev_info = &default_backing_dev_info; | ||
261 | inode->i_mapping = mapping; | ||
262 | inode->i_nlink = 1; | ||
263 | } | ||
264 | 253 | ||
265 | return inode; | 254 | return inode; |
266 | } | 255 | } |
@@ -276,7 +265,7 @@ struct inode *logfs_read_meta_inode(struct super_block *sb, u64 ino) | |||
276 | 265 | ||
277 | err = logfs_read_inode(inode); | 266 | err = logfs_read_inode(inode); |
278 | if (err) { | 267 | if (err) { |
279 | destroy_meta_inode(inode); | 268 | iput(inode); |
280 | return ERR_PTR(err); | 269 | return ERR_PTR(err); |
281 | } | 270 | } |
282 | logfs_inode_setops(inode); | 271 | logfs_inode_setops(inode); |
@@ -297,18 +286,8 @@ static int logfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
297 | return ret; | 286 | return ret; |
298 | } | 287 | } |
299 | 288 | ||
300 | void destroy_meta_inode(struct inode *inode) | ||
301 | { | ||
302 | if (inode) { | ||
303 | if (inode->i_data.nrpages) | ||
304 | truncate_inode_pages(&inode->i_data, 0); | ||
305 | logfs_clear_inode(inode); | ||
306 | kmem_cache_free(logfs_inode_cache, logfs_inode(inode)); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | /* called with inode_lock held */ | 289 | /* called with inode_lock held */ |
311 | static void logfs_drop_inode(struct inode *inode) | 290 | static int logfs_drop_inode(struct inode *inode) |
312 | { | 291 | { |
313 | struct logfs_super *super = logfs_super(inode->i_sb); | 292 | struct logfs_super *super = logfs_super(inode->i_sb); |
314 | struct logfs_inode *li = logfs_inode(inode); | 293 | struct logfs_inode *li = logfs_inode(inode); |
@@ -316,7 +295,7 @@ static void logfs_drop_inode(struct inode *inode) | |||
316 | spin_lock(&logfs_inode_lock); | 295 | spin_lock(&logfs_inode_lock); |
317 | list_move(&li->li_freeing_list, &super->s_freeing_list); | 296 | list_move(&li->li_freeing_list, &super->s_freeing_list); |
318 | spin_unlock(&logfs_inode_lock); | 297 | spin_unlock(&logfs_inode_lock); |
319 | generic_drop_inode(inode); | 298 | return generic_drop_inode(inode); |
320 | } | 299 | } |
321 | 300 | ||
322 | static void logfs_set_ino_generation(struct super_block *sb, | 301 | static void logfs_set_ino_generation(struct super_block *sb, |
@@ -326,7 +305,7 @@ static void logfs_set_ino_generation(struct super_block *sb, | |||
326 | u64 ino; | 305 | u64 ino; |
327 | 306 | ||
328 | mutex_lock(&super->s_journal_mutex); | 307 | mutex_lock(&super->s_journal_mutex); |
329 | ino = logfs_seek_hole(super->s_master_inode, super->s_last_ino); | 308 | ino = logfs_seek_hole(super->s_master_inode, super->s_last_ino + 1); |
330 | super->s_last_ino = ino; | 309 | super->s_last_ino = ino; |
331 | super->s_inos_till_wrap--; | 310 | super->s_inos_till_wrap--; |
332 | if (super->s_inos_till_wrap < 0) { | 311 | if (super->s_inos_till_wrap < 0) { |
@@ -357,14 +336,7 @@ struct inode *logfs_new_inode(struct inode *dir, int mode) | |||
357 | inode->i_mode = mode; | 336 | inode->i_mode = mode; |
358 | logfs_set_ino_generation(sb, inode); | 337 | logfs_set_ino_generation(sb, inode); |
359 | 338 | ||
360 | inode->i_uid = current_fsuid(); | 339 | inode_init_owner(inode, dir, mode); |
361 | inode->i_gid = current_fsgid(); | ||
362 | if (dir->i_mode & S_ISGID) { | ||
363 | inode->i_gid = dir->i_gid; | ||
364 | if (S_ISDIR(mode)) | ||
365 | inode->i_mode |= S_ISGID; | ||
366 | } | ||
367 | |||
368 | logfs_inode_setops(inode); | 340 | logfs_inode_setops(inode); |
369 | insert_inode_hash(inode); | 341 | insert_inode_hash(inode); |
370 | 342 | ||
@@ -386,17 +358,25 @@ static void logfs_init_once(void *_li) | |||
386 | 358 | ||
387 | static int logfs_sync_fs(struct super_block *sb, int wait) | 359 | static int logfs_sync_fs(struct super_block *sb, int wait) |
388 | { | 360 | { |
389 | /* FIXME: write anchor */ | 361 | logfs_write_anchor(sb); |
390 | logfs_super(sb)->s_devops->sync(sb); | ||
391 | return 0; | 362 | return 0; |
392 | } | 363 | } |
393 | 364 | ||
365 | static void logfs_put_super(struct super_block *sb) | ||
366 | { | ||
367 | struct logfs_super *super = logfs_super(sb); | ||
368 | /* kill the meta-inodes */ | ||
369 | iput(super->s_master_inode); | ||
370 | iput(super->s_segfile_inode); | ||
371 | iput(super->s_mapping_inode); | ||
372 | } | ||
373 | |||
394 | const struct super_operations logfs_super_operations = { | 374 | const struct super_operations logfs_super_operations = { |
395 | .alloc_inode = logfs_alloc_inode, | 375 | .alloc_inode = logfs_alloc_inode, |
396 | .clear_inode = logfs_clear_inode, | ||
397 | .delete_inode = logfs_delete_inode, | ||
398 | .destroy_inode = logfs_destroy_inode, | 376 | .destroy_inode = logfs_destroy_inode, |
377 | .evict_inode = logfs_evict_inode, | ||
399 | .drop_inode = logfs_drop_inode, | 378 | .drop_inode = logfs_drop_inode, |
379 | .put_super = logfs_put_super, | ||
400 | .write_inode = logfs_write_inode, | 380 | .write_inode = logfs_write_inode, |
401 | .statfs = logfs_statfs, | 381 | .statfs = logfs_statfs, |
402 | .sync_fs = logfs_sync_fs, | 382 | .sync_fs = logfs_sync_fs, |