aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/ifile.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/ifile.c')
-rw-r--r--fs/nilfs2/ifile.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c
index 922d9dd42c8f..684d76300a80 100644
--- a/fs/nilfs2/ifile.c
+++ b/fs/nilfs2/ifile.c
@@ -80,7 +80,7 @@ int nilfs_ifile_create_inode(struct inode *ifile, ino_t *out_ino,
80 return ret; 80 return ret;
81 } 81 }
82 nilfs_palloc_commit_alloc_entry(ifile, &req); 82 nilfs_palloc_commit_alloc_entry(ifile, &req);
83 nilfs_mdt_mark_buffer_dirty(req.pr_entry_bh); 83 mark_buffer_dirty(req.pr_entry_bh);
84 nilfs_mdt_mark_dirty(ifile); 84 nilfs_mdt_mark_dirty(ifile);
85 *out_ino = (ino_t)req.pr_entry_nr; 85 *out_ino = (ino_t)req.pr_entry_nr;
86 *out_bh = req.pr_entry_bh; 86 *out_bh = req.pr_entry_bh;
@@ -128,7 +128,7 @@ int nilfs_ifile_delete_inode(struct inode *ifile, ino_t ino)
128 raw_inode->i_flags = 0; 128 raw_inode->i_flags = 0;
129 kunmap_atomic(kaddr, KM_USER0); 129 kunmap_atomic(kaddr, KM_USER0);
130 130
131 nilfs_mdt_mark_buffer_dirty(req.pr_entry_bh); 131 mark_buffer_dirty(req.pr_entry_bh);
132 brelse(req.pr_entry_bh); 132 brelse(req.pr_entry_bh);
133 133
134 nilfs_palloc_commit_free_entry(ifile, &req); 134 nilfs_palloc_commit_free_entry(ifile, &req);
@@ -149,37 +149,53 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino,
149 } 149 }
150 150
151 err = nilfs_palloc_get_entry_block(ifile, ino, 0, out_bh); 151 err = nilfs_palloc_get_entry_block(ifile, ino, 0, out_bh);
152 if (unlikely(err)) { 152 if (unlikely(err))
153 if (err == -EINVAL) 153 nilfs_warning(sb, __func__, "unable to read inode: %lu",
154 nilfs_error(sb, __func__, "ifile is broken"); 154 (unsigned long) ino);
155 else
156 nilfs_warning(sb, __func__,
157 "unable to read inode: %lu",
158 (unsigned long) ino);
159 }
160 return err; 155 return err;
161} 156}
162 157
163/** 158/**
164 * nilfs_ifile_new - create inode file 159 * nilfs_ifile_read - read or get ifile inode
165 * @sbi: nilfs_sb_info struct 160 * @sb: super block instance
161 * @root: root object
166 * @inode_size: size of an inode 162 * @inode_size: size of an inode
163 * @raw_inode: on-disk ifile inode
164 * @inodep: buffer to store the inode
167 */ 165 */
168struct inode *nilfs_ifile_new(struct nilfs_sb_info *sbi, size_t inode_size) 166int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root,
167 size_t inode_size, struct nilfs_inode *raw_inode,
168 struct inode **inodep)
169{ 169{
170 struct inode *ifile; 170 struct inode *ifile;
171 int err; 171 int err;
172 172
173 ifile = nilfs_mdt_new(sbi->s_nilfs, sbi->s_super, NILFS_IFILE_INO, 173 ifile = nilfs_iget_locked(sb, root, NILFS_IFILE_INO);
174 sizeof(struct nilfs_ifile_info)); 174 if (unlikely(!ifile))
175 if (ifile) { 175 return -ENOMEM;
176 err = nilfs_palloc_init_blockgroup(ifile, inode_size); 176 if (!(ifile->i_state & I_NEW))
177 if (unlikely(err)) { 177 goto out;
178 nilfs_mdt_destroy(ifile); 178
179 return NULL; 179 err = nilfs_mdt_init(ifile, NILFS_MDT_GFP,
180 } 180 sizeof(struct nilfs_ifile_info));
181 nilfs_palloc_setup_cache(ifile, 181 if (err)
182 &NILFS_IFILE_I(ifile)->palloc_cache); 182 goto failed;
183 } 183
184 return ifile; 184 err = nilfs_palloc_init_blockgroup(ifile, inode_size);
185 if (err)
186 goto failed;
187
188 nilfs_palloc_setup_cache(ifile, &NILFS_IFILE_I(ifile)->palloc_cache);
189
190 err = nilfs_read_inode_common(ifile, raw_inode);
191 if (err)
192 goto failed;
193
194 unlock_new_inode(ifile);
195 out:
196 *inodep = ifile;
197 return 0;
198 failed:
199 iget_failed(ifile);
200 return err;
185} 201}