Lines Matching refs:fxr

84 	const struct xfs_exchrange	*fxr,  in xfs_exchrange_check_freshness()  argument
91 trace_xfs_exchrange_freshness(fxr, ip2); in xfs_exchrange_check_freshness()
94 if (fxr->file2_ino != ip2->i_ino || in xfs_exchrange_check_freshness()
95 fxr->file2_gen != inode2->i_generation || in xfs_exchrange_check_freshness()
96 !timespec64_equal(&fxr->file2_ctime, &ctime) || in xfs_exchrange_check_freshness()
97 !timespec64_equal(&fxr->file2_mtime, &mtime)) in xfs_exchrange_check_freshness()
190 const struct xfs_exchrange *fxr, in xfs_exchrange_mappings() argument
198 .startoff1 = XFS_B_TO_FSBT(mp, fxr->file1_offset), in xfs_exchrange_mappings()
199 .startoff2 = XFS_B_TO_FSBT(mp, fxr->file2_offset), in xfs_exchrange_mappings()
200 .blockcount = XFS_B_TO_FSB(mp, fxr->length), in xfs_exchrange_mappings()
207 trace_xfs_exchrange_mappings(fxr, ip1, ip2); in xfs_exchrange_mappings()
209 if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) in xfs_exchrange_mappings()
211 if (fxr->flags & XFS_EXCHANGE_RANGE_FILE1_WRITTEN) in xfs_exchrange_mappings()
262 if (fxr->flags & XFS_EXCHANGE_RANGE_DRY_RUN) in xfs_exchrange_mappings()
266 if (fxr->flags & __XFS_EXCHANGE_RANGE_UPD_CMTIME1) in xfs_exchrange_mappings()
268 if (fxr->flags & __XFS_EXCHANGE_RANGE_UPD_CMTIME2) in xfs_exchrange_mappings()
278 if (xfs_has_wsync(mp) || (fxr->flags & XFS_EXCHANGE_RANGE_DSYNC)) in xfs_exchrange_mappings()
295 if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) { in xfs_exchrange_mappings()
332 struct xfs_exchrange *fxr) in xfs_exchange_range_verify_area() argument
336 ret = remap_verify_area(fxr->file1, fxr->file1_offset, fxr->length, in xfs_exchange_range_verify_area()
341 return remap_verify_area(fxr->file2, fxr->file2_offset, fxr->length, in xfs_exchange_range_verify_area()
351 struct xfs_exchrange *fxr, in xfs_exchange_range_checks() argument
354 struct inode *inode1 = file_inode(fxr->file1); in xfs_exchange_range_checks()
355 struct inode *inode2 = file_inode(fxr->file2); in xfs_exchange_range_checks()
372 if (fxr->file1_offset > size1 || fxr->file2_offset > size2) in xfs_exchange_range_checks()
379 if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) { in xfs_exchange_range_checks()
380 fxr->length = max_t(int64_t, size1 - fxr->file1_offset, in xfs_exchange_range_checks()
381 size2 - fxr->file2_offset); in xfs_exchange_range_checks()
383 error = xfs_exchange_range_verify_area(fxr); in xfs_exchange_range_checks()
392 if (!IS_ALIGNED(fxr->file1_offset, alloc_unit) || in xfs_exchange_range_checks()
393 !IS_ALIGNED(fxr->file2_offset, alloc_unit)) in xfs_exchange_range_checks()
397 if (check_add_overflow(fxr->file1_offset, fxr->length, &tmp) || in xfs_exchange_range_checks()
398 check_add_overflow(fxr->file2_offset, fxr->length, &tmp)) in xfs_exchange_range_checks()
405 if (!(fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) && in xfs_exchange_range_checks()
406 (fxr->file1_offset + fxr->length > size1 || in xfs_exchange_range_checks()
407 fxr->file2_offset + fxr->length > size2)) in xfs_exchange_range_checks()
415 test_len = fxr->length; in xfs_exchange_range_checks()
416 error = generic_write_check_limits(fxr->file2, fxr->file2_offset, in xfs_exchange_range_checks()
420 error = generic_write_check_limits(fxr->file1, fxr->file1_offset, in xfs_exchange_range_checks()
424 if (test_len != fxr->length) in xfs_exchange_range_checks()
435 if (fxr->file1_offset + fxr->length == size1) in xfs_exchange_range_checks()
436 blen = ALIGN(size1, alloc_unit) - fxr->file1_offset; in xfs_exchange_range_checks()
437 else if (fxr->file2_offset + fxr->length == size2) in xfs_exchange_range_checks()
438 blen = ALIGN(size2, alloc_unit) - fxr->file2_offset; in xfs_exchange_range_checks()
439 else if (!IS_ALIGNED(fxr->length, alloc_unit)) in xfs_exchange_range_checks()
442 blen = fxr->length; in xfs_exchange_range_checks()
446 fxr->file2_offset + blen > fxr->file1_offset && in xfs_exchange_range_checks()
447 fxr->file1_offset + blen > fxr->file2_offset) in xfs_exchange_range_checks()
454 if ((fxr->length & allocmask) == 0) in xfs_exchange_range_checks()
457 blen = fxr->length; in xfs_exchange_range_checks()
458 if (fxr->file2_offset + blen < size2) in xfs_exchange_range_checks()
461 if (fxr->file1_offset + blen < size1) in xfs_exchange_range_checks()
464 return blen == fxr->length ? 0 : -EINVAL; in xfs_exchange_range_checks()
474 struct xfs_exchrange *fxr, in xfs_exchange_range_prep() argument
477 struct inode *inode1 = file_inode(fxr->file1); in xfs_exchange_range_prep()
478 struct inode *inode2 = file_inode(fxr->file2); in xfs_exchange_range_prep()
483 error = xfs_exchange_range_checks(fxr, alloc_unit); in xfs_exchange_range_prep()
484 if (error || fxr->length == 0) in xfs_exchange_range_prep()
493 fxr->file1_offset, in xfs_exchange_range_prep()
494 fxr->file1_offset + fxr->length - 1); in xfs_exchange_range_prep()
499 fxr->file2_offset, in xfs_exchange_range_prep()
500 fxr->file2_offset + fxr->length - 1); in xfs_exchange_range_prep()
509 if (((fxr->file1->f_flags | fxr->file2->f_flags) & O_SYNC) || in xfs_exchange_range_prep()
511 fxr->flags |= XFS_EXCHANGE_RANGE_DSYNC; in xfs_exchange_range_prep()
522 struct xfs_exchrange *fxr) in xfs_exchange_range_finish() argument
526 error = file_remove_privs(fxr->file1); in xfs_exchange_range_finish()
529 if (file_inode(fxr->file1) == file_inode(fxr->file2)) in xfs_exchange_range_finish()
532 return file_remove_privs(fxr->file2); in xfs_exchange_range_finish()
542 const struct xfs_exchrange *fxr, in xfs_exchrange_check_rtalign() argument
547 uint64_t length = fxr->length; in xfs_exchrange_check_rtalign()
555 if (!isaligned_64(fxr->file1_offset, alloc_unit) || in xfs_exchrange_check_rtalign()
556 !isaligned_64(fxr->file2_offset, alloc_unit)) in xfs_exchrange_check_rtalign()
559 if (fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF) in xfs_exchrange_check_rtalign()
560 length = max_t(int64_t, size1 - fxr->file1_offset, in xfs_exchrange_check_rtalign()
561 size2 - fxr->file2_offset); in xfs_exchrange_check_rtalign()
572 if (fxr->file1_offset + length == size1) in xfs_exchrange_check_rtalign()
573 blen = roundup_64(size1, alloc_unit) - fxr->file1_offset; in xfs_exchrange_check_rtalign()
574 else if (fxr->file2_offset + length == size2) in xfs_exchrange_check_rtalign()
575 blen = roundup_64(size2, alloc_unit) - fxr->file2_offset; in xfs_exchrange_check_rtalign()
583 fxr->file2_offset + blen > fxr->file1_offset && in xfs_exchrange_check_rtalign()
584 fxr->file1_offset + blen > fxr->file2_offset) in xfs_exchrange_check_rtalign()
595 if (fxr->file2_offset + length < size2) in xfs_exchrange_check_rtalign()
598 if (fxr->file1_offset + blen < size1) in xfs_exchrange_check_rtalign()
607 struct xfs_exchrange *fxr, in xfs_exchrange_prep() argument
615 trace_xfs_exchrange_prep(fxr, ip1, ip2); in xfs_exchrange_prep()
623 error = xfs_exchrange_check_rtalign(fxr, ip1, ip2, alloc_unit); in xfs_exchrange_prep()
634 error = xfs_exchange_range_prep(fxr, alloc_unit); in xfs_exchrange_prep()
635 if (error || fxr->length == 0) in xfs_exchrange_prep()
638 if (fxr->flags & __XFS_EXCHANGE_RANGE_CHECK_FRESH2) { in xfs_exchrange_prep()
639 error = xfs_exchrange_check_freshness(fxr, ip2); in xfs_exchrange_prep()
652 trace_xfs_exchrange_flush(fxr, ip1, ip2); in xfs_exchrange_prep()
655 error = xfs_flush_unmap_range(ip2, fxr->file2_offset, fxr->length); in xfs_exchrange_prep()
658 error = xfs_flush_unmap_range(ip1, fxr->file1_offset, fxr->length); in xfs_exchrange_prep()
668 error = xfs_reflink_cancel_cow_range(ip1, fxr->file1_offset, in xfs_exchrange_prep()
669 fxr->length, true); in xfs_exchrange_prep()
675 error = xfs_reflink_cancel_cow_range(ip2, fxr->file2_offset, in xfs_exchrange_prep()
676 fxr->length, true); in xfs_exchrange_prep()
690 struct xfs_exchrange *fxr) in xfs_exchrange_contents() argument
692 struct inode *inode1 = file_inode(fxr->file1); in xfs_exchrange_contents()
693 struct inode *inode2 = file_inode(fxr->file2); in xfs_exchrange_contents()
702 if (fxr->flags & ~(XFS_EXCHANGE_RANGE_ALL_FLAGS | in xfs_exchrange_contents()
715 error = xfs_exchrange_prep(fxr, ip1, ip2); in xfs_exchrange_contents()
719 error = xfs_exchrange_mappings(fxr, ip1, ip2); in xfs_exchrange_contents()
728 error = xfs_exchange_range_finish(fxr); in xfs_exchrange_contents()
743 struct xfs_exchrange *fxr) in xfs_exchange_range() argument
745 struct inode *inode1 = file_inode(fxr->file1); in xfs_exchange_range()
746 struct inode *inode2 = file_inode(fxr->file2); in xfs_exchange_range()
753 if (fxr->file1->f_path.mnt != fxr->file2->f_path.mnt) in xfs_exchange_range()
756 if (fxr->flags & ~(XFS_EXCHANGE_RANGE_ALL_FLAGS | in xfs_exchange_range()
767 if (!(fxr->file1->f_mode & FMODE_READ) || in xfs_exchange_range()
768 !(fxr->file1->f_mode & FMODE_WRITE) || in xfs_exchange_range()
769 !(fxr->file2->f_mode & FMODE_READ) || in xfs_exchange_range()
770 !(fxr->file2->f_mode & FMODE_WRITE)) in xfs_exchange_range()
774 if ((fxr->file1->f_flags & O_APPEND) || in xfs_exchange_range()
775 (fxr->file2->f_flags & O_APPEND)) in xfs_exchange_range()
782 if (!(fxr->flags & XFS_EXCHANGE_RANGE_TO_EOF)) { in xfs_exchange_range()
783 ret = xfs_exchange_range_verify_area(fxr); in xfs_exchange_range()
789 if (!(fxr->file1->f_mode & FMODE_NOCMTIME) && !IS_NOCMTIME(inode1)) in xfs_exchange_range()
790 fxr->flags |= __XFS_EXCHANGE_RANGE_UPD_CMTIME1; in xfs_exchange_range()
791 if (!(fxr->file2->f_mode & FMODE_NOCMTIME) && !IS_NOCMTIME(inode2)) in xfs_exchange_range()
792 fxr->flags |= __XFS_EXCHANGE_RANGE_UPD_CMTIME2; in xfs_exchange_range()
794 file_start_write(fxr->file2); in xfs_exchange_range()
795 ret = xfs_exchrange_contents(fxr); in xfs_exchange_range()
796 file_end_write(fxr->file2); in xfs_exchange_range()
800 fsnotify_modify(fxr->file1); in xfs_exchange_range()
801 if (fxr->file2 != fxr->file1) in xfs_exchange_range()
802 fsnotify_modify(fxr->file2); in xfs_exchange_range()
812 struct xfs_exchrange fxr = { in xfs_ioc_exchange_range() local
826 fxr.file1_offset = args.file1_offset; in xfs_ioc_exchange_range()
827 fxr.file2_offset = args.file2_offset; in xfs_ioc_exchange_range()
828 fxr.length = args.length; in xfs_ioc_exchange_range()
829 fxr.flags = args.flags; in xfs_ioc_exchange_range()
834 fxr.file1 = fd_file(file1); in xfs_ioc_exchange_range()
836 error = xfs_exchange_range(&fxr); in xfs_ioc_exchange_range()
905 struct xfs_exchrange fxr = { in xfs_ioc_commit_range() local
926 fxr.file1_offset = args.file1_offset; in xfs_ioc_commit_range()
927 fxr.file2_offset = args.file2_offset; in xfs_ioc_commit_range()
928 fxr.length = args.length; in xfs_ioc_commit_range()
929 fxr.flags = args.flags | __XFS_EXCHANGE_RANGE_CHECK_FRESH2; in xfs_ioc_commit_range()
930 fxr.file2_ino = kern_f->file2_ino; in xfs_ioc_commit_range()
931 fxr.file2_gen = kern_f->file2_gen; in xfs_ioc_commit_range()
932 fxr.file2_mtime.tv_sec = kern_f->file2_mtime; in xfs_ioc_commit_range()
933 fxr.file2_mtime.tv_nsec = kern_f->file2_mtime_nsec; in xfs_ioc_commit_range()
934 fxr.file2_ctime.tv_sec = kern_f->file2_ctime; in xfs_ioc_commit_range()
935 fxr.file2_ctime.tv_nsec = kern_f->file2_ctime_nsec; in xfs_ioc_commit_range()
940 fxr.file1 = fd_file(file1); in xfs_ioc_commit_range()
942 error = xfs_exchange_range(&fxr); in xfs_ioc_commit_range()