[PATCHES] more quota cleanups - remove EDQUOT checks

Jeremy Allison jra at samba.org
Tue May 31 20:12:44 UTC 2016


On Sat, May 28, 2016 at 08:44:25PM +0300, Uri Simchoni wrote:
> Hi,
> 
> The attached patch set removes checks for EDQUOT errno in linux-specific
> code, in the platform-independent sysquota code (which is the default
> VFS implementation), and in disk-free code, which relies on VFS quota
> interface.
> 
> On some Unices (e.g. HP-UX), there's a convention that the quotactl
> system call for getting/setting user/group quota may return an EDQUOT
> errno to signal that the request has been fulfilled, but the user/group
> is over quota. This convention has trickled into platform-independent code.
> 
> The attached patch set removes this convention from platform-independent
> code. The interface is thus simplified to the regular unix interface - a
> system call returns 0 if and only if it has succeeded. Specific drivers
> (sysquotas_4A.c, which supports HP-UX) have the responsibility to return
> 0 if their underlying OS uses the above mentioned convention and has
> returned -1 with EDQUOT as errno. On Linux, such a convention does not
> exist and therefore the patch removes the extra checks for EDQUOT on the
> sysquota_linux.c driver.
> 
> Review appreciated.

LGTM - thanks for the cleanup ! Pushed.


