netatalk icon indicating copy to clipboard operation
netatalk copied to clipboard

NetBSD using compatibility layer for quota

Open rdmark opened this issue 1 year ago • 16 comments

In the latest main branch code:

[195/255] Linking target etc/afpd/afpd
ld: etc/afpd/libafpd.a.p/quota.c.o: in function `getfsquota':
/home/dmark/netatalk/build/../etc/afpd/quota.c:544: warning: warning: reference to compatibility quotactl(); include <sys/quota.h> for correct reference

rdmark avatar Jul 12 '24 06:07 rdmark

This is NetBSD 9.3. It's best to test on NetBSD 10 as well.

rdmark avatar Jul 12 '24 06:07 rdmark

No change in NetBSD 10.0

[188/257] Linking target etc/afpd/afpd
ld: etc/afpd/libafpd.a.p/quota.c.o: in function `getfsquota':
/home/dmark/netatalk/build/../etc/afpd/quota.c:544: warning: warning: reference to compatibility quotactl(); include <sys/quota.h> for correct reference

rdmark avatar Jul 12 '24 10:07 rdmark

It looks like meson fails to detect libquota on NetBSD, and then ends up with some deprecated 4.4BSD API...

hfath avatar Nov 21 '24 18:11 hfath

On netbsd-10, the meson script gives me

Library prop found: YES
Library quota found: YES
Library rpcsvc found: YES
Run-time dependency libtirpc found: NO (tried pkgconfig and cmake)
Has header "rpc/rpc.h" : YES 
Has header "rpc/pmap_prot.h" : YES 
Has header "rpcsvc/rquota.h" : YES 
Checking for function "getfsquota" with dependencies -lquota, -lprop, -lrpcsvc: NO 

and then

      Quota                    : YES
      Quota provider           : SunRPC

but

% grep QUOTA  output/config.h
/* #undef HAVE_LIBQUOTA */
#define HAVE_RPCSVC_RQUOTA_H 1
/* #undef HAVE_RQUOTA_H_QR_STATUS */
/* #undef HAVE_UFS_QUOTA_H */
/* #undef NEED_RQUOTA */
/* #undef NO_QUOTA_SUPPORT */
%

hfath avatar Nov 21 '24 18:11 hfath

Where does the check for "getfsquota()" come from? I can't find that function in any NetBSD younger than 10 yrs.

Maybe this will help?

hfath avatar Nov 21 '24 20:11 hfath

This one makes it look better:

--- meson.build.orig    2024-11-15 06:52:12.000000000 +0000
+++ meson.build
@@ -1017,7 +1017,7 @@ else
         if have_quota
             quota_deps += rpcsvc
             quota_provider += 'SunRPC'
-            if quota.found() and cc.has_function('getfsquota', dependencies: [quota, prop, rpcsvc])
+            if quota.found() and cc.has_function('quota_open', dependencies: [quota, prop, rpcsvc])
                 quota_deps += [quota, prop]
                 cdata.set('HAVE_LIBQUOTA', 1)
             endif

hfath avatar Nov 21 '24 21:11 hfath

Breaks the build, because other parts (etc/afpd/nfsquota.c) are still using the old, deprecated quota interface.

Looks like moving to libquota needs a lot more work.

hfath avatar Nov 21 '24 21:11 hfath

So this means NetBSD has gone in a radically different direction than the other BSDs (and Solaris-likes) with their SunRPC style quota implementation?

rdmark avatar Nov 21 '24 22:11 rdmark

There is a longish tech-kern thread on redesigning the NetBSD quota support from 2011 ( libquota proposal ), coincidentally initiated by Netatalk build problems.

It looks like FreeBSD implements the same API, but in libutil.

The old interface is still available, if the kernel option QUOTA is present.

hfath avatar Nov 21 '24 22:11 hfath

I struggle to understand the function of nfsquota.c -- is that supposed to deal with shares that reside on a nfs volume?

The question is whether that functionality can be implemented in terms of libquota calls, or whether you actually need to go lowlevel here.

hfath avatar Nov 21 '24 23:11 hfath

getnfsquota() is the only function exported from nfsquota.c. It is only called from a section in quota.c that will be '#ifdef HAVE_LIBQUOTA'ed out.

IOW, for libquota support nfsquota.c shouldn't be compiled, however you do that in meson.

hfath avatar Nov 21 '24 23:11 hfath

In Meson, you exclude a file from compilation by modifying the list of source file that you pass to the executable or library target. It could look like this in etc/afpd/meson.build for instance

if have_quota
    afpd_sources += [
        'quota.c',
    ]
    if have_libquota
        afpd_sources += [
            'nfsquota.c',
        ]
    endif
    afpd_external_deps += quota_deps
endif

Here's a hack that demonstrates how it can be done: https://github.com/Netatalk/netatalk/pull/1768

I wonder, does NetBSD (and FreeBSD) linquota have their own native equivalent to getnfsquota()?

rdmark avatar Nov 22 '24 06:11 rdmark

Thanks, I'll play around with that.

To my understanding, the point of libquota is a filesystem independent API, to avoid rummaging around in low-level data structures. So yes, I would expect that it accesses nfs quota, too.

hfath avatar Nov 22 '24 10:11 hfath

Reopening since the fix caused a severe regression https://github.com/Netatalk/netatalk/issues/1900

rdmark avatar Jan 19 '25 10:01 rdmark

We have a user report now that there's a deadlock for them when connecting with System 7 clients with the latest code running on NetBSD. Disabling quota altogether made it work again. For the time being, I'm leaning towards disabling quota by default when building on NetBSD. (Until we find a permanent solution.)

https://68kmla.org/bb/index.php?threads/netatalk-4-0-future-proofing-apple-file-sharing.47958/post-556205

rdmark avatar Feb 28 '25 21:02 rdmark

On Fri, 28 Feb 2025 13:27:33 -0800, Daniel Markstedt wrote:

We have a user report now that there's a deadlock for them when connecting with System 7 clients with the latest code running on NetBSD. Disabling quota altogether made it work again. For the time being, I'm leaning towards disabling quota by default when building on NetBSD. (Until we find a permanent solution.)

Hi Daniel,

that makes sense, yes - and I might do the same for the pkgsrc package.

I do have file quotas set on the workplace server, though, so I'll have to dig into this some time.

Cheerio, Hauke

-- The ASCII Ribbon Campaign Hauke Fath () No HTML/RTF in email Institut für Nachrichtentechnik /\ No Word docs in email TU Darmstadt Respect for open standards Ruf +49-6151-16-21344

hfath avatar Feb 28 '25 21:02 hfath