aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/bmap.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-10-02 12:39:19 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2006-10-02 12:39:19 -0400
commit48516ced21e83a755ebae3d1ed03f1731befc391 (patch)
tree9cf3c78506056d36909ce8da5560162d4c0fbc17 /fs/gfs2/bmap.c
parent3cf1e7bed4681bdb1c14b6e146ae9c0afb6c1552 (diff)
[GFS2] Remove uneeded endian conversion
In many places GFS2 was calling the endian conversion routines for an inode even when only a single field, or a few fields might have changed. As a result we were copying lots of data needlessly. This patch replaces those calls with conversion of just the required fields in each case. This should be faster and easier to understand. There are still other places which suffer from this problem, but this is a start in the right direction. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/bmap.c')
-rw-r--r--fs/gfs2/bmap.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 92eef825167d..cc57f2ecd219 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -121,6 +121,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
121int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) 121int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
122{ 122{
123 struct buffer_head *bh, *dibh; 123 struct buffer_head *bh, *dibh;
124 struct gfs2_dinode *di;
124 u64 block = 0; 125 u64 block = 0;
125 int isdir = gfs2_is_dir(ip); 126 int isdir = gfs2_is_dir(ip);
126 int error; 127 int error;
@@ -141,8 +142,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
141 error = gfs2_dir_get_new_buffer(ip, block, &bh); 142 error = gfs2_dir_get_new_buffer(ip, block, &bh);
142 if (error) 143 if (error)
143 goto out_brelse; 144 goto out_brelse;
144 gfs2_buffer_copy_tail(bh, 145 gfs2_buffer_copy_tail(bh, sizeof(struct gfs2_meta_header),
145 sizeof(struct gfs2_meta_header),
146 dibh, sizeof(struct gfs2_dinode)); 146 dibh, sizeof(struct gfs2_dinode));
147 brelse(bh); 147 brelse(bh);
148 } else { 148 } else {
@@ -157,18 +157,17 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
157 /* Set up the pointer to the new block */ 157 /* Set up the pointer to the new block */
158 158
159 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 159 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
160 160 di = (struct gfs2_dinode *)dibh->b_data;
161 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 161 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
162 162
163 if (ip->i_di.di_size) { 163 if (ip->i_di.di_size) {
164 *(u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)) = 164 *(__be64 *)(di + 1) = cpu_to_be64(block);
165 cpu_to_be64(block);
166 ip->i_di.di_blocks++; 165 ip->i_di.di_blocks++;
166 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
167 } 167 }
168 168
169 ip->i_di.di_height = 1; 169 ip->i_di.di_height = 1;
170 170 di->di_height = cpu_to_be16(1);
171 gfs2_dinode_out(&ip->i_di, dibh->b_data);
172 171
173out_brelse: 172out_brelse:
174 brelse(dibh); 173 brelse(dibh);
@@ -229,6 +228,7 @@ static int build_height(struct inode *inode, unsigned height)
229 unsigned new_height = height - ip->i_di.di_height; 228 unsigned new_height = height - ip->i_di.di_height;
230 struct buffer_head *dibh; 229 struct buffer_head *dibh;
231 struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; 230 struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
231 struct gfs2_dinode *di;
232 int error; 232 int error;
233 u64 *bp; 233 u64 *bp;
234 u64 bn; 234 u64 bn;
@@ -267,12 +267,13 @@ static int build_height(struct inode *inode, unsigned height)
267 dibh, sizeof(struct gfs2_dinode)); 267 dibh, sizeof(struct gfs2_dinode));
268 brelse(blocks[n]); 268 brelse(blocks[n]);
269 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 269 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
270 di = (struct gfs2_dinode *)dibh->b_data;
270 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 271 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
271 bp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)); 272 *(__be64 *)(di + 1) = cpu_to_be64(bn);
272 *bp = cpu_to_be64(bn);
273 ip->i_di.di_height += new_height; 273 ip->i_di.di_height += new_height;
274 ip->i_di.di_blocks += new_height; 274 ip->i_di.di_blocks += new_height;
275 gfs2_dinode_out(&ip->i_di, dibh->b_data); 275 di->di_height = cpu_to_be16(ip->i_di.di_height);
276 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
276 brelse(dibh); 277 brelse(dibh);
277 return error; 278 return error;
278} 279}