Lines Matching refs:ip
43 static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length);
55 static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, in gfs2_unstuffer_page() argument
58 struct inode *inode = &ip->i_inode; in gfs2_unstuffer_page()
71 if (gfs2_is_jdata(ip)) { in gfs2_unstuffer_page()
83 gfs2_trans_add_data(ip->i_gl, bh); in gfs2_unstuffer_page()
86 gfs2_ordered_add_inode(ip); in gfs2_unstuffer_page()
92 static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct page *page) in __gfs2_unstuff_inode() argument
97 int isdir = gfs2_is_dir(ip); in __gfs2_unstuff_inode()
100 error = gfs2_meta_inode_buffer(ip, &dibh); in __gfs2_unstuff_inode()
104 if (i_size_read(&ip->i_inode)) { in __gfs2_unstuff_inode()
109 error = gfs2_alloc_blocks(ip, &block, &n, 0, NULL); in __gfs2_unstuff_inode()
113 gfs2_trans_remove_revoke(GFS2_SB(&ip->i_inode), block, 1); in __gfs2_unstuff_inode()
114 error = gfs2_dir_get_new_buffer(ip, block, &bh); in __gfs2_unstuff_inode()
121 error = gfs2_unstuffer_page(ip, dibh, block, page); in __gfs2_unstuff_inode()
129 gfs2_trans_add_meta(ip->i_gl, dibh); in __gfs2_unstuff_inode()
133 if (i_size_read(&ip->i_inode)) { in __gfs2_unstuff_inode()
135 gfs2_add_inode_blocks(&ip->i_inode, 1); in __gfs2_unstuff_inode()
136 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); in __gfs2_unstuff_inode()
139 ip->i_height = 1; in __gfs2_unstuff_inode()
157 int gfs2_unstuff_dinode(struct gfs2_inode *ip) in gfs2_unstuff_dinode() argument
159 struct inode *inode = &ip->i_inode; in gfs2_unstuff_dinode()
163 down_write(&ip->i_rw_mutex); in gfs2_unstuff_dinode()
168 error = __gfs2_unstuff_inode(ip, page); in gfs2_unstuff_dinode()
172 up_write(&ip->i_rw_mutex); in gfs2_unstuff_dinode()
320 static int __fillup_metapath(struct gfs2_inode *ip, struct metapath *mp, in __fillup_metapath() argument
330 ret = gfs2_meta_buffer(ip, GFS2_METATYPE_IN, dblock, &mp->mp_bh[x + 1]); in __fillup_metapath()
355 static int lookup_metapath(struct gfs2_inode *ip, struct metapath *mp) in lookup_metapath() argument
357 return __fillup_metapath(ip, mp, 0, ip->i_height - 1); in lookup_metapath()
371 static int fillup_metapath(struct gfs2_inode *ip, struct metapath *mp, int h) in fillup_metapath() argument
383 ret = __fillup_metapath(ip, mp, x, h); in fillup_metapath()
469 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_walk_metadata() local
537 ret = fillup_metapath(ip, mp, ip->i_height - 1); in gfs2_walk_metadata()
661 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_iomap_alloc() local
677 gfs2_trans_add_meta(ip->i_gl, dibh); in __gfs2_iomap_alloc()
679 down_write(&ip->i_rw_mutex); in __gfs2_iomap_alloc()
686 if (mp->mp_fheight == ip->i_height) { in __gfs2_iomap_alloc()
693 iblks = mp->mp_fheight - ip->i_height; in __gfs2_iomap_alloc()
705 ret = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL); in __gfs2_iomap_alloc()
709 if (state != ALLOC_DATA || gfs2_is_jdata(ip)) in __gfs2_iomap_alloc()
719 for (; i - 1 < mp->mp_fheight - ip->i_height && n > 0; in __gfs2_iomap_alloc()
721 gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++); in __gfs2_iomap_alloc()
722 if (i - 1 == mp->mp_fheight - ip->i_height) { in __gfs2_iomap_alloc()
747 gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[i-1]); in __gfs2_iomap_alloc()
749 gfs2_indirect_init(mp, ip->i_gl, i, in __gfs2_iomap_alloc()
759 gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[end_of_metadata]); in __gfs2_iomap_alloc()
772 ip->i_height = mp->mp_fheight; in __gfs2_iomap_alloc()
773 gfs2_add_inode_blocks(&ip->i_inode, alloced); in __gfs2_iomap_alloc()
774 gfs2_dinode_out(ip, dibh->b_data); in __gfs2_iomap_alloc()
776 up_write(&ip->i_rw_mutex); in __gfs2_iomap_alloc()
794 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_alloc_size() local
806 if (gfs2_is_stuffed(ip) || mp->mp_fheight != mp->mp_aheight) { in gfs2_alloc_size()
815 first = metapointer(ip->i_height - 1, mp); in gfs2_alloc_size()
816 end = metaend(ip->i_height - 1, mp); in gfs2_alloc_size()
841 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_iomap_get() local
856 down_read(&ip->i_rw_mutex); in __gfs2_iomap_get()
858 ret = gfs2_meta_inode_buffer(ip, &dibh); in __gfs2_iomap_get()
863 if (gfs2_is_stuffed(ip)) { in __gfs2_iomap_get()
865 loff_t max_size = gfs2_max_stuffed_size(ip); in __gfs2_iomap_get()
883 iomap->addr = (ip->i_no_addr << inode->i_blkbits) + in __gfs2_iomap_get()
897 height = ip->i_height; in __gfs2_iomap_get()
901 if (height > ip->i_height || gfs2_is_stuffed(ip)) in __gfs2_iomap_get()
904 ret = lookup_metapath(ip, mp); in __gfs2_iomap_get()
908 if (mp->mp_aheight != ip->i_height) in __gfs2_iomap_get()
911 ptr = metapointer(ip->i_height - 1, mp); in __gfs2_iomap_get()
915 bh = mp->mp_bh[ip->i_height - 1]; in __gfs2_iomap_get()
928 up_read(&ip->i_rw_mutex); in __gfs2_iomap_get()
935 else if (height == ip->i_height) in __gfs2_iomap_get()
950 if (pos < size && height == ip->i_height) in __gfs2_iomap_get()
974 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_page_done() local
977 if (page && !gfs2_is_stuffed(ip)) in gfs2_iomap_page_done()
978 gfs2_page_add_databufs(ip, page, offset_in_page(pos), copied); in gfs2_iomap_page_done()
996 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_begin_write() local
1001 unstuff = gfs2_is_stuffed(ip) && in gfs2_iomap_begin_write()
1002 pos + length > gfs2_max_stuffed_size(ip); in gfs2_iomap_begin_write()
1010 gfs2_write_calc_reserv(ip, iomap->length, &data_blocks, in gfs2_iomap_begin_write()
1013 ret = gfs2_quota_lock_check(ip, &ap); in gfs2_iomap_begin_write()
1017 ret = gfs2_inplace_reserve(ip, &ap); in gfs2_iomap_begin_write()
1022 if (gfs2_is_jdata(ip)) in gfs2_iomap_begin_write()
1028 rblocks += gfs2_rg_blocks(ip, data_blocks + ind_blocks); in gfs2_iomap_begin_write()
1036 ret = gfs2_unstuff_dinode(ip); in gfs2_iomap_begin_write()
1050 gfs2_inplace_release(ip); in gfs2_iomap_begin_write()
1051 punch_hole(ip, iomap->offset, iomap->length); in gfs2_iomap_begin_write()
1063 if (gfs2_is_stuffed(ip) || gfs2_is_jdata(ip)) in gfs2_iomap_begin_write()
1070 gfs2_inplace_release(ip); in gfs2_iomap_begin_write()
1072 gfs2_quota_unlock(ip); in gfs2_iomap_begin_write()
1080 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_begin() local
1084 if (gfs2_is_jdata(ip)) in gfs2_iomap_begin()
1087 trace_gfs2_iomap_start(ip, pos, length, flags); in gfs2_iomap_begin()
1116 trace_gfs2_iomap_end(ip, iomap, ret); in gfs2_iomap_begin()
1123 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_end() local
1139 if (!gfs2_is_stuffed(ip)) in gfs2_iomap_end()
1140 gfs2_ordered_add_inode(ip); in gfs2_iomap_end()
1145 gfs2_inplace_release(ip); in gfs2_iomap_end()
1147 if (ip->i_qadata && ip->i_qadata->qa_qd_num) in gfs2_iomap_end()
1148 gfs2_quota_unlock(ip); in gfs2_iomap_end()
1157 punch_hole(ip, hstart, hend - hstart); in gfs2_iomap_end()
1166 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags); in gfs2_iomap_end()
1199 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_block_map() local
1208 trace_gfs2_bmap(ip, bh_map, lblock, create, 1); in gfs2_block_map()
1230 trace_gfs2_bmap(ip, bh_map, lblock, create, ret); in gfs2_block_map()
1339 struct gfs2_inode *ip = GFS2_I(inode); in trunc_start() local
1342 int journaled = gfs2_is_jdata(ip); in trunc_start()
1346 if (!gfs2_is_stuffed(ip)) { in trunc_start()
1363 error = gfs2_meta_inode_buffer(ip, &dibh); in trunc_start()
1367 gfs2_trans_add_meta(ip->i_gl, dibh); in trunc_start()
1369 if (gfs2_is_stuffed(ip)) in trunc_start()
1372 ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG; in trunc_start()
1375 ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode); in trunc_start()
1376 gfs2_dinode_out(ip, dibh->b_data); in trunc_start()
1436 static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh, in sweep_bh_for_rgrps() argument
1440 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in sweep_bh_for_rgrps()
1483 if (gfs2_rs_active(&ip->i_res) && in sweep_bh_for_rgrps()
1484 rgd == ip->i_res.rs_rgd) in sweep_bh_for_rgrps()
1485 gfs2_rs_deltree(&ip->i_res); in sweep_bh_for_rgrps()
1498 isize_blks = gfs2_get_inode_blocks(&ip->i_inode); in sweep_bh_for_rgrps()
1507 else if (ip->i_depth) in sweep_bh_for_rgrps()
1512 down_write(&ip->i_rw_mutex); in sweep_bh_for_rgrps()
1539 gfs2_trans_add_meta(ip->i_gl, bh); in sweep_bh_for_rgrps()
1547 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta); in sweep_bh_for_rgrps()
1549 gfs2_add_inode_blocks(&ip->i_inode, -blen); in sweep_bh_for_rgrps()
1555 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta); in sweep_bh_for_rgrps()
1557 gfs2_add_inode_blocks(&ip->i_inode, -blen); in sweep_bh_for_rgrps()
1566 ret = gfs2_meta_inode_buffer(ip, &dibh); in sweep_bh_for_rgrps()
1572 ip->i_inode.i_mtime = ip->i_inode.i_ctime = in sweep_bh_for_rgrps()
1573 current_time(&ip->i_inode); in sweep_bh_for_rgrps()
1574 gfs2_trans_add_meta(ip->i_gl, dibh); in sweep_bh_for_rgrps()
1575 gfs2_dinode_out(ip, dibh->b_data); in sweep_bh_for_rgrps()
1577 up_write(&ip->i_rw_mutex); in sweep_bh_for_rgrps()
1697 static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length) in punch_hole() argument
1699 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in punch_hole()
1700 u64 maxsize = sdp->sd_heightsize[ip->i_height]; in punch_hole()
1709 unsigned int strip_h = ip->i_height - 1; in punch_hole()
1752 find_metapath(sdp, lend, &mp, ip->i_height); in punch_hole()
1756 for (mp_h = ip->i_height - 1; mp_h > 0; mp_h--) { in punch_hole()
1763 find_metapath(sdp, lblock, &mp, ip->i_height); in punch_hole()
1766 for (mp_h = ip->i_height - 1; mp_h > 0; mp_h--) { in punch_hole()
1772 ret = gfs2_meta_inode_buffer(ip, &dibh); in punch_hole()
1777 ret = lookup_metapath(ip, &mp); in punch_hole()
1785 gfs2_metapath_ra(ip->i_gl, start, end); in punch_hole()
1788 if (mp.mp_aheight == ip->i_height) in punch_hole()
1797 ret = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in punch_hole()
1815 (unsigned long long)ip->i_no_addr, in punch_hole()
1816 prev_bnr, ip->i_height, strip_h, mp_h); in punch_hole()
1836 ret = sweep_bh_for_rgrps(ip, &rd_gh, mp.mp_bh[mp_h], in punch_hole()
1838 mp_h != ip->i_height - 1, in punch_hole()
1888 ret = fillup_metapath(ip, &mp, mp_h); in punch_hole()
1893 if (mp.mp_aheight > 1 && strip_h == ip->i_height - 1) { in punch_hole()
1905 gfs2_metapath_ra(ip->i_gl, start, end); in punch_hole()
1914 if (mp.mp_aheight < ip->i_height) /* We have a partial height */ in punch_hole()
1934 down_write(&ip->i_rw_mutex); in punch_hole()
1937 gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid, in punch_hole()
1938 ip->i_inode.i_gid); in punch_hole()
1939 ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode); in punch_hole()
1940 gfs2_trans_add_meta(ip->i_gl, dibh); in punch_hole()
1941 gfs2_dinode_out(ip, dibh->b_data); in punch_hole()
1942 up_write(&ip->i_rw_mutex); in punch_hole()
1950 up_write(&ip->i_rw_mutex); in punch_hole()
1954 gfs2_quota_unhold(ip); in punch_hole()
1960 static int trunc_end(struct gfs2_inode *ip) in trunc_end() argument
1962 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in trunc_end()
1970 down_write(&ip->i_rw_mutex); in trunc_end()
1972 error = gfs2_meta_inode_buffer(ip, &dibh); in trunc_end()
1976 if (!i_size_read(&ip->i_inode)) { in trunc_end()
1977 ip->i_height = 0; in trunc_end()
1978 ip->i_goal = ip->i_no_addr; in trunc_end()
1980 gfs2_ordered_del_inode(ip); in trunc_end()
1982 ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode); in trunc_end()
1983 ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG; in trunc_end()
1985 gfs2_trans_add_meta(ip->i_gl, dibh); in trunc_end()
1986 gfs2_dinode_out(ip, dibh->b_data); in trunc_end()
1990 up_write(&ip->i_rw_mutex); in trunc_end()
2008 struct gfs2_inode *ip = GFS2_I(inode); in do_shrink() local
2014 if (gfs2_is_stuffed(ip)) in do_shrink()
2017 error = punch_hole(ip, newsize, 0); in do_shrink()
2019 error = trunc_end(ip); in do_shrink()
2054 struct gfs2_inode *ip = GFS2_I(inode); in do_grow() local
2061 if (gfs2_is_stuffed(ip) && size > gfs2_max_stuffed_size(ip)) { in do_grow()
2062 error = gfs2_quota_lock_check(ip, &ap); in do_grow()
2066 error = gfs2_inplace_reserve(ip, &ap); in do_grow()
2074 gfs2_is_jdata(ip) ? RES_JDATA : 0) + in do_grow()
2081 error = gfs2_unstuff_dinode(ip); in do_grow()
2086 error = gfs2_meta_inode_buffer(ip, &dibh); in do_grow()
2091 ip->i_inode.i_mtime = ip->i_inode.i_ctime = current_time(&ip->i_inode); in do_grow()
2092 gfs2_trans_add_meta(ip->i_gl, dibh); in do_grow()
2093 gfs2_dinode_out(ip, dibh->b_data); in do_grow()
2100 gfs2_inplace_release(ip); in do_grow()
2102 gfs2_quota_unlock(ip); in do_grow()
2121 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_setattr_size() local
2132 ret = gfs2_qa_get(ip); in gfs2_setattr_size()
2143 gfs2_rs_delete(ip); in gfs2_setattr_size()
2144 gfs2_qa_put(ip); in gfs2_setattr_size()
2148 int gfs2_truncatei_resume(struct gfs2_inode *ip) in gfs2_truncatei_resume() argument
2151 error = punch_hole(ip, i_size_read(&ip->i_inode), 0); in gfs2_truncatei_resume()
2153 error = trunc_end(ip); in gfs2_truncatei_resume()
2157 int gfs2_file_dealloc(struct gfs2_inode *ip) in gfs2_file_dealloc() argument
2159 return punch_hole(ip, 0, 0); in gfs2_file_dealloc()
2236 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); in gfs2_map_journal_extents() local
2260 lblock += (bh.b_size >> ip->i_inode.i_blkbits); in gfs2_map_journal_extents()
2289 int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, in gfs2_write_alloc_required() argument
2292 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_write_alloc_required()
2301 if (gfs2_is_stuffed(ip)) { in gfs2_write_alloc_required()
2302 if (offset + len > gfs2_max_stuffed_size(ip)) in gfs2_write_alloc_required()
2308 BUG_ON(gfs2_is_dir(ip)); in gfs2_write_alloc_required()
2309 end_of_file = (i_size_read(&ip->i_inode) + sdp->sd_sb.sb_bsize - 1) >> shift; in gfs2_write_alloc_required()
2312 if (lblock_stop > end_of_file && ip != GFS2_I(sdp->sd_rindex)) in gfs2_write_alloc_required()
2319 gfs2_block_map(&ip->i_inode, lblock, &bh, 0); in gfs2_write_alloc_required()
2323 lblock += (bh.b_size >> ip->i_inode.i_blkbits); in gfs2_write_alloc_required()
2331 struct gfs2_inode *ip = GFS2_I(inode); in stuffed_zero_range() local
2340 error = gfs2_meta_inode_buffer(ip, &dibh); in stuffed_zero_range()
2343 gfs2_trans_add_meta(ip->i_gl, dibh); in stuffed_zero_range()
2389 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_punch_hole() local
2395 if (!gfs2_is_stuffed(ip)) { in __gfs2_punch_hole()
2424 if (gfs2_is_jdata(ip)) in __gfs2_punch_hole()
2432 if (gfs2_is_stuffed(ip)) { in __gfs2_punch_hole()
2438 if (gfs2_is_jdata(ip)) { in __gfs2_punch_hole()
2450 if (!gfs2_is_stuffed(ip)) in __gfs2_punch_hole()
2451 error = punch_hole(ip, offset, length); in __gfs2_punch_hole()