X-Git-Url: http://git.cascardo.info/?a=blobdiff_plain;f=fs%2Fgfs2%2Fbmap.c;h=113f6c9110c745c31a6759a613ef628b4a3f68cb;hb=549ae0ac3d574a682e82b02e79259a65445a675b;hp=d20d41e1c0285bf8b89f79373eb8aa95ed96ea5c;hpb=ba7f72901cfd437d6de087bf44d2b64357cb38a5;p=cascardo%2Flinux.git diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index d20d41e1c028..113f6c9110c7 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -4,7 +4,7 @@ * * This copyrighted material is made available to anyone wishing to use, * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU General Public License v.2. + * of the GNU General Public License version 2. */ #include @@ -14,9 +14,9 @@ #include #include #include +#include #include "gfs2.h" -#include "lm_interface.h" #include "incore.h" #include "bmap.h" #include "glock.h" @@ -38,8 +38,8 @@ struct metapath { }; typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh, - struct buffer_head *bh, uint64_t *top, - uint64_t *bottom, unsigned int height, + struct buffer_head *bh, __be64 *top, + __be64 *bottom, unsigned int height, void *data); struct strip_mine { @@ -58,7 +58,7 @@ struct strip_mine { */ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, - uint64_t block, struct page *page) + u64 block, struct page *page) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct inode *inode = &ip->i_inode; @@ -94,7 +94,7 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, map_bh(bh, inode->i_sb, block); set_buffer_uptodate(bh); - if ((sdp->sd_args.ar_data == GFS2_DATA_ORDERED) || gfs2_is_jdata(ip)) + if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) gfs2_trans_add_bh(ip->i_gl, bh, 0); mark_buffer_dirty(bh); @@ -121,7 +121,8 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) { struct buffer_head *bh, *dibh; - uint64_t block = 0; + struct gfs2_dinode *di; + u64 block = 0; int isdir = gfs2_is_dir(ip); int error; @@ -130,7 +131,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) error = gfs2_meta_inode_buffer(ip, &dibh); if (error) goto out; - + if (ip->i_di.di_size) { /* Get a free block, fill it with the stuffed data, and write it out to disk */ @@ -141,8 +142,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) error = gfs2_dir_get_new_buffer(ip, block, &bh); if (error) goto out_brelse; - gfs2_buffer_copy_tail(bh, - sizeof(struct gfs2_meta_header), + gfs2_buffer_copy_tail(bh, sizeof(struct gfs2_meta_header), dibh, sizeof(struct gfs2_dinode)); brelse(bh); } else { @@ -157,25 +157,23 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) /* Set up the pointer to the new block */ gfs2_trans_add_bh(ip->i_gl, dibh, 1); - + di = (struct gfs2_dinode *)dibh->b_data; gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); if (ip->i_di.di_size) { - *(uint64_t *)(dibh->b_data + sizeof(struct gfs2_dinode)) = - cpu_to_be64(block); + *(__be64 *)(di + 1) = cpu_to_be64(block); ip->i_di.di_blocks++; + gfs2_set_inode_blocks(&ip->i_inode); + di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); } ip->i_di.di_height = 1; + di->di_height = cpu_to_be16(1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); - - out_brelse: +out_brelse: brelse(dibh); - - out: +out: up_write(&ip->i_rw_mutex); - return error; } @@ -192,10 +190,10 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page) * Returns: the height the tree should be */ -static unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size) +static unsigned int calc_tree_height(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t *arr; + u64 *arr; unsigned int max, height; if (ip->i_di.di_size > size) @@ -231,8 +229,9 @@ static int build_height(struct inode *inode, unsigned height) unsigned new_height = height - ip->i_di.di_height; struct buffer_head *dibh; struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; + struct gfs2_dinode *di; int error; - u64 *bp; + __be64 *bp; u64 bn; unsigned n; @@ -248,7 +247,7 @@ static int build_height(struct inode *inode, unsigned height) blocks[n] = gfs2_meta_new(ip->i_gl, bn); gfs2_trans_add_bh(ip->i_gl, blocks[n], 1); } - + n = 0; bn = blocks[0]->b_blocknr; if (new_height > 1) { @@ -257,7 +256,7 @@ static int build_height(struct inode *inode, unsigned height) GFS2_FORMAT_IN); gfs2_buffer_clear_tail(blocks[n], sizeof(struct gfs2_meta_header)); - bp = (u64 *)(blocks[n]->b_data + + bp = (__be64 *)(blocks[n]->b_data + sizeof(struct gfs2_meta_header)); *bp = cpu_to_be64(blocks[n+1]->b_blocknr); brelse(blocks[n]); @@ -269,12 +268,14 @@ static int build_height(struct inode *inode, unsigned height) dibh, sizeof(struct gfs2_dinode)); brelse(blocks[n]); gfs2_trans_add_bh(ip->i_gl, dibh, 1); + di = (struct gfs2_dinode *)dibh->b_data; gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); - bp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)); - *bp = cpu_to_be64(bn); + *(__be64 *)(di + 1) = cpu_to_be64(bn); ip->i_di.di_height += new_height; ip->i_di.di_blocks += new_height; - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_set_inode_blocks(&ip->i_inode); + di->di_height = cpu_to_be16(ip->i_di.di_height); + di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); brelse(dibh); return error; } @@ -338,15 +339,15 @@ static int build_height(struct inode *inode, unsigned height) * */ -static void find_metapath(struct gfs2_inode *ip, uint64_t block, +static void find_metapath(struct gfs2_inode *ip, u64 block, struct metapath *mp) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t b = block; + u64 b = block; unsigned int i; for (i = ip->i_di.di_height; i--;) - mp->mp_list[i] = (__u16)do_div(b, sdp->sd_inptrs); + mp->mp_list[i] = do_div(b, sdp->sd_inptrs); } @@ -361,15 +362,15 @@ static void find_metapath(struct gfs2_inode *ip, uint64_t block, * metadata tree. */ -static inline u64 *metapointer(struct buffer_head *bh, int *boundary, +static inline __be64 *metapointer(struct buffer_head *bh, int *boundary, unsigned int height, const struct metapath *mp) { unsigned int head_size = (height > 0) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode); - u64 *ptr; + __be64 *ptr; *boundary = 0; - ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height]; - if (ptr + 1 == (u64*)(bh->b_data + bh->b_size)) + ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height]; + if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size)) *boundary = 1; return ptr; } @@ -392,10 +393,10 @@ static inline u64 *metapointer(struct buffer_head *bh, int *boundary, static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, unsigned int height, struct metapath *mp, int create, - int *new, uint64_t *block) + int *new, u64 *block) { int boundary; - uint64_t *ptr = metapointer(bh, &boundary, height, mp); + __be64 *ptr = metapointer(bh, &boundary, height, mp); if (*ptr) { *block = be64_to_cpu(*ptr); @@ -416,18 +417,35 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, *ptr = cpu_to_be64(*block); ip->i_di.di_blocks++; + gfs2_set_inode_blocks(&ip->i_inode); *new = 1; return 0; } +static inline void bmap_lock(struct inode *inode, int create) +{ + struct gfs2_inode *ip = GFS2_I(inode); + if (create) + down_write(&ip->i_rw_mutex); + else + down_read(&ip->i_rw_mutex); +} + +static inline void bmap_unlock(struct inode *inode, int create) +{ + struct gfs2_inode *ip = GFS2_I(inode); + if (create) + up_write(&ip->i_rw_mutex); + else + up_read(&ip->i_rw_mutex); +} + /** - * gfs2_block_pointers - Map a block from an inode to a disk block + * gfs2_block_map - Map a block from an inode to a disk block * @inode: The inode * @lblock: The logical block number - * @new: Value/Result argument (1 = may create/did create new blocks) - * @boundary: gets set if we've hit a block boundary - * @mp: metapath to use + * @bh_map: The bh to be mapped * * Find the block number on the current device which corresponds to an * inode's block. If the block had to be created, "new" will be set. @@ -435,146 +453,121 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh, * Returns: errno */ -static struct buffer_head *gfs2_block_pointers(struct inode *inode, u64 lblock, - int *new, u64 *dblock, - int *boundary, - struct metapath *mp) +int gfs2_block_map(struct inode *inode, u64 lblock, int create, + struct buffer_head *bh_map) { struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_sbd *sdp = GFS2_SB(inode); struct buffer_head *bh; - int create = *new; unsigned int bsize; unsigned int height; unsigned int end_of_metadata; unsigned int x; int error = 0; + int new = 0; + u64 dblock = 0; + int boundary; + unsigned int maxlen = bh_map->b_size >> inode->i_blkbits; + struct metapath mp; + u64 size; - *new = 0; - *dblock = 0; + BUG_ON(maxlen == 0); if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) - goto out; - - bsize = (gfs2_is_dir(ip)) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; - - height = calc_tree_height(ip, (lblock + 1) * bsize); - if (ip->i_di.di_height < height) { - if (!create) - goto out; + return 0; - error = build_height(inode, height); - if (error) - goto out; + bmap_lock(inode, create); + clear_buffer_mapped(bh_map); + clear_buffer_new(bh_map); + clear_buffer_boundary(bh_map); + bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; + size = (lblock + 1) * bsize; + + if (size > ip->i_di.di_size) { + height = calc_tree_height(ip, size); + if (ip->i_di.di_height < height) { + if (!create) + goto out_ok; + + error = build_height(inode, height); + if (error) + goto out_fail; + } } - find_metapath(ip, lblock, mp); + find_metapath(ip, lblock, &mp); end_of_metadata = ip->i_di.di_height - 1; - error = gfs2_meta_inode_buffer(ip, &bh); if (error) - goto out; + goto out_fail; for (x = 0; x < end_of_metadata; x++) { - lookup_block(ip, bh, x, mp, create, new, dblock); + lookup_block(ip, bh, x, &mp, create, &new, &dblock); brelse(bh); - if (!*dblock) - goto out; + if (!dblock) + goto out_ok; - error = gfs2_meta_indirect_buffer(ip, x+1, *dblock, *new, &bh); + error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh); if (error) - goto out; + goto out_fail; } - *boundary = lookup_block(ip, bh, end_of_metadata, mp, create, new, dblock); - if (*new) { - struct buffer_head *dibh; - error = gfs2_meta_inode_buffer(ip, &dibh); - if (!error) { - gfs2_trans_add_bh(ip->i_gl, dibh, 1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); - brelse(dibh); + boundary = lookup_block(ip, bh, end_of_metadata, &mp, create, &new, &dblock); + if (dblock) { + map_bh(bh_map, inode->i_sb, dblock); + if (boundary) + set_buffer_boundary(bh_map); + if (new) { + struct buffer_head *dibh; + error = gfs2_meta_inode_buffer(ip, &dibh); + if (!error) { + gfs2_trans_add_bh(ip->i_gl, dibh, 1); + gfs2_dinode_out(ip, dibh->b_data); + brelse(dibh); + } + set_buffer_new(bh_map); + goto out_brelse; } - } - return bh; -out: - return ERR_PTR(error); -} - - -static inline void bmap_lock(struct inode *inode, int create) -{ - struct gfs2_inode *ip = GFS2_I(inode); - if (create) - down_write(&ip->i_rw_mutex); - else - down_read(&ip->i_rw_mutex); -} + while(--maxlen && !buffer_boundary(bh_map)) { + u64 eblock; -static inline void bmap_unlock(struct inode *inode, int create) -{ - struct gfs2_inode *ip = GFS2_I(inode); - if (create) - up_write(&ip->i_rw_mutex); - else - up_read(&ip->i_rw_mutex); -} - -int gfs2_block_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, int *boundary) -{ - struct metapath mp; - struct buffer_head *bh; - int create = *new; - - bmap_lock(inode, create); - bh = gfs2_block_pointers(inode, lblock, new, dblock, boundary, &mp); - bmap_unlock(inode, create); - if (!bh) - return 0; - if (IS_ERR(bh)) - return PTR_ERR(bh); + mp.mp_list[end_of_metadata]++; + boundary = lookup_block(ip, bh, end_of_metadata, &mp, 0, &new, &eblock); + if (eblock != ++dblock) + break; + bh_map->b_size += (1 << inode->i_blkbits); + if (boundary) + set_buffer_boundary(bh_map); + } + } +out_brelse: brelse(bh); - return 0; +out_ok: + error = 0; +out_fail: + bmap_unlock(inode, create); + return error; } int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) { - struct gfs2_inode *ip = GFS2_I(inode); - struct gfs2_sbd *sdp = GFS2_SB(inode); - struct metapath mp; - struct buffer_head *bh; - int boundary; + struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; + int ret; int create = *new; BUG_ON(!extlen); BUG_ON(!dblock); BUG_ON(!new); - bmap_lock(inode, create); - bh = gfs2_block_pointers(inode, lblock, new, dblock, &boundary, &mp); - *extlen = 1; - - if (bh && !IS_ERR(bh) && *dblock && !*new) { - u64 tmp_dblock; - int tmp_new; - unsigned int nptrs; - unsigned end_of_metadata = ip->i_di.di_height - 1; - - nptrs = (end_of_metadata) ? sdp->sd_inptrs : sdp->sd_diptrs; - while (++mp.mp_list[end_of_metadata] < nptrs) { - lookup_block(ip, bh, end_of_metadata, &mp, 0, &tmp_new, &tmp_dblock); - if (*dblock + *extlen != tmp_dblock) - break; - (*extlen)++; - } - } - bmap_unlock(inode, create); - if (!bh) - return 0; - if (IS_ERR(bh)) - return PTR_ERR(bh); - brelse(bh); - return 0; + bh.b_size = 1 << (inode->i_blkbits + 5); + ret = gfs2_block_map(inode, lblock, create, &bh); + *extlen = bh.b_size >> inode->i_blkbits; + *dblock = bh.b_blocknr; + if (buffer_new(&bh)) + *new = 1; + else + *new = 0; + return ret; } /** @@ -596,13 +589,13 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, struct metapath *mp, unsigned int height, - uint64_t block, int first, block_call_t bc, + u64 block, int first, block_call_t bc, void *data) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *bh = NULL; - uint64_t *top, *bottom; - uint64_t bn; + __be64 *top, *bottom; + u64 bn; int error; int mh_size = sizeof(struct gfs2_meta_header); @@ -612,19 +605,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, return error; dibh = bh; - top = (uint64_t *)(bh->b_data + sizeof(struct gfs2_dinode)) + - mp->mp_list[0]; - bottom = (uint64_t *)(bh->b_data + sizeof(struct gfs2_dinode)) + - sdp->sd_diptrs; + top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0]; + bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs; } else { error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh); if (error) return error; - top = (uint64_t *)(bh->b_data + mh_size) + - ((first) ? mp->mp_list[height] : 0); + top = (__be64 *)(bh->b_data + mh_size) + + (first ? mp->mp_list[height] : 0); - bottom = (uint64_t *)(bh->b_data + mh_size) + sdp->sd_inptrs; + bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs; } error = bc(ip, dibh, bh, top, bottom, height, data); @@ -644,9 +635,8 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, break; } - out: +out: brelse(bh); - return error; } @@ -664,15 +654,15 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh, */ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, - struct buffer_head *bh, uint64_t *top, uint64_t *bottom, + struct buffer_head *bh, __be64 *top, __be64 *bottom, unsigned int height, void *data) { struct strip_mine *sm = data; struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_rgrp_list rlist; - uint64_t bn, bstart; - uint32_t blen; - uint64_t *p; + u64 bn, bstart; + u32 blen; + __be64 *p; unsigned int rg_blocks = 0; int metadata; unsigned int revokes = 0; @@ -774,6 +764,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, if (!ip->i_di.di_blocks) gfs2_consist_inode(ip); ip->i_di.di_blocks--; + gfs2_set_inode_blocks(&ip->i_inode); } if (bstart) { if (metadata) @@ -782,23 +773,20 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, gfs2_free_data(ip, bstart, blen); } - ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME_SEC; - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_dinode_out(ip, dibh->b_data); up_write(&ip->i_rw_mutex); gfs2_trans_end(sdp); - out_rg_gunlock: +out_rg_gunlock: gfs2_glock_dq_m(rlist.rl_rgrps, rlist.rl_ghs); - - out_rlist: +out_rlist: gfs2_rlist_free(&rlist); - - out: +out: gfs2_glock_dq_uninit(&ip->i_alloc.al_ri_gh); - return error; } @@ -812,7 +800,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, * Returns: errno */ -static int do_grow(struct gfs2_inode *ip, uint64_t size) +static int do_grow(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_alloc *al; @@ -826,7 +814,7 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size) if (error) goto out; - error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); + error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid); if (error) goto out_gunlock_q; @@ -860,28 +848,24 @@ static int do_grow(struct gfs2_inode *ip, uint64_t size) } ip->i_di.di_size = size; - ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME_SEC; error = gfs2_meta_inode_buffer(ip, &dibh); if (error) goto out_end_trans; gfs2_trans_add_bh(ip->i_gl, dibh, 1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_dinode_out(ip, dibh->b_data); brelse(dibh); - out_end_trans: +out_end_trans: gfs2_trans_end(sdp); - - out_ipres: +out_ipres: gfs2_inplace_release(ip); - - out_gunlock_q: +out_gunlock_q: gfs2_quota_unlock(ip); - - out: +out: gfs2_alloc_put(ip); - return error; } @@ -961,7 +945,7 @@ unlock: return err; } -static int trunc_start(struct gfs2_inode *ip, uint64_t size) +static int trunc_start(struct gfs2_inode *ip, u64 size) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct buffer_head *dibh; @@ -969,7 +953,7 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size) int error; error = gfs2_trans_begin(sdp, - RES_DINODE + ((journaled) ? RES_JDATA : 0), 0); + RES_DINODE + (journaled ? RES_JDATA : 0), 0); if (error) return error; @@ -979,37 +963,36 @@ static int trunc_start(struct gfs2_inode *ip, uint64_t size) if (gfs2_is_stuffed(ip)) { ip->i_di.di_size = size; - ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME_SEC; gfs2_trans_add_bh(ip->i_gl, dibh, 1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_dinode_out(ip, dibh->b_data); gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size); error = 1; } else { - if (size & (uint64_t)(sdp->sd_sb.sb_bsize - 1)) + if (size & (u64)(sdp->sd_sb.sb_bsize - 1)) error = gfs2_block_truncate_page(ip->i_inode.i_mapping); if (!error) { ip->i_di.di_size = size; - ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME_SEC; ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG; gfs2_trans_add_bh(ip->i_gl, dibh, 1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_dinode_out(ip, dibh->b_data); } } brelse(dibh); - out: +out: gfs2_trans_end(sdp); - return error; } -static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) +static int trunc_dealloc(struct gfs2_inode *ip, u64 size) { unsigned int height = ip->i_di.di_height; - uint64_t lblock; + u64 lblock; struct metapath mp; int error; @@ -1037,7 +1020,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, uint64_t size) gfs2_quota_unhold(ip); - out: +out: gfs2_alloc_put(ip); return error; } @@ -1065,18 +1048,16 @@ static int trunc_end(struct gfs2_inode *ip) ip->i_num.no_addr; gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); } - ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); + ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME_SEC; ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG; gfs2_trans_add_bh(ip->i_gl, dibh, 1); - gfs2_dinode_out(&ip->i_di, dibh->b_data); + gfs2_dinode_out(ip, dibh->b_data); brelse(dibh); - out: +out: up_write(&ip->i_rw_mutex); - gfs2_trans_end(sdp); - return error; } @@ -1091,7 +1072,7 @@ static int trunc_end(struct gfs2_inode *ip) * Returns: errno */ -static int do_shrink(struct gfs2_inode *ip, uint64_t size) +static int do_shrink(struct gfs2_inode *ip, u64 size) { int error; @@ -1119,11 +1100,11 @@ static int do_shrink(struct gfs2_inode *ip, uint64_t size) * Returns: errno */ -int gfs2_truncatei(struct gfs2_inode *ip, uint64_t size) +int gfs2_truncatei(struct gfs2_inode *ip, u64 size) { int error; - if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_di.di_mode))) + if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode))) return -EINVAL; if (size > ip->i_di.di_size) @@ -1187,12 +1168,12 @@ void gfs2_write_calc_reserv(struct gfs2_inode *ip, unsigned int len, * Returns: errno */ -int gfs2_write_alloc_required(struct gfs2_inode *ip, uint64_t offset, +int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, unsigned int len, int *alloc_required) { struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); - uint64_t lblock, lblock_stop, dblock; - uint32_t extlen; + u64 lblock, lblock_stop, dblock; + u32 extlen; int new = 0; int error = 0;