From: Nathan Scott Date: Fri, 8 Apr 2005 03:50:59 +0000 (+0000) Subject: Abstract out some common quota shell code, add project operation to fsstress. X-Git-Tag: v1.1.0~736 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a175e4429759b748632c2208fcc723b57afa731f;p=xfstests-dev.git Abstract out some common quota shell code, add project operation to fsstress. Merge of master-melb:xfs-cmds:22099a by kenmcd. --- diff --git a/050 b/050 index 6c2beeb7..e1a010c9 100755 --- 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 diff --git a/common.config b/common.config index 93a483be..192a8b32 100644 --- a/common.config +++ b/common.config @@ -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 diff --git a/ltp/fsstress.c b/ltp/fsstress.c index e787f101..d21f878c 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -39,6 +39,7 @@ #include #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) {