zfs icon indicating copy to clipboard operation
zfs copied to clipboard

Linux quota API support

Open pavel-odintsov opened this issue 11 years ago • 18 comments

Hello, folks!

I'm using ZFS with OpenVZ containers (separate ZFS volume for every containers) and customers want standard linux quotas inside containers (inside ZFS volume).

Is it possible to provide API for backward compatibility for old software without ZFS quota support?

pavel-odintsov avatar Nov 22 '14 13:11 pavel-odintsov

Yes, at a minimum quota reporting should be available when #2577 is finalized and merged.

behlendorf avatar Dec 02 '14 00:12 behlendorf

Hello!

Maybe my company can help project with some donation? This feature is very important for us.

pavel-odintsov avatar Dec 02 '14 18:12 pavel-odintsov

@pavel-odintsov Unfortunately, it's man power that's in limited supply. You could try and sponsoring a developer to add this functionality. Adding the missing quota ioctl() handlers should get the basic space account working. I node accounting is a bigger change and that's being actively worked in #2577 but realistically it's a few months out.

behlendorf avatar Dec 02 '14 21:12 behlendorf

@behlendorf I'm hired to do the job. I will start with adding ioctl() for regular quotas.

paboldin avatar Mar 19 '15 18:03 paboldin

@paboldin that is awesome news. You can't imagine how many people are waiting at my org (vpsfree.cz) for support of that. Would you be willing to extend the work to support OpenVZ containers? We'll need some mechanism how to pass the control of this down to the containers. We're willing to make a contract with you, if you'd be interested.

snajpa avatar Mar 19 '15 20:03 snajpa

Pavel will add full support for OpenVZ because we working together on implementing complete ZFS support for OpenVZ :)

pavel-odintsov avatar Mar 19 '15 20:03 pavel-odintsov

@paboldin that's great news. Please let me know if you need any pointers to get started on this!

behlendorf avatar Mar 20 '15 17:03 behlendorf

@behlendorf well, I did some investigation and compiled results into the following plan:

  1. Implement an option for the ZFS instance that makes kernel export pseudo block-device named e.g. /dev/zfsfakes/<mountpoint> for the quotactl tools to use. This is required because quotaon and other tools do check for existence of the blockdevice used as a mountpoint. Note that this will also change the /etc/fstab entries for the ZFS instance a bit different. The other option was to patch the quota tools but the quotactl requires a valid block device to acquire struct super_block anyway.
  2. Implement appropriate quotactl_ops using the API provided. Use zfs_set_userquota for setting quota (quotactl_ops->set_dqblk) and general *get_props to read the quota status. As far as I see there is no grace implementation since there is no softlimit so no quotactl_ops->set_info is required.

Is this corresponding with your expectations? I'm very interested if there is any alternative for the first item.

paboldin avatar Mar 21 '15 19:03 paboldin

As a high level description of the solution at least I like the approach, this will make it very easy to pass it to the container. Though I am curious about the OpenVZ side of thibg as well. Is there a maching bug filed in the public OpenVZ bugzilla too, that you could link for reference?

snajpa avatar Mar 21 '15 20:03 snajpa

Let's ask @pavel-odintsov to file one.

I'm not very good at the OpenVZ part of the deal at the moment, so someone will have to help me with that.

paboldin avatar Mar 21 '15 23:03 paboldin

Well, bad news. quota-tools have a list of supported file systems hardcoded. So the fix for it is required anyway.

paboldin avatar Mar 22 '15 14:03 paboldin

That's expected (at least I expected that). I've made my piece with the fact, that we're going to need to provide a repo for every major distribution we support with modified quota-utils(/tools). Can't be avoided. I've had a look at the source some time ago, but didn't find the time to do more about it, so I'm really glad that you guys have picked this up.

snajpa avatar Mar 22 '15 19:03 snajpa

Well, for the OpenVZ containers that do have a lot of emulations it could be optional. But for the plain quota it is indeed necessary.

Seems like I will have to start with a simple implementation of quotas w/o OpenVZ involved first.

paboldin avatar Mar 22 '15 19:03 paboldin

IMHO, the best approach for this would be to have quota-utils open the mountpoint of the filesystem to do the quota operations, rather than the block device. That avoids the need to even have a block device, which is useful for ZFS as well as network filesystems like Lustre that don't have block devices at all.

adilger avatar Sep 22 '17 18:09 adilger

See https://github.com/FastVPSEestiOu/zfs-quota for the implementation of ZFS quota for OpenVZ.

paboldin avatar Mar 18 '19 13:03 paboldin

Hi folks, I asked a couple of years ago on #3500 about whether we're likely to see any of this work merged into mainline zfsonlinux soon.

We're not OpenVZ users - just vanilla ZFS, migrated across from ext4. We were blindsided by the lack of Linux quota support, and have hacked in setting ZFS userquota properties for enforcement, but we don't have any reporting. On Linux this relies, universally, on support for the standard Linux "way".

We've just had our first user trip over the fact that our quota reporting is broken, and it's a bit embarrassing.

If zfsonlinux doesn't support standard quota reporting, what are sysadmins advised to do? I would really rather avoid writing replacements for warnquota, repquota, quotacheck, etc.

nickcmaynard avatar Jan 30 '25 22:01 nickcmaynard

@ixhamza I see that you have been doing some excellent work on userquotas. Please could you shed any light on what the chances are that we'll see this (Linux quota API support) hitting OpenZFS on Linux at any point?

nickcmaynard avatar Jun 04 '25 22:06 nickcmaynard

The problem is that Linux Diskquota Tools that is responsible for Linux quota doesn't use a universal API. Instead, it takes quotas info from different file systems using different ways in their hardcoded commands and libs.

So they need to implement a way to get/set quota from/to ZFS in their tools in order to this work for that in future releases of distros they implement this support.

yuri-ccp avatar Jun 13 '25 09:06 yuri-ccp