> From 21eab0eb19f4da642ec279285bad5e8450084083 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Thu, 26 May 2016 10:24:58 +0300
> Subject: [PATCH 1/5] s3-sysquotas-linux: do not check for EDQUOT
> 
> When obtaining user/group quota, remove check for EDQUOT
> errno return. Apparently on some Unices, EDQUOT means that
> the get-quota function has succeeded, but the user/group is
> over-quota. Not so in Linux.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  source3/lib/sysquotas_linux.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/source3/lib/sysquotas_linux.c b/source3/lib/sysquotas_linux.c
> index 55d1518..c0987de 100644
> --- a/source3/lib/sysquotas_linux.c
> +++ b/source3/lib/sysquotas_linux.c
> @@ -59,7 +59,8 @@ int sys_get_vfs_quota(const char *path, const char *bdev,
>  				   "SMB_USER_QUOTA_TYPE uid[%u]\n",
>  				   path, bdev, (unsigned)id.uid));
>  
> -			if ((ret = quotactl(QCMD(Q_GETQUOTA,USRQUOTA), bdev, id.uid, (caddr_t)&D))&&errno != EDQUOT) {
> +			if ((ret = quotactl(QCMD(Q_GETQUOTA, USRQUOTA), bdev,
> +					    id.uid, (caddr_t)&D))) {
>  				return ret;
>  			}
>  
> @@ -69,7 +70,8 @@ int sys_get_vfs_quota(const char *path, const char *bdev,
>  				   "SMB_GROUP_QUOTA_TYPE gid[%u]\n",
>  				   path, bdev, (unsigned)id.gid));
>  
> -			if ((ret = quotactl(QCMD(Q_GETQUOTA,GRPQUOTA), bdev, id.gid, (caddr_t)&D))&&errno != EDQUOT) {
> +			if ((ret = quotactl(QCMD(Q_GETQUOTA, GRPQUOTA), bdev,
> +					    id.gid, (caddr_t)&D))) {
>  				return ret;
>  			}
>  
> -- 
> 2.5.5
> 
> 
> From d2bc846e61e32a3a0225c190754f2e5cae00cd83 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Fri, 27 May 2016 21:40:06 +0300
> Subject: [PATCH 2/5] selftest: remove test for EDQUOT returned from quota
>  backend
> 
> Remove a test for special handling of EDQUOT errno when determining
> user/group quota - If the backend has obtained the quota settings it
> has to return 0 and not error.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  source3/script/tests/test_dfree_quota.sh | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/source3/script/tests/test_dfree_quota.sh b/source3/script/tests/test_dfree_quota.sh
> index d36530d..ab28a07 100755
> --- a/source3/script/tests/test_dfree_quota.sh
> +++ b/source3/script/tests/test_dfree_quota.sh
> @@ -48,8 +48,6 @@ confdfq3:df:block size = 4096:disk free = 10:disk size = 80
>  confdfq3:u$uid:block size = 4096:hard limit = 40:soft limit = 40:cur blocks = 0
>  confdfq4:df:block size = 4096:disk free = 10:disk size = 80
>  confdfq4:u$uid:block size = 4096:hard limit = 40:soft limit = 40:cur blocks = 37
> -edquot:df:block size = 4096:disk free = 10:disk size = 80
> -edquot:u$uid:block size = 4096:hard limit = 40:soft limit = 40:cur blocks = 41:edquot = 1
>  slimit:df:block size = 4096:disk free = 10:disk size = 80
>  slimit:u$uid:block size = 4096:hard limit = 44:soft limit = 40:cur blocks = 42
>  hlimit:df:block size = 4096:disk free = 10:disk size = 80
> @@ -170,7 +168,6 @@ test_smbclient_dfree "Test dfree share root df vs quota case 4" "." "confdfq4 ."
>  test_smbclient_dfree "Test dfree subdir df vs quota case 4" "subdir1" "confdfq4 subdir1" "160 1024. 12" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
>  
>  #quota-->disk free special cases
> -test_smbclient_dfree "Test quota->dfree edquot" "subdir1" "edquot subdir1" "164 1024. 0" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
>  test_smbclient_dfree "Test quota->dfree soft limit" "subdir1" "slimit subdir1" "168 1024. 0" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
>  test_smbclient_dfree "Test quota->dfree hard limit" "subdir1" "hlimit subdir1" "180 1024. 0" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
>  test_smbclient_dfree "Test quota->dfree inode soft limit" "subdir1" "islimit subdir1" "148 1024. 0" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
> -- 
> 2.5.5
> 
> 
> From c01c3382efae9db1b7390c2b0fdd908b1684d317 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Fri, 27 May 2016 21:42:49 +0300
> Subject: [PATCH 3/5] vfs_fake_dfq - remove support for generating EDQUOT
> 
> Remove the option to retrieve valid user/group quota while
> returning -1 and EDQUOT errno - this is no longer part of the
> protocol between the quota backend and smbd.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  source3/modules/vfs_fake_dfq.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/source3/modules/vfs_fake_dfq.c b/source3/modules/vfs_fake_dfq.c
> index bf49860..51ab7bb 100644
> --- a/source3/modules/vfs_fake_dfq.c
> +++ b/source3/modules/vfs_fake_dfq.c
> @@ -154,11 +154,6 @@ static int dfq_get_quota(struct vfs_handle_struct *handle, const char *path,
>  	qt->curinodes = dfq_load_param(snum, rpath, section, "cur inodes", 0);
>  	qt->qflags = dfq_load_param(snum, rpath, section, "qflags", QUOTAS_DENY_DISK);
>  
> -	if (dfq_load_param(snum, rpath, section, "edquot", 0) != 0) {
> -		errno = EDQUOT;
> -		rc = -1;
> -	}
> -
>  	goto out;
>  
>  dflt:
> -- 
> 2.5.5
> 
> 
> From fe0ec04a03f3fba3d1d98e84621869acd0f6b0cc Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Fri, 27 May 2016 21:51:38 +0300
> Subject: [PATCH 4/5] s3-sysquotas: remove special handling of EDQUOT
> 
> The sysquotas module has several supported backends for
> getting/setting user/group quota. This patch removes a check
> by the common code, to see if the backend has returned EDQUOT.
> 
> Before this patch, it was OK for a backend to return with error
> and errno set to EDQUOT, and that meant success, but with a warning
> that the user/group is over quota. This is the system behavior on
> some Unices. This patch removes this from the protocol between the
> sysquota module and its backend drivers - it's the responsibility
> of the backend to return 0 iff it has fulfilled the request to get or
> set quota.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  source3/lib/sysquotas.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c
> index 102e458..c2d09da 100644
> --- a/source3/lib/sysquotas.c
> +++ b/source3/lib/sysquotas.c
> @@ -493,11 +493,6 @@ int sys_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI
>  	SAFE_FREE(bdev);
>  	SAFE_FREE(fs);
>  
> -	if ((ret!=0)&& (errno == EDQUOT)) {
> -		DEBUG(10,("sys_get_quota() warning over quota!\n"));
> -		return 0;
> -	}
> -
>  	return ret;
>  }
>  
> @@ -560,11 +555,6 @@ int sys_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DI
>  	SAFE_FREE(bdev);
>  	SAFE_FREE(fs);
>  
> -	if ((ret!=0)&& (errno == EDQUOT)) {
> -		DEBUG(10,("sys_set_quota() warning over quota!\n"));
> -		return 0;
> -	}
> -
>  	return ret;		
>  }
>  
> -- 
> 2.5.5
> 
> 
> From 1d031e8cd63018674a8ff193dce0a31e97268cc0 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Fri, 27 May 2016 22:15:46 +0300
> Subject: [PATCH 5/5] s3-dfree-quota: remove special handling of EDQUOT
> 
> It is no longer part of the quota VFS interface to return
> an EDQUOT error as an indication that getting quota succeeded
> but the user/group is over-quota. A VFS module implementing
> quota interface always returns 0 on success.
> 
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
>  source3/smbd/quotas.c | 22 ++++------------------
>  1 file changed, 4 insertions(+), 18 deletions(-)
> 
> diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c
> index 20f74b4..9d3b906 100644
> --- a/source3/smbd/quotas.c
> +++ b/source3/smbd/quotas.c
> @@ -509,18 +509,11 @@ bool disk_quotas(connection_struct *conn, const char *path, uint64_t *bsize,
>  
>  	r = SMB_VFS_GET_QUOTA(conn, path, SMB_USER_QUOTA_TYPE, id, &D);
>  
> -	/* Use softlimit to determine disk space, except when it has been exceeded */
> -	*bsize = D.bsize;
>  	if (r == -1) {
> -		if (errno == EDQUOT) {
> -			*dfree =0;
> -			*dsize =D.curblocks;
> -			return (True);
> -		} else {
> -			goto try_group_quota;
> -		}
> +		goto try_group_quota;
>  	}
>  
> +	*bsize = D.bsize;
>  	/* Use softlimit to determine disk space, except when it has been exceeded */
>  	if (
>  		(D.softlimit && D.curblocks >= D.softlimit) ||
> @@ -563,18 +556,11 @@ try_group_quota:
>  	ZERO_STRUCT(D);
>  	r = SMB_VFS_GET_QUOTA(conn, path, SMB_GROUP_QUOTA_TYPE, id, &D);
>  
> -	/* Use softlimit to determine disk space, except when it has been exceeded */
> -	*bsize = D.bsize;
>  	if (r == -1) {
> -		if (errno == EDQUOT) {
> -			*dfree =0;
> -			*dsize =D.curblocks;
> -			return (True);
> -		} else {
> -			return False;
> -		}
> +		return False;
>  	}
>  
> +	*bsize = D.bsize;
>  	/* Use softlimit to determine disk space, except when it has been exceeded */
>  	if (
>  		(D.softlimit && D.curblocks >= D.softlimit) ||
> -- 
> 2.5.5
> 




More information about the samba-technical mailing list