From nobody Sat Apr 05 23:12:15 2025 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZVWTR6qP5z5sV3r for ; Sat, 05 Apr 2025 23:12:27 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZVWTR2MB6z3dkX for ; Sat, 05 Apr 2025 23:12:27 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5e5e22e6ed2so4700106a12.3 for ; Sat, 05 Apr 2025 16:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743894746; x=1744499546; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yVnlZOs7PkSS8+cqpMechgMBgOFumU3IYOQ3kMG+LCs=; b=ErgD0F6LzDf0hszncXnmE2LqGpEefu9uhmKROg+S06HK6daDd/pFftXxsqxMkYNgcu HhLVFMs5+F6MovDOCbdTsgCjsFkxZZ2tv4YjmdAbX3KzJ7eZFgKAumx4+1rCcWeUaogm dEcWooi3XjwPHB7FztVpK+qb+qO1XbSjUrXh0kss0CKRPMxK9fVmhtKOndGpevXzrRen wARaZFVvy9gTuQxS8Q9YLa3yb3P6SgVfzT+27kM/oYGlmJS8buF9yZX7XCb4G/ocaAIr lroX6WeouMlDnWburYcgmlhAfKYFr26G24IQ9OiOGPHRHOMhQ4xIalZxMUSC281aOPVB bGLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743894746; x=1744499546; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yVnlZOs7PkSS8+cqpMechgMBgOFumU3IYOQ3kMG+LCs=; b=QY9RuLqnMs4trigtqgC12dvdKLITs7HmWnGdS7tu4RxgeCekxwFsIVonsQstmTUkM2 6OGm64f3bc9VV8DLjsZ+x1tnPkhcrJ1/AlsDD4rn3fLV1FFlkEzfhJABMW1jmODGsQR4 BFC20shLUxgY5a1POPjBh0G9Gj5zFNHBI5jnffXBJy0nnTeS3VgjcSapQMjmW1UKub8v hSPvJ/9iogX+lGd4M2r8ee2AwKxhy8Eq7hOn9S1BR++0WZWrmdpisc49ol8zxDwgbohi mRfPAHYm1OqdTBnP9Vi2jn8sZjjNxCcV6sOPj7hrLUiWM4++mvAAHZf5vy0MfCAQ4Iqu bCJQ== X-Gm-Message-State: AOJu0YycVsuSk+ixxlyEinTNuuWLYL3ONEaZGPfNmSrnAM5lrlLE4p5K 5AfsVz+HVk4NNFnDSHG6n1IPgdmJR9nvTk0qKCU5la8OlGksWKFLQROMyjCxs24qCwikUujQyB7 sbiIKRSVTvPaRHPQ6M9WHUnOsbQ== X-Gm-Gg: ASbGnctLowJavR1kvwir+C8nOFEflsCzh5SglcjlubmtJhH97GBZvB1YBkwyMdOeQFo GwDL+powotBmaAMT2NFs6syrtGnbkIz4ZERG+MsdevA366pKFICvQcLNBCmK6dIW4+8mzzyak9s Wi41S0oktUMHOa37Z2Ewfy1pUoTSzgM67qwP4lOFrVXMsTRpk2dRyRz5U5 X-Google-Smtp-Source: AGHT+IF/7f/s8KSg1M6Hb/dTjotUBzCdHM806hZz4VfEFHj4pUxtd6dl5Rl2/cWzIG0BmlIr6NCD6SR5lKrud0w7F8Q= X-Received: by 2002:a05:6402:40c6:b0:5ed:1444:7914 with SMTP id 4fb4d7f45d1cf-5f0b6630aa0mr6928783a12.28.1743894745605; Sat, 05 Apr 2025 16:12:25 -0700 (PDT) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 References: <2rq3bpvhclcipvgg3mo4gml7ysuzbvt6rfnzkprceumzeaeh4b@casrpprm6mgt> <4beaxy5dpajikvafxpjogcxrpyuwwicng5ln5rxbxlbzp2o2g7@ib7wo5jzlte4> In-Reply-To: <4beaxy5dpajikvafxpjogcxrpyuwwicng5ln5rxbxlbzp2o2g7@ib7wo5jzlte4> From: Rick Macklem Date: Sat, 5 Apr 2025 16:12:15 -0700 X-Gm-Features: ATxdqUHx3Hkhbl65gkbQDAz9-pAFgZtDfdrmMTL00EgFC5TMBNFyCU13iLbqU_k Message-ID: Subject: Re: Heads Up: commit 2ec2ba7e232d just hit main To: Shawn Webb Cc: FreeBSD CURRENT Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Queue-Id: 4ZVWTR2MB6z3dkX X-Spamd-Bar: ---- On Sat, Apr 5, 2025 at 9:12=E2=80=AFAM Shawn Webb wrote: > > On Sat, Apr 05, 2025 at 08:52:06AM -0700, Rick Macklem wrote: > > On Sat, Apr 5, 2025 at 8:50=E2=80=AFAM Rick Macklem wrote: > > > > > > On Fri, Apr 4, 2025 at 6:27=E2=80=AFPM Shawn Webb wrote: > > > > > > > > On Sat, Apr 05, 2025 at 01:04:25AM +0000, Shawn Webb wrote: > > > > > On Fri, Apr 04, 2025 at 05:40:21PM -0700, Rick Macklem wrote: > > > > > > On Fri, Apr 4, 2025 at 10:50=E2=80=AFAM Shawn Webb wrote: > > > > > > > > > > > > > > On Thu, Apr 03, 2025 at 06:12:59PM -0700, Rick Macklem wrote: > > > > > > > > On Thu, Apr 3, 2025 at 4:52=E2=80=AFPM Shawn Webb wrote: > > > > > > > > > > > > > > > > > > On Wed, Apr 02, 2025 at 01:51:26PM -0700, Rick Macklem wr= ote: > > > > > > > > > > The commit 2ec2ba7e232d just hit main. I do not think = it will > > > > > > > > > > cause problems, but it is fairly large. > > > > > > > > > > > > > > > > > > > > Man page updates will be done as separate commits. > > > > > > > > > > > > > > > > > > > > Hopefully this will not cause grief, rick > > > > > > > > > > > > > > > > > > Hey Rick, > > > > > > > > > > > > > > > > > > The patch review test plan mentions a patch to ZFS itself= to support > > > > > > > > > named attributes. Is that patch available somewhere? > > > > > > > > The ZFS patch is currently in phabricator as D49654. > > > > > > > > Feel free to review it. > > > > > > > > > > > > > > > > It can also be found at: > > > > > > > > https://people.freebsd.org/~rmacklem/zfs-xattr.patch > > > > > > > > (this is a smaller diff which can be applied to an up-to-da= te main src > > > > > > > > tree easily) > > > > > > > > > > > > > > Hey Rick, > > > > > > > > > > > > > > I applied that zfs patch, but trying pathconf(2) on a file on= a ZFS > > > > > > > dataset with xattr=3Don (which seems to be the default) retur= ns 0. Am I > > > > > > > doing something wrong? > > > > > > > > > > > > > > =3D=3D=3D=3D BEGIN LOG =3D=3D=3D=3D > > > > > > > hbsd-current-01[shawn]:/home/shawn/tmp $ ./xattrtest xattrtes= t > > > > > > > xattrtest: Named attributes not enabled: No error: 0 > > > > > > > hbsd-current-01[shawn]:/home/shawn/tmp (1) $ zfs list /usr/ho= me/shawn > > > > > > > NAME USED AVAIL REFER MOUNTPOINT > > > > > > > rpool/usr/home 10.4G 71.4G 9.85G /usr/home > > > > > > > hbsd-current-01[shawn]:/home/shawn/tmp $ zfs get xattr rpool/= usr/home > > > > > > > NAME PROPERTY VALUE SOURCE > > > > > > > rpool/usr/home xattr on default > > > > > > > =3D=3D=3D=3D END LOG =3D=3D=3D=3D > > > > > > > > > > > > > > That xattrtest application is yours from: > > > > > > > https://people.freebsd.org/~rmacklem/xattrtest.c > > > > > > No idea. It works for me. You used up-to-date kernel sources? > > > > > > (Check that VIRF_NAMEDATTR is defined in sys/sys/vnode.h.) > > > > > > Oh, and one more thing to check. zfs_xattr_compat needs to be n= on-zero. > > > > > > (It's found in sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vn= ops_os.c. > > > > > > It's initialized to 1 and I don't see anything that sets it to = 0?) > > > > > > > > > > It is indeed set to 1. > > > > > > > > > > > > > > > > > The only thing I can think if is, if you changed xattr to on, y= ou need to > > > > > > reboot (or at least remount) to get it to take effect. > > > > > > (Maybe try setting it to "dir" and then reboot/remount. Maybe t= here is > > > > > > a difference between "on" and "dir"?) > > > > > > > > > > Yeah, tried rebooting and still no go. Note that xattr defaults t= o > > > > > "on" in FreeBSD by default. My src tree is synced up to FreeBSD c= ommit > > > > > 7e70d94acd68b3ac6b45f49d4ab7a0f7867c3ea7. I brought in the ZFS pa= tch > > > > > you linked to. > > > > > > > > > > > > > > > > > Or, did you build zfs.ko some other way than as part of a kerne= l build? > > > > > > (It needs the patched .h files in the kernel sources, not somet= hing in > > > > > > /usr/include/sys > > > > > > that has not yet been updated.) > > > > > > All the ZFS changes are #ifdef'd, since OpenZFS requires the so= urces > > > > > > build for older kernels. (Basically #ifdef'd on that VIRF_NAMED= ATTR mentioned > > > > > > above.) > > > > > > > > > > Perhaps I need to do a clean build. I'll try that and report back= . > > > > > > > > > > > > > > > > > It does remind me that I need to try a build of zfs.ko by doing= a "make" in > > > > > > the module directory. > > > > > > > > > > > > You can try the attached trivial patch and see if it spits out = "pathconf ret=3D1" > > > > > > on the console. > > > > > > > > > > I'll try that after a clean rebuild of the kernel. > > > > > > > > Clean rebuild didn't resolve it. However, I made some progress. > > > > > > > > I created a dataset specifically for this since I can't really unmo= unt > > > > my /usr/home dataset, so my example down below is a bit different t= han > > > > the previous example I gave. > > > > > > > > The xattr property is set to "on" for the dataset. However, it's no= t > > > > mounted with the xattr property. In order to get it to work, I had = to > > > > run the following commands: > > > > > > > > =3D=3D=3D=3D BEGIN LOG =3D=3D=3D=3D > > > > $ sudo zfs umount rpool/scratch/xattr > > > > $ sudo mount -t zfs -o xattr rpool/scratch/xattr /scratch/xattr > > > > $ zfs get xattr rpool/scratch/xattr > > > > NAME PROPERTY VALUE SOURCE > > > > rpool/scratch/xattr xattr on local > > > > $ mount | grep xattr > > > > rpool/scratch/xattr on /scratch/xattr (zfs, local, noatime, nfsv4ac= ls, named attributes) > > > > $ mount | grep named > > > > rpool/scratch/xattr on /scratch/xattr (zfs, local, noatime, nfsv4ac= ls, named attributes) > > > > =3D=3D=3D=3D END LOG =3D=3D=3D=3D > > > > > > > > So it looks like FreeBSD does not honor the xattr zfs property, > > > > otherwise you would see a whole bunch of datasets mounted with the > > > > "named attributes" flag in that last `mount | grep` command. > > > I've looked at this a little more... > > > There is a function xattr_changed_cb() that updates the xattr propert= y > > > information. > > > It gets called when "zfs set xattr=3DXX " is done or whe= n > > > the mount option "xattr" is set. > > > > > > The question seems to be "Why was the stuff not correctly set for you= r file > > > systems, although they show xattr=3Don?" > > This is indeed what I was inferring. xattr has been set to "on" since > the pool's creation as far as I can tell. Until experimenting with > your patch, I didn't really even know the xattr property even existed. I was able to reproduce this with a fresh zpool. Although it reported "xattr on", that is not really accurate. I stuck a printf() in here (line#853-861 of sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.) /* should either have both of these objects or none */ error =3D zap_lookup(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1, &sa_obj); if (error !=3D 0) return (error); error =3D zfs_get_zplprop(os, ZFS_PROP_XATTR, &val); --> The printf here shows that error =3D=3D ENOENT. if (error =3D=3D 0 && val =3D=3D ZFS_XATTR_SA) zfsvfs->z_xattr_sa =3D B_TRUE; The printf() of error showed ENOENT. So, "xattr" actually does not exist. "zfs get xattr " calls it "on" but that's not accurate. As root, I did: # zfs set xattr=3Ddir - reboot This makes it work, although the above call still returns ENOENT. It looks to me like zfsvfs_init() gets called from zfsvfs_create() right at the beginning of zfs_domount(). Later in zfs_domount() it calls zfsvfs_setup()->zfs_register_callbacks(), which now finds the property (because of the "zfs set xattr=3Ddir ") and registers it via dsl_prop_register(). I don't know if the above is correct? Personally, I would prefer to see "zfs get xattr " reply "not = set" instead of "on". rick Setting the property makes it work, but only after rebooting (a umount/mount would probably have the same effect, I think?). > > > > Maybe I'll try and ask somewhere there are ZFS wizards or look in som= e > > > OpenZFS commit logs. > > > > > > Have your ZFS file systems that do not have "named attribute" set bee= n > > > around for quite a while? (I'm thinking that they might have been con= figured > > > differently when they were created and never changed.) > > > > > > It does look like the commands (done as root) should do the same thin= g > > > as your umount/mount did. > > > # zfs set xattr=3Doff > > > # zfs set xattr=3Ddir > > Oh, and followed by a reboot or umount/mount without the xattr mount op= tion. > > The ZFS pool in the VM I'm testing was created in 2020. I would have > thought that the datasets would be mounted with "named attribute" > support by default since the xattr attribute is set to "on" for every > single dataset. A reboot does not cause the datasets to be mounted > with "named attribute" support. I had to unmount the dataset manually, > then run that `mount -t zfs -o xattr ...` command manually. > > I suspect that the dataset automounting code paths, as performed at > boot time, might need to be updated. I have zero experience with ZFS > code, so my suspicion could be completely incorrect. > > From a user's perspective, it seems that the xattr property is ignored > when ZFS automounts a dataset on FreeBSD. That behavior is what is > causing my suspicion above. > > Thanks, > > -- > Shawn Webb > Cofounder / Security Engineer > HardenedBSD > > Signal Username: shawn_webb.74 > Tor-ified Signal: +1 303-901-1600 / shawn_webb_opsec.50 > https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/0= 3A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc