diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2011-05-09 08:49:59 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2011-05-09 11:44:49 -0400 |
commit | d4b2cf1b0566eebfe39a6d70e9e4b5fa01ddaace (patch) | |
tree | 2f682adea3ac272ea865335ee3449c056a96f088 /fs/gfs2/glops.c | |
parent | 94fb763b1a76a2000ad21f3119b05c90040acaf0 (diff) |
GFS2: Move gfs2_refresh_inode() and friends into glops.c
Eventually there will only be a single caller of this code, so lets
move it where it can be made static at some future date.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/glops.c')
-rw-r--r-- | fs/gfs2/glops.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 7c1b08f63ddb..8ef70f464731 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c | |||
@@ -252,6 +252,119 @@ static int inode_go_demote_ok(const struct gfs2_glock *gl) | |||
252 | } | 252 | } |
253 | 253 | ||
254 | /** | 254 | /** |
255 | * gfs2_set_nlink - Set the inode's link count based on on-disk info | ||
256 | * @inode: The inode in question | ||
257 | * @nlink: The link count | ||
258 | * | ||
259 | * If the link count has hit zero, it must never be raised, whatever the | ||
260 | * on-disk inode might say. When new struct inodes are created the link | ||
261 | * count is set to 1, so that we can safely use this test even when reading | ||
262 | * in on disk information for the first time. | ||
263 | */ | ||
264 | |||
265 | static void gfs2_set_nlink(struct inode *inode, u32 nlink) | ||
266 | { | ||
267 | /* | ||
268 | * We will need to review setting the nlink count here in the | ||
269 | * light of the forthcoming ro bind mount work. This is a reminder | ||
270 | * to do that. | ||
271 | */ | ||
272 | if ((inode->i_nlink != nlink) && (inode->i_nlink != 0)) { | ||
273 | if (nlink == 0) | ||
274 | clear_nlink(inode); | ||
275 | else | ||
276 | inode->i_nlink = nlink; | ||
277 | } | ||
278 | } | ||
279 | |||
280 | static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) | ||
281 | { | ||
282 | const struct gfs2_dinode *str = buf; | ||
283 | struct timespec atime; | ||
284 | u16 height, depth; | ||
285 | |||
286 | if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr))) | ||
287 | goto corrupt; | ||
288 | ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino); | ||
289 | ip->i_inode.i_mode = be32_to_cpu(str->di_mode); | ||
290 | ip->i_inode.i_rdev = 0; | ||
291 | switch (ip->i_inode.i_mode & S_IFMT) { | ||
292 | case S_IFBLK: | ||
293 | case S_IFCHR: | ||
294 | ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major), | ||
295 | be32_to_cpu(str->di_minor)); | ||
296 | break; | ||
297 | }; | ||
298 | |||
299 | ip->i_inode.i_uid = be32_to_cpu(str->di_uid); | ||
300 | ip->i_inode.i_gid = be32_to_cpu(str->di_gid); | ||
301 | gfs2_set_nlink(&ip->i_inode, be32_to_cpu(str->di_nlink)); | ||
302 | i_size_write(&ip->i_inode, be64_to_cpu(str->di_size)); | ||
303 | gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks)); | ||
304 | atime.tv_sec = be64_to_cpu(str->di_atime); | ||
305 | atime.tv_nsec = be32_to_cpu(str->di_atime_nsec); | ||
306 | if (timespec_compare(&ip->i_inode.i_atime, &atime) < 0) | ||
307 | ip->i_inode.i_atime = atime; | ||
308 | ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); | ||
309 | ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec); | ||
310 | ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime); | ||
311 | ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec); | ||
312 | |||
313 | ip->i_goal = be64_to_cpu(str->di_goal_meta); | ||
314 | ip->i_generation = be64_to_cpu(str->di_generation); | ||
315 | |||
316 | ip->i_diskflags = be32_to_cpu(str->di_flags); | ||
317 | gfs2_set_inode_flags(&ip->i_inode); | ||
318 | height = be16_to_cpu(str->di_height); | ||
319 | if (unlikely(height > GFS2_MAX_META_HEIGHT)) | ||
320 | goto corrupt; | ||
321 | ip->i_height = (u8)height; | ||
322 | |||
323 | depth = be16_to_cpu(str->di_depth); | ||
324 | if (unlikely(depth > GFS2_DIR_MAX_DEPTH)) | ||
325 | goto corrupt; | ||
326 | ip->i_depth = (u8)depth; | ||
327 | ip->i_entries = be32_to_cpu(str->di_entries); | ||
328 | |||
329 | ip->i_eattr = be64_to_cpu(str->di_eattr); | ||
330 | if (S_ISREG(ip->i_inode.i_mode)) | ||
331 | gfs2_set_aops(&ip->i_inode); | ||
332 | |||
333 | return 0; | ||
334 | corrupt: | ||
335 | gfs2_consist_inode(ip); | ||
336 | return -EIO; | ||
337 | } | ||
338 | |||
339 | /** | ||
340 | * gfs2_inode_refresh - Refresh the incore copy of the dinode | ||
341 | * @ip: The GFS2 inode | ||
342 | * | ||
343 | * Returns: errno | ||
344 | */ | ||
345 | |||
346 | int gfs2_inode_refresh(struct gfs2_inode *ip) | ||
347 | { | ||
348 | struct buffer_head *dibh; | ||
349 | int error; | ||
350 | |||
351 | error = gfs2_meta_inode_buffer(ip, &dibh); | ||
352 | if (error) | ||
353 | return error; | ||
354 | |||
355 | if (gfs2_metatype_check(GFS2_SB(&ip->i_inode), dibh, GFS2_METATYPE_DI)) { | ||
356 | brelse(dibh); | ||
357 | return -EIO; | ||
358 | } | ||
359 | |||
360 | error = gfs2_dinode_in(ip, dibh->b_data); | ||
361 | brelse(dibh); | ||
362 | clear_bit(GIF_INVALID, &ip->i_flags); | ||
363 | |||
364 | return error; | ||
365 | } | ||
366 | |||
367 | /** | ||
255 | * inode_go_lock - operation done after an inode lock is locked by a process | 368 | * inode_go_lock - operation done after an inode lock is locked by a process |
256 | * @gl: the glock | 369 | * @gl: the glock |
257 | * @flags: | 370 | * @flags: |