From nobody Wed Mar 26 23:05:34 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 4ZNMpN2mjGz5rLJP; Wed, 26 Mar 2025 23:05:48 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) (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 4ZNMpM2jGrz3QyQ; Wed, 26 Mar 2025 23:05:47 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rc4vAPkT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of rick.macklem@gmail.com designates 2a00:1450:4864:20::531 as permitted sender) smtp.mailfrom=rick.macklem@gmail.com Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5dccaaca646so724752a12.0; Wed, 26 Mar 2025 16:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743030345; x=1743635145; 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=o+oLB2GNxgriqy+EeEpVqOQ31KGAfaWQ4mI/0+VQp/A=; b=Rc4vAPkTefSxayK6vmbFhKVp9r5M9NZS9bcmFPeR02TQz9uVR6DEybN7N7rylpL9sG vw0hzp5vEiumfjeDBwiJn6y6vmghWo+PvRooQ7b17O+jBzlHo9cro/oj808VfoNOd/1g LHkWRmpQqe9PpuTusdQH+ZDtVcbpnUUqLtsaYmI9jET1kz+YvDZDc5EoSB2pApRDnmre AYOpIqJ93/Ic8ayI2RAwinCHurqPlcaTfitR7npbTtnbLVJsegzbUngTGlwW9/yjBwQP Z/PhYaqbVqRQXHrKVnjjdMfDuQVeEeLs2GIJnTxjDoVW6ccZIXtbQxgzGH89StWTNdIP Ruuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743030345; x=1743635145; 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=o+oLB2GNxgriqy+EeEpVqOQ31KGAfaWQ4mI/0+VQp/A=; b=TU0UyOz2OGZfdiT7dzAfRyykHn5varPjVXXIV8TCK9lZ4BHTuAaYzAd1SKPJQ6PSQM 67BuODjTVrVju4p9T7zlfXg2ya7z4ASS6nZ73YGqt6GNpRSfbKh7TWFp/Bs8M7Q3BtUq ugo3sK4Mj5UclJrxgxxZwPV6xRkiA+3FTwMlxOEwHAOgcosv5f7JD/K8Evme0ztkzvfv 2MQQ69AhGldboMUYASlsngqQ3nM/UEuX73f4dF4BxfPCKOFb8pQrWeFTXEvexMBPX5GF 2NfnjdlsK629Kmh9bacHBIMA6kRvNeAyGbdn3d5DRzJh/7vwSWiQqzpiSGBXIpysEpSs HmKQ== X-Forwarded-Encrypted: i=1; AJvYcCVtDTHyLGqSoDDKMB/GgU4XbGb7IWLQhw0xzgXyFKFY5q5NBHfrOWPm1kLn7KAka1wPFlm+@freebsd.org, AJvYcCVvb3TxsvQ5QNZ+IJvZC7R/WuwLC1mg/ghO09WeF1B6mRtFv4keo1ar9gThOntjVhZiHN6gh+dF2DLRpyc=@freebsd.org, AJvYcCXTwgqfQsLo4DnKnXR4XzwKde4F83v5I6xKvmJN8T2S1UMU+iXA9JJCwVhEIK/184FnmNdEpfg7oevYW8AQ82rb@freebsd.org X-Gm-Message-State: AOJu0YwznoaYbEOWjJ043jP9kP8fCyrJPWtdac/xTzOVdbjshu10sZAm tL9trXTlh/kbRzWFAJMVbbG0tHpwnaggQnng756XsjJxq4SNYFkEeRS9aLIYBI+PKjqLVIBMrQI VVSPq6tn4ueef2nGxI2vLjv/bpw== X-Gm-Gg: ASbGncue5tjEp/Cy3+8U8IF7G0qKu+CgjTswZtXSmuEq6Cu8+df0yUvPNbolZ/CyvWt SMffKAS8PkYXBMBCat+j9lm+eY/Yl9L50KSVeFQhV2m4enu+5frB7P/YgJFo/G3FG4XWlCvZuPN SvGd0suOpk1P0RtCHoPt2GMnr45zXuSVGs2Jr9u3Conj2yBjzpCxLYtZsmkw== X-Google-Smtp-Source: AGHT+IGiX5jcGz0LQtKvMPJBWhwAeJLIJX000YCFHgb+X2ENVOUG1+TMr748BbOVmoQ6EFV34myyRrz77ms6Rp2MlUE= X-Received: by 2002:a05:6402:27c6:b0:5ed:5cf6:e168 with SMTP id 4fb4d7f45d1cf-5ed8a2eccc4mr1473812a12.9.1743030345169; Wed, 26 Mar 2025 16:05:45 -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: In-Reply-To: From: Rick Macklem Date: Wed, 26 Mar 2025 16:05:34 -0700 X-Gm-Features: AQ5f1JqVFoKmDeMn45nktPTVOOT3rQmaDgUIZjjAu9KzQHSMIpWapJuJLadi7S0 Message-ID: Subject: Re: RFC: Solaris style extended attributes for FreeBSD To: Lionel Cons Cc: Andrew Walker , Konstantin Belousov , freebsd-arch@freebsd.org, FreeBSD CURRENT , Cedric Blancher Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.21 / 15.00]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-0.999]; NEURAL_HAM_MEDIUM(-0.89)[-0.890]; NEURAL_HAM_SHORT(-0.82)[-0.820]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; MIME_GOOD(-0.10)[text/plain]; TAGGED_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::531:from]; ARC_NA(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; FREEMAIL_CC(0.00)[ixsystems.com,freebsd.org,gmail.com]; MISSING_XM_UA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MID_RHS_MATCH_FROMTLD(0.00)[]; TAGGED_RCPT(0.00)[]; MLMMJ_DEST(0.00)[freebsd-arch@freebsd.org,freebsd-current@freebsd.org]; RCVD_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCPT_COUNT_FIVE(0.00)[6] X-Rspamd-Queue-Id: 4ZNMpM2jGrz3QyQ X-Spamd-Bar: -- On Wed, Mar 26, 2025 at 7:43=E2=80=AFAM Rick Macklem wrote: > > On Wed, Mar 26, 2025 at 2:39=E2=80=AFAM Lionel Cons wrote: > > > > On Tue, 25 Mar 2025 at 22:14, Rick Macklem wro= te: > > > > > > On Tue, Mar 25, 2025 at 1:53=E2=80=AFPM Rick Macklem wrote: > > > > > > > > On Tue, Mar 25, 2025 at 12:06=E2=80=AFPM Lionel Cons wrote: > > > > > > > > > > On Sat, 22 Mar 2025 at 21:34, Rick Macklem wrote: > > > > > > > > > > > > On Sun, Mar 9, 2025 at 5:38=E2=80=AFAM Andrew Walker wrote: > > > > > > > > > > > > > > > Since ZFS is already wired for them, adding the basics is p= retty > > > > > > > > straightforward. I am not suggesting that they should repla= ce the > > > > > > > > current FreeBSD extended attributes > > > > > > > > > > > > > > The ZFS story is more complicated. When ZFS is configured wit= h > > > > > > > `xattr=3Dsa`, xattrs are preferentially written into system a= ttributes > > > > > > > (SA). This was introduced IIRC primarily for performance reas= ons > > > > > > > This allows tiny xattrs (~100 bytes) to be stored with the dn= ode and > > > > > > > up to 64 KiB of xattrs to be stored in the dnode spill block.= If > > > > > > > additional space is needed then they are written using the ol= der-style > > > > > > > file-backed approach. > > > > > > > > > > > > > > What this means is that if someone is using this relatively c= ommon > > > > > > > configuration (the default in TrueNAS and in many Linux distr= os), then > > > > > > > the result would be that only some xattrs written via extattr= would be > > > > > > > visible by directly opening the ZFS attr dir. It would also i= ntroduce > > > > > > > a mechanism whereby an xattr with the same name is written to= two > > > > > > > different ZFS locations, which would potentially cause you to= see > > > > > > > different xattr data depending on whether you read it from ex= tattr or > > > > > > > via the attr dir. I don't know off-hand whether this could le= ad to > > > > > > > corruption / unexpected behavior in ZFS but if you haven't lo= oked into > > > > > > > it yet you may want to make sure you're properly handling the= case > > > > > > > where someone has already written SA-backed xattrs. > > > > > > I am in the process of defining a new setting for the xattr pro= perty > > > > > > I've called "named" which would need to be set for the Solaris = style > > > > > > extended attributes to work. > > > > > > > > > > > > I am making progress on the patch and am currently working thro= ugh > > > > > > permissions (or authorization if you prefer). > > > > > > > > > > > > Here is what OpenZFS appears to do currently. > > > > > > I am wondering if these sound reasonable for these attributes? > > > > > > > > > > > > - When an attr directory is created for a file object, the owne= rship > > > > > > (uid and gid) is set to the same value as the file object. > > > > > > The mode is set to 041777 (a directory with sticky bit set an= d > > > > > > permissions for everyone. (It ignores the "mode" argument to > > > > > > the open.) > > > > > > --> As such, anyone who has access to the file object can acc= ess > > > > > > the extended attribute directory. > > > > > > > > > > Yes, that is the expected behaviour > > > > > > > > > > > > > > > > > - When an attribute is created in the attribute directory, the = uid is > > > > > > set to that of the creating process (cr_uid), the gid is set= to that > > > > > > of the directory (which is also the gid of the file object). > > > > > > The mode is set to that of a regular file with low order mod= e bits > > > > > > as specified by the "mode" argument to the openat() that cr= eated > > > > > > it. > > > > > > The mode can be changed with fchmod(2). > > > > > > --> As such, access to each attribute file is controlled by the > > > > > > attribute file's creator. > > > > > > > > > > > > Any comments on the above? > > > > > > > > > > Yes, that would be the expected behaviour. > > > > > > > > > > > > > > > > > A couple of other questions... > > > > > > - Should subdirectories of the attribute directory be supported= ? > > > > > > I currently do not allow this, but it appears to be supportab= le > > > > > > by both OpenZFS and NFSv4. > > > > > > > > > > No, please no subdirs for now. As far as I can see all consumes o= f > > > > > such an API (Windows, MacOS etc) use flat layouts for the attribu= te > > > > > and alternate data streams virtual dirs > > > > > > > > > > > > > > > > > - Does restricting this support to ZFS file systems with the > > > > > > xattr property set to "named" sound reasonable? > > > > > > > > > > What does that mean? > > > > > Also, it should be "on" by default, both in FreeBSD ZFS, UFS and = NFS >=3D v4.1 > > > > Hmm. I think (and the discussion with Andrew seemed to confirm it) > > > > that they do not > > > > mix well with FreeBSD/Linux style extended attributes. (For example= , > > > > the code that > > > > checked access for the parent directory is disabled for FreeBSD sty= le > > > > attributes and > > > > this is intentional, according to the comment.) > > > > > > > > Also, I doubt anyone will ever do support for UFS? (I am certainly = not > > > > volunteering.) > > > > > > > > The above means that a sysadmin will need to choose between which s= tyle > > > > of extended attributes they want on a "per file system basis" and t= hat FreeBSD > > > > style will be the default, since to change that would be a POLA vio= lation, imho. > > > > (If others feel that having the two styles co-exist on the same fil= e > > > > system is needed, > > > > there might be a way to do it, but doing so properly won't be easy. > > > > Another example > > > > is naming. If both co-exist on the same file system, you can end up > > > > with two different > > > > attributes with the same name. I did this during testing, so I know= it > > > > can happen.) > > > > > > > > > > > > > > > > > > > > > Thanks for any comments, rick > > > > > > ps: I have not, as yet, heard any comments w.r.t. whether or > > > > > > not this should go into FreeBSD15. (No rush on this one, > > > > > > but comments would be appreciated. > > > > > > > > > > I'd prefer the integration as soon as possible. > > > > A couple of problems here. > > > > 1 - You and Cedric are the only ones that have spoken up with suppo= rt for this. > > > > (Having said that, no one has spoken up against it.) > > > > 2 - Someone needs to do the "userspace" lifting at some point. > > > > I haven't yet asked, so I do not know if you feel commands lik= e "chmod(1)" > > > > need to be "named attribute aware"? (The fchmod(2) syscall wor= ks, but > > > > does the command line need to know how to do it? If yes, this = is work. > > > > Probably more than I've spent getting the syscalls to work.) > > > > 3 - A lot of the changes need to go into OpenZFS and I have no idea= what > > > > their position will be? (Most of the changes are in the os/fre= ebsd/zfs > > > > source subtree, which may make it easier?) > > > Oh, and another one... > > > Testing. I have yet to hear from anyone trying to test the code. I ob= viously > > > do some testing, but my resources are limited. > > > > How can we do this? Grab patch, apply patch, build FreeBSD, install > > new FreeBSD kernel? > Yes. For now, only the kernel needs to be replaced. (I haven't yet quite > figured out how to get the "zfs" command to set the new "named" value > for the xattr property, so the patch always sets it (ok for testing only)= . > > Basically, install a recent FreeBSD snapshot of 15. If you go onto > ftp.freebsd.org anonymous ftp, then cd into: > pub/FreeBSD/snapshots/ISO-IMAGES/15.0 > - You'll find a bunch of install images there. > If you are installing on 64bit Intel (x86-64), you want one with "amd64= " > in the name. > The ones I use have "disc1.iso" in the name. These are full install > images that I burn onto a DVD. (I don't know what is convenient > for newer hardware, but I'm sure someone will help if you can't > figure out which one to use for the hardware/vm you are installing on.) > > Install it, including src. You'll need ZFS setup. This is covered in the > handbook or you can just install a ZFS root fs for testing. > > Once this system is up, grab the patches and apply them to /usr/src. > (If they don't apply cleanly, let me know and I can help. I am not tracki= ng > main/current and am using a Jan. snapshot.) > > Build/install a new kernel via (as root/su): > # cd /usr/src > # make buildkernel > # make installkernel > -> Reboot. > # cp /usr/src/sys/sys/fcntl.h /usr/include/sys Oh, and you have to set xattr to dir and not sa. # zfs set xattr=3Ddir - If you do not know what the file system is called, do: # zfs get xattr - and look for it under Name I am now less convinced that a new value for xattr is needed. I need to do more testing, but with xattr set to dir and not sa (shown as "on" for zfs get xattr), the attributes seem compatible and it is just the KAPI which changes. rick > > Now, you have to set up NFSv4. The basic steps are: > - Create a /etc/exports. For testing one file system, 2 lines are needed. > /filesystem -alldirs -maproot=3Droot > V4: / > (should be all you need for testing) > > Add the following lines to /etc/rc.conf: > nfsuserd_enable=3D"YES" > nfsuserd_flags=3D"-domain " > nfs_server_enable=3D"YES" > nfsv4_server_enable=3D"YES" > nfsv4_server_only=3D"YES" > - This should be sufficient for the NFSv4 server. > To use the NFSv4 client, add: > nfs_client_enable=3D"YES" > nfscbd_enable=3D"YES" > > To do local testing of ZFS, you don't need the NFSv4 setup. > Just cd into the ZFS file system and bash away at it. > > For both local testing and testing over NFSv4, you can start with > https://people.freebsd.org/~rmacklem/xattrtest.c > and work from there. > > > > > The biggest issue for me is building and installing a new kernel in an > > existing FreeBSD installation, or finding someone in-house who can do > > that. > > Howto or short blog post would be nice > > > > > > > > For example, the pynfs test suite does have some xattr testing in it. > > > However, I haven't used the pynfs test suite in a long time and am no= t > > > a Python guy. It would be nice if someone else fired it up and did th= is > > > testing. (If problems are found, I could probably track them down and > > > fix them.) > > > > > > rick > > > ps: In case you do not know, I am one guy who does this NFS stuff as > > > a spare time hobby. I am not paid any $$$ by anyone to do it. > > > > Well, if you want a (NFS) job at CERN let me know (on-site, not remote)= . > Thanks, but I am just shy of the big 70 and happily retired. > > rick > > > > > Lionel