aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/inode.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-01-28 05:37:35 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2008-03-31 05:39:46 -0400
commitecc30c79157103e8bd7492043ee992b763443832 (patch)
tree51b1af9b58dfcf1b561888a6752255ac86070808 /fs/gfs2/inode.c
parent941e6d7d09aaf455c0d7ad383f7f5ae67e4ccf16 (diff)
[GFS2] Streamline indirect pointer tree height calculation
This patch improves the calculation of the tree height in order to reduce the number of operations which are carried out on each call to gfs2_block_map. In the common case, we now make a single comparison, rather than calculating the required tree height from scratch each time. Also in the case that the tree does need some extra height, we start from the current height rather from zero when we work out what the new height ought to be. In addition the di_height field is moved into the inode proper and reduced in size to a u8 since the value must be between 0 and GFS2_MAX_META_HEIGHT (10). Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r--fs/gfs2/inode.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 37725ade3c51..ff66ab7a17c8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -248,12 +248,10 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
248{ 248{
249 struct gfs2_dinode_host *di = &ip->i_di; 249 struct gfs2_dinode_host *di = &ip->i_di;
250 const struct gfs2_dinode *str = buf; 250 const struct gfs2_dinode *str = buf;
251 u16 height;
251 252
252 if (ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)) { 253 if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)))
253 if (gfs2_consist_inode(ip)) 254 goto corrupt;
254 gfs2_dinode_print(ip);
255 return -EIO;
256 }
257 ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino); 255 ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino);
258 ip->i_inode.i_mode = be32_to_cpu(str->di_mode); 256 ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
259 ip->i_inode.i_rdev = 0; 257 ip->i_inode.i_rdev = 0;
@@ -290,7 +288,10 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
290 288
291 di->di_flags = be32_to_cpu(str->di_flags); 289 di->di_flags = be32_to_cpu(str->di_flags);
292 gfs2_set_inode_flags(&ip->i_inode); 290 gfs2_set_inode_flags(&ip->i_inode);
293 di->di_height = be16_to_cpu(str->di_height); 291 height = be16_to_cpu(str->di_height);
292 if (unlikely(height > GFS2_MAX_META_HEIGHT))
293 goto corrupt;
294 ip->i_height = (u8)height;
294 295
295 di->di_depth = be16_to_cpu(str->di_depth); 296 di->di_depth = be16_to_cpu(str->di_depth);
296 di->di_entries = be32_to_cpu(str->di_entries); 297 di->di_entries = be32_to_cpu(str->di_entries);
@@ -300,6 +301,10 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
300 gfs2_set_aops(&ip->i_inode); 301 gfs2_set_aops(&ip->i_inode);
301 302
302 return 0; 303 return 0;
304corrupt:
305 if (gfs2_consist_inode(ip))
306 gfs2_dinode_print(ip);
307 return -EIO;
303} 308}
304 309
305/** 310/**
@@ -1401,7 +1406,7 @@ void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
1401 str->di_generation = cpu_to_be64(di->di_generation); 1406 str->di_generation = cpu_to_be64(di->di_generation);
1402 1407
1403 str->di_flags = cpu_to_be32(di->di_flags); 1408 str->di_flags = cpu_to_be32(di->di_flags);
1404 str->di_height = cpu_to_be16(di->di_height); 1409 str->di_height = cpu_to_be16(ip->i_height);
1405 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) && 1410 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
1406 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ? 1411 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
1407 GFS2_FORMAT_DE : 0); 1412 GFS2_FORMAT_DE : 0);
@@ -1430,7 +1435,6 @@ void gfs2_dinode_print(const struct gfs2_inode *ip)
1430 printk(KERN_INFO " di_goal_data = %llu\n", 1435 printk(KERN_INFO " di_goal_data = %llu\n",
1431 (unsigned long long)di->di_goal_data); 1436 (unsigned long long)di->di_goal_data);
1432 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags); 1437 printk(KERN_INFO " di_flags = 0x%.8X\n", di->di_flags);
1433 printk(KERN_INFO " di_height = %u\n", di->di_height);
1434 printk(KERN_INFO " di_depth = %u\n", di->di_depth); 1438 printk(KERN_INFO " di_depth = %u\n", di->di_depth);
1435 printk(KERN_INFO " di_entries = %u\n", di->di_entries); 1439 printk(KERN_INFO " di_entries = %u\n", di->di_entries);
1436 printk(KERN_INFO " di_eattr = %llu\n", 1440 printk(KERN_INFO " di_eattr = %llu\n",