xfs_file.c (2f63296578cad1ae681152d5b2122a4595195f16) xfs_file.c (f736d93d76d3e97d6986c6d26c8eaa32536ccc5c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 15 unchanged lines hidden (view full) ---

24#include "xfs_pnfs.h"
25#include "xfs_iomap.h"
26#include "xfs_reflink.h"
27
28#include <linux/falloc.h>
29#include <linux/backing-dev.h>
30#include <linux/mman.h>
31#include <linux/fadvise.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6#include "xfs.h"
7#include "xfs_fs.h"
8#include "xfs_shared.h"

--- 15 unchanged lines hidden (view full) ---

24#include "xfs_pnfs.h"
25#include "xfs_iomap.h"
26#include "xfs_reflink.h"
27
28#include <linux/falloc.h>
29#include <linux/backing-dev.h>
30#include <linux/mman.h>
31#include <linux/fadvise.h>
32#include <linux/mount.h>
32
33static const struct vm_operations_struct xfs_file_vm_ops;
34
35/*
36 * Decide if the given file range is aligned to the size of the fundamental
37 * allocation unit for the file.
38 */
39static bool

--- 174 unchanged lines hidden (view full) ---

214 file_accessed(iocb->ki_filp);
215
216 if (iocb->ki_flags & IOCB_NOWAIT) {
217 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
218 return -EAGAIN;
219 } else {
220 xfs_ilock(ip, XFS_IOLOCK_SHARED);
221 }
33
34static const struct vm_operations_struct xfs_file_vm_ops;
35
36/*
37 * Decide if the given file range is aligned to the size of the fundamental
38 * allocation unit for the file.
39 */
40static bool

--- 174 unchanged lines hidden (view full) ---

215 file_accessed(iocb->ki_filp);
216
217 if (iocb->ki_flags & IOCB_NOWAIT) {
218 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_SHARED))
219 return -EAGAIN;
220 } else {
221 xfs_ilock(ip, XFS_IOLOCK_SHARED);
222 }
222 ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, 0);
223 ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL,
224 is_sync_kiocb(iocb));
223 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
224
225 return ret;
226}
227
228static noinline ssize_t
229xfs_file_dax_read(
230 struct kiocb *iocb,

--- 347 unchanged lines hidden (view full) ---

578
579 trace_xfs_file_direct_write(ip, count, iocb->ki_pos);
580 /*
581 * If unaligned, this is the only IO in-flight. Wait on it before we
582 * release the iolock to prevent subsequent overlapping IO.
583 */
584 ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops,
585 &xfs_dio_write_ops,
225 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
226
227 return ret;
228}
229
230static noinline ssize_t
231xfs_file_dax_read(
232 struct kiocb *iocb,

--- 347 unchanged lines hidden (view full) ---

580
581 trace_xfs_file_direct_write(ip, count, iocb->ki_pos);
582 /*
583 * If unaligned, this is the only IO in-flight. Wait on it before we
584 * release the iolock to prevent subsequent overlapping IO.
585 */
586 ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops,
587 &xfs_dio_write_ops,
586 unaligned_io ? IOMAP_DIO_FORCE_WAIT : 0);
588 is_sync_kiocb(iocb) || unaligned_io);
587out:
588 xfs_iunlock(ip, iolock);
589
590 /*
591 * No fallback to buffered IO after short writes for XFS, direct I/O
592 * will either complete fully or return an error.
593 */
594 ASSERT(ret < 0 || ret == count);

--- 393 unchanged lines hidden (view full) ---

988 goto out_unlock;
989
990 /* Change file size if needed */
991 if (new_size) {
992 struct iattr iattr;
993
994 iattr.ia_valid = ATTR_SIZE;
995 iattr.ia_size = new_size;
589out:
590 xfs_iunlock(ip, iolock);
591
592 /*
593 * No fallback to buffered IO after short writes for XFS, direct I/O
594 * will either complete fully or return an error.
595 */
596 ASSERT(ret < 0 || ret == count);

--- 393 unchanged lines hidden (view full) ---

990 goto out_unlock;
991
992 /* Change file size if needed */
993 if (new_size) {
994 struct iattr iattr;
995
996 iattr.ia_valid = ATTR_SIZE;
997 iattr.ia_size = new_size;
996 error = xfs_vn_setattr_size(file_dentry(file), &iattr);
998 error = xfs_vn_setattr_size(file_mnt_user_ns(file),
999 file_dentry(file), &iattr);
997 if (error)
998 goto out_unlock;
999 }
1000
1001 /*
1002 * Perform hole insertion now that the file size has been
1003 * updated so that if we crash during the operation we don't
1004 * leave shifted extents past EOF and hence losing access to

--- 392 unchanged lines hidden ---
1000 if (error)
1001 goto out_unlock;
1002 }
1003
1004 /*
1005 * Perform hole insertion now that the file size has been
1006 * updated so that if we crash during the operation we don't
1007 * leave shifted extents past EOF and hence losing access to

--- 392 unchanged lines hidden ---