aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-11-01 14:04:17 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-11-30 10:34:20 -0500
commit4f56110a00af5fb2e22fbccfcaf944d62cae8fcf (patch)
tree764e9b9e6b48637f6b3339496fa11e7047c37899 /fs/gfs2/inode.c
parent2933f9254a6af33db25270778c998a42029da668 (diff)
[GFS2] Shrink gfs2_inode (5) - di_nlink
Remove the di_nlink field in favour of inode->i_nlink and update the nlink handling to use the proper macros. This saves 4 bytes. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 0de9b22f454b..711203984823 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -51,7 +51,6 @@ void gfs2_inode_attr_in(struct gfs2_inode *ip)
51 struct gfs2_dinode_host *di = &ip->i_di; 51 struct gfs2_dinode_host *di = &ip->i_di;
52 52
53 inode->i_ino = ip->i_num.no_addr; 53 inode->i_ino = ip->i_num.no_addr;
54 inode->i_nlink = di->di_nlink;
55 i_size_write(inode, di->di_size); 54 i_size_write(inode, di->di_size);
56 inode->i_atime.tv_sec = di->di_atime; 55 inode->i_atime.tv_sec = di->di_atime;
57 inode->i_mtime.tv_sec = di->di_mtime; 56 inode->i_mtime.tv_sec = di->di_mtime;
@@ -214,7 +213,12 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
214 213
215 ip->i_inode.i_uid = be32_to_cpu(str->di_uid); 214 ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
216 ip->i_inode.i_gid = be32_to_cpu(str->di_gid); 215 ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
217 di->di_nlink = be32_to_cpu(str->di_nlink); 216 /*
217 * We will need to review setting the nlink count here in the
218 * light of the forthcoming ro bind mount work. This is a reminder
219 * to do that.
220 */
221 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
218 di->di_size = be64_to_cpu(str->di_size); 222 di->di_size = be64_to_cpu(str->di_size);
219 di->di_blocks = be64_to_cpu(str->di_blocks); 223 di->di_blocks = be64_to_cpu(str->di_blocks);
220 di->di_atime = be64_to_cpu(str->di_atime); 224 di->di_atime = be64_to_cpu(str->di_atime);
@@ -336,12 +340,12 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
336 u32 nlink; 340 u32 nlink;
337 int error; 341 int error;
338 342
339 BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink); 343 BUG_ON(diff != 1 && diff != -1);
340 nlink = ip->i_di.di_nlink + diff; 344 nlink = ip->i_inode.i_nlink + diff;
341 345
342 /* If we are reducing the nlink count, but the new value ends up being 346 /* If we are reducing the nlink count, but the new value ends up being
343 bigger than the old one, we must have underflowed. */ 347 bigger than the old one, we must have underflowed. */
344 if (diff < 0 && nlink > ip->i_di.di_nlink) { 348 if (diff < 0 && nlink > ip->i_inode.i_nlink) {
345 if (gfs2_consist_inode(ip)) 349 if (gfs2_consist_inode(ip))
346 gfs2_dinode_print(ip); 350 gfs2_dinode_print(ip);
347 return -EIO; 351 return -EIO;
@@ -351,16 +355,19 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
351 if (error) 355 if (error)
352 return error; 356 return error;
353 357
354 ip->i_di.di_nlink = nlink; 358 if (diff > 0)
359 inc_nlink(&ip->i_inode);
360 else
361 drop_nlink(&ip->i_inode);
362
355 ip->i_di.di_ctime = get_seconds(); 363 ip->i_di.di_ctime = get_seconds();
356 ip->i_inode.i_nlink = nlink;
357 364
358 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 365 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
359 gfs2_dinode_out(ip, dibh->b_data); 366 gfs2_dinode_out(ip, dibh->b_data);
360 brelse(dibh); 367 brelse(dibh);
361 mark_inode_dirty(&ip->i_inode); 368 mark_inode_dirty(&ip->i_inode);
362 369
363 if (ip->i_di.di_nlink == 0) { 370 if (ip->i_inode.i_nlink == 0) {
364 struct gfs2_rgrpd *rgd; 371 struct gfs2_rgrpd *rgd;
365 struct gfs2_holder ri_gh, rg_gh; 372 struct gfs2_holder ri_gh, rg_gh;
366 373
@@ -375,7 +382,6 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
375 if (error) 382 if (error)
376 goto out_norgrp; 383 goto out_norgrp;
377 384
378 clear_nlink(&ip->i_inode);
379 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ 385 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
380 gfs2_glock_dq_uninit(&rg_gh); 386 gfs2_glock_dq_uninit(&rg_gh);
381out_norgrp: 387out_norgrp:
@@ -586,7 +592,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
586 return error; 592 return error;
587 593
588 /* Don't create entries in an unlinked directory */ 594 /* Don't create entries in an unlinked directory */
589 if (!dip->i_di.di_nlink) 595 if (!dip->i_inode.i_nlink)
590 return -EPERM; 596 return -EPERM;
591 597
592 error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL); 598 error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL);
@@ -602,7 +608,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
602 608
603 if (dip->i_di.di_entries == (u32)-1) 609 if (dip->i_di.di_entries == (u32)-1)
604 return -EFBIG; 610 return -EFBIG;
605 if (S_ISDIR(mode) && dip->i_di.di_nlink == (u32)-1) 611 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
606 return -EMLINK; 612 return -EMLINK;
607 613
608 return 0; 614 return 0;
@@ -808,7 +814,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
808 error = gfs2_meta_inode_buffer(ip, &dibh); 814 error = gfs2_meta_inode_buffer(ip, &dibh);
809 if (error) 815 if (error)
810 goto fail_end_trans; 816 goto fail_end_trans;
811 ip->i_di.di_nlink = 1; 817 ip->i_inode.i_nlink = 1;
812 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 818 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
813 gfs2_dinode_out(ip, dibh->b_data); 819 gfs2_dinode_out(ip, dibh->b_data);
814 brelse(dibh); 820 brelse(dibh);
@@ -1016,7 +1022,12 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
1016 if (error) 1022 if (error)
1017 return error; 1023 return error;
1018 1024
1019 error = gfs2_change_nlink(ip, -2); 1025 /* It looks odd, but it really should be done twice */
1026 error = gfs2_change_nlink(ip, -1);
1027 if (error)
1028 return error;
1029
1030 error = gfs2_change_nlink(ip, -1);
1020 if (error) 1031 if (error)
1021 return error; 1032 return error;
1022 1033