diff options
Diffstat (limited to 'fs/nilfs2/ifile.c')
-rw-r--r-- | fs/nilfs2/ifile.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/fs/nilfs2/ifile.c b/fs/nilfs2/ifile.c index 922d9dd42c8f..9f8a2da67f90 100644 --- a/fs/nilfs2/ifile.c +++ b/fs/nilfs2/ifile.c | |||
@@ -161,25 +161,46 @@ int nilfs_ifile_get_inode_block(struct inode *ifile, ino_t ino, | |||
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * nilfs_ifile_new - create inode file | 164 | * nilfs_ifile_read - read or get ifile inode |
165 | * @sbi: nilfs_sb_info struct | 165 | * @sb: super block instance |
166 | * @root: root object | ||
166 | * @inode_size: size of an inode | 167 | * @inode_size: size of an inode |
168 | * @raw_inode: on-disk ifile inode | ||
169 | * @inodep: buffer to store the inode | ||
167 | */ | 170 | */ |
168 | struct inode *nilfs_ifile_new(struct nilfs_sb_info *sbi, size_t inode_size) | 171 | int nilfs_ifile_read(struct super_block *sb, struct nilfs_root *root, |
172 | size_t inode_size, struct nilfs_inode *raw_inode, | ||
173 | struct inode **inodep) | ||
169 | { | 174 | { |
170 | struct inode *ifile; | 175 | struct inode *ifile; |
171 | int err; | 176 | int err; |
172 | 177 | ||
173 | ifile = nilfs_mdt_new(sbi->s_nilfs, sbi->s_super, NILFS_IFILE_INO, | 178 | ifile = nilfs_iget_locked(sb, root, NILFS_IFILE_INO); |
174 | sizeof(struct nilfs_ifile_info)); | 179 | if (unlikely(!ifile)) |
175 | if (ifile) { | 180 | return -ENOMEM; |
176 | err = nilfs_palloc_init_blockgroup(ifile, inode_size); | 181 | if (!(ifile->i_state & I_NEW)) |
177 | if (unlikely(err)) { | 182 | goto out; |
178 | nilfs_mdt_destroy(ifile); | 183 | |
179 | return NULL; | 184 | err = nilfs_mdt_init(ifile, NILFS_MDT_GFP, |
180 | } | 185 | sizeof(struct nilfs_ifile_info)); |
181 | nilfs_palloc_setup_cache(ifile, | 186 | if (err) |
182 | &NILFS_IFILE_I(ifile)->palloc_cache); | 187 | goto failed; |
183 | } | 188 | |
184 | return ifile; | 189 | err = nilfs_palloc_init_blockgroup(ifile, inode_size); |
190 | if (err) | ||
191 | goto failed; | ||
192 | |||
193 | nilfs_palloc_setup_cache(ifile, &NILFS_IFILE_I(ifile)->palloc_cache); | ||
194 | |||
195 | err = nilfs_read_inode_common(ifile, raw_inode); | ||
196 | if (err) | ||
197 | goto failed; | ||
198 | |||
199 | unlock_new_inode(ifile); | ||
200 | out: | ||
201 | *inodep = ifile; | ||
202 | return 0; | ||
203 | failed: | ||
204 | iget_failed(ifile); | ||
205 | return err; | ||
185 | } | 206 | } |