Lines Matching +full:buffered +full:- +full:negative
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
29 #include <linux/backing-dev.h>
45 struct xfs_mount *mp = ip->i_mount; in xfs_is_falloc_aligned()
49 if (!is_power_of_2(mp->m_sb.sb_rextsize)) { in xfs_is_falloc_aligned()
53 rextbytes = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize); in xfs_is_falloc_aligned()
60 mask = XFS_FSB_TO_B(mp, mp->m_sb.sb_rextsize) - 1; in xfs_is_falloc_aligned()
62 mask = mp->m_sb.sb_blocksize - 1; in xfs_is_falloc_aligned()
76 error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_writeid, in xfs_update_prealloc_flags()
85 VFS_I(ip)->i_mode &= ~S_ISUID; in xfs_update_prealloc_flags()
86 if (VFS_I(ip)->i_mode & S_IXGRP) in xfs_update_prealloc_flags()
87 VFS_I(ip)->i_mode &= ~S_ISGID; in xfs_update_prealloc_flags()
92 ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC; in xfs_update_prealloc_flags()
94 ip->i_d.di_flags &= ~XFS_DIFLAG_PREALLOC; in xfs_update_prealloc_flags()
105 * cache flush operations, and there are no non-transaction metadata updates
115 struct xfs_inode *ip = XFS_I(file->f_mapping->host); in xfs_dir_fsync()
128 struct inode *inode = file->f_mapping->host; in xfs_file_fsync()
130 struct xfs_inode_log_item *iip = ip->i_itemp; in xfs_file_fsync()
131 struct xfs_mount *mp = ip->i_mount; in xfs_file_fsync()
143 return -EIO; in xfs_file_fsync()
154 xfs_blkdev_issue_flush(mp->m_rtdev_targp); in xfs_file_fsync()
155 else if (mp->m_logdev_targp != mp->m_ddev_targp) in xfs_file_fsync()
156 xfs_blkdev_issue_flush(mp->m_ddev_targp); in xfs_file_fsync()
174 (iip->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) in xfs_file_fsync()
175 lsn = iip->ili_last_lsn; in xfs_file_fsync()
180 spin_lock(&iip->ili_lock); in xfs_file_fsync()
181 iip->ili_fsync_fields = 0; in xfs_file_fsync()
182 spin_unlock(&iip->ili_lock); in xfs_file_fsync()
188 * a no-op we might have to flush the data device cache here. in xfs_file_fsync()
194 mp->m_logdev_targp == mp->m_ddev_targp) in xfs_file_fsync()
195 xfs_blkdev_issue_flush(mp->m_ddev_targp); in xfs_file_fsync()
205 struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); in xfs_file_dio_aio_read()
209 trace_xfs_file_direct_read(ip, count, iocb->ki_pos); in xfs_file_dio_aio_read()
214 file_accessed(iocb->ki_filp); in xfs_file_dio_aio_read()
216 if (iocb->ki_flags & IOCB_NOWAIT) { in xfs_file_dio_aio_read()
218 return -EAGAIN; in xfs_file_dio_aio_read()
234 struct xfs_inode *ip = XFS_I(iocb->ki_filp->f_mapping->host); in xfs_file_dax_read()
238 trace_xfs_file_dax_read(ip, count, iocb->ki_pos); in xfs_file_dax_read()
243 if (iocb->ki_flags & IOCB_NOWAIT) { in xfs_file_dax_read()
245 return -EAGAIN; in xfs_file_dax_read()
253 file_accessed(iocb->ki_filp); in xfs_file_dax_read()
262 struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); in xfs_file_buffered_aio_read()
265 trace_xfs_file_buffered_read(ip, iov_iter_count(to), iocb->ki_pos); in xfs_file_buffered_aio_read()
267 if (iocb->ki_flags & IOCB_NOWAIT) { in xfs_file_buffered_aio_read()
269 return -EAGAIN; in xfs_file_buffered_aio_read()
284 struct inode *inode = file_inode(iocb->ki_filp); in xfs_file_read_iter()
285 struct xfs_mount *mp = XFS_I(inode)->i_mount; in xfs_file_read_iter()
291 return -EIO; in xfs_file_read_iter()
295 else if (iocb->ki_flags & IOCB_DIRECT) in xfs_file_read_iter()
306 * Common pre-write limit and setup checks.
318 struct file *file = iocb->ki_filp; in xfs_file_aio_write_checks()
319 struct inode *inode = file->f_mapping->host; in xfs_file_aio_write_checks()
360 spin_lock(&ip->i_flags_lock); in xfs_file_aio_write_checks()
362 if (iocb->ki_pos > isize) { in xfs_file_aio_write_checks()
363 spin_unlock(&ip->i_flags_lock); in xfs_file_aio_write_checks()
374 * we now need to wait for all of them to drain. Non-AIO in xfs_file_aio_write_checks()
377 * no-op. in xfs_file_aio_write_checks()
384 trace_xfs_zero_eof(ip, isize, iocb->ki_pos - isize); in xfs_file_aio_write_checks()
385 error = iomap_zero_range(inode, isize, iocb->ki_pos - isize, in xfs_file_aio_write_checks()
390 spin_unlock(&ip->i_flags_lock); in xfs_file_aio_write_checks()
408 struct inode *inode = file_inode(iocb->ki_filp); in xfs_dio_write_end_io()
410 loff_t offset = iocb->ki_pos; in xfs_dio_write_end_io()
415 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) in xfs_dio_write_end_io()
416 return -EIO; in xfs_dio_write_end_io()
427 XFS_STATS_ADD(ip->i_mount, xs_write_bytes, size); in xfs_dio_write_end_io()
432 * task-wide nofs context for the following operations. in xfs_dio_write_end_io()
443 * Unwritten conversion updates the in-core isize after extent in xfs_dio_write_end_io()
444 * conversion but before updating the on-disk size. Updating isize any in xfs_dio_write_end_io()
454 * We need to update the in-core inode size here so that we don't end up in xfs_dio_write_end_io()
455 * with the on-disk inode size being outside the in-core inode size. We in xfs_dio_write_end_io()
464 spin_lock(&ip->i_flags_lock); in xfs_dio_write_end_io()
467 spin_unlock(&ip->i_flags_lock); in xfs_dio_write_end_io()
470 spin_unlock(&ip->i_flags_lock); in xfs_dio_write_end_io()
483 * xfs_file_dio_aio_write - handle direct IO writes
486 * By separating it from the buffered write path we remove all the tricky to
496 * needs to do sub-block zeroing and that requires serialisation against other
505 * negative return values.
512 struct file *file = iocb->ki_filp; in xfs_file_dio_aio_write()
513 struct address_space *mapping = file->f_mapping; in xfs_file_dio_aio_write()
514 struct inode *inode = mapping->host; in xfs_file_dio_aio_write()
516 struct xfs_mount *mp = ip->i_mount; in xfs_file_dio_aio_write()
524 if ((iocb->ki_pos | count) & target->bt_logical_sectormask) in xfs_file_dio_aio_write()
525 return -EINVAL; in xfs_file_dio_aio_write()
534 if ((iocb->ki_pos & mp->m_blockmask) || in xfs_file_dio_aio_write()
535 ((iocb->ki_pos + count) & mp->m_blockmask)) { in xfs_file_dio_aio_write()
543 trace_xfs_reflink_bounce_dio_write(ip, iocb->ki_pos, count); in xfs_file_dio_aio_write()
544 return -ENOTBLK; in xfs_file_dio_aio_write()
551 if (iocb->ki_flags & IOCB_NOWAIT) { in xfs_file_dio_aio_write()
554 return -EAGAIN; in xfs_file_dio_aio_write()
556 return -EAGAIN; in xfs_file_dio_aio_write()
568 * in-flight at the same time or we risk data corruption. Wait for all in xfs_file_dio_aio_write()
580 trace_xfs_file_direct_write(ip, count, iocb->ki_pos); in xfs_file_dio_aio_write()
582 * If unaligned, this is the only IO in-flight. Wait on it before we in xfs_file_dio_aio_write()
592 * No fallback to buffered IO after short writes for XFS, direct I/O in xfs_file_dio_aio_write()
604 struct inode *inode = iocb->ki_filp->f_mapping->host; in xfs_file_dax_write()
611 if (iocb->ki_flags & IOCB_NOWAIT) { in xfs_file_dax_write()
613 return -EAGAIN; in xfs_file_dax_write()
622 pos = iocb->ki_pos; in xfs_file_dax_write()
627 if (ret > 0 && iocb->ki_pos > i_size_read(inode)) { in xfs_file_dax_write()
628 i_size_write(inode, iocb->ki_pos); in xfs_file_dax_write()
637 XFS_STATS_ADD(ip->i_mount, xs_write_bytes, ret); in xfs_file_dax_write()
639 /* Handle various SYNC-type writes */ in xfs_file_dax_write()
650 struct file *file = iocb->ki_filp; in xfs_file_buffered_aio_write()
651 struct address_space *mapping = file->f_mapping; in xfs_file_buffered_aio_write()
652 struct inode *inode = mapping->host; in xfs_file_buffered_aio_write()
658 if (iocb->ki_flags & IOCB_NOWAIT) in xfs_file_buffered_aio_write()
659 return -EOPNOTSUPP; in xfs_file_buffered_aio_write()
670 current->backing_dev_info = inode_to_bdi(inode); in xfs_file_buffered_aio_write()
672 trace_xfs_file_buffered_write(ip, iov_iter_count(from), iocb->ki_pos); in xfs_file_buffered_aio_write()
676 iocb->ki_pos += ret; in xfs_file_buffered_aio_write()
687 if (ret == -EDQUOT && !enospc) { in xfs_file_buffered_aio_write()
696 } else if (ret == -ENOSPC && !enospc) { in xfs_file_buffered_aio_write()
700 xfs_flush_inodes(ip->i_mount); in xfs_file_buffered_aio_write()
704 xfs_icache_free_eofblocks(ip->i_mount, &eofb); in xfs_file_buffered_aio_write()
705 xfs_icache_free_cowblocks(ip->i_mount, &eofb); in xfs_file_buffered_aio_write()
709 current->backing_dev_info = NULL; in xfs_file_buffered_aio_write()
715 XFS_STATS_ADD(ip->i_mount, xs_write_bytes, ret); in xfs_file_buffered_aio_write()
716 /* Handle various SYNC-type writes */ in xfs_file_buffered_aio_write()
727 struct file *file = iocb->ki_filp; in xfs_file_write_iter()
728 struct address_space *mapping = file->f_mapping; in xfs_file_write_iter()
729 struct inode *inode = mapping->host; in xfs_file_write_iter()
734 XFS_STATS_INC(ip->i_mount, xs_write_calls); in xfs_file_write_iter()
739 if (XFS_FORCED_SHUTDOWN(ip->i_mount)) in xfs_file_write_iter()
740 return -EIO; in xfs_file_write_iter()
745 if (iocb->ki_flags & IOCB_DIRECT) { in xfs_file_write_iter()
747 * Allow a directio write to fall back to a buffered in xfs_file_write_iter()
750 * allow an operation to fall back to buffered mode. in xfs_file_write_iter()
753 if (ret != -ENOTBLK) in xfs_file_write_iter()
780 page = dax_layout_busy_page(inode->i_mapping); in xfs_break_dax_layouts()
785 return ___wait_var_event(&page->_refcount, in xfs_break_dax_layouts()
786 atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE, in xfs_break_dax_layouts()
814 error = -EINVAL; in xfs_break_layouts()
841 if (!S_ISREG(inode->i_mode)) in xfs_file_fallocate()
842 return -EINVAL; in xfs_file_fallocate()
844 return -EOPNOTSUPP; in xfs_file_fallocate()
856 * require the in-memory size to be fully up-to-date. in xfs_file_fallocate()
887 error = -EINVAL; in xfs_file_fallocate()
896 error = -EINVAL; in xfs_file_fallocate()
900 new_size = i_size_read(inode) - len; in xfs_file_fallocate()
909 error = -EINVAL; in xfs_file_fallocate()
914 * New inode size must not exceed ->s_maxbytes, accounting for in xfs_file_fallocate()
917 if (inode->i_sb->s_maxbytes - isize < len) { in xfs_file_fallocate()
918 error = -EFBIG; in xfs_file_fallocate()
925 error = -EINVAL; in xfs_file_fallocate()
948 * still zero-valued by virtue of the hole punch. in xfs_file_fallocate()
958 len = round_up(offset + len, blksize) - in xfs_file_fallocate()
971 error = -EOPNOTSUPP; in xfs_file_fallocate()
984 if (file->f_flags & O_DSYNC) in xfs_file_fallocate()
1046 if (ip->i_mount->m_flags & XFS_MOUNT_WSYNC) in xfs_file_sync_writes()
1048 if (filp->f_flags & (__O_SYNC | O_DSYNC)) in xfs_file_sync_writes()
1069 struct xfs_mount *mp = src->i_mount; in xfs_file_remap_range()
1075 return -EINVAL; in xfs_file_remap_range()
1077 if (!xfs_sb_version_hasreflink(&mp->m_sb)) in xfs_file_remap_range()
1078 return -EOPNOTSUPP; in xfs_file_remap_range()
1081 return -EIO; in xfs_file_remap_range()
1103 (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) && in xfs_file_remap_range()
1105 !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) in xfs_file_remap_range()
1106 cowextsize = src->i_d.di_cowextsize; in xfs_file_remap_range()
1127 if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS) in xfs_file_open()
1128 return -EFBIG; in xfs_file_open()
1129 if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb))) in xfs_file_open()
1130 return -EIO; in xfs_file_open()
1131 file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; in xfs_file_open()
1149 * If there are any blocks, read-ahead block 0 as we're almost in xfs_dir_open()
1153 if (ip->i_df.if_nextents > 0) in xfs_dir_open()
1185 * point we can change the ->readdir prototype to include the in xfs_file_readdir()
1188 bufsize = (size_t)min_t(loff_t, XFS_READDIR_BUFSIZE, ip->i_d.di_size); in xfs_file_readdir()
1199 struct inode *inode = file->f_mapping->host; in xfs_file_llseek()
1201 if (XFS_FORCED_SHUTDOWN(XFS_I(inode)->i_mount)) in xfs_file_llseek()
1202 return -EIO; in xfs_file_llseek()
1217 return vfs_setpos(file, offset, inode->i_sb->s_maxbytes); in xfs_file_llseek()
1226 * i_mmaplock (XFS - truncate serialisation)
1228 * i_lock (XFS - extent map serialisation)
1236 struct inode *inode = file_inode(vmf->vma->vm_file); in __xfs_filemap_fault()
1243 sb_start_pagefault(inode->i_sb); in __xfs_filemap_fault()
1244 file_update_time(vmf->vma->vm_file); in __xfs_filemap_fault()
1252 (write_fault && !vmf->cow_page) ? in __xfs_filemap_fault()
1267 sb_end_pagefault(inode->i_sb); in __xfs_filemap_fault()
1275 return (vmf->flags & FAULT_FLAG_WRITE) && in xfs_is_write_fault()
1276 (vmf->vma->vm_flags & VM_SHARED); in xfs_is_write_fault()
1285 IS_DAX(file_inode(vmf->vma->vm_file)) && in xfs_filemap_fault()
1294 if (!IS_DAX(file_inode(vmf->vma->vm_file))) in xfs_filemap_huge_fault()
1328 struct inode *inode = file_inode(vmf->vma->vm_file); in xfs_filemap_map_pages()
1352 * We don't support synchronous mappings for non-DAX files and in xfs_file_mmap()
1355 if (!daxdev_mapping_supported(vma, target->bt_daxdev)) in xfs_file_mmap()
1356 return -EOPNOTSUPP; in xfs_file_mmap()
1359 vma->vm_ops = &xfs_file_vm_ops; in xfs_file_mmap()
1361 vma->vm_flags |= VM_HUGEPAGE; in xfs_file_mmap()