Lines Matching +full:ip +full:- +full:blocks
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * Copyright (c) 2016-2018 Christoph Hellwig.
36 * Fast and loose check if this write could update the on-disk inode size.
40 return ioend->io_offset + ioend->io_size > in xfs_ioend_is_append()
41 XFS_I(ioend->io_inode)->i_disk_size; in xfs_ioend_is_append()
45 * Update on-disk file size now that data has been written to disk.
49 struct xfs_inode *ip, in xfs_setfilesize() argument
53 struct xfs_mount *mp = ip->i_mount; in xfs_setfilesize()
58 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); in xfs_setfilesize()
62 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_setfilesize()
63 isize = xfs_new_eof(ip, offset + size); in xfs_setfilesize()
65 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_setfilesize()
70 trace_xfs_setfilesize(ip, offset, size); in xfs_setfilesize()
72 ip->i_disk_size = isize; in xfs_setfilesize()
73 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_setfilesize()
74 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_setfilesize()
86 struct xfs_inode *ip = XFS_I(ioend->io_inode); in xfs_end_ioend() local
87 struct xfs_mount *mp = ip->i_mount; in xfs_end_ioend()
88 xfs_off_t offset = ioend->io_offset; in xfs_end_ioend()
89 size_t size = ioend->io_size; in xfs_end_ioend()
96 * task-wide nofs context for the following operations. in xfs_end_ioend()
101 * Just clean up the in-memory structures if the fs has been shut down. in xfs_end_ioend()
104 error = -EIO; in xfs_end_ioend()
109 * Clean up all COW blocks and underlying data fork delalloc blocks on in xfs_end_ioend()
111 * mapped to blocks in the COW fork and the associated pages are no in xfs_end_ioend()
112 * longer dirty. If we don't remove delalloc blocks here, they become in xfs_end_ioend()
115 error = blk_status_to_errno(ioend->io_bio.bi_status); in xfs_end_ioend()
117 if (ioend->io_flags & IOMAP_F_SHARED) { in xfs_end_ioend()
118 xfs_reflink_cancel_cow_range(ip, offset, size, true); in xfs_end_ioend()
119 xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, offset, in xfs_end_ioend()
126 * Success: commit the COW or unwritten blocks if needed. in xfs_end_ioend()
128 if (ioend->io_flags & IOMAP_F_SHARED) in xfs_end_ioend()
129 error = xfs_reflink_end_cow(ip, offset, size); in xfs_end_ioend()
130 else if (ioend->io_type == IOMAP_UNWRITTEN) in xfs_end_ioend()
131 error = xfs_iomap_write_unwritten(ip, offset, size, false); in xfs_end_ioend()
134 error = xfs_setfilesize(ip, ioend->io_offset, ioend->io_size); in xfs_end_ioend()
158 struct xfs_inode *ip = in xfs_end_io() local
164 spin_lock_irqsave(&ip->i_ioend_lock, flags); in xfs_end_io()
165 list_replace_init(&ip->i_ioend_list, &tmp); in xfs_end_io()
166 spin_unlock_irqrestore(&ip->i_ioend_lock, flags); in xfs_end_io()
171 list_del_init(&ioend->io_list); in xfs_end_io()
183 struct xfs_inode *ip = XFS_I(ioend->io_inode); in xfs_end_bio() local
186 spin_lock_irqsave(&ip->i_ioend_lock, flags); in xfs_end_bio()
187 if (list_empty(&ip->i_ioend_list)) in xfs_end_bio()
188 WARN_ON_ONCE(!queue_work(ip->i_mount->m_unwritten_workqueue, in xfs_end_bio()
189 &ip->i_ioend_work)); in xfs_end_bio()
190 list_add_tail(&ioend->io_list, &ip->i_ioend_list); in xfs_end_bio()
191 spin_unlock_irqrestore(&ip->i_ioend_lock, flags); in xfs_end_bio()
201 struct xfs_inode *ip, in xfs_imap_valid() argument
204 if (offset < wpc->iomap.offset || in xfs_imap_valid()
205 offset >= wpc->iomap.offset + wpc->iomap.length) in xfs_imap_valid()
212 if (wpc->iomap.flags & IOMAP_F_SHARED) in xfs_imap_valid()
220 * overlapping blocks. in xfs_imap_valid()
222 if (XFS_WPC(wpc)->data_seq != READ_ONCE(ip->i_df.if_seq)) { in xfs_imap_valid()
223 trace_xfs_wb_data_iomap_invalid(ip, &wpc->iomap, in xfs_imap_valid()
224 XFS_WPC(wpc)->data_seq, XFS_DATA_FORK); in xfs_imap_valid()
227 if (xfs_inode_has_cow_data(ip) && in xfs_imap_valid()
228 XFS_WPC(wpc)->cow_seq != READ_ONCE(ip->i_cowfp->if_seq)) { in xfs_imap_valid()
229 trace_xfs_wb_cow_iomap_invalid(ip, &wpc->iomap, in xfs_imap_valid()
230 XFS_WPC(wpc)->cow_seq, XFS_COW_FORK); in xfs_imap_valid()
243 struct xfs_inode *ip = XFS_I(inode); in xfs_map_blocks() local
244 struct xfs_mount *mp = ip->i_mount; in xfs_map_blocks()
257 return -EIO; in xfs_map_blocks()
262 * COW fork blocks can overlap data fork blocks even if the blocks in xfs_map_blocks()
276 if (xfs_imap_valid(wpc, ip, offset)) in xfs_map_blocks()
288 xfs_ilock(ip, XFS_ILOCK_SHARED); in xfs_map_blocks()
289 ASSERT(!xfs_need_iread_extents(&ip->i_df)); in xfs_map_blocks()
295 if (xfs_inode_has_cow_data(ip) && in xfs_map_blocks()
296 xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &imap)) in xfs_map_blocks()
299 XFS_WPC(wpc)->cow_seq = READ_ONCE(ip->i_cowfp->if_seq); in xfs_map_blocks()
300 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_map_blocks()
308 * ->cow_seq. If the data mapping is still valid, we're done. in xfs_map_blocks()
310 if (xfs_imap_valid(wpc, ip, offset)) { in xfs_map_blocks()
311 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_map_blocks()
320 if (!xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap)) in xfs_map_blocks()
322 XFS_WPC(wpc)->data_seq = READ_ONCE(ip->i_df.if_seq); in xfs_map_blocks()
323 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_map_blocks()
327 imap.br_blockcount = imap.br_startoff - offset_fsb; in xfs_map_blocks()
336 * subsequent blocks in the mapping; however, the requirement to treat in xfs_map_blocks()
341 imap.br_blockcount = cow_fsb - imap.br_startoff; in xfs_map_blocks()
348 xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, 0, XFS_WPC(wpc)->data_seq); in xfs_map_blocks()
349 trace_xfs_map_blocks_found(ip, offset, count, whichfork, &imap); in xfs_map_blocks()
359 seq = &XFS_WPC(wpc)->cow_seq; in xfs_map_blocks()
361 seq = &XFS_WPC(wpc)->data_seq; in xfs_map_blocks()
363 error = xfs_bmapi_convert_delalloc(ip, whichfork, offset, in xfs_map_blocks()
364 &wpc->iomap, seq); in xfs_map_blocks()
373 if (error == -EAGAIN && whichfork == XFS_COW_FORK && !retries++) in xfs_map_blocks()
375 ASSERT(error != -EAGAIN); in xfs_map_blocks()
382 * boundary again to force a re-lookup. in xfs_map_blocks()
387 if (cow_offset < wpc->iomap.offset + wpc->iomap.length) in xfs_map_blocks()
388 wpc->iomap.length = cow_offset - wpc->iomap.offset; in xfs_map_blocks()
391 ASSERT(wpc->iomap.offset <= offset); in xfs_map_blocks()
392 ASSERT(wpc->iomap.offset + wpc->iomap.length > offset); in xfs_map_blocks()
393 trace_xfs_map_blocks_alloc(ip, offset, count, whichfork, &imap); in xfs_map_blocks()
407 * task-wide nofs context for the following operations. in xfs_prepare_ioend()
412 if (!status && (ioend->io_flags & IOMAP_F_SHARED)) { in xfs_prepare_ioend()
413 status = xfs_reflink_convert_cow(XFS_I(ioend->io_inode), in xfs_prepare_ioend()
414 ioend->io_offset, ioend->io_size); in xfs_prepare_ioend()
420 if (xfs_ioend_is_append(ioend) || ioend->io_type == IOMAP_UNWRITTEN || in xfs_prepare_ioend()
421 (ioend->io_flags & IOMAP_F_SHARED)) in xfs_prepare_ioend()
422 ioend->io_bio.bi_end_io = xfs_end_bio; in xfs_prepare_ioend()
427 * If the folio has delalloc blocks on it, the caller is asking us to punch them
434 * they are delalloc, we can do this without needing a transaction. Indeed - if
444 struct xfs_inode *ip = XFS_I(folio->mapping->host); in xfs_discard_folio() local
445 struct xfs_mount *mp = ip->i_mount; in xfs_discard_folio()
452 folio, ip->i_ino, pos); in xfs_discard_folio()
459 xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, pos, in xfs_discard_folio()
476 xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); in xfs_vm_writepages()
485 struct xfs_inode *ip = XFS_I(mapping->host); in xfs_dax_writepages() local
487 xfs_iflags_clear(ip, XFS_ITRUNCATED); in xfs_dax_writepages()
489 xfs_inode_buftarg(ip)->bt_daxdev, wbc); in xfs_dax_writepages()
497 struct xfs_inode *ip = XFS_I(mapping->host); in xfs_vm_bmap() local
499 trace_xfs_vm_bmap(ip); in xfs_vm_bmap()
502 * The swap code (ab-)uses ->bmap to get a block mapping and then in xfs_vm_bmap()
510 if (xfs_is_cow_inode(ip) || XFS_IS_REALTIME_INODE(ip)) in xfs_vm_bmap()
536 sis->bdev = xfs_inode_buftarg(XFS_I(file_inode(swap_file)))->bt_bdev; in xfs_iomap_swapfile_activate()