aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-11-08 15:45:46 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2006-11-30 10:34:52 -0500
commit9e2dbdac3df300516ffdd9a8631f23164d068a50 (patch)
tree088a7dce1a0cc678a80ca1609642e7e3ecacd4dd
parente7c698d74fc9e0e76b3086062b0519df3601ff52 (diff)
[GFS2] Remove gfs2_inode_attr_in
This function wasn't really doing the right thing. There was no need to update the inode size at this point and the updating of the i_blocks field has now been moved to the places where di_blocks is updated. A result of this patch and some those preceeding it is that unlocking a glock is now a much more efficient process, since there is no longer any requirement to copy data from the gfs2 inode into the vfs inode at this point. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/bmap.c4
-rw-r--r--fs/gfs2/dir.c4
-rw-r--r--fs/gfs2/eattr.c6
-rw-r--r--fs/gfs2/glops.c8
-rw-r--r--fs/gfs2/inode.c21
-rw-r--r--fs/gfs2/inode.h7
6 files changed, 26 insertions, 24 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 692d4a3da1bc..06e3447ea132 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -163,6 +163,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
163 if (ip->i_di.di_size) { 163 if (ip->i_di.di_size) {
164 *(__be64 *)(di + 1) = cpu_to_be64(block); 164 *(__be64 *)(di + 1) = cpu_to_be64(block);
165 ip->i_di.di_blocks++; 165 ip->i_di.di_blocks++;
166 gfs2_set_inode_blocks(&ip->i_inode);
166 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); 167 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
167 } 168 }
168 169
@@ -272,6 +273,7 @@ static int build_height(struct inode *inode, unsigned height)
272 *(__be64 *)(di + 1) = cpu_to_be64(bn); 273 *(__be64 *)(di + 1) = cpu_to_be64(bn);
273 ip->i_di.di_height += new_height; 274 ip->i_di.di_height += new_height;
274 ip->i_di.di_blocks += new_height; 275 ip->i_di.di_blocks += new_height;
276 gfs2_set_inode_blocks(&ip->i_inode);
275 di->di_height = cpu_to_be16(ip->i_di.di_height); 277 di->di_height = cpu_to_be16(ip->i_di.di_height);
276 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); 278 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
277 brelse(dibh); 279 brelse(dibh);
@@ -415,6 +417,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
415 417
416 *ptr = cpu_to_be64(*block); 418 *ptr = cpu_to_be64(*block);
417 ip->i_di.di_blocks++; 419 ip->i_di.di_blocks++;
420 gfs2_set_inode_blocks(&ip->i_inode);
418 421
419 *new = 1; 422 *new = 1;
420 return 0; 423 return 0;
@@ -770,6 +773,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
770 if (!ip->i_di.di_blocks) 773 if (!ip->i_di.di_blocks)
771 gfs2_consist_inode(ip); 774 gfs2_consist_inode(ip);
772 ip->i_di.di_blocks--; 775 ip->i_di.di_blocks--;
776 gfs2_set_inode_blocks(&ip->i_inode);
773 } 777 }
774 if (bstart) { 778 if (bstart) {
775 if (metadata) 779 if (metadata)
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index c82d7cb4a654..a2923fb91bba 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -901,6 +901,7 @@ static int dir_make_exhash(struct inode *inode)
901 901
902 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2; 902 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2;
903 dip->i_di.di_blocks++; 903 dip->i_di.di_blocks++;
904 gfs2_set_inode_blocks(&dip->i_inode);
904 dip->i_di.di_flags |= GFS2_DIF_EXHASH; 905 dip->i_di.di_flags |= GFS2_DIF_EXHASH;
905 906
906 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ; 907 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
@@ -1038,6 +1039,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1038 error = gfs2_meta_inode_buffer(dip, &dibh); 1039 error = gfs2_meta_inode_buffer(dip, &dibh);
1039 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) { 1040 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) {
1040 dip->i_di.di_blocks++; 1041 dip->i_di.di_blocks++;
1042 gfs2_set_inode_blocks(&dip->i_inode);
1041 gfs2_dinode_out(dip, dibh->b_data); 1043 gfs2_dinode_out(dip, dibh->b_data);
1042 brelse(dibh); 1044 brelse(dibh);
1043 } 1045 }
@@ -1516,6 +1518,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1516 return error; 1518 return error;
1517 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1519 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1518 ip->i_di.di_blocks++; 1520 ip->i_di.di_blocks++;
1521 gfs2_set_inode_blocks(&ip->i_inode);
1519 gfs2_dinode_out(ip, bh->b_data); 1522 gfs2_dinode_out(ip, bh->b_data);
1520 brelse(bh); 1523 brelse(bh);
1521 return 0; 1524 return 0;
@@ -1860,6 +1863,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1860 if (!dip->i_di.di_blocks) 1863 if (!dip->i_di.di_blocks)
1861 gfs2_consist_inode(dip); 1864 gfs2_consist_inode(dip);
1862 dip->i_di.di_blocks--; 1865 dip->i_di.di_blocks--;
1866 gfs2_set_inode_blocks(&dip->i_inode);
1863 } 1867 }
1864 1868
1865 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size); 1869 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size);
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c
index 7dde84775ba7..ebebbdcd7057 100644
--- a/fs/gfs2/eattr.c
+++ b/fs/gfs2/eattr.c
@@ -281,6 +281,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
281 if (!ip->i_di.di_blocks) 281 if (!ip->i_di.di_blocks)
282 gfs2_consist_inode(ip); 282 gfs2_consist_inode(ip);
283 ip->i_di.di_blocks--; 283 ip->i_di.di_blocks--;
284 gfs2_set_inode_blocks(&ip->i_inode);
284 } 285 }
285 if (bstart) 286 if (bstart)
286 gfs2_free_meta(ip, bstart, blen); 287 gfs2_free_meta(ip, bstart, blen);
@@ -598,6 +599,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
598 ea->ea_num_ptrs = 0; 599 ea->ea_num_ptrs = 0;
599 600
600 ip->i_di.di_blocks++; 601 ip->i_di.di_blocks++;
602 gfs2_set_inode_blocks(&ip->i_inode);
601 603
602 return 0; 604 return 0;
603} 605}
@@ -649,6 +651,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
649 gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED); 651 gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED);
650 652
651 ip->i_di.di_blocks++; 653 ip->i_di.di_blocks++;
654 gfs2_set_inode_blocks(&ip->i_inode);
652 655
653 copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize : 656 copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize :
654 data_len; 657 data_len;
@@ -977,6 +980,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
977 ip->i_di.di_eattr = blk; 980 ip->i_di.di_eattr = blk;
978 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT; 981 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
979 ip->i_di.di_blocks++; 982 ip->i_di.di_blocks++;
983 gfs2_set_inode_blocks(&ip->i_inode);
980 984
981 eablk++; 985 eablk++;
982 } 986 }
@@ -1387,6 +1391,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1387 if (!ip->i_di.di_blocks) 1391 if (!ip->i_di.di_blocks)
1388 gfs2_consist_inode(ip); 1392 gfs2_consist_inode(ip);
1389 ip->i_di.di_blocks--; 1393 ip->i_di.di_blocks--;
1394 gfs2_set_inode_blocks(&ip->i_inode);
1390 } 1395 }
1391 if (bstart) 1396 if (bstart)
1392 gfs2_free_meta(ip, bstart, blen); 1397 gfs2_free_meta(ip, bstart, blen);
@@ -1441,6 +1446,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1441 if (!ip->i_di.di_blocks) 1446 if (!ip->i_di.di_blocks)
1442 gfs2_consist_inode(ip); 1447 gfs2_consist_inode(ip);
1443 ip->i_di.di_blocks--; 1448 ip->i_di.di_blocks--;
1449 gfs2_set_inode_blocks(&ip->i_inode);
1444 1450
1445 error = gfs2_meta_inode_buffer(ip, &dibh); 1451 error = gfs2_meta_inode_buffer(ip, &dibh);
1446 if (!error) { 1452 if (!error) {
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 9c2033714b08..b92de0af0bf3 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -356,7 +356,6 @@ static int inode_go_lock(struct gfs2_holder *gh)
356 error = gfs2_inode_refresh(ip); 356 error = gfs2_inode_refresh(ip);
357 if (error) 357 if (error)
358 return error; 358 return error;
359 gfs2_inode_attr_in(ip);
360 } 359 }
361 360
362 if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) && 361 if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) &&
@@ -380,11 +379,8 @@ static void inode_go_unlock(struct gfs2_holder *gh)
380 struct gfs2_glock *gl = gh->gh_gl; 379 struct gfs2_glock *gl = gh->gh_gl;
381 struct gfs2_inode *ip = gl->gl_object; 380 struct gfs2_inode *ip = gl->gl_object;
382 381
383 if (ip == NULL) 382 if (ip)
384 return; 383 gfs2_meta_cache_flush(ip);
385 if (test_bit(GLF_DIRTY, &gl->gl_flags))
386 gfs2_inode_attr_in(ip);
387 gfs2_meta_cache_flush(ip);
388} 384}
389 385
390/** 386/**
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 19b2736cd52f..ea9ca239c878 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -38,29 +38,12 @@
38#include "trans.h" 38#include "trans.h"
39#include "util.h" 39#include "util.h"
40 40
41/**
42 * gfs2_inode_attr_in - Copy attributes from the dinode into the VFS inode
43 * @ip: The GFS2 inode (with embedded disk inode data)
44 * @inode: The Linux VFS inode
45 *
46 */
47
48void gfs2_inode_attr_in(struct gfs2_inode *ip)
49{
50 struct inode *inode = &ip->i_inode;
51 struct gfs2_dinode_host *di = &ip->i_di;
52
53 i_size_write(inode, di->di_size);
54 inode->i_blocks = di->di_blocks <<
55 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
56}
57
58static int iget_test(struct inode *inode, void *opaque) 41static int iget_test(struct inode *inode, void *opaque)
59{ 42{
60 struct gfs2_inode *ip = GFS2_I(inode); 43 struct gfs2_inode *ip = GFS2_I(inode);
61 struct gfs2_inum_host *inum = opaque; 44 struct gfs2_inum_host *inum = opaque;
62 45
63 if (ip && ip->i_num.no_addr == inum->no_addr) 46 if (ip->i_num.no_addr == inum->no_addr)
64 return 1; 47 return 1;
65 48
66 return 0; 49 return 0;
@@ -187,7 +170,9 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
187 */ 170 */
188 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink); 171 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
189 di->di_size = be64_to_cpu(str->di_size); 172 di->di_size = be64_to_cpu(str->di_size);
173 i_size_write(&ip->i_inode, di->di_size);
190 di->di_blocks = be64_to_cpu(str->di_blocks); 174 di->di_blocks = be64_to_cpu(str->di_blocks);
175 gfs2_set_inode_blocks(&ip->i_inode);
191 ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime); 176 ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime);
192 ip->i_inode.i_atime.tv_nsec = 0; 177 ip->i_inode.i_atime.tv_nsec = 0;
193 ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime); 178 ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 54d584eddf29..46917edfdd6c 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -25,6 +25,13 @@ static inline int gfs2_is_dir(struct gfs2_inode *ip)
25 return S_ISDIR(ip->i_inode.i_mode); 25 return S_ISDIR(ip->i_inode.i_mode);
26} 26}
27 27
28static inline void gfs2_set_inode_blocks(struct inode *inode)
29{
30 struct gfs2_inode *ip = GFS2_I(inode);
31 inode->i_blocks = ip->i_di.di_blocks <<
32 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
33}
34
28void gfs2_inode_attr_in(struct gfs2_inode *ip); 35void gfs2_inode_attr_in(struct gfs2_inode *ip);
29struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned type); 36struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned type);
30struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum); 37struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum);