Bug 1697605

Summary: Fix 32-bit quota usage limit for RPC format
Product: Red Hat Enterprise Linux 7 Reporter: Frank Sorenson <fsorenso>
Component: quotaAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Maryna Nalbandian <mnalband>
Severity: unspecified Docs Contact: Lenka Špačková <lkuprova>
Priority: unspecified    
Version: 7.6CC: bnater, jorton, kdsouza, pasik, ppisar
Target Milestone: rcKeywords: Patch, Reproducer
Target Release: 7.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: quota-4.01-19.el7 Doc Type: Bug Fix
Doc Text:
.Setting disk quota limits over a network works again for users occupying more than 4 GB of space on the network file system Previously, the `setquota` utility was unable to handle an occupied space greater than 4 GB when communicating with an NFS server due to an incorrect format of the used disk size. Consequently, when setting disk quota limits for a user exceeding 4 GB of used space on a NFS-mounted file system, `setquota` failed to perform the operation. This update corrects the conversion of the used disk size to an RPC protocol format, and the described problem no longer occurs.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-06 12:44:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frank Sorenson 2019-04-08 19:51:27 UTC
Description of problem:

The rpc quota format sets a limit on the maximum current usage at 4 GiB, due to using a 32-bit-unsigned value.

Upstream patch exists to fix this issue.



Version-Release number of selected component (if applicable):

quota-4.01-18.el7


How reproducible:

easy, see below


Steps to Reproduce:

make a user's current usage greater than 4 GiB:
 on the server:
  # truncate -s 10G /var/tmp/test_fs.img
  # mkfs -t xfs /var/tmp/test_fs.img
  # mkdir -p /mnt/export
  # mount -oloop,usrquota /var/tmp/test_fs.img /mnt/export
  # exportfs '*:/mnt/export
  # touch /mnt/export/testfile
  # chown user1 /mnt/export/testfile
  # dd if=/dev/zero of=/mnt/export/testfile bs=1M count=4100

 on the client:
  # mount server:/mnt/export /mnt/server
  # setquota -F rpc -r -u user1 100M 200M 0 0 /mnt/server


Actual results:

  # setquota -F rpc -r -u user1 100M 200M 0 0 /mnt/server
  setquota: Trying to set quota usage out of range supported by quota format on server:/mnt/export.
  setquota: Cannot write quota for 501 on server:/mnt/export: Numerical result out of range


Expected results:

quota set without error
  # setquota -F rpc -r -u user1 100M 200M 0 0 /mnt/server



Additional info:

due to the incorrect maximum, the test in check_dquot_range fails:

quotaio.c:
int check_dquot_range(struct dquot *dquot)
...
        if (dquot->dq_dqb.dqb_curinodes > info->dqi_max_i_usage ||
            dquot->dq_dqb.dqb_curspace > info->dqi_max_b_usage) {
                errstr(_("Trying to set quota usage out of range "
                         "supported by quota format on %s.\n"), dquot->dq_h->qh_quotadev);
                return -1;
        }


both of these tests must be false in order for the range to be valid:
  	(dquot->dq_dqb.dqb_curspace = 4831772672) > (info->dqi_max_b_usage = 4294966272): FAIL
  	dquot->dq_dqb.dqb_curinodeo = 2) > (info->dqi_max_i_usage = 4294967295): PASS



upstream commit - 
https://sourceforge.net/p/linuxquota/code/ci/d7694c952073bf2ebb852014d9f979b5e3e7c018/


From d7694c952073bf2ebb852014d9f979b5e3e7c018 Mon Sep 17 00:00:00 2001
From: Jan Kara <jack>
Date: Mon, 28 May 2018 18:08:24 +0200
Subject: [PATCH] rpc: Fix wrong limit for space usage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Limit of maximum allowable space usage for RPC transfer was wrongly set
to ~4GB instead of ~4TB due to overflow in constant initialization. Fix
it.

Signed-off-by: Jan Kara <jack>
Signed-off-by: Petr Písař <ppisar>
---
 quotaio_rpc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/quotaio_rpc.c b/quotaio_rpc.c
index 6f25144..edc1e9f 100644
--- a/quotaio_rpc.c
+++ b/quotaio_rpc.c
@@ -33,7 +33,8 @@ static int rpc_init_io(struct quota_handle *h)
 #ifdef RPC
        h->qh_info.dqi_max_b_limit = ~(uint32_t)0;
        h->qh_info.dqi_max_i_limit = ~(uint32_t)0;
-       h->qh_info.dqi_max_b_usage = (~(uint32_t)0) << QUOTABLOCK_BITS;
+       h->qh_info.dqi_max_b_usage = ((uint64_t)(~(uint32_t)0))
+                                                        << QUOTABLOCK_BITS;
        h->qh_info.dqi_max_i_usage = ~(uint32_t)0;
        return 0;
 #else
-- 
2.14.3

Comment 2 Petr Pisar 2019-04-09 08:18:00 UTC
Thank you for the report. I confirm the issue exists in RHEL 7 and that the patch fixes it.

Comment 11 errata-xmlrpc 2019-08-06 12:44:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2019:2093