Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block_cloning: multiple bugfixes on FreeBSD #14713

Closed
wants to merge 1 commit into from

Conversation

mmatuska
Copy link
Contributor

@mmatuska mmatuska commented Apr 4, 2023

Motivation and Context

FreeBSD:

  • if copying files on the same dataset and block_cloning is not enabled, the copy is refused and EXDEV is returned
  • zfs_freebsd_copy_file_range() may panic if

Description

Fall back to vn_generic_copy_file_range() if EXDEV is returned.
Use a_outcred if a_fsizetd is NULL

How Has This Been Tested?

Local testing

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@mmatuska mmatuska force-pushed the copy_file_range-fallback branch 2 times, most recently from 69779ab to cc1eadc Compare April 4, 2023 10:58
@mcmilk
Copy link
Contributor

mcmilk commented Apr 4, 2023

Does not build on my FreeBSD 13.1 box:

lk/src/zfs.mmatuska/module/os/freebsd/zfs/zfs_vnops_os.c -o zfs_vnops_os.o
/home/mcmilk/src/zfs.mmatuska/module/os/freebsd/zfs/zfs_vnops_os.c:6286:6: error: incompatible pointer types assigning to 'struct thread *' from 'struct ucred *' [-Werror,-Wincompatible-pointer-types]
                td = ap->a_outcred;
                   ^ ~~~~~~~~~~~~~
/home/mcmilk/src/zfs.mmatuska/module/os/freebsd/zfs/zfs_vnops_os.c:6288:6: error: incompatible pointer types assigning to 'struct thread *' from 'struct ucred *' [-Werror,-Wincompatible-pointer-types]
                td = ap->a_fsizetd->td_ucred;
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~
/home/mcmilk/src/zfs.mmatuska/module/os/freebsd/zfs/zfs_vnops_os.c:6291:33: error: incompatible pointer types passing 'struct thread *' to parameter of type 'cred_t *' (aka 'struct ucred *') [-Werror,-Wincompatible-pointer-types]
            ap->a_outoffp, ap->a_lenp, td);
                                       ^~
/home/mcmilk/src/zfs.mmatuska/include/sys/zfs_vnops.h:35:25: note: passing argument to parameter here
    uint64_t *, cred_t *);
                        ^
3 errors generated.
*** Error code 1

If copying files on the same dataset and block_cloning is not enabled
the copy is refused and EXDEV is returned. In this case fall back to
vn_generic_copy_file_range()

When calling in block_cloning zfs_clone_range() from
zfs_freebsd_copy_file_range(), ap->a_fsizetd may be NULL.
ap->a_outcred is a better candidate.

Signed-off-by: Martin Matuska <mm@FreeBSD.org>
@mmatuska mmatuska changed the title block_cloning: fall back to vn_generic_copy_file_range() on FreeBSD block_cloning: multiple bugfixes on FreeBSD Apr 4, 2023
@mmatuska
Copy link
Contributor Author

mmatuska commented Apr 5, 2023

Closed in favor of #14723

@mmatuska mmatuska closed this Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants