Re: RFC: #f FreeBSD_version of #ifdef <feature> for OpenZFS pull request

From: Warner Losh <imp_at_bsdimp.com>
Date: Wed, 22 Nov 2023 21:30:09 UTC
On Wed, Nov 22, 2023, 1:24 PM Rick Macklem <rick.macklem@gmail.com> wrote:

> Hi,
>
> I have a patch currently under review at D42672 that fixes visibility
> of snapshots under .zfs/snapshot for NFS clients.
> It adds a new function called vfs_exjail_clone(), which the ZFS
> code needs to use to fill in the mnt_exjail field.
>
> Since the OpenZFS code is supposed to build for 12.2 or later,
> I can see two ways of doing this:
> (A) #if on the FreeBSD_versions, which will look something like:
>
> #if (__FreeBSD_version >= 1300xxx && __FreeBSD_version < 1400000) ||
>      (__FreeBSD_version >= 1400yyy && __FreeBSD_version < 1400500) ||
>      (__FreeBSD_version >= 1400zzz && __FreeBSD_version < 1500000) ||
>      __FreeBSD_version >= 1500wwww
>          vfs_exjail_clone();
> #endif
>
> The problem with this one is I do not know what www, xxx, yyy and zzz are
> until I have MFC'd the patch and bumped __FreeBSD_version.
> --> I cannot generate the OpenZFS pull request until after that and,
>      since I am headed to Florida for a few weeks, it would be late
> December
>      at the earliest.
> OR
> (B) add a line like
> #define VFS_SUPPORTS_EXJAIL_CLONE    1
> to mount.h in the patch and then:
>
> #ifdef VFS_SUPPORTS_EXJAIL_CLONE
>          vfs_exjail_clone();
> #endif
>
> The adavntage of (B) is that I can do the pull request on OpenZFS
> right away and commit the patch to main, etc as soon as possible,
>
> So, which do you think is preferred? rick
> ps: Unless D42672 gets reviewed soon, it won't really matter w.r.t. timing.
>

I'd do B if I were doing this. With a comment for why I'm doing this
define. Then version numbers don't matter unless we botch something badly
and need them as a fallback.

Warner