xfs
[Top] [All Lists]

Re: Samba 2.2.2 and XFS quotas

To: John Trostel <jtrostel@xxxxxxxxxxxxxx>, Buchan Milne <bgmilne@xxxxxxxxx>, Sylvestre Taburet <staburet@xxxxxxxxxxxxxxxx>
Subject: Re: Samba 2.2.2 and XFS quotas
From: Nathan Scott <nathans@xxxxxxx>
Date: Wed, 24 Oct 2001 19:05:21 +1100
Cc: linux-xfs@xxxxxxxxxxx
In-reply-to: <2.1-439792-249-D-OEWW@xxxxxxxxxxxxxxxxxxx>; from jtrostel@xxxxxxxxxxxxxx on Mon, Oct 22, 2001 at 10:21:44PM -0500
References: <2.1-439792-249-D-OEWW@xxxxxxxxxxxxxxxxxxx>
Sender: owner-linux-xfs@xxxxxxxxxxx
User-agent: Mutt/1.2.5i
hi,

On Mon, Oct 22, 2001 at 10:21:44PM -0500, John Trostel wrote:
> 
> I took a quick look at the patch today. There seem to be some reasonably 
> large changes between quota.c in 2.2.1a & 2.2.2. I'll probably be able 
> to work a bit at it but will likely be asking about for helpful hints.
> 

To try to help out, I've attached a 2.2.2 patch which is probably the
sort of approach the Samba people will be looking for here.  As I don't
have a clue on how to exercise this code, it is completely untested.
If you are lucky, it may even compile.  ;-)

Its actually got alot simpler this time, with those changes you've
foreshadowed, John, as the 2.4.x quota snarfoo is sorted out now in
smbd/quota.c (see Jeremy's comment in that file, about the spot where
this change is), and it turned out that this makes things a whole lot
easier for us.

Hope this helps.

cheers.

-- 
Nathan


> >> Sylvestre Taburet and I are working on updates to samba-2.2.2 for
> >> Mandrake 8.1. Since Mandrake 8.1 shipped with XFS, we would like to keep
> >> working  samba/XFS/quotas.
> > 
> > Excellent.  This really needs someone with a vested interest
> > to follow it up and push the changes to the Samba folk.
> > 
> >> In the package of samba-2.2.1a, we applied
> >> the patch by Nathan Scott:
> >> (http://marc.theaimsgroup.com/?l=linux-xfs&m=100002981924172&w=2).
> > 
> > Caveat - I have had one report that this patch does not work.
> > As I said originally, it is a patch which shows the sort of
> > changes that are needed, but it is untested as I know very
> > little about Samba & how to go about testing this.
> > 
> >> We have forwarded the patch to samba developers, but they would prefer a
> >> patch against current CVS tag SAMBA_2_2.
> > 
> > It will need to be tested and fixed first, by the sound of it.
> > 
> ... Snip...
> > Thanks for pushing this - if some other developer out there can
> > take a shot at fixing the original patch, I could certainly look
> > over their new patch and cross-check the XFS quota side of things
> > for them.
> John M. Trostel
> jtrostel@xxxxxxxxxxxxxx


diff -Naur samba-2.2.2/source/configure.in samba-2.2.2+ns/source/configure.in
--- samba-2.2.2/source/configure.in     Sun Oct 14 07:09:16 2001
+++ samba-2.2.2+ns/source/configure.in  Wed Oct 24 17:43:19 2001
@@ -383,6 +383,9 @@
 # For quotas on Veritas VxFS filesystems
 AC_CHECK_HEADERS(sys/fs/vx_quota.h)
 
+# For quotas on Linux XFS filesystems
+AC_CHECK_HEADERS(linux/xqm.h)
+
 AC_CHECK_SIZEOF(int,cross)
 AC_CHECK_SIZEOF(long,cross)
 AC_CHECK_SIZEOF(short,cross)
diff -Naur samba-2.2.2/source/include/config.h.in 
samba-2.2.2+ns/source/include/config.h.in
--- samba-2.2.2/source/include/config.h.in      Sun Oct 14 07:09:21 2001
+++ samba-2.2.2+ns/source/include/config.h.in   Wed Oct 24 17:41:05 2001
@@ -903,6 +903,9 @@
 /* Define if you have the <sys/fs/vx_quota.h> header file.  */
 #undef HAVE_SYS_FS_VX_QUOTA_H
 
+/* Define if you have the <linux/xqm.h> header file.  */
+#undef HAVE_LINUX_XQM_H
+
 /* Define if you have the <sys/id.h> header file.  */
 #undef HAVE_SYS_ID_H
 
diff -Naur samba-2.2.2/source/smbd/quotas.c samba-2.2.2+ns/source/smbd/quotas.c
--- samba-2.2.2/source/smbd/quotas.c    Sun Oct 14 07:09:41 2001
+++ samba-2.2.2+ns/source/smbd/quotas.c Wed Oct 24 17:42:15 2001
@@ -57,6 +57,9 @@
  */
 
 #include <linux/quota.h>
+#ifdef HAVE_LINUX_XQM_H
+#include <linux/xqm.h>
+#endif
 
 #include <mntent.h>
 #include <linux/unistd.h>
@@ -75,10 +78,35 @@
 } LINUX_SMB_DISK_QUOTA;
 
 /****************************************************************************
+ Abstract out the XFS Quota Manager quota get call.
+****************************************************************************/
+
+static int get_smb_linux_xfs_quota(char *path, uid_t euser_id, 
LINUX_SMB_DISK_QUOTA *dp)
+{
+       int ret = -1;
+#ifdef HAVE_LINUX_XQM_H
+       struct fs_disk_quota D;
+       ZERO_STRUCT(D);
+
+       if ((ret = quotactl(QCMD(Q_XGETQUOTA,USRQUOTA), path, euser_id, 
(caddr_t)&D)))
+               return ret;
+
+       dp->bsize = (SMB_BIG_UINT)512;
+       dp->softlimit = (SMB_BIG_UINT)D.d_blk_softlimit;
+       dp->hardlimit = (SMB_BIG_UINT)D.d_blk_hardlimit;
+       dp->ihardlimit = (SMB_BIG_UINT)D.d_ino_hardlimit;
+       dp->isoftlimit = (SMB_BIG_UINT)D.d_ino_softlimit;
+       dp->curinodes = (SMB_BIG_UINT)D.d_icount;
+       dp->curblocks = (SMB_BIG_UINT)D.d_bcount;
+#endif
+       return ret;
+}
+
+/****************************************************************************
  Abstract out the old and new Linux quota get calls.
 ****************************************************************************/
 
-static int get_smb_linux_quota(char *path, uid_t euser_id, 
LINUX_SMB_DISK_QUOTA *dp)
+static int get_smb_linux_vfs_quota(char *path, uid_t euser_id, 
LINUX_SMB_DISK_QUOTA *dp)
 {
        int ret;
 #ifdef LINUX_QUOTAS_1
@@ -156,7 +184,10 @@
 
        save_re_uid();
        set_effective_uid(0);  
-       r=get_smb_linux_quota(mnt->mnt_fsname, euser_id, &D);
+       if (strcmp(mnt->mnt_type, "xfs") == 0)
+               r=get_smb_linux_xfs_quota(mnt->mnt_fsname, euser_id, &D);
+       else
+               r=get_smb_linux_vfs_quota(mnt->mnt_fsname, euser_id, &D);
        restore_re_uid();
 
        /* Use softlimit to determine disk space, except when it has been 
exceeded */


<Prev in Thread] Current Thread [Next in Thread>