Fw: Re: Samba 2.2.1 and Linux XFS quota

Tim Potter tpot at samba.org
Tue Jul 24 03:10:52 GMT 2001


More mail stopped by the spamstopper...

>From matthew at arts.usyd.edu.au  Mon Jul 23 19:58:49 2001
Message-ID: <3B5CE70E.943D51C7 at arts.usyd.edu.au>
Date: Tue, 24 Jul 2001 13:10:06 +1000
From: Matthew Geier <matthew at arts.usyd.edu.au>
Organization: Arts IT Unit, Sydney University
Cc: linux-xfs at oss.sgi.com, samba-technical at samba.org
Subject: Re: Samba 2.2.1 and Linux XFS quota

Nathan Scott wrote:

> On Sat, Jul 21, 2001 at 09:54:38AM +1000, Matthew Geier wrote:
> > ...
> >  I did notice one problem with Samba on XFS systems. Quota support
> > doesn't work. After a look in smbd/quota.c, I see the quota's don't work


> look through that file.  In fact, having just looked through that file,
> I see the IRIX quota system call interface is recognised (which is quite
> similar to the Linux/XFS interface), so someone should be able to join
> the dots here and make this code work for Linux/XFS.
> 



 Here is a first attempt at it if any one is interested. Seems to work
for me, but I havent tested it to hard. Im also not sure I did it the
right way either :-)

 Its quite dumb - it assume XFS quotas or 'linux' quotas. I just wrapped
the changes around #ifdefs. I didn't try and copy the irix code where it
changes what structures it uses depending on the file system type it
finds.

Its also full of DEBUG(0 statements so I could 'trace' what ended up
where.

--- quotas.c.orig	Fri Jul  6 12:02:03 2001
+++ quotas.c	Mon Jul 23 18:44:19 2001
@@ -43,12 +43,18 @@
 
 #ifdef LINUX
 
+#define XFS	/* MG - Tag XFS quota changes, dunno how to configure */
+		/* Mostly pinched from the IRIX section */
+
 #include <sys/types.h>
 #include <asm/types.h>
 #include <sys/quota.h>
 
 #include <mntent.h>
 #include <linux/unistd.h>
+#ifdef XFS
+#include <linux/xqm.h>
+#endif
 
 _syscall4(int, quotactl, int, cmd, const char *, special, int, id,
caddr_t, addr);
 
@@ -60,6 +66,9 @@
 {
   int r;
   struct dqblk D;
+#ifdef XFS
+ 	struct fs_disk_quota F;
+#endif
   SMB_STRUCT_STAT S;
   FILE *fp;
   struct mntent *mnt;
@@ -96,6 +105,50 @@
 
   save_re_uid();
   set_effective_uid(0);  
+
+#ifdef XFS
+	r=quotactl (QCMD(Q_XGETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id,
(caddr_t) &F);
+
+    restore_re_uid();
+DEBUG(0,("xfs_quotas: %s, %i, used %i
\n",mnt->mnt_fsname,euser_id,F.d_bcount));
+DEBUG(0,("xfs_quotas:r is %i\n",r));
+/*   if (ret==-1)
+	{
+	DEBUG(0,("xfs_quotas: ret evaluated -1 r is %i\n",r));
+     return(False); 
+	}
+ */
+
+DEBUG(0,("xfs_quotas: d_blk_softlimit %i, d_blk_hardlimit %i\n"
+           ,F.d_blk_softlimit,F.d_blk_hardlimit));
+   /* Use softlimit to determine disk space, except when it has been
exceeded */
+    if (
+        (F.d_blk_softlimit && F.d_bcount>=F.d_blk_softlimit) ||
+        (F.d_blk_hardlimit && F.d_bcount>=F.d_blk_hardlimit) ||
+        (F.d_ino_softlimit && F.d_icount>=F.d_ino_softlimit) ||
+        (F.d_ino_hardlimit && F.d_icount>=F.d_ino_hardlimit)
+       )
+    {
+DEBUG(0,("xfs_quotas: No blocks free\n"));
+
+      *dfree = 0;
+      *dsize = F.d_bcount;
+    }
+    else if (F.d_blk_softlimit==0 && F.d_blk_hardlimit==0)
+    {
+      return(False);
+    }
+    else
+    {
+      *dfree = (F.d_blk_softlimit - F.d_bcount);
+      *dsize = F.d_blk_softlimit;
+    }
+
+
+  return (True);
+
+
+#else
   r=quotactl(QCMD(Q_GETQUOTA,USRQUOTA), mnt->mnt_fsname, euser_id,
(caddr_t)&D);
   restore_re_uid();
 
@@ -133,6 +186,9 @@
     *dsize = D.dqb_bsoftlimit;
   }
   return (True);
+
+#endif
+
 }
 
 #elif defined(CRAY)
sh-2.04# 

-- 
Matthew Geier			matthew at arts.usyd.edu.au
Arts IT Unit			+61 2 9351 4713
Sydney University




More information about the samba-technical mailing list