Bug 31632
Summary: | Quota do not work on SAMBA Server. | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Keiichi Mori <kmori> |
Component: | samba | Assignee: | Trond Eivind Glomsrxd <teg> |
Status: | CLOSED RAWHIDE | QA Contact: | David Lawrence <dkl> |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 7.0 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2001-03-30 04:13:32 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Keiichi Mori
2001-03-13 11:55:31 UTC
I make a patch for this problem. I'm sure that the problem has been resolved by applying this patch. Would you try to test this patch? If you approve this patch, would you apply this patch to samba RPM package? ---- samba-quotafix.patch ----- diff -uNr samba-2.0.7.org/source/lib/util_sock.c samba-2.0.7/source/lib/util_sock.c --- samba-2.0.7.org/source/lib/util_sock.c Thu Mar 29 17:38:24 2001 +++ samba-2.0.7/source/lib/util_sock.c Thu Mar 29 17:42:25 2001 @@ -506,6 +506,11 @@ if (ret == -1) { DEBUG(0,("write_data: write failure. Error = %s\n", strerror(errno) )); + if (errno = EDQUOT) { + SMB_OFF_T off = sys_lseek(fd, 0, SEEK_CUR); + int result = sys_ftruncate(fd, off); + DEBUG(3,("write_data: truncate file at the size = %d, result = %d errno = %d\n", off, result, errno)); + } return -1; } if (ret == 0) return total; diff -uNr samba-2.0.7.org/source/smbd/quotas.c samba-2.0.7/source/smbd/quotas.c --- samba-2.0.7.org/source/smbd/quotas.c Thu Mar 29 17:38:24 2001 +++ samba-2.0.7/source/smbd/quotas.c Thu Mar 29 17:40:44 2001 @@ -47,7 +47,7 @@ #include <sys/types.h> #include <asm/types.h> -#include <sys/quota.h> +#include <linux/quota.h> #include <mntent.h> #include <linux/unistd.h> @@ -61,7 +61,7 @@ BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { int r; - struct dqblk D; + struct mem_dqblk D; SMB_STRUCT_STAT S; FILE *fp; struct mntent *mnt; @@ -99,6 +99,9 @@ save_re_uid(); set_effective_uid(0); r=quotactl(QCMD(Q_GETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id, (caddr_t)&D); + /* change unit from byte to Kbyte, but I'm not sure this change is correct. */ + D.dqb_curspace /= 1024; + restore_re_uid(); /* Use softlimit to determine disk space, except when it has been exceeded */ @@ -108,21 +111,21 @@ if (errno == EDQUOT) { *dfree =0; - *dsize =D.dqb_curblocks; + *dsize =D.dqb_curspace; return (True); } else return(False); } /* Use softlimit to determine disk space, except when it has been exceeded */ if ( - (D.dqb_bsoftlimit && D.dqb_curblocks>=D.dqb_bsoftlimit) || - (D.dqb_bhardlimit && D.dqb_curblocks>=D.dqb_bhardlimit) || + (D.dqb_bsoftlimit && D.dqb_curspace>=D.dqb_bsoftlimit) || + (D.dqb_bhardlimit && D.dqb_curspace>=D.dqb_bhardlimit) || (D.dqb_isoftlimit && D.dqb_curinodes>=D.dqb_isoftlimit) || (D.dqb_ihardlimit && D.dqb_curinodes>=D.dqb_ihardlimit) ) { *dfree = 0; - *dsize = D.dqb_curblocks; + *dsize = D.dqb_curspace; } else if (D.dqb_bsoftlimit==0 && D.dqb_bhardlimit==0) { @@ -131,7 +134,7 @@ else { if (D.dqb_bsoftlimit == 0) D.dqb_bsoftlimit = D.dqb_bhardlimit; - *dfree = D.dqb_bsoftlimit - D.dqb_curblocks; + *dfree = D.dqb_bsoftlimit - D.dqb_curspace; *dsize = D.dqb_bsoftlimit; } return (True); diff -uNr samba-2.0.7.org/source/smbd/reply.c samba-2.0.7/source/smbd/reply.c --- samba-2.0.7.org/source/smbd/reply.c Thu Mar 29 17:38:24 2001 +++ samba-2.0.7/source/smbd/reply.c Thu Mar 29 17:40:44 2001 @@ -2371,7 +2371,7 @@ DEBUG(3,("writebraw1 fnum=%d start=%.0f num=%d wrote=%d sync=%d\n", fsp->fnum, (double)startpos, (int)numtowrite, (int)nwritten, (int)write_through)); - if (nwritten < numtowrite) + if (nwritten < (ssize_t)numtowrite) return(UNIXERROR(ERRHRD,ERRdiskfull)); total_written = nwritten; ------------ *** Bug 33915 has been marked as a duplicate of this bug. *** This patch is completely broken; it does not build in a 7.0 environment. Does this problem only occur when running on a 2.4.recent kernel? This problem occur when running on both 2.2 kernel and a 2.4.recent kernel But I'm sorry. I have mixed the patch for this problem and the patch only for kernel2.4. So I break up the patch what I sent to you into two patches. "samba-quotafix.patch" is a patch for resolving this problems. I build this on RH7.0 environment and on RH7.1 QA0327 environment. "samba-quota4kernel24.patch" is a patch for samba running on kernel 2.4. I build this only on RH7.1 QA0327 environment. --- samba-quotafix.patch ---- diff -uNr samba-2.0.7.org/source/lib/util_sock.c samba-2.0.7/source/lib/util_sock.c --- samba-2.0.7.org/source/lib/util_sock.c Fri Mar 30 11:48:30 2001 +++ samba-2.0.7/source/lib/util_sock.c Fri Mar 30 12:16:16 2001 @@ -506,6 +506,11 @@ if (ret == -1) { DEBUG(0,("write_data: write failure. Error = %s\n", strerror(errno) )); + if (errno == EDQUOT) { + SMB_OFF_T off = sys_lseek(fd, 0, SEEK_CUR); + int result = sys_ftruncate(fd, off); + DEBUG(3, ("write_data: truncate file at the size = %d, result = %d, errno = %d\n", off, result, errno)); + } return -1; } if (ret == 0) return total; diff -uNr samba-2.0.7.org/source/smbd/reply.c samba-2.0.7/source/smbd/reply.c --- samba-2.0.7.org/source/smbd/reply.c Fri Mar 30 11:48:30 2001 +++ samba-2.0.7/source/smbd/reply.c Fri Mar 30 11:52:22 2001 @@ -2371,7 +2371,7 @@ DEBUG(3,("writebraw1 fnum=%d start=%.0f num=%d wrote=%d sync=%d\n", fsp->fnum, (double)startpos, (int)numtowrite, (int)nwritten, (int)write_through)); - if (nwritten < numtowrite) + if (nwritten < (ssize_t)numtowrite) return(UNIXERROR(ERRHRD,ERRdiskfull)); total_written = nwritten; ------------------ --- samba-quota4kernel24.patch ---- --- samba-2.0.7.org/source/smbd/quotas.c Thu Mar 29 17:38:24 2001 +++ samba-2.0.7/source/smbd/quotas.c Thu Mar 29 17:40:44 2001 @@ -47,7 +47,7 @@ #include <sys/types.h> #include <asm/types.h> -#include <sys/quota.h> +#include <linux/quota.h> #include <mntent.h> #include <linux/unistd.h> @@ -61,7 +61,7 @@ BOOL disk_quotas(char *path, SMB_BIG_UINT *bsize, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { int r; - struct dqblk D; + struct mem_dqblk D; SMB_STRUCT_STAT S; FILE *fp; struct mntent *mnt; @@ -99,6 +99,9 @@ save_re_uid(); set_effective_uid(0); r=quotactl(QCMD(Q_GETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id, (caddr_t)&D); + /* change unit from byte to Kbyte, but I'm not sure this change is correct. */ + D.dqb_curspace /= 1024; + restore_re_uid(); /* Use softlimit to determine disk space, except when it has been exceeded */ @@ -108,21 +111,21 @@ if (errno == EDQUOT) { *dfree =0; - *dsize =D.dqb_curblocks; + *dsize =D.dqb_curspace; return (True); } else return(False); } /* Use softlimit to determine disk space, except when it has been exceeded */ if ( - (D.dqb_bsoftlimit && D.dqb_curblocks>=D.dqb_bsoftlimit) || - (D.dqb_bhardlimit && D.dqb_curblocks>=D.dqb_bhardlimit) || + (D.dqb_bsoftlimit && D.dqb_curspace>=D.dqb_bsoftlimit) || + (D.dqb_bhardlimit && D.dqb_curspace>=D.dqb_bhardlimit) || (D.dqb_isoftlimit && D.dqb_curinodes>=D.dqb_isoftlimit) || (D.dqb_ihardlimit && D.dqb_curinodes>=D.dqb_ihardlimit) ) { *dfree = 0; - *dsize = D.dqb_curblocks; + *dsize = D.dqb_curspace; } else if (D.dqb_bsoftlimit==0 && D.dqb_bhardlimit==0) { @@ -131,7 +134,7 @@ else { if (D.dqb_bsoftlimit == 0) D.dqb_bsoftlimit = D.dqb_bhardlimit; - *dfree = D.dqb_bsoftlimit - D.dqb_curblocks; + *dfree = D.dqb_bsoftlimit - D.dqb_curspace; } return (True); ------------------------ OK, both parts are applied in 2.0.7-35; the first patch may make its way into a 7.0 samba package. Thank you very much. If you release sampa-2.0.7-35 package, I'd like to test this and report. |