Lines Matching +full:ip +full:- +full:block
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
33 * block is 512, so __u16 is fine for that. It saves stack space to
43 static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length);
46 * gfs2_unstuffer_folio - unstuff a stuffed inode into a block cached by a folio
47 * @ip: the inode
49 * @block: the block number that was allocated
54 static int gfs2_unstuffer_folio(struct gfs2_inode *ip, struct buffer_head *dibh, in gfs2_unstuffer_folio() argument
55 u64 block, struct folio *folio) in gfs2_unstuffer_folio() argument
57 struct inode *inode = &ip->i_inode; in gfs2_unstuffer_folio()
63 memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize); in gfs2_unstuffer_folio()
64 memset(kaddr + dsize, 0, folio_size(folio) - dsize); in gfs2_unstuffer_folio()
70 if (gfs2_is_jdata(ip)) { in gfs2_unstuffer_folio()
75 BIT(inode->i_blkbits), BIT(BH_Uptodate)); in gfs2_unstuffer_folio()
78 map_bh(bh, inode->i_sb, block); in gfs2_unstuffer_folio()
81 gfs2_trans_add_data(ip->i_gl, bh); in gfs2_unstuffer_folio()
84 gfs2_ordered_add_inode(ip); in gfs2_unstuffer_folio()
90 static int __gfs2_unstuff_inode(struct gfs2_inode *ip, struct folio *folio) in __gfs2_unstuff_inode() argument
94 u64 block = 0; in __gfs2_unstuff_inode() local
95 int isdir = gfs2_is_dir(ip); in __gfs2_unstuff_inode()
98 error = gfs2_meta_inode_buffer(ip, &dibh); in __gfs2_unstuff_inode()
102 if (i_size_read(&ip->i_inode)) { in __gfs2_unstuff_inode()
103 /* Get a free block, fill it with the stuffed data, in __gfs2_unstuff_inode()
107 error = gfs2_alloc_blocks(ip, &block, &n, 0); in __gfs2_unstuff_inode()
111 gfs2_trans_remove_revoke(GFS2_SB(&ip->i_inode), block, 1); in __gfs2_unstuff_inode()
112 error = gfs2_dir_get_new_buffer(ip, block, &bh); in __gfs2_unstuff_inode()
119 error = gfs2_unstuffer_folio(ip, dibh, block, folio); in __gfs2_unstuff_inode()
125 /* Set up the pointer to the new block */ in __gfs2_unstuff_inode()
127 gfs2_trans_add_meta(ip->i_gl, dibh); in __gfs2_unstuff_inode()
128 di = (struct gfs2_dinode *)dibh->b_data; in __gfs2_unstuff_inode()
131 if (i_size_read(&ip->i_inode)) { in __gfs2_unstuff_inode()
132 *(__be64 *)(di + 1) = cpu_to_be64(block); in __gfs2_unstuff_inode()
133 gfs2_add_inode_blocks(&ip->i_inode, 1); in __gfs2_unstuff_inode()
134 di->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode)); in __gfs2_unstuff_inode()
137 ip->i_height = 1; in __gfs2_unstuff_inode()
138 di->di_height = cpu_to_be16(1); in __gfs2_unstuff_inode()
146 * gfs2_unstuff_dinode - Unstuff a dinode when the data has grown too big
147 * @ip: The GFS2 inode to unstuff
155 int gfs2_unstuff_dinode(struct gfs2_inode *ip) in gfs2_unstuff_dinode() argument
157 struct inode *inode = &ip->i_inode; in gfs2_unstuff_dinode()
161 down_write(&ip->i_rw_mutex); in gfs2_unstuff_dinode()
162 folio = filemap_grab_folio(inode->i_mapping, 0); in gfs2_unstuff_dinode()
166 error = __gfs2_unstuff_inode(ip, folio); in gfs2_unstuff_dinode()
170 up_write(&ip->i_rw_mutex); in gfs2_unstuff_dinode()
175 * find_metapath - Find path through the metadata tree
177 * @block: The disk block to look up
179 * @height: The pre-calculated height of the metadata tree
182 * through the metadata of inode "ip" to get to block "block".
185 * Given: "ip" is a height 3 file, "offset" is 101342453, and this is a
191 * That means that in order to get to the block containing the byte at
192 * offset 101342453, we would load the indirect block pointed to by pointer
193 * 0 in the dinode. We would then load the indirect block pointed to by
194 * pointer 48 in that indirect block. We would then load the data block
195 * pointed to by pointer 165 in that indirect block.
197 * ----------------------------------------
202 * ----------------------------------------
206 * ----------------------------------------
207 * | Indirect Block |
211 * ----------------------------------------
215 * ----------------------------------------
216 * | Indirect Block |
220 * ----------------------------------------
224 * ----------------------------------------
225 * | Data block containing offset |
229 * ----------------------------------------
233 static void find_metapath(const struct gfs2_sbd *sdp, u64 block, in find_metapath() argument
238 mp->mp_fheight = height; in find_metapath()
239 for (i = height; i--;) in find_metapath()
240 mp->mp_list[i] = do_div(block, sdp->sd_inptrs); in find_metapath()
245 if (mp->mp_list[0] == 0) in metapath_branch_start()
251 * metaptr1 - Return the first possible metadata pointer in a metapath buffer
257 struct buffer_head *bh = mp->mp_bh[height]; in metaptr1()
259 return ((__be64 *)(bh->b_data + sizeof(struct gfs2_dinode))); in metaptr1()
260 return ((__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header))); in metaptr1()
264 * metapointer - Return pointer to start of metadata in a buffer
268 * Return a pointer to the block number of the next height of the metadata
276 return p + mp->mp_list[height]; in metapointer()
281 const struct buffer_head *bh = mp->mp_bh[height]; in metaend()
282 return (const __be64 *)(bh->b_data + bh->b_size); in metaend()
290 for (hgt = 0; hgt < mp->mp_aheight; hgt++) in clone_metapath()
291 get_bh(clone->mp_bh[hgt]); in clone_metapath()
307 rabh->b_end_io = end_buffer_read_sync; in gfs2_metapath_ra()
321 return mp->mp_bh[0]; in metapath_dibh()
324 static int __fillup_metapath(struct gfs2_inode *ip, struct metapath *mp, in __fillup_metapath() argument
334 ret = gfs2_meta_buffer(ip, GFS2_METATYPE_IN, dblock, &mp->mp_bh[x + 1]); in __fillup_metapath()
338 mp->mp_aheight = x + 1; in __fillup_metapath()
343 * lookup_metapath - Walk the metadata tree to a specific point
344 * @ip: The inode
348 * hooked onto mp->mp_bh[0] and that the metapath has been initialised
353 * at which it found the unallocated block. Blocks which are found are
354 * added to the mp->mp_bh[] list.
359 static int lookup_metapath(struct gfs2_inode *ip, struct metapath *mp) in lookup_metapath() argument
361 return __fillup_metapath(ip, mp, 0, ip->i_height - 1); in lookup_metapath()
365 * fillup_metapath - fill up buffers for the metadata path to a specific height
366 * @ip: The inode
375 static int fillup_metapath(struct gfs2_inode *ip, struct metapath *mp, int h) in fillup_metapath() argument
382 for (x = h - 1; x > 0; x--) { in fillup_metapath()
383 if (mp->mp_bh[x]) in fillup_metapath()
387 ret = __fillup_metapath(ip, mp, x, h); in fillup_metapath()
390 return mp->mp_aheight - x - 1; in fillup_metapath()
395 sector_t factor = 1, block = 0; in metapath_to_block() local
398 for (hgt = mp->mp_fheight - 1; hgt >= 0; hgt--) { in metapath_to_block()
399 if (hgt < mp->mp_aheight) in metapath_to_block()
400 block += mp->mp_list[hgt] * factor; in metapath_to_block()
401 factor *= sdp->sd_inptrs; in metapath_to_block()
403 return block; in metapath_to_block()
411 if (mp->mp_bh[i] == NULL) in release_metapath()
413 brelse(mp->mp_bh[i]); in release_metapath()
414 mp->mp_bh[i] = NULL; in release_metapath()
419 * gfs2_extent_length - Returns length of an extent of blocks
420 * @bh: The metadata block
422 * @eob: Set to 1 if we hit "end of block"
424 * Returns: The length of the extent (minimum of one block)
429 const __be64 *end = (__be64 *)(bh->b_data + bh->b_size); in gfs2_extent_length()
442 return ptr - first; in gfs2_extent_length()
448 * gfs2_metadata_walker - walk an indirect block
449 * @mp: Metapath to indirect block
453 * indirect block to follow.
459 * gfs2_walk_metadata - walk a tree of indirect blocks
472 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_walk_metadata() local
479 * The walk starts in the lowest allocated indirect block, which may be in gfs2_walk_metadata()
483 for (hgt = mp->mp_fheight - 1; hgt >= mp->mp_aheight; hgt--) { in gfs2_walk_metadata()
484 max_len += mp->mp_list[hgt] * factor; in gfs2_walk_metadata()
485 mp->mp_list[hgt] = 0; in gfs2_walk_metadata()
486 factor *= sdp->sd_inptrs; in gfs2_walk_metadata()
490 u16 start = mp->mp_list[hgt]; in gfs2_walk_metadata()
495 /* Walk indirect block. */ in gfs2_walk_metadata()
496 ptrs = (hgt >= 1 ? sdp->sd_inptrs : sdp->sd_diptrs) - start; in gfs2_walk_metadata()
505 BUG_ON(mp->mp_aheight == mp->mp_fheight); in gfs2_walk_metadata()
506 ptrs = mp->mp_list[hgt] - start; in gfs2_walk_metadata()
514 max_len -= len; in gfs2_walk_metadata()
520 brelse(mp->mp_bh[hgt]); in gfs2_walk_metadata()
521 mp->mp_bh[hgt] = NULL; in gfs2_walk_metadata()
522 mp->mp_list[hgt] = 0; in gfs2_walk_metadata()
525 hgt--; in gfs2_walk_metadata()
526 factor *= sdp->sd_inptrs; in gfs2_walk_metadata()
529 (mp->mp_list[hgt])++; in gfs2_walk_metadata()
531 if (mp->mp_list[hgt] >= sdp->sd_inptrs) in gfs2_walk_metadata()
534 if (mp->mp_list[hgt] >= sdp->sd_diptrs) in gfs2_walk_metadata()
540 ret = fillup_metapath(ip, mp, ip->i_height - 1); in gfs2_walk_metadata()
544 for (; ret; ret--) in gfs2_walk_metadata()
545 do_div(factor, sdp->sd_inptrs); in gfs2_walk_metadata()
546 mp->mp_aheight = hgt + 1; in gfs2_walk_metadata()
557 hgt = mp->mp_aheight - 1; in gfs2_hole_walker()
563 mp->mp_list[hgt] += ptr - start; in gfs2_hole_walker()
564 if (mp->mp_aheight == mp->mp_fheight) in gfs2_hole_walker()
573 * gfs2_hole_size - figure out the size of a hole
575 * @lblock: The logical starting block number
597 hole_size = metapath_to_block(GFS2_SB(inode), &clone) - lblock; in gfs2_hole_size()
600 iomap->length = hole_size << inode->i_blkbits; in gfs2_hole_size()
612 __be64 *ptr = (__be64 *)(mp->mp_bh[i - 1]->b_data + in gfs2_indirect_init()
616 BUG_ON(mp->mp_bh[i] != NULL); in gfs2_indirect_init()
617 mp->mp_bh[i] = gfs2_meta_new(gl, bn); in gfs2_indirect_init()
618 gfs2_trans_add_meta(gl, mp->mp_bh[i]); in gfs2_indirect_init()
619 gfs2_metatype_set(mp->mp_bh[i], GFS2_METATYPE_IN, GFS2_FORMAT_IN); in gfs2_indirect_init()
620 gfs2_buffer_clear_tail(mp->mp_bh[i], sizeof(struct gfs2_meta_header)); in gfs2_indirect_init()
633 * __gfs2_iomap_alloc - Build a metadata tree of the requested height
651 * Right now, this function will allocate at most one indirect block
652 * worth of data -- with a default block size of 4K, that's slightly
664 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_iomap_alloc() local
669 size_t dblks = iomap->length >> inode->i_blkbits; in __gfs2_iomap_alloc()
670 const unsigned end_of_metadata = mp->mp_fheight - 1; in __gfs2_iomap_alloc()
676 BUG_ON(mp->mp_aheight < 1); in __gfs2_iomap_alloc()
680 gfs2_trans_add_meta(ip->i_gl, dibh); in __gfs2_iomap_alloc()
682 down_write(&ip->i_rw_mutex); in __gfs2_iomap_alloc()
684 if (mp->mp_fheight == mp->mp_aheight) { in __gfs2_iomap_alloc()
685 /* Bottom indirect block exists */ in __gfs2_iomap_alloc()
689 if (mp->mp_fheight == ip->i_height) { in __gfs2_iomap_alloc()
691 iblks = mp->mp_fheight - mp->mp_aheight; in __gfs2_iomap_alloc()
696 iblks = mp->mp_fheight - ip->i_height; in __gfs2_iomap_alloc()
698 iblks += (mp->mp_fheight - branch_start); in __gfs2_iomap_alloc()
705 i = mp->mp_aheight; in __gfs2_iomap_alloc()
707 n = blks - alloced; in __gfs2_iomap_alloc()
708 ret = gfs2_alloc_blocks(ip, &bn, &n, 0); in __gfs2_iomap_alloc()
712 if (state != ALLOC_DATA || gfs2_is_jdata(ip)) in __gfs2_iomap_alloc()
718 ptr = (__be64 *)(dibh->b_data + in __gfs2_iomap_alloc()
722 for (; i - 1 < mp->mp_fheight - ip->i_height && n > 0; in __gfs2_iomap_alloc()
723 i++, n--) in __gfs2_iomap_alloc()
724 gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++); in __gfs2_iomap_alloc()
725 if (i - 1 == mp->mp_fheight - ip->i_height) { in __gfs2_iomap_alloc()
726 i--; in __gfs2_iomap_alloc()
727 gfs2_buffer_copy_tail(mp->mp_bh[i], in __gfs2_iomap_alloc()
733 ptr = (__be64 *)(mp->mp_bh[i]->b_data + in __gfs2_iomap_alloc()
737 for(i = branch_start; i < mp->mp_fheight; i++) { in __gfs2_iomap_alloc()
738 if (mp->mp_bh[i] == NULL) in __gfs2_iomap_alloc()
740 brelse(mp->mp_bh[i]); in __gfs2_iomap_alloc()
741 mp->mp_bh[i] = NULL; in __gfs2_iomap_alloc()
749 if (i > 1 && i < mp->mp_fheight) in __gfs2_iomap_alloc()
750 gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[i-1]); in __gfs2_iomap_alloc()
751 for (; i < mp->mp_fheight && n > 0; i++, n--) in __gfs2_iomap_alloc()
752 gfs2_indirect_init(mp, ip->i_gl, i, in __gfs2_iomap_alloc()
753 mp->mp_list[i-1], bn++); in __gfs2_iomap_alloc()
754 if (i == mp->mp_fheight) in __gfs2_iomap_alloc()
761 BUG_ON(mp->mp_bh[end_of_metadata] == NULL); in __gfs2_iomap_alloc()
762 gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[end_of_metadata]); in __gfs2_iomap_alloc()
765 iomap->addr = bn << inode->i_blkbits; in __gfs2_iomap_alloc()
766 iomap->flags |= IOMAP_F_MERGED | IOMAP_F_NEW; in __gfs2_iomap_alloc()
767 while (n-- > 0) in __gfs2_iomap_alloc()
771 } while (iomap->addr == IOMAP_NULL_ADDR); in __gfs2_iomap_alloc()
773 iomap->type = IOMAP_MAPPED; in __gfs2_iomap_alloc()
774 iomap->length = (u64)dblks << inode->i_blkbits; in __gfs2_iomap_alloc()
775 ip->i_height = mp->mp_fheight; in __gfs2_iomap_alloc()
776 gfs2_add_inode_blocks(&ip->i_inode, alloced); in __gfs2_iomap_alloc()
777 gfs2_dinode_out(ip, dibh->b_data); in __gfs2_iomap_alloc()
779 up_write(&ip->i_rw_mutex); in __gfs2_iomap_alloc()
786 * gfs2_alloc_size - Compute the maximum allocation size
797 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_alloc_size() local
809 if (gfs2_is_stuffed(ip) || mp->mp_fheight != mp->mp_aheight) { in gfs2_alloc_size()
810 unsigned int maxsize = mp->mp_fheight > 1 ? in gfs2_alloc_size()
811 sdp->sd_inptrs : sdp->sd_diptrs; in gfs2_alloc_size()
812 maxsize -= mp->mp_list[mp->mp_fheight - 1]; in gfs2_alloc_size()
818 first = metapointer(ip->i_height - 1, mp); in gfs2_alloc_size()
819 end = metaend(ip->i_height - 1, mp); in gfs2_alloc_size()
820 if (end - first > size) in gfs2_alloc_size()
826 return ptr - first; in gfs2_alloc_size()
830 * __gfs2_iomap_get - Map blocks from an inode to disk blocks
844 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_iomap_get() local
857 return -EINVAL; in __gfs2_iomap_get()
859 down_read(&ip->i_rw_mutex); in __gfs2_iomap_get()
861 ret = gfs2_meta_inode_buffer(ip, &dibh); in __gfs2_iomap_get()
864 mp->mp_bh[0] = dibh; in __gfs2_iomap_get()
866 if (gfs2_is_stuffed(ip)) { in __gfs2_iomap_get()
868 loff_t max_size = gfs2_max_stuffed_size(ip); in __gfs2_iomap_get()
872 iomap->length = max_size; in __gfs2_iomap_get()
876 ret = -ENOENT; in __gfs2_iomap_get()
879 iomap->offset = pos; in __gfs2_iomap_get()
880 iomap->length = length; in __gfs2_iomap_get()
884 iomap->length = size; in __gfs2_iomap_get()
886 iomap->addr = (ip->i_no_addr << inode->i_blkbits) + in __gfs2_iomap_get()
888 iomap->type = IOMAP_INLINE; in __gfs2_iomap_get()
889 iomap->inline_data = dibh->b_data + sizeof(struct gfs2_dinode); in __gfs2_iomap_get()
894 lblock = pos >> inode->i_blkbits; in __gfs2_iomap_get()
895 iomap->offset = lblock << inode->i_blkbits; in __gfs2_iomap_get()
896 lblock_stop = (pos + length - 1) >> inode->i_blkbits; in __gfs2_iomap_get()
897 len = lblock_stop - lblock + 1; in __gfs2_iomap_get()
898 iomap->length = len << inode->i_blkbits; in __gfs2_iomap_get()
900 height = ip->i_height; in __gfs2_iomap_get()
901 while ((lblock + 1) * sdp->sd_sb.sb_bsize > sdp->sd_heightsize[height]) in __gfs2_iomap_get()
904 if (height > ip->i_height || gfs2_is_stuffed(ip)) in __gfs2_iomap_get()
907 ret = lookup_metapath(ip, mp); in __gfs2_iomap_get()
911 if (mp->mp_aheight != ip->i_height) in __gfs2_iomap_get()
914 ptr = metapointer(ip->i_height - 1, mp); in __gfs2_iomap_get()
918 bh = mp->mp_bh[ip->i_height - 1]; in __gfs2_iomap_get()
921 iomap->addr = be64_to_cpu(*ptr) << inode->i_blkbits; in __gfs2_iomap_get()
922 iomap->length = len << inode->i_blkbits; in __gfs2_iomap_get()
923 iomap->type = IOMAP_MAPPED; in __gfs2_iomap_get()
924 iomap->flags |= IOMAP_F_MERGED; in __gfs2_iomap_get()
926 iomap->flags |= IOMAP_F_GFS2_BOUNDARY; in __gfs2_iomap_get()
929 iomap->bdev = inode->i_sb->s_bdev; in __gfs2_iomap_get()
931 up_read(&ip->i_rw_mutex); in __gfs2_iomap_get()
937 ret = -ENOENT; in __gfs2_iomap_get()
938 else if (height == ip->i_height) in __gfs2_iomap_get()
941 iomap->length = size - iomap->offset; in __gfs2_iomap_get()
949 alloc_size = len << inode->i_blkbits; in __gfs2_iomap_get()
950 if (alloc_size < iomap->length) in __gfs2_iomap_get()
951 iomap->length = alloc_size; in __gfs2_iomap_get()
953 if (pos < size && height == ip->i_height) in __gfs2_iomap_get()
957 iomap->addr = IOMAP_NULL_ADDR; in __gfs2_iomap_get()
958 iomap->type = IOMAP_HOLE; in __gfs2_iomap_get()
965 struct inode *inode = iter->inode; in gfs2_iomap_get_folio()
966 unsigned int blockmask = i_blocksize(inode) - 1; in gfs2_iomap_get_folio()
972 blocks = ((pos & blockmask) + len + blockmask) >> inode->i_blkbits; in gfs2_iomap_get_folio()
986 struct gfs2_trans *tr = current->journal_info; in gfs2_iomap_put_folio()
987 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_put_folio() local
990 if (!gfs2_is_stuffed(ip)) in gfs2_iomap_put_folio()
991 gfs2_trans_add_databufs(ip, folio, offset_in_folio(folio, pos), in gfs2_iomap_put_folio()
997 if (tr->tr_num_buf_new) in gfs2_iomap_put_folio()
1013 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_begin_write() local
1018 unstuff = gfs2_is_stuffed(ip) && in gfs2_iomap_begin_write()
1019 pos + length > gfs2_max_stuffed_size(ip); in gfs2_iomap_begin_write()
1021 if (unstuff || iomap->type == IOMAP_HOLE) { in gfs2_iomap_begin_write()
1027 gfs2_write_calc_reserv(ip, iomap->length, &data_blocks, in gfs2_iomap_begin_write()
1030 ret = gfs2_quota_lock_check(ip, &ap); in gfs2_iomap_begin_write()
1034 ret = gfs2_inplace_reserve(ip, &ap); in gfs2_iomap_begin_write()
1039 if (gfs2_is_jdata(ip)) in gfs2_iomap_begin_write()
1043 if (inode == sdp->sd_rindex) in gfs2_iomap_begin_write()
1045 rblocks += gfs2_rg_blocks(ip, data_blocks + ind_blocks); in gfs2_iomap_begin_write()
1048 iomap->length >> inode->i_blkbits); in gfs2_iomap_begin_write()
1053 ret = gfs2_unstuff_dinode(ip); in gfs2_iomap_begin_write()
1057 ret = __gfs2_iomap_get(inode, iomap->offset, in gfs2_iomap_begin_write()
1058 iomap->length, flags, iomap, mp); in gfs2_iomap_begin_write()
1063 if (iomap->type == IOMAP_HOLE) { in gfs2_iomap_begin_write()
1067 gfs2_inplace_release(ip); in gfs2_iomap_begin_write()
1068 punch_hole(ip, iomap->offset, iomap->length); in gfs2_iomap_begin_write()
1073 tr = current->journal_info; in gfs2_iomap_begin_write()
1074 if (tr->tr_num_buf_new) in gfs2_iomap_begin_write()
1080 if (gfs2_is_stuffed(ip) || gfs2_is_jdata(ip)) in gfs2_iomap_begin_write()
1081 iomap->folio_ops = &gfs2_iomap_folio_ops; in gfs2_iomap_begin_write()
1087 gfs2_inplace_release(ip); in gfs2_iomap_begin_write()
1089 gfs2_quota_unlock(ip); in gfs2_iomap_begin_write()
1097 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_begin() local
1101 if (gfs2_is_jdata(ip)) in gfs2_iomap_begin()
1102 iomap->flags |= IOMAP_F_BUFFER_HEAD; in gfs2_iomap_begin()
1104 trace_gfs2_iomap_start(ip, pos, length, flags); in gfs2_iomap_begin()
1116 if (iomap->type != IOMAP_MAPPED) in gfs2_iomap_begin()
1117 ret = -ENOTBLK; in gfs2_iomap_begin()
1122 if (iomap->type == IOMAP_HOLE) in gfs2_iomap_begin()
1133 trace_gfs2_iomap_end(ip, iomap, ret); in gfs2_iomap_begin()
1140 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_iomap_end() local
1149 if (iomap->type == IOMAP_HOLE) in gfs2_iomap_end()
1156 if (!gfs2_is_stuffed(ip)) in gfs2_iomap_end()
1157 gfs2_ordered_add_inode(ip); in gfs2_iomap_end()
1159 if (inode == sdp->sd_rindex) in gfs2_iomap_end()
1162 gfs2_inplace_release(ip); in gfs2_iomap_end()
1164 if (ip->i_qadata && ip->i_qadata->qa_qd_num) in gfs2_iomap_end()
1165 gfs2_quota_unlock(ip); in gfs2_iomap_end()
1167 if (length != written && (iomap->flags & IOMAP_F_NEW)) { in gfs2_iomap_end()
1170 loff_t hend = iomap->offset + iomap->length; in gfs2_iomap_end()
1173 truncate_pagecache_range(inode, hstart, hend - 1); in gfs2_iomap_end()
1174 punch_hole(ip, hstart, hend - hstart); in gfs2_iomap_end()
1181 if (iomap->flags & IOMAP_F_SIZE_CHANGED) in gfs2_iomap_end()
1183 set_bit(GLF_DIRTY, &ip->i_gl->gl_flags); in gfs2_iomap_end()
1193 * gfs2_block_map - Map one or more blocks of an inode to a disk block
1195 * @lblock: The logical block number
1199 * The size of the requested mapping is defined in bh_map->b_size.
1201 * Clears buffer_mapped(bh_map) and leaves bh_map->b_size unchanged
1203 * bh_map->b_size to indicate the size of the mapping when @lblock and
1207 * before the next block can be mapped. Sets buffer_new() if new
1216 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_block_map() local
1217 loff_t pos = (loff_t)lblock << inode->i_blkbits; in gfs2_block_map()
1218 loff_t length = bh_map->b_size; in gfs2_block_map()
1225 trace_gfs2_bmap(ip, bh_map, lblock, create, 1); in gfs2_block_map()
1234 if (iomap.length > bh_map->b_size) { in gfs2_block_map()
1235 iomap.length = bh_map->b_size; in gfs2_block_map()
1239 map_bh(bh_map, inode->i_sb, iomap.addr >> inode->i_blkbits); in gfs2_block_map()
1240 bh_map->b_size = iomap.length; in gfs2_block_map()
1247 trace_gfs2_bmap(ip, bh_map, lblock, create, ret); in gfs2_block_map()
1254 unsigned int blkbits = inode->i_blkbits; in gfs2_get_extent()
1264 return -EIO; in gfs2_get_extent()
1275 unsigned int blkbits = inode->i_blkbits; in gfs2_alloc_extent()
1285 return -EIO; in gfs2_alloc_extent()
1302 BUG_ON(current->journal_info); in gfs2_block_zero_range()
1309 * gfs2_journaled_truncate - Wrapper for truncate_pagecache for jdata files
1314 * With jdata files, we have to journal a revoke for each block which is
1322 u64 max_chunk = GFS2_JTRUNC_REVOKES * sdp->sd_vfs->s_blocksize; in gfs2_journaled_truncate()
1330 chunk = oldsize - newsize; in gfs2_journaled_truncate()
1336 chunk = offs + ((chunk - offs) & PAGE_MASK); in gfs2_journaled_truncate()
1338 truncate_pagecache(inode, oldsize - chunk); in gfs2_journaled_truncate()
1339 oldsize -= chunk; in gfs2_journaled_truncate()
1341 tr = current->journal_info; in gfs2_journaled_truncate()
1342 if (!test_bit(TR_TOUCHED, &tr->tr_flags)) in gfs2_journaled_truncate()
1356 struct gfs2_inode *ip = GFS2_I(inode); in trunc_start() local
1359 int journaled = gfs2_is_jdata(ip); in trunc_start()
1360 u64 oldsize = inode->i_size; in trunc_start()
1363 if (!gfs2_is_stuffed(ip)) { in trunc_start()
1365 unsigned int offs = newsize & (blocksize - 1); in trunc_start()
1368 blocksize - offs); in trunc_start()
1380 error = gfs2_meta_inode_buffer(ip, &dibh); in trunc_start()
1384 gfs2_trans_add_meta(ip->i_gl, dibh); in trunc_start()
1386 if (gfs2_is_stuffed(ip)) in trunc_start()
1389 ip->i_diskflags |= GFS2_DIF_TRUNC_IN_PROG; in trunc_start()
1392 inode_set_mtime_to_ts(&ip->i_inode, inode_set_ctime_current(&ip->i_inode)); in trunc_start()
1393 gfs2_dinode_out(ip, dibh->b_data); in trunc_start()
1402 if (current->journal_info) in trunc_start()
1425 if (!ret && iomap->type == IOMAP_HOLE) in gfs2_iomap_alloc()
1432 * sweep_bh_for_rgrps - find an rgrp in a meta buffer and free blocks therein
1433 * @ip: inode
1443 * block has references to multiple rgrps, we break it into individual
1448 * if we're interrupted by power-outages.
1453 static int sweep_bh_for_rgrps(struct gfs2_inode *ip, struct gfs2_holder *rd_gh, in sweep_bh_for_rgrps() argument
1457 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in sweep_bh_for_rgrps()
1470 rgd = gfs2_glock2rgrp(rd_gh->gh_gl); in sweep_bh_for_rgrps()
1472 gfs2_glock_is_locked_by_me(rd_gh->gh_gl)); in sweep_bh_for_rgrps()
1491 ret = -EIO; in sweep_bh_for_rgrps()
1494 ret = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, in sweep_bh_for_rgrps()
1500 if (gfs2_rs_active(&ip->i_res) && in sweep_bh_for_rgrps()
1501 rgd == ip->i_res.rs_rgd) in sweep_bh_for_rgrps()
1502 gfs2_rs_deltree(&ip->i_res); in sweep_bh_for_rgrps()
1510 if (current->journal_info == NULL) { in sweep_bh_for_rgrps()
1513 jblocks_rqsted = rgd->rd_length + RES_DINODE + in sweep_bh_for_rgrps()
1515 isize_blks = gfs2_get_inode_blocks(&ip->i_inode); in sweep_bh_for_rgrps()
1516 if (isize_blks > atomic_read(&sdp->sd_log_thresh2)) in sweep_bh_for_rgrps()
1518 atomic_read(&sdp->sd_log_thresh2); in sweep_bh_for_rgrps()
1523 revokes += end - start; in sweep_bh_for_rgrps()
1524 else if (ip->i_depth) in sweep_bh_for_rgrps()
1525 revokes += sdp->sd_inptrs; in sweep_bh_for_rgrps()
1529 down_write(&ip->i_rw_mutex); in sweep_bh_for_rgrps()
1532 tr = current->journal_info; in sweep_bh_for_rgrps()
1533 if (tr->tr_num_buf_new + RES_STATFS + in sweep_bh_for_rgrps()
1534 RES_QUOTA >= atomic_read(&sdp->sd_log_thresh2)) { in sweep_bh_for_rgrps()
1540 to the transaction, we've already set some block in sweep_bh_for_rgrps()
1556 gfs2_trans_add_meta(ip->i_gl, bh); in sweep_bh_for_rgrps()
1564 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta); in sweep_bh_for_rgrps()
1566 gfs2_add_inode_blocks(&ip->i_inode, -blen); in sweep_bh_for_rgrps()
1572 __gfs2_free_blocks(ip, rgd, bstart, (u32)blen, meta); in sweep_bh_for_rgrps()
1574 gfs2_add_inode_blocks(&ip->i_inode, -blen); in sweep_bh_for_rgrps()
1577 if (!ret && blks_outside_rgrp) { /* If buffer still has non-zero blocks in sweep_bh_for_rgrps()
1580 if (current->journal_info) { in sweep_bh_for_rgrps()
1583 ret = gfs2_meta_inode_buffer(ip, &dibh); in sweep_bh_for_rgrps()
1589 inode_set_mtime_to_ts(&ip->i_inode, inode_set_ctime_current(&ip->i_inode)); in sweep_bh_for_rgrps()
1590 gfs2_trans_add_meta(ip->i_gl, dibh); in sweep_bh_for_rgrps()
1591 gfs2_dinode_out(ip, dibh->b_data); in sweep_bh_for_rgrps()
1593 up_write(&ip->i_rw_mutex); in sweep_bh_for_rgrps()
1607 if (memcmp(mp->mp_list, list, h * sizeof(mp->mp_list[0]))) in mp_eq_to_hgt()
1613 * find_nonnull_ptr - find a non-null pointer given a metapath and height
1621 * Returns: true if a non-null pointer was found in the metapath buffer
1628 struct buffer_head *bh = mp->mp_bh[h]; in find_nonnull_ptr()
1632 ptr = first + mp->mp_list[h]; in find_nonnull_ptr()
1633 end = (__be64 *)(bh->b_data + bh->b_size); in find_nonnull_ptr()
1640 if (*ptr) { /* if we have a non-null pointer */ in find_nonnull_ptr()
1641 mp->mp_list[h] = ptr - first; in find_nonnull_ptr()
1644 mp->mp_list[h] = 0; in find_nonnull_ptr()
1665 struct buffer_head *bh = mp->mp_bh[height]; in metapointer_range()
1674 *end = (__be64 *)(bh->b_data + bh->b_size); in metapointer_range()
1693 end = (height > 0) ? sdp->sd_inptrs : sdp->sd_diptrs; in walk_done()
1694 return mp->mp_list[height] >= end; in walk_done()
1698 * punch_hole - deallocate blocks in a file
1699 * @ip: inode to truncate
1713 static int punch_hole(struct gfs2_inode *ip, u64 offset, u64 length) in punch_hole() argument
1715 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in punch_hole()
1716 u64 maxsize = sdp->sd_heightsize[ip->i_height]; in punch_hole()
1720 unsigned int bsize_shift = sdp->sd_sb.sb_bsize_shift; in punch_hole()
1722 u64 lblock = (offset + bsize - 1) >> bsize_shift; in punch_hole()
1726 unsigned int strip_h = ip->i_height - 1; in punch_hole()
1733 if (offset + bsize - 1 >= maxsize) { in punch_hole()
1769 find_metapath(sdp, lend, &mp, ip->i_height); in punch_hole()
1773 for (mp_h = ip->i_height - 1; mp_h > 0; mp_h--) { in punch_hole()
1780 find_metapath(sdp, lblock, &mp, ip->i_height); in punch_hole()
1783 for (mp_h = ip->i_height - 1; mp_h > 0; mp_h--) { in punch_hole()
1789 ret = gfs2_meta_inode_buffer(ip, &dibh); in punch_hole()
1794 ret = lookup_metapath(ip, &mp); in punch_hole()
1798 /* issue read-ahead on metadata */ in punch_hole()
1799 for (mp_h = 0; mp_h < mp.mp_aheight - 1; mp_h++) { in punch_hole()
1802 gfs2_metapath_ra(ip->i_gl, start, end); in punch_hole()
1805 if (mp.mp_aheight == ip->i_height) in punch_hole()
1814 ret = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE); in punch_hole()
1829 prev_bnr != bh->b_blocknr)) { in punch_hole()
1830 fs_emerg(sdp, "inode %llu, block:%llu, i_h:%u, " in punch_hole()
1832 (unsigned long long)ip->i_no_addr, in punch_hole()
1833 prev_bnr, ip->i_height, strip_h, mp_h); in punch_hole()
1835 prev_bnr = bh->b_blocknr; in punch_hole()
1840 ret = -EIO; in punch_hole()
1853 ret = sweep_bh_for_rgrps(ip, &rd_gh, mp.mp_bh[mp_h], in punch_hole()
1855 mp_h != ip->i_height - 1, in punch_hole()
1880 strip_h--; in punch_hole()
1887 mp_h--; /* search one metadata height down */ in punch_hole()
1893 * next non-null pointer. */ in punch_hole()
1898 /* No more non-null pointers at this height. Back up in punch_hole()
1905 ret = fillup_metapath(ip, &mp, mp_h); in punch_hole()
1909 /* On the first pass, issue read-ahead on metadata. */ in punch_hole()
1910 if (mp.mp_aheight > 1 && strip_h == ip->i_height - 1) { in punch_hole()
1911 unsigned int height = mp.mp_aheight - 1; in punch_hole()
1913 /* No read-ahead for data blocks. */ in punch_hole()
1914 if (mp.mp_aheight - 1 == strip_h) in punch_hole()
1915 height--; in punch_hole()
1917 for (; height >= mp.mp_aheight - ret; height--) { in punch_hole()
1922 gfs2_metapath_ra(ip->i_gl, start, end); in punch_hole()
1927 if (mp.mp_aheight - 1 == strip_h) { in punch_hole()
1931 if (mp.mp_aheight < ip->i_height) /* We have a partial height */ in punch_hole()
1932 mp_h = mp.mp_aheight - 1; in punch_hole()
1934 /* If we find a non-null block pointer, crawl a bit in punch_hole()
1946 if (current->journal_info == NULL) { in punch_hole()
1951 down_write(&ip->i_rw_mutex); in punch_hole()
1954 gfs2_quota_change(ip, -(s64)btotal, ip->i_inode.i_uid, in punch_hole()
1955 ip->i_inode.i_gid); in punch_hole()
1956 inode_set_mtime_to_ts(&ip->i_inode, inode_set_ctime_current(&ip->i_inode)); in punch_hole()
1957 gfs2_trans_add_meta(ip->i_gl, dibh); in punch_hole()
1958 gfs2_dinode_out(ip, dibh->b_data); in punch_hole()
1959 up_write(&ip->i_rw_mutex); in punch_hole()
1966 if (current->journal_info) { in punch_hole()
1967 up_write(&ip->i_rw_mutex); in punch_hole()
1971 gfs2_quota_unhold(ip); in punch_hole()
1977 static int trunc_end(struct gfs2_inode *ip) in trunc_end() argument
1979 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in trunc_end()
1987 down_write(&ip->i_rw_mutex); in trunc_end()
1989 error = gfs2_meta_inode_buffer(ip, &dibh); in trunc_end()
1993 if (!i_size_read(&ip->i_inode)) { in trunc_end()
1994 ip->i_height = 0; in trunc_end()
1995 ip->i_goal = ip->i_no_addr; in trunc_end()
1997 gfs2_ordered_del_inode(ip); in trunc_end()
1999 inode_set_mtime_to_ts(&ip->i_inode, inode_set_ctime_current(&ip->i_inode)); in trunc_end()
2000 ip->i_diskflags &= ~GFS2_DIF_TRUNC_IN_PROG; in trunc_end()
2002 gfs2_trans_add_meta(ip->i_gl, dibh); in trunc_end()
2003 gfs2_dinode_out(ip, dibh->b_data); in trunc_end()
2007 up_write(&ip->i_rw_mutex); in trunc_end()
2013 * do_shrink - make a file smaller
2025 struct gfs2_inode *ip = GFS2_I(inode); in do_shrink() local
2031 if (gfs2_is_stuffed(ip)) in do_shrink()
2034 error = punch_hole(ip, newsize, 0); in do_shrink()
2036 error = trunc_end(ip); in do_shrink()
2042 * do_grow - Touch and update inode size
2058 * Returns: 0 on success, or -ve on error
2063 struct gfs2_inode *ip = GFS2_I(inode); in do_grow() local
2070 if (gfs2_is_stuffed(ip) && size > gfs2_max_stuffed_size(ip)) { in do_grow()
2071 error = gfs2_quota_lock_check(ip, &ap); in do_grow()
2075 error = gfs2_inplace_reserve(ip, &ap); in do_grow()
2083 gfs2_is_jdata(ip) ? RES_JDATA : 0) + in do_grow()
2084 (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF ? in do_grow()
2090 error = gfs2_unstuff_dinode(ip); in do_grow()
2095 error = gfs2_meta_inode_buffer(ip, &dibh); in do_grow()
2100 inode_set_mtime_to_ts(&ip->i_inode, inode_set_ctime_current(&ip->i_inode)); in do_grow()
2101 gfs2_trans_add_meta(ip->i_gl, dibh); in do_grow()
2102 gfs2_dinode_out(ip, dibh->b_data); in do_grow()
2109 gfs2_inplace_release(ip); in do_grow()
2111 gfs2_quota_unlock(ip); in do_grow()
2117 * gfs2_setattr_size - make a file a given size
2130 struct gfs2_inode *ip = GFS2_I(inode); in gfs2_setattr_size() local
2133 BUG_ON(!S_ISREG(inode->i_mode)); in gfs2_setattr_size()
2141 ret = gfs2_qa_get(ip); in gfs2_setattr_size()
2145 if (newsize >= inode->i_size) { in gfs2_setattr_size()
2152 gfs2_rs_delete(ip); in gfs2_setattr_size()
2153 gfs2_qa_put(ip); in gfs2_setattr_size()
2157 int gfs2_truncatei_resume(struct gfs2_inode *ip) in gfs2_truncatei_resume() argument
2160 error = punch_hole(ip, i_size_read(&ip->i_inode), 0); in gfs2_truncatei_resume()
2162 error = trunc_end(ip); in gfs2_truncatei_resume()
2166 int gfs2_file_dealloc(struct gfs2_inode *ip) in gfs2_file_dealloc() argument
2168 return punch_hole(ip, 0, 0); in gfs2_file_dealloc()
2172 * gfs2_free_journal_extents - Free cached journal bmap info
2181 while(!list_empty(&jd->extent_list)) { in gfs2_free_journal_extents()
2182 jext = list_first_entry(&jd->extent_list, struct gfs2_journal_extent, list); in gfs2_free_journal_extents()
2183 list_del(&jext->list); in gfs2_free_journal_extents()
2189 * gfs2_add_jextent - Add or merge a new extent to extent cache
2191 * @lblock: The logical block at start of new extent
2192 * @dblock: The physical block at start of new extent
2195 * Returns: 0 on success or -ENOMEM
2202 if (!list_empty(&jd->extent_list)) { in gfs2_add_jextent()
2203 jext = list_last_entry(&jd->extent_list, struct gfs2_journal_extent, list); in gfs2_add_jextent()
2204 if ((jext->dblock + jext->blocks) == dblock) { in gfs2_add_jextent()
2205 jext->blocks += blocks; in gfs2_add_jextent()
2212 return -ENOMEM; in gfs2_add_jextent()
2213 jext->dblock = dblock; in gfs2_add_jextent()
2214 jext->lblock = lblock; in gfs2_add_jextent()
2215 jext->blocks = blocks; in gfs2_add_jextent()
2216 list_add_tail(&jext->list, &jd->extent_list); in gfs2_add_jextent()
2217 jd->nr_extents++; in gfs2_add_jextent()
2222 * gfs2_map_journal_extents - Cache journal bmap info
2223 * @sdp: The super block
2231 * So the extent would map the first block for the entire file length.
2245 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); in gfs2_map_journal_extents() local
2247 unsigned int shift = sdp->sd_sb.sb_bsize_shift; in gfs2_map_journal_extents()
2253 lblock_stop = i_size_read(jd->jd_inode) >> shift; in gfs2_map_journal_extents()
2254 size = (lblock_stop - lblock) << shift; in gfs2_map_journal_extents()
2255 jd->nr_extents = 0; in gfs2_map_journal_extents()
2256 WARN_ON(!list_empty(&jd->extent_list)); in gfs2_map_journal_extents()
2262 rc = gfs2_block_map(jd->jd_inode, lblock, &bh, 0); in gfs2_map_journal_extents()
2268 size -= bh.b_size; in gfs2_map_journal_extents()
2269 lblock += (bh.b_size >> ip->i_inode.i_blkbits); in gfs2_map_journal_extents()
2273 fs_info(sdp, "journal %d mapped with %u extents in %lldms\n", jd->jd_jid, in gfs2_map_journal_extents()
2274 jd->nr_extents, ktime_ms_delta(end, start)); in gfs2_map_journal_extents()
2279 rc, jd->jd_jid, in gfs2_map_journal_extents()
2280 (unsigned long long)(i_size_read(jd->jd_inode) - size), in gfs2_map_journal_extents()
2281 jd->nr_extents); in gfs2_map_journal_extents()
2282 fs_warn(sdp, "bmap=%d lblock=%llu block=%llu, state=0x%08lx, size=%llu\n", in gfs2_map_journal_extents()
2290 * gfs2_write_alloc_required - figure out if a write will require an allocation
2291 * @ip: the file being written to
2298 int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, in gfs2_write_alloc_required() argument
2301 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_write_alloc_required()
2310 if (gfs2_is_stuffed(ip)) { in gfs2_write_alloc_required()
2311 if (offset + len > gfs2_max_stuffed_size(ip)) in gfs2_write_alloc_required()
2316 shift = sdp->sd_sb.sb_bsize_shift; in gfs2_write_alloc_required()
2317 BUG_ON(gfs2_is_dir(ip)); in gfs2_write_alloc_required()
2318 end_of_file = (i_size_read(&ip->i_inode) + sdp->sd_sb.sb_bsize - 1) >> shift; in gfs2_write_alloc_required()
2320 lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; in gfs2_write_alloc_required()
2321 if (lblock_stop > end_of_file && ip != GFS2_I(sdp->sd_rindex)) in gfs2_write_alloc_required()
2324 size = (lblock_stop - lblock) << shift; in gfs2_write_alloc_required()
2328 gfs2_block_map(&ip->i_inode, lblock, &bh, 0); in gfs2_write_alloc_required()
2331 size -= bh.b_size; in gfs2_write_alloc_required()
2332 lblock += (bh.b_size >> ip->i_inode.i_blkbits); in gfs2_write_alloc_required()
2340 struct gfs2_inode *ip = GFS2_I(inode); in stuffed_zero_range() local
2344 if (offset >= inode->i_size) in stuffed_zero_range()
2346 if (offset + length > inode->i_size) in stuffed_zero_range()
2347 length = inode->i_size - offset; in stuffed_zero_range()
2349 error = gfs2_meta_inode_buffer(ip, &dibh); in stuffed_zero_range()
2352 gfs2_trans_add_meta(ip->i_gl, dibh); in stuffed_zero_range()
2353 memset(dibh->b_data + sizeof(struct gfs2_dinode) + offset, 0, in stuffed_zero_range()
2363 loff_t max_chunk = GFS2_JTRUNC_REVOKES * sdp->sd_vfs->s_blocksize; in gfs2_journaled_truncate_range()
2377 chunk = offs + ((chunk - offs) & PAGE_MASK); in gfs2_journaled_truncate_range()
2381 length -= chunk; in gfs2_journaled_truncate_range()
2383 tr = current->journal_info; in gfs2_journaled_truncate_range()
2384 if (!test_bit(TR_TOUCHED, &tr->tr_flags)) in gfs2_journaled_truncate_range()
2398 struct gfs2_inode *ip = GFS2_I(inode); in __gfs2_punch_hole() local
2404 if (!gfs2_is_stuffed(ip)) { in __gfs2_punch_hole()
2407 start_off = offset & (blocksize - 1); in __gfs2_punch_hole()
2408 end_len = (offset + length) & (blocksize - 1); in __gfs2_punch_hole()
2411 if (length > blocksize - start_off) in __gfs2_punch_hole()
2412 len = blocksize - start_off; in __gfs2_punch_hole()
2421 offset + length - end_len, end_len); in __gfs2_punch_hole()
2428 end = round_up(offset + length, blocksize) - 1; in __gfs2_punch_hole()
2429 error = filemap_write_and_wait_range(inode->i_mapping, start, end); in __gfs2_punch_hole()
2433 if (gfs2_is_jdata(ip)) in __gfs2_punch_hole()
2441 if (gfs2_is_stuffed(ip)) { in __gfs2_punch_hole()
2447 if (gfs2_is_jdata(ip)) { in __gfs2_punch_hole()
2448 BUG_ON(!current->journal_info); in __gfs2_punch_hole()
2451 truncate_pagecache_range(inode, offset, offset + length - 1); in __gfs2_punch_hole()
2456 if (current->journal_info) in __gfs2_punch_hole()
2459 if (!gfs2_is_stuffed(ip)) in __gfs2_punch_hole()
2460 error = punch_hole(ip, offset, length); in __gfs2_punch_hole()
2463 if (current->journal_info) in __gfs2_punch_hole()
2474 return -EIO; in gfs2_map_blocks()
2476 if (offset >= wpc->iomap.offset && in gfs2_map_blocks()
2477 offset < wpc->iomap.offset + wpc->iomap.length) in gfs2_map_blocks()
2480 memset(&wpc->iomap, 0, sizeof(wpc->iomap)); in gfs2_map_blocks()
2481 ret = gfs2_iomap_get(inode, offset, INT_MAX, &wpc->iomap); in gfs2_map_blocks()