Lines Matching +full:trim +full:- +full:data +full:- +full:valid

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * Copyright (c) 2016-2018 Christoph Hellwig.
37 * Fast and loose check if this write could update the on-disk inode size.
41 return ioend->io_offset + ioend->io_size > in xfs_ioend_is_append()
42 XFS_I(ioend->io_inode)->i_disk_size; in xfs_ioend_is_append()
46 * Update on-disk file size now that data has been written to disk.
54 struct xfs_mount *mp = ip->i_mount; in xfs_setfilesize()
59 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_fsyncts, 0, 0, 0, &tp); in xfs_setfilesize()
73 ip->i_disk_size = isize; in xfs_setfilesize()
87 struct xfs_inode *ip = XFS_I(ioend->io_inode); in xfs_end_ioend()
88 struct xfs_mount *mp = ip->i_mount; in xfs_end_ioend()
89 xfs_off_t offset = ioend->io_offset; in xfs_end_ioend()
90 size_t size = ioend->io_size; in xfs_end_ioend()
97 * task-wide nofs context for the following operations. in xfs_end_ioend()
102 * Just clean up the in-memory structures if the fs has been shut down. in xfs_end_ioend()
105 error = -EIO; in xfs_end_ioend()
110 * Clean up all COW blocks and underlying data fork delalloc blocks on in xfs_end_ioend()
116 error = blk_status_to_errno(ioend->io_bio.bi_status); in xfs_end_ioend()
118 if (ioend->io_flags & IOMAP_F_SHARED) { in xfs_end_ioend()
129 if (ioend->io_flags & IOMAP_F_SHARED) in xfs_end_ioend()
131 else if (ioend->io_type == IOMAP_UNWRITTEN) in xfs_end_ioend()
165 spin_lock_irqsave(&ip->i_ioend_lock, flags); in xfs_end_io()
166 list_replace_init(&ip->i_ioend_list, &tmp); in xfs_end_io()
167 spin_unlock_irqrestore(&ip->i_ioend_lock, flags); in xfs_end_io()
172 list_del_init(&ioend->io_list); in xfs_end_io()
184 struct xfs_inode *ip = XFS_I(ioend->io_inode); in xfs_end_bio()
187 spin_lock_irqsave(&ip->i_ioend_lock, flags); in xfs_end_bio()
188 if (list_empty(&ip->i_ioend_list)) in xfs_end_bio()
189 WARN_ON_ONCE(!queue_work(ip->i_mount->m_unwritten_workqueue, in xfs_end_bio()
190 &ip->i_ioend_work)); in xfs_end_bio()
191 list_add_tail(&ioend->io_list, &ip->i_ioend_list); in xfs_end_bio()
192 spin_unlock_irqrestore(&ip->i_ioend_lock, flags); in xfs_end_bio()
197 * mapping is valid, false otherwise.
205 if (offset < wpc->iomap.offset || in xfs_imap_valid()
206 offset >= wpc->iomap.offset + wpc->iomap.length) in xfs_imap_valid()
211 * can revalidate a COW mapping without updating the data seqno. in xfs_imap_valid()
213 if (wpc->iomap.flags & IOMAP_F_SHARED) in xfs_imap_valid()
217 * This is not a COW mapping. Check the sequence number of the data fork in xfs_imap_valid()
223 if (XFS_WPC(wpc)->data_seq != READ_ONCE(ip->i_df.if_seq)) { in xfs_imap_valid()
224 trace_xfs_wb_data_iomap_invalid(ip, &wpc->iomap, in xfs_imap_valid()
225 XFS_WPC(wpc)->data_seq, XFS_DATA_FORK); in xfs_imap_valid()
229 XFS_WPC(wpc)->cow_seq != READ_ONCE(ip->i_cowfp->if_seq)) { in xfs_imap_valid()
230 trace_xfs_wb_cow_iomap_invalid(ip, &wpc->iomap, in xfs_imap_valid()
231 XFS_WPC(wpc)->cow_seq, XFS_COW_FORK); in xfs_imap_valid()
245 struct xfs_mount *mp = ip->i_mount; in xfs_map_blocks()
258 return -EIO; in xfs_map_blocks()
263 * COW fork blocks can overlap data fork blocks even if the blocks in xfs_map_blocks()
281 * If we don't have a valid map, now it's time to get a new one for this in xfs_map_blocks()
283 * into real extents. If we return without a valid map, it means we in xfs_map_blocks()
290 ASSERT(!xfs_need_iread_extents(&ip->i_df)); in xfs_map_blocks()
294 * it directly instead of looking up anything in the data fork. in xfs_map_blocks()
297 xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &imap)) in xfs_map_blocks()
300 XFS_WPC(wpc)->cow_seq = READ_ONCE(ip->i_cowfp->if_seq); in xfs_map_blocks()
309 * ->cow_seq. If the data mapping is still valid, we're done. in xfs_map_blocks()
317 * If we don't have a valid map, now it's time to get a new one for this in xfs_map_blocks()
321 if (!xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap)) in xfs_map_blocks()
323 XFS_WPC(wpc)->data_seq = READ_ONCE(ip->i_df.if_seq); in xfs_map_blocks()
328 imap.br_blockcount = imap.br_startoff - offset_fsb; in xfs_map_blocks()
342 imap.br_blockcount = cow_fsb - imap.br_startoff; in xfs_map_blocks()
349 xfs_bmbt_to_iomap(ip, &wpc->iomap, &imap, 0, 0, XFS_WPC(wpc)->data_seq); in xfs_map_blocks()
356 * although it could have moved from the COW to the data fork by another in xfs_map_blocks()
360 seq = &XFS_WPC(wpc)->cow_seq; in xfs_map_blocks()
362 seq = &XFS_WPC(wpc)->data_seq; in xfs_map_blocks()
365 &wpc->iomap, seq); in xfs_map_blocks()
369 * raced with a COW to data fork conversion or truncate. in xfs_map_blocks()
370 * Restart the lookup to catch the extent in the data fork for in xfs_map_blocks()
374 if (error == -EAGAIN && whichfork == XFS_COW_FORK && !retries++) in xfs_map_blocks()
376 ASSERT(error != -EAGAIN); in xfs_map_blocks()
382 * original delalloc one. Trim the return extent to the next COW in xfs_map_blocks()
383 * boundary again to force a re-lookup. in xfs_map_blocks()
388 if (cow_offset < wpc->iomap.offset + wpc->iomap.length) in xfs_map_blocks()
389 wpc->iomap.length = cow_offset - wpc->iomap.offset; in xfs_map_blocks()
392 ASSERT(wpc->iomap.offset <= offset); in xfs_map_blocks()
393 ASSERT(wpc->iomap.offset + wpc->iomap.length > offset); in xfs_map_blocks()
408 * task-wide nofs context for the following operations. in xfs_prepare_ioend()
413 if (!status && (ioend->io_flags & IOMAP_F_SHARED)) { in xfs_prepare_ioend()
414 status = xfs_reflink_convert_cow(XFS_I(ioend->io_inode), in xfs_prepare_ioend()
415 ioend->io_offset, ioend->io_size); in xfs_prepare_ioend()
421 if (xfs_ioend_is_append(ioend) || ioend->io_type == IOMAP_UNWRITTEN || in xfs_prepare_ioend()
422 (ioend->io_flags & IOMAP_F_SHARED)) in xfs_prepare_ioend()
423 ioend->io_bio.bi_end_io = xfs_end_bio; in xfs_prepare_ioend()
435 * they are delalloc, we can do this without needing a transaction. Indeed - if
445 struct xfs_inode *ip = XFS_I(folio->mapping->host); in xfs_discard_folio()
446 struct xfs_mount *mp = ip->i_mount; in xfs_discard_folio()
453 folio, ip->i_ino, pos); in xfs_discard_folio()
477 xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED); in xfs_vm_writepages()
486 struct xfs_inode *ip = XFS_I(mapping->host); in xfs_dax_writepages()
490 xfs_inode_buftarg(ip)->bt_daxdev, wbc); in xfs_dax_writepages()
498 struct xfs_inode *ip = XFS_I(mapping->host); in xfs_vm_bmap()
503 * The swap code (ab-)uses ->bmap to get a block mapping and then in xfs_vm_bmap()
562 xfs_inodegc_flush(ip->i_mount); in xfs_vm_swap_activate()
568 sis->bdev = xfs_inode_buftarg(ip)->bt_bdev; in xfs_vm_swap_activate()