Abstract out some common quota shell code, add project operation to fsstress.
authorNathan Scott <nathans@sgi.com>
Fri, 8 Apr 2005 03:50:59 +0000 (03:50 +0000)
committerNathan Scott <nathans@sgi.com>
Fri, 8 Apr 2005 03:50:59 +0000 (03:50 +0000)
Merge of master-melb:xfs-cmds:22099a by kenmcd.

050
common.config
ltp/fsstress.c

diff --git a/050 b/050
index 6c2beeb7b9d5a11651be2c9a2e84c4a26e848435..e1a010c9a0af43bcd8c74299254f38cff48b9153 100755 (executable)
--- a/050
+++ b/050
@@ -74,9 +74,7 @@ _require_scratch
 _require_quota
 
 # setup a default run
-if [ -z "$MOUNT_OPTIONS" ]; then
-        export MOUNT_OPTIONS="-o uquota"
-fi
+[ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS="-o uquota"
 
 blksoft=100
 blkhard=500
@@ -119,25 +117,7 @@ else
     QUOTA_FS=$SCRATCH_MNT
 fi
 
-# setup exactly what it is we'll be testing
-enforce=1
-if src/feature -u $SCRATCH_DEV
-then
-       type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
-elif src/feature -g $SCRATCH_DEV
-then
-       type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
-elif src/feature -U $SCRATCH_DEV
-then
-       type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
-       enforce=0
-elif src/feature -G $SCRATCH_DEV
-then
-       type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
-       enforce=0
-else
-       _notrun "No quota support at mount time"
-fi
+_qsetup
 
 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
 echo "and using type=$type id=$id" >>$seq.full
index 93a483beb63b4962b2492595cc69a68deaad100f..192a8b3254c8fe96a03a49957b3268893c64fdee 100644 (file)
@@ -187,7 +187,7 @@ known_hosts()
                EMAIL="nathans@larry"
                SCRATCH_MNT=/mnt/xfs0
                SCRATCH_DEV=/dev/sdb5
-               #SCRATCH_RTDEV=/dev/sdc1
+               #SCRATCH_RTDEV=/dev/md0
                SCRATCH_LOGDEV=/dev/sda11
                TEST_DIR=/mnt/xfs1
                TEST_DEV=/dev/sdc3
index e787f101464bf52d6071588d2979c031b03ebd4c..d21f878cb2eaf586e8a081ce00427dffcd274a59 100644 (file)
@@ -39,6 +39,7 @@
 #include <math.h>
 #define XFS_ERRTAG_MAX         17
 #define XFS_IDMODULO_MAX       32
+#define XFS_PROJIDMODULO_MAX   16
 
 /* was (getpagesize()*32) BUT want it to be same
  * on all platforms
@@ -52,6 +53,7 @@ typedef enum {
        OP_BULKSTAT,
        OP_BULKSTAT1,
        OP_CHOWN,
+       OP_CHPROJ,
        OP_CREAT,
        OP_DREAD,
        OP_DWRITE,
@@ -131,6 +133,7 @@ void        attr_set_f(int, long);
 void   bulkstat_f(int, long);
 void   bulkstat1_f(int, long);
 void   chown_f(int, long);
+void   chproj_f(int, long);
 void   creat_f(int, long);
 void   dread_f(int, long);
 void   dwrite_f(int, long);
@@ -161,6 +164,7 @@ opdesc_t    ops[] = {
        { OP_BULKSTAT, "bulkstat", bulkstat_f, 1, 0 },
        { OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0 },
        { OP_CHOWN, "chown", chown_f, 3, 1 },
+       { OP_CHPROJ, "chproj", chproj_f, 1, 1 },
        { OP_CREAT, "creat", creat_f, 4, 1 },
        { OP_DREAD, "dread", dread_f, 4, 0 },
        { OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
@@ -1621,6 +1625,38 @@ chown_f(int opno, long r)
        free_pathname(&f);
 }
 
+void
+chproj_f(int opno, long r)
+{
+       int             fd;
+       int             e;
+       pathname_t      f;
+       int             nbits;
+       uint            p;
+       int             v;
+
+       init_pathname(&f);
+       if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
+               append_pathname(&f, ".");
+       fd = open_path(&f, O_RDWR);
+       e = fd < 0 ? errno : 0;
+       check_cwd();
+
+       p = (uid_t)random();
+       e = MIN(idmodulo, XFS_PROJIDMODULO_MAX);
+       nbits = (int)(random() % e);
+       p &= (1 << nbits) - 1;
+#if defined(__sgi__)
+       e = fchproj(fd, p);
+#else
+       e = xfsctl(f.path, fd, XFS_IOC_SETPROJID, &p);
+#endif
+       if (v)
+               printf("%d/%d: chproj %s %u %d\n", procid, opno, f.path, p, e);
+       free_pathname(&f);
+       close(fd);
+}
+
 void
 creat_f(int opno, long r)
 {