vmscan: fix shrinker callback bug in fs/super.c
[linux-2.6.git] / fs / nilfs2 / ifile.c
index 922d9dd..684d763 100644 (file)
@@ -80,7 +80,7 @@ int nilfs_ifile_create_inode(struct inode *ifile, ino_t *out_ino,
                return ret;
        }
        nilfs_palloc_commit_alloc_entry(ifile, &req);
-       nilfs_mdt_mark_buffer_dirty(req.pr_entry_bh);
+       mark_buffer_dirty(req.pr_entry_bh);
        nilfs_mdt_mark_dirty(ifile);
        *out_ino = (ino_t)req.pr_entry_nr;
        *out_bh = req.pr_entry_bh;
@@ -128,7 +128,7 @@ int nilfs_ifile_delete_inode(struct inode *ifile, ino_t ino)
        raw_inode->i_flags = 0;
        kunmap_atomic(kaddr, KM_USER0);
 
-       nilfs_mdt_mark_buffer_dirty(req.pr_entry_bh);
+       mark_buffer_dirty(req.pr_entry_bh);
        brelse(req.pr_entry_bh);
 
        nilfs_palloc_commit_free_entry(ifile, &req);
@@ -149,37 +149,53 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
        }
 
        err = nilfs_palloc_get_entry_block(ifile, ino, 0, out_bh);
-       if (unlikely(err)) {
-               if (err == -EINVAL)
-                       nilfs_error(sb, __func__, "ifile is broken");
-               else
-                       nilfs_warning(sb, __func__,
-                                     "unable to read inode: %lu",
-                                     (unsigned long) ino);
-       }
+       if (unlikely(err))
+               nilfs_warning(sb, __func__, "unable to read inode: %lu",
+                             (unsigned long) ino);
        return err;
 }
 
 /**
- * nilfs_ifile_new - create inode file
- * @sbi: nilfs_sb_info struct
+ * nilfs_ifile_read - read or get ifile inode
+ * @sb: super block instance
+ * @root: root object
  * @inode_size: size of an inode
+ * @raw_inode: on-disk ifile inode
+ * @inodep: buffer to store the inode
  */
-struct inode *nilfs_ifile_new(struct nilfs_sb_info *sbi, size_t inode_size)
+int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root,
+                    size_t inode_size, struct nilfs_inode *raw_inode,
+                    struct inode **inodep)
 {
        struct inode *ifile;
        int err;
 
-       ifile = nilfs_mdt_new(sbi->s_nilfs, sbi->s_super, NILFS_IFILE_INO,
-                             sizeof(struct nilfs_ifile_info));
-       if (ifile) {
-               err = nilfs_palloc_init_blockgroup(ifile, inode_size);
-               if (unlikely(err)) {
-                       nilfs_mdt_destroy(ifile);
-                       return NULL;
-               }
-               nilfs_palloc_setup_cache(ifile,
-                                        &NILFS_IFILE_I(ifile)->palloc_cache);
-       }
-       return ifile;
+       ifile = nilfs_iget_locked(sb, root, NILFS_IFILE_INO);
+       if (unlikely(!ifile))
+               return -ENOMEM;
+       if (!(ifile->i_state & I_NEW))
+               goto out;
+
+       err = nilfs_mdt_init(ifile, NILFS_MDT_GFP,
+                            sizeof(struct nilfs_ifile_info));
+       if (err)
+               goto failed;
+
+       err = nilfs_palloc_init_blockgroup(ifile, inode_size);
+       if (err)
+               goto failed;
+
+       nilfs_palloc_setup_cache(ifile, &NILFS_IFILE_I(ifile)->palloc_cache);
+
+       err = nilfs_read_inode_common(ifile, raw_inode);
+       if (err)
+               goto failed;
+
+       unlock_new_inode(ifile);
+ out:
+       *inodep = ifile;
+       return 0;
+ failed:
+       iget_failed(ifile);
+       return err;
 }