Whamcloud - gitweb
- update from HEAD
authoralex <alex>
Thu, 12 Feb 2009 08:05:17 +0000 (08:05 +0000)
committeralex <alex>
Thu, 12 Feb 2009 08:05:17 +0000 (08:05 +0000)
34 files changed:
lustre/cmm/cmm_device.c
lustre/include/lclient.h
lustre/include/lu_object.h
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_lite.h
lustre/include/obd.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/dir.c
lustre/llite/dir.c
lustre/lov/lov_obd.c
lustre/lov/lov_qos.c
lustre/lov/lproc_lov.c
lustre/mdc/mdc_lib.c
lustre/mdd/mdd_object.c
lustre/mds/mds_lov.c
lustre/mdt/mdt_handler.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/obd_mount.c
lustre/obdfilter/filter.c
lustre/osc/osc_create.c
lustre/osc/osc_request.c
lustre/osd/osd_handler.c
lustre/osd/osd_internal.h
lustre/tests/cfg/insanity-lmv.sh [deleted file]
lustre/tests/cfg/lmv.sh [deleted file]
lustre/tests/cfg/local.sh
lustre/tests/conf-sanity.sh
lustre/tests/recovery-small.sh
lustre/tests/replay-ost-single.sh
lustre/tests/replay-single.sh
lustre/tests/sanity-quota.sh
lustre/tests/sanity.sh
lustre/tests/utime.c
lustre/utils/wirecheck.c

index 681e2db..40f77bf 100644 (file)
@@ -720,6 +720,40 @@ struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
 /* type constructor/destructor: cmm_type_init/cmm_type_fini */
 LU_TYPE_INIT_FINI(cmm, &cmm_thread_key);
 
+/* 
+ * Kludge code : it should be moved mdc_device.c if mdc_(mds)_device
+ * is really stacked.
+ */
+static int __cmm_type_init(struct lu_device_type *t)
+{
+        int rc;
+        rc = lu_device_type_init(&mdc_device_type);
+        if (rc == 0) {
+                rc = cmm_type_init(t);
+                if (rc)
+                        lu_device_type_fini(&mdc_device_type);
+        }
+        return rc;
+}
+
+static void __cmm_type_fini(struct lu_device_type *t)
+{
+        lu_device_type_fini(&mdc_device_type);
+        cmm_type_fini(t);
+}
+
+static void __cmm_type_start(struct lu_device_type *t)
+{
+        mdc_device_type.ldt_ops->ldto_start(&mdc_device_type);
+        cmm_type_start(t);
+}
+
+static void __cmm_type_stop(struct lu_device_type *t)
+{
+        mdc_device_type.ldt_ops->ldto_stop(&mdc_device_type);
+        cmm_type_stop(t);
+}
+
 static int cmm_device_init(const struct lu_env *env, struct lu_device *d,
                            const char *name, struct lu_device *next)
 {
@@ -780,11 +814,11 @@ static struct lu_device *cmm_device_fini(const struct lu_env *env,
 }
 
 static struct lu_device_type_operations cmm_device_type_ops = {
-        .ldto_init = cmm_type_init,
-        .ldto_fini = cmm_type_fini,
+        .ldto_init = __cmm_type_init,
+        .ldto_fini = __cmm_type_fini,
 
-        .ldto_start = cmm_type_start,
-        .ldto_stop  = cmm_type_stop,
+        .ldto_start = __cmm_type_start,
+        .ldto_stop  = __cmm_type_stop,
 
         .ldto_device_alloc = cmm_device_alloc,
         .ldto_device_free  = cmm_device_free,
index 2c88beb..974a03f 100644 (file)
@@ -358,6 +358,8 @@ int cl_inode_init(struct inode *inode, struct lustre_md *md);
 void cl_inode_fini(struct inode *inode);
 int cl_local_size(struct inode *inode);
 
+__u16 ll_dirent_type_get(struct lu_dirent *ent);
+
 #ifdef INVARIANT_CHECK
 # define CLOBINVRNT(env, clob, expr)                                    \
   do {                                                                  \
index 54ef3df..73fe7af 100644 (file)
@@ -905,12 +905,18 @@ static inline void lu_object_ref_del_at(struct lu_object *o,
         lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source);
 }
 
+/** input params, should be filled out by mdt */
 struct lu_rdpg {
-        /* input params, should be filled out by mdt */
-        __u64                   rp_hash;        /* hash */
-        int                     rp_count;       /* count in bytes       */
-        int                     rp_npages;      /* number of pages      */
-        struct page           **rp_pages;       /* pointers to pages    */
+        /** hash */
+        __u64                   rp_hash;
+        /** count in bytes */
+        unsigned int            rp_count;
+        /** number of pages */
+        unsigned int            rp_npages;
+        /** requested attr */
+        __u32                   rp_attrs;
+        /** pointers to pages */
+        struct page           **rp_pages;
 };
 
 enum lu_xattr_flags {
index 76327b2..5ea31cf 100644 (file)
@@ -490,18 +490,69 @@ static inline int lu_fid_cmp(const struct lu_fid *f0,
 
 /** \defgroup lu_dir lu_dir
  * @{ */
+
+/**
+ * Enumeration of possible directory entry attributes.
+ *
+ * Attributes follow directory entry header in the order they appear in this
+ * enumeration.
+ */
+enum lu_dirent_attrs {
+        LUDA_FID    = 0x0001,
+        LUDA_TYPE   = 0x0002,
+};
+
 /**
  * Layout of readdir pages, as transmitted on wire.
  */
 struct lu_dirent {
+        /** valid if LUDA_FID is set. */
         struct lu_fid lde_fid;
+        /** a unique entry identifier: a hash or an offset. */
         __u64         lde_hash;
+        /** total record length, including all attributes. */
         __u16         lde_reclen;
+        /** name length */
         __u16         lde_namelen;
-        __u32         lde_pad0;
+        /** optional variable size attributes following this entry.
+         *  taken from enum lu_dirent_attrs.
+         */
+        __u32         lde_attrs;
+        /** name is followed by the attributes indicated in ->ldp_attrs, in
+         *  their natural order. After the last attribute, padding bytes are
+         *  added to make ->lde_reclen a multiple of 8.
+         */
         char          lde_name[0];
 };
 
+/*
+ * Definitions of optional directory entry attributes formats.
+ *
+ * Individual attributes do not have their length encoded in a generic way. It
+ * is assumed that consumer of an attribute knows its format. This means that
+ * it is impossible to skip over an unknown attribute, except by skipping over all
+ * remaining attributes (by using ->lde_reclen), which is not too
+ * constraining, because new server versions will append new attributes at
+ * the end of an entry.
+ */
+
+/**
+ * Fid directory attribute: a fid of an object referenced by the entry. This
+ * will be almost always requested by the client and supplied by the server.
+ *
+ * Aligned to 8 bytes.
+ */
+/* To have compatibility with 1.8, lets have fid in lu_dirent struct. */
+
+/**
+ * File type.
+ *
+ * Aligned to 2 bytes.
+ */
+struct luda_type {
+        __u16 lt_type;
+};
+
 struct lu_dirpage {
         __u64            ldp_hash_start;
         __u64            ldp_hash_end;
@@ -534,11 +585,25 @@ static inline struct lu_dirent *lu_dirent_next(struct lu_dirent *ent)
         return next;
 }
 
+static inline int lu_dirent_calc_size(int namelen, __u16 attr)
+{
+        int size;
+
+        if (attr & LUDA_TYPE) {
+                const unsigned align = sizeof(struct luda_type) - 1;
+                size = (sizeof(struct lu_dirent) + namelen + align) & ~align;
+                size += sizeof(struct luda_type);
+        } else
+                size = sizeof(struct lu_dirent) + namelen;
+
+        return (size + 7) & ~7;
+}
+
 static inline int lu_dirent_size(struct lu_dirent *ent)
 {
         if (le16_to_cpu(ent->lde_reclen) == 0) {
-                return (sizeof(*ent) +
-                        le16_to_cpu(ent->lde_namelen) + 7) & ~7;
+                return lu_dirent_calc_size(le16_to_cpu(ent->lde_namelen),
+                                           le32_to_cpu(ent->lde_attrs));
         }
         return le16_to_cpu(ent->lde_reclen);
 }
@@ -699,7 +764,8 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define OBD_CONNECT_CKSUM      0x20000000ULL /*support several cksum algos */
 #define OBD_CONNECT_FID        0x40000000ULL /*FID is supported by server */
 #define OBD_CONNECT_VBR        0x80000000ULL /*version based recovery */
-#define OBD_CONNECT_LOV_V3    0x100000000ULL /*client supports LOV v3 EA */
+#define OBD_CONNECT_LOV_V3      0x100000000ULL /*client supports LOV v3 EA */
+#define OBD_CONNECT_SKIP_ORPHAN 0x400000000ULL /* don't reuse orphan objids */
 /* also update obd_connect_names[] for lprocfs_rd_connect_flags()
  * and lustre/utils/wirecheck.c */
 
@@ -729,7 +795,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_CHANGE_QS | \
                                 OBD_CONNECT_OSS_CAPA  | OBD_CONNECT_RMT_CLIENT | \
                                 OBD_CONNECT_RMT_CLIENT_FORCE | \
-                                OBD_CONNECT_MDS)
+                                OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN)
 #define ECHO_CONNECT_SUPPORTED (0)
 #define MGS_CONNECT_SUPPORTED  (OBD_CONNECT_VERSION | OBD_CONNECT_AT)
 
index 9fab984..f0c6495 100644 (file)
@@ -145,8 +145,8 @@ static inline void ll_dir_chain_fini(struct ll_dir_chain *chain)
 {
 }
 
-static inline __u32 hash_x_index(__u32 value)
+static inline unsigned long hash_x_index(unsigned long value)
 {
-        return ((__u32)~0) - value;
+        return ~0UL - value;
 }
 #endif
index f4ee771..868e86f 100644 (file)
@@ -640,6 +640,7 @@ struct lov_qos {
         struct rw_semaphore lq_rw_sem;
         __u32               lq_active_oss_count;
         unsigned int        lq_prio_free;   /* priority for free space */
+        unsigned int        lq_threshold_rr;/* priority for rr */
         struct lov_qos_rr   lq_rr;          /* round robin qos data */
         unsigned long       lq_dirty:1,     /* recalc qos data */
                             lq_same_space:1,/* the ost's all have approx.
index d68ba37..c06573a 100644 (file)
@@ -1186,3 +1186,25 @@ void cl_inode_fini(struct inode *inode)
                 cl_env_reexit(cookie);
         }
 }
+
+/**
+ * return IF_* type for given lu_dirent entry.
+ * IF_* flag shld be converted to particular OS file type in
+ * platform llite module.
+ */
+__u16 ll_dirent_type_get(struct lu_dirent *ent)
+{
+        __u16 type = 0;
+        struct luda_type *lt;
+        int len = 0;
+
+        if (le32_to_cpu(ent->lde_attrs) & LUDA_TYPE) {
+                const unsigned align = sizeof(struct luda_type) - 1;
+
+                len = le16_to_cpu(ent->lde_namelen);
+                len = (len + align) & ~align;
+                lt = (void *) ent->lde_name + len;
+                type = CFS_IFTODT(le16_to_cpu(lt->lt_type));
+        }
+        return type;
+}
index 8999ae6..c8e3300 100644 (file)
@@ -132,8 +132,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
         return rc;
 }
 
-static cfs_page_t *llu_dir_read_page(struct inode *ino, __u32 hash,
-                                      int exact, struct ll_dir_chain *chain)
+static cfs_page_t *llu_dir_read_page(struct inode *ino, __u64 hash,
+                                     int exact, struct ll_dir_chain *chain)
 {
         cfs_page_t *page;
         int rc;
@@ -211,6 +211,7 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
         int rc;
         int done;
         int shift;
+        __u16 type;
         ENTRY;
 
         liblustre_wait_event(0);
@@ -272,9 +273,9 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
                                 name = ent->lde_name;
                                 fid_le_to_cpu(&fid, &fid);
                                 ino  = llu_fid_build_ino(llu_i2sbi(dir), &fid);
-
+                                type = ll_dirent_type_get(ent);
                                 done = filldir(buf, nbytes, name, namelen,
-                                               (loff_t)hash, ino, DT_UNKNOWN,
+                                               (loff_t)hash, ino, type,
                                                &filled);
                         }
                         next = le64_to_cpu(dp->ldp_hash_end);
@@ -309,7 +310,7 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
                                PFID(&lli->lli_fid), (unsigned long)pos, rc);
                 }
         }
-        lli->lli_dir_pos = (loff_t)(__s32)pos;
+        lli->lli_dir_pos = (loff_t)pos;
         *basep = lli->lli_dir_pos;
 out:
         ll_dir_chain_fini(&chain);
index 8506022..a31cc3e 100644 (file)
@@ -221,7 +221,7 @@ static struct page *ll_dir_page_locate(struct inode *dir, __u64 hash,
          * radix_tree_gang_lookup() can be used to find a page with starting
          * hash _smaller_ than one we are looking for.
          */
-        unsigned long offset = hash_x_index((__u32)hash);
+        unsigned long offset = hash_x_index((unsigned long)hash);
         struct page *page;
         int found;
 
@@ -345,7 +345,7 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, int exact,
                 }
         }
 
-        page = read_cache_page(mapping, hash_x_index((__u32)hash),
+        page = read_cache_page(mapping, hash_x_index((unsigned long)hash),
                                (filler_t*)mapping->a_ops->readpage, NULL);
         if (IS_ERR(page))
                 GOTO(out_unlock, page);
@@ -394,6 +394,7 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
         int rc;
         int done;
         int shift;
+        __u16 type;
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu\n",
@@ -457,9 +458,9 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                                 name = ent->lde_name;
                                 fid_le_to_cpu(&fid, &fid);
                                 ino  = ll_fid_build_ino(sbi, &fid);
-
+                                type = ll_dirent_type_get(ent);
                                 done = filldir(cookie, name, namelen,
-                                               (loff_t)hash, ino, DT_UNKNOWN);
+                                               (loff_t)hash, ino, type);
                         }
                         next = le64_to_cpu(dp->ldp_hash_end);
                         ll_put_page(page);
@@ -491,7 +492,7 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                 }
         }
 
-        filp->f_pos = (loff_t)(__s32)pos;
+        filp->f_pos = (loff_t)pos;
         filp->f_version = inode->i_version;
         touch_atime(filp->f_vfsmnt, filp->f_dentry);
 
index 00ce37d..88369ec 100644 (file)
@@ -805,6 +805,8 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         lov->lov_qos.lq_reset = 1;
         /* Default priority is toward free space balance */
         lov->lov_qos.lq_prio_free = 232;
+        /* Default threshold for rr (roughly 17%) */
+        lov->lov_qos.lq_threshold_rr = 43;
 
         lov->lov_pools_hash_body = lustre_hash_init("POOLS", 7, 7,
                                                     &pool_hash_operations, 0);
index 94539b3..8913d90 100644 (file)
@@ -253,10 +253,7 @@ static int qos_calc_ppo(struct obd_device *obd)
         /* If each ost has almost same free space,
          * do rr allocation for better creation performance */
         lov->lov_qos.lq_same_space = 0;
-        temp = ba_max - ba_min;
-        ba_min = (ba_min * 51) >> 8;     /* 51/256 = .20 */
-        if (temp < ba_min) {
-                /* Difference is less than 20% */
+        if ((ba_max * (256 - lov->lov_qos.lq_threshold_rr)) >> 8 < ba_min) {
                 lov->lov_qos.lq_same_space = 1;
                 /* Reset weights for the next time we enter qos mode */
                 lov->lov_qos.lq_reset = 1;
index 71ab80f..7526bd8 100644 (file)
@@ -237,6 +237,40 @@ static int lov_wr_qos_priofree(struct file *file, const char *buffer,
         return count;
 }
 
+static int lov_rd_qos_thresholdrr(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data)
+{
+        struct obd_device *dev = (struct obd_device*) data;
+        struct lov_obd *lov;
+
+        LASSERT(dev != NULL);
+        lov = &dev->u.lov;
+        *eof = 1;
+        return snprintf(page, count, "%d%%\n",
+                        (lov->lov_qos.lq_threshold_rr * 100) >> 8);
+}
+
+static int lov_wr_qos_thresholdrr(struct file *file, const char *buffer,
+                                  unsigned long count, void *data)
+{
+        struct obd_device *dev = (struct obd_device *)data;
+        struct lov_obd *lov;
+        int val, rc;
+        LASSERT(dev != NULL);
+
+        lov = &dev->u.lov;
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        if (val > 100 || val < 0)
+                return -EINVAL;
+
+        lov->lov_qos.lq_threshold_rr = (val << 8) / 100;
+        lov->lov_qos.lq_dirty = 1;
+        return count;
+}
+
 static int lov_rd_qos_maxage(char *page, char **start, off_t off, int count,
                              int *eof, void *data)
 {
@@ -347,6 +381,7 @@ struct lprocfs_vars lprocfs_lov_obd_vars[] = {
         { "kbytesavail",  lprocfs_rd_kbytesavail, 0, 0 },
         { "desc_uuid",    lov_rd_desc_uuid,       0, 0 },
         { "qos_prio_free",lov_rd_qos_priofree,    lov_wr_qos_priofree, 0 },
+        { "qos_threshold_rr",  lov_rd_qos_thresholdrr, lov_wr_qos_thresholdrr, 0 },
         { "qos_maxage",   lov_rd_qos_maxage,      lov_wr_qos_maxage, 0 },
         { 0 }
 };
index dc5aa09..7094b5a 100644 (file)
@@ -122,6 +122,8 @@ void mdc_readdir_pack(struct ptlrpc_request *req, __u64 pgoff,
         b->size = pgoff;                       /* !! */
         b->nlink = size;                        /* !! */
         __mdc_pack_body(b, -1);
+        b->mode = LUDA_FID | LUDA_TYPE;
+
         mdc_pack_capa(req, &RMF_CAPA1, oc);
 }
 
index 0d9de14..c99bf70 100644 (file)
@@ -2003,16 +2003,80 @@ static int mdd_readpage_sanity_check(const struct lu_env *env,
         RETURN(rc);
 }
 
-static int mdd_dir_page_build(const struct lu_env *env, int first,
-                              void *area, int nob, const struct dt_it_ops *iops,
-                              struct dt_it *it, __u64 *start, __u64 *end,
-                              struct lu_dirent **last)
+static int mdd_append_attrs(const struct lu_env *env,
+                             struct mdd_device *mdd,
+                             __u32 attr,
+                             const struct dt_it_ops *iops,
+                             struct dt_it *it,
+                             struct lu_dirent*ent)
+{
+        struct mdd_thread_info  *info = mdd_env_info(env);
+        struct lu_fid           *fid  = &info->mti_fid2;
+        int                      len = cpu_to_le16(ent->lde_namelen);
+        const unsigned           align = sizeof(struct luda_type) - 1;
+        struct lu_fid_pack      *pack;
+        struct mdd_object       *obj;
+        struct luda_type        *lt;
+        int rc = 0;
+
+        if (attr & LUDA_FID) {
+                pack = (struct lu_fid_pack *)iops->rec(env, it);
+                if (IS_ERR(pack)) {
+                        rc = PTR_ERR(pack);
+                        ent->lde_attrs = 0;
+                        goto out;
+                }
+                rc = fid_unpack(pack, fid);
+                if (rc != 0) {
+                        ent->lde_attrs = 0;
+                        goto out;
+                }
+
+                fid_cpu_to_le(&ent->lde_fid, fid);
+                ent->lde_attrs = LUDA_FID;
+        }
+
+        /* check if file type is required */
+        if (attr & LUDA_TYPE) {
+                if (!(attr & LUDA_FID)) {
+                        CERROR("wrong attr : [%x]\n",attr);
+                        rc = -EINVAL;
+                        goto out;
+                }
+
+                obj = mdd_object_find(env, mdd, fid);
+                if (obj == NULL) /* remote object */
+                        goto out;
+
+                if (IS_ERR(obj)) {
+                        rc = PTR_ERR(obj);
+                        goto out;
+                }
+
+                if (mdd_object_exists(obj) == +1) {
+                        len = (len + align) & ~align;
+
+                        lt = (void *) ent->lde_name + len;
+                        lt->lt_type = cpu_to_le16(mdd_object_type(obj));
+
+                        ent->lde_attrs |= LUDA_TYPE;
+                }
+                mdd_object_put(env, obj);
+        }
+out:
+        ent->lde_attrs = cpu_to_le32(ent->lde_attrs);
+        return rc;
+}
+
+static int mdd_dir_page_build(const struct lu_env *env, struct mdd_device *mdd,
+                              int first, void *area, int nob,
+                              const struct dt_it_ops *iops, struct dt_it *it,
+                              __u64 *start, __u64 *end,
+                              struct lu_dirent **last, __u32 attr)
 {
-        struct lu_fid          *fid  = &mdd_env_info(env)->mti_fid2;
-        struct mdd_thread_info *info = mdd_env_info(env);
-        struct lu_fid_pack     *pack = &info->mti_pack;
         int                     result;
         struct lu_dirent       *ent;
+        __u64  hash = 0;
 
         if (first) {
                 memset(area, 0, sizeof (struct lu_dirpage));
@@ -2020,56 +2084,64 @@ static int mdd_dir_page_build(const struct lu_env *env, int first,
                 nob  -= sizeof (struct lu_dirpage);
         }
 
-        LASSERT(nob > sizeof *ent);
-
         ent  = area;
-        result = 0;
         do {
                 char  *name;
                 int    len;
                 int    recsize;
-                __u64  hash;
 
-                name = (char *)iops->key(env, it);
                 len  = iops->key_size(env, it);
 
-                pack = (struct lu_fid_pack *)iops->rec(env, it);
-                result = fid_unpack(pack, fid);
-                if (result != 0)
-                        break;
+                /* IAM iterator can return record with zero len. */
+                if (len == 0)
+                        goto next;
 
-                recsize = (sizeof(*ent) + len + 7) & ~7;
+                name = (char *)iops->key(env, it);
                 hash = iops->store(env, it);
-                *end = hash;
 
-                CDEBUG(D_INFO, "%p %p %d "DFID": "LPU64" (%d) \"%*.*s\"\n",
-                       name, ent, nob, PFID(fid), hash, len, len, len, name);
+                if (unlikely(first)) {
+                        first = 0;
+                        *start = hash;
+                }
+
+                recsize = lu_dirent_calc_size(len, attr);
+
+                CDEBUG(D_INFO, "%p %p %d "LPU64" (%d) \"%*.*s\"\n",
+                                name, ent, nob, hash, len, len, len, name);
 
                 if (nob >= recsize) {
-                        ent->lde_fid = *fid;
-                        fid_cpu_to_le(&ent->lde_fid, &ent->lde_fid);
-                        ent->lde_hash = hash;
+                        ent->lde_hash    = cpu_to_le64(hash);
                         ent->lde_namelen = cpu_to_le16(len);
                         ent->lde_reclen  = cpu_to_le16(recsize);
                         memcpy(ent->lde_name, name, len);
-                        if (first && ent == area)
-                                *start = hash;
-                        *last = ent;
-                        ent = (void *)ent + recsize;
-                        nob -= recsize;
-                        result = iops->next(env, it);
+
+                        result = mdd_append_attrs(env, mdd, attr, iops, it, ent);
+                        if (result != 0)
+                                goto out;
                 } else {
                         /*
                          * record doesn't fit into page, enlarge previous one.
                          */
-                        LASSERT(*last != NULL);
-                        (*last)->lde_reclen =
-                                cpu_to_le16(le16_to_cpu((*last)->lde_reclen) +
-                                            nob);
-                        break;
+                        if (*last) {
+                                (*last)->lde_reclen =
+                                        cpu_to_le16(le16_to_cpu((*last)->lde_reclen) +
+                                                        nob);
+                                result = 0;
+                        } else
+                                result = -EINVAL;
+
+                        goto out;
                 }
+                *last = ent;
+                ent = (void *)ent + recsize;
+                nob -= recsize;
+
+next:
+                result = iops->next(env, it);
         } while (result == 0);
 
+out:
+        *end = hash;
         return result;
 }
 
@@ -2081,6 +2153,7 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj,
         const struct dt_it_ops  *iops;
         struct page       *pg;
         struct lu_dirent  *last = NULL;
+        struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
         int i;
         int rc;
         int nob;
@@ -2130,11 +2203,14 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj,
              i++, nob -= CFS_PAGE_SIZE) {
                 LASSERT(i < rdpg->rp_npages);
                 pg = rdpg->rp_pages[i];
-                rc = mdd_dir_page_build(env, !i, cfs_kmap(pg),
+                rc = mdd_dir_page_build(env, mdd, !i, cfs_kmap(pg),
                                         min_t(int, nob, CFS_PAGE_SIZE), iops,
-                                        it, &hash_start, &hash_end, &last);
-                if (rc != 0 || i == rdpg->rp_npages - 1)
-                        last->lde_reclen = 0;
+                                        it, &hash_start, &hash_end, &last,
+                                        rdpg->rp_attrs);
+                if (rc != 0 || i == rdpg->rp_npages - 1) {
+                        if (last)
+                                last->lde_reclen = 0;
+                }
                 cfs_kunmap(pg);
         }
         if (rc > 0) {
@@ -2148,13 +2224,14 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj,
                 struct lu_dirpage *dp;
 
                 dp = cfs_kmap(rdpg->rp_pages[0]);
-                dp->ldp_hash_start = rdpg->rp_hash;
-                dp->ldp_hash_end   = hash_end;
+                dp->ldp_hash_start = cpu_to_le64(rdpg->rp_hash);
+                dp->ldp_hash_end   = cpu_to_le64(hash_end);
                 if (i == 0)
                         /*
                          * No pages were processed, mark this.
                          */
                         dp->ldp_flags |= LDF_EMPTY;
+
                 dp->ldp_flags = cpu_to_le32(dp->ldp_flags);
                 cfs_kunmap(rdpg->rp_pages[0]);
         }
@@ -2196,8 +2273,8 @@ static int mdd_readpage(const struct lu_env *env, struct md_object *obj,
                 pg = rdpg->rp_pages[0];
                 dp = (struct lu_dirpage*)cfs_kmap(pg);
                 memset(dp, 0 , sizeof(struct lu_dirpage));
-                dp->ldp_hash_start = rdpg->rp_hash;
-                dp->ldp_hash_end   = DIR_END_OFF;
+                dp->ldp_hash_start = cpu_to_le64(rdpg->rp_hash);
+                dp->ldp_hash_end   = cpu_to_le64(DIR_END_OFF);
                 dp->ldp_flags |= LDF_EMPTY;
                 dp->ldp_flags = cpu_to_le32(dp->ldp_flags);
                 cfs_kunmap(pg);
index 9c6142f..51b2fbc 100644 (file)
@@ -643,7 +643,7 @@ int mds_lov_connect(struct obd_device *obd, char * lov_name)
                                   OBD_CONNECT_OSS_CAPA  | OBD_CONNECT_FID     |
                                   OBD_CONNECT_BRW_SIZE  | OBD_CONNECT_CKSUM   |
                                   OBD_CONNECT_CHANGE_QS | OBD_CONNECT_AT      |
-                                  OBD_CONNECT_MDS;
+                                  OBD_CONNECT_MDS | OBD_CONNECT_SKIP_ORPHAN;
 #ifdef HAVE_LRU_RESIZE_SUPPORT
         data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
index b46baaf..f95d6b4 100644 (file)
@@ -1414,6 +1414,8 @@ static int mdt_readpage(struct mdt_thread_info *info)
                        rdpg->rp_hash, reqbody->size);
                 RETURN(-EFAULT);
         }
+
+        rdpg->rp_attrs = reqbody->mode;
         rdpg->rp_count  = reqbody->nlink;
         rdpg->rp_npages = (rdpg->rp_count + CFS_PAGE_SIZE - 1)>>CFS_PAGE_SHIFT;
         OBD_ALLOC(rdpg->rp_pages, rdpg->rp_npages * sizeof rdpg->rp_pages[0]);
index a6f0311..043ba88 100644 (file)
@@ -808,6 +808,8 @@ static const char *obd_connect_names[] = {
         "fid_is_enabled",
         "version_recovery",
         "pools",
+        "", /* reserved for simplified interop */
+        "skip_orphan",
         NULL
 };
 
index 04d012c..5a618ff 100644 (file)
@@ -1684,6 +1684,18 @@ int server_name2index(char *svname, __u32 *idx, char **endptr)
         if (!dash)
                 return(-EINVAL);
 
+        if (dash == svname) /* svname started w/ a `-' and only has one `-' */
+                return(-EINVAL);
+
+        /* intepret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass
+         * in the fsname, then determine the server index */
+        if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) {
+                dash--;
+                for (; dash > svname && *dash != '-'; dash--);
+                if (dash == svname)
+                        return(-EINVAL);
+        }
+
         if (strncmp(dash + 1, "MDT", 3) == 0)
                 rc = LDD_F_SV_TYPE_MDT;
         else if (strncmp(dash + 1, "OST", 3) == 0)
index 191b3e5..d6782e2 100644 (file)
@@ -2670,6 +2670,11 @@ static int filter_connect_internal(struct obd_export *exp,
         exp->exp_connect_flags = data->ocd_connect_flags;
         data->ocd_version = LUSTRE_VERSION_CODE;
 
+        /* Kindly make sure the SKIP_ORPHAN flag is from MDS. */
+        if (!ergo(data->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN,
+                  data->ocd_connect_flags & OBD_CONNECT_MDS))
+                RETURN(-EPROTO);
+
         if (exp->exp_connect_flags & OBD_CONNECT_GRANT) {
                 obd_size left, want;
 
@@ -3491,11 +3496,12 @@ static int filter_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
 
 /* caller must hold fo_create_locks[oa->o_gr] */
 static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa,
-                                      struct filter_obd *filter)
+                                     struct filter_obd *filter)
 {
         struct obdo doa; /* XXX obdo on stack */
         obd_id last, id;
-        int rc;
+        int rc = 0;
+        int skip_orphan;
         ENTRY;
 
         LASSERT(oa);
@@ -3517,8 +3523,11 @@ static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa,
 
         last = filter_last_id(filter, doa.o_gr);
 
-        CWARN("%s: deleting orphan objects from "LPU64" to "LPU64"\n",
-               exp->exp_obd->obd_name, oa->o_id + 1, last);
+        skip_orphan = !!(exp->exp_connect_flags & OBD_CONNECT_SKIP_ORPHAN);
+
+        CWARN("%s: deleting orphan objects from "LPU64" to "LPU64"%s\n",
+               exp->exp_obd->obd_name, oa->o_id + 1, last,
+               skip_orphan ? ", orphan objids won't be reused any more." : ".");
 
         for (id = last; id > oa->o_id; id--) {
                 doa.o_id = id;
@@ -3526,17 +3535,26 @@ static int filter_destroy_precreated(struct obd_export *exp, struct obdo *oa,
                 if (rc && rc != -ENOENT) /* this is pretty fatal... */
                         CEMERG("error destroying precreate objid "LPU64": %d\n",
                                id, rc);
-                filter_set_last_id(filter, id - 1, doa.o_gr);
+
                 /* update last_id on disk periodically so that if we restart
                  * we don't need to re-scan all of the just-deleted objects. */
-                if ((id & 511) == 0)
+                if ((id & 511) == 0 && !skip_orphan) {
+                        filter_set_last_id(filter, id - 1, doa.o_gr);
                         filter_update_last_objid(exp->exp_obd, doa.o_gr, 0);
+                }
         }
 
         CDEBUG(D_HA, "%s: after destroy: set last_objids["LPU64"] = "LPU64"\n",
                exp->exp_obd->obd_name, doa.o_gr, oa->o_id);
 
-        rc = filter_update_last_objid(exp->exp_obd, doa.o_gr, 1);
+        if (!skip_orphan) {
+                filter_set_last_id(filter, id, doa.o_gr);
+                rc = filter_update_last_objid(exp->exp_obd, doa.o_gr, 1);
+        } else {
+                /* don't reuse orphan object, return last used objid */
+                oa->o_id = last;
+                rc = 0;
+        }
         clear_bit(doa.o_gr, &filter->fo_destroys_in_progress);
 
         RETURN(rc);
@@ -3555,6 +3573,8 @@ static int filter_handle_precreate(struct obd_export *exp, struct obdo *oa,
 
         /* delete orphans request */
         if ((oa->o_valid & OBD_MD_FLFLAGS) && (oa->o_flags & OBD_FL_DELORPHAN)){
+                obd_id last = filter_last_id(filter, group);
+
                 if (oti->oti_conn_cnt < exp->exp_conn_cnt) {
                         CERROR("%s: dropping old orphan cleanup request\n",
                                obd->obd_name);
@@ -3569,14 +3589,14 @@ static int filter_handle_precreate(struct obd_export *exp, struct obdo *oa,
                         up(&filter->fo_create_locks[group]);
                         RETURN(0);
                 }
-                diff = oa->o_id - filter_last_id(filter, group);
+                diff = oa->o_id - last;
                 CDEBUG(D_HA, "filter_last_id() = "LPU64" -> diff = %d\n",
-                       filter_last_id(filter, group), diff);
+                       last, diff);
 
                 if (-diff > OST_MAX_PRECREATE) {
                         CERROR("%s: ignoring bogus orphan destroy request: "
                                "obdid "LPU64" last_id "LPU64"\n", obd->obd_name,
-                               oa->o_id, filter_last_id(filter, group));
+                               oa->o_id, last);
                         /* FIXME: should reset precreate_next_id on MDS */
                         GOTO(out, rc = -EINVAL);
                 }
index e432aa4..8b71f60 100644 (file)
@@ -309,6 +309,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                struct lov_stripe_md **ea, struct obd_trans_info *oti)
 {
         struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
+        struct obd_import  *imp  = exp->exp_obd->u.cli.cl_import;
         struct lov_stripe_md *lsm;
         int try_again = 1, rc = 0;
         ENTRY;
@@ -355,10 +356,22 @@ int osc_create(struct obd_export *exp, struct obdo *oa,
                 spin_lock(&oscc->oscc_lock);
                 oscc->oscc_flags &= ~OSCC_FLAG_SYNC_IN_PROGRESS;
                 if (rc == 0 || rc == -ENOSPC) {
+                        struct obd_connect_data *ocd;
+
                         if (rc == -ENOSPC)
                                 oscc->oscc_flags |= OSCC_FLAG_NOSPC;
                         oscc->oscc_flags &= ~OSCC_FLAG_RECOVERING;
+
                         oscc->oscc_last_id = oa->o_id;
+                        ocd = &imp->imp_connect_data;
+                        if (ocd->ocd_connect_flags & OBD_CONNECT_SKIP_ORPHAN) {
+                                CWARN("Skip orphan set, reset the last objid\n");
+                                oscc->oscc_next_id = oa->o_id + 1;
+                        }
+
+                        /* sanity check for next objid. see bug 17025 */
+                        LASSERT(oscc->oscc_next_id == oa->o_id + 1);
+
                         CDEBUG(D_HA, "%s: oscc recovery finished, last_id: "
                                LPU64", rc: %d\n", oscc->oscc_obd->obd_name,
                                oscc->oscc_last_id, rc);
index 1f7e465..fa7d01f 100644 (file)
@@ -2147,7 +2147,8 @@ osc_send_oap_rpc(const struct lu_env *env, struct client_obd *cli,
                                  oap_pending_item) {
                 ops = oap->oap_caller_ops;
 
-                LASSERT(oap->oap_magic == OAP_MAGIC);
+                LASSERTF(oap->oap_magic == OAP_MAGIC, "Bad oap magic: oap %p, "
+                         "magic 0x%x\n", oap, oap->oap_magic);
 
                 if (clob == NULL) {
                         /* pin object in memory, so that completion call-backs
index 19b55ae..7950a3e 100644 (file)
@@ -1821,12 +1821,11 @@ static int __osd_xattr_set(const struct lu_env *env, struct dt_object *dt,
         *t = inode->i_ctime;
         rc = inode->i_op->setxattr(dentry, name, buf->lb_buf,
                                    buf->lb_len, fs_flags);
-        if (likely(rc == 0)) {
-                spin_lock(&obj->oo_guard);
-                inode->i_ctime = *t;
-                spin_unlock(&obj->oo_guard);
-                mark_inode_dirty(inode);
-        }
+        /* ctime should not be updated with server-side time. */
+        spin_lock(&obj->oo_guard);
+        inode->i_ctime = *t;
+        spin_unlock(&obj->oo_guard);
+        mark_inode_dirty(inode);
         return rc;
 }
 
@@ -2172,13 +2171,11 @@ static int osd_xattr_del(const struct lu_env *env,
         dentry->d_inode = inode;
         *t = inode->i_ctime;
         rc = inode->i_op->removexattr(dentry, name);
-        if (likely(rc == 0)) {
-                /* ctime should not be updated with server-side time. */
-                spin_lock(&obj->oo_guard);
-                inode->i_ctime = *t;
-                spin_unlock(&obj->oo_guard);
-                mark_inode_dirty(inode);
-        }
+        /* ctime should not be updated with server-side time. */
+        spin_lock(&obj->oo_guard);
+        inode->i_ctime = *t;
+        spin_unlock(&obj->oo_guard);
+        mark_inode_dirty(inode);
         return rc;
 }
 
@@ -2719,10 +2716,20 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt,
                                       (char *)key, strlen((char *)key));
         bh = ldiskfs_find_entry(dentry, &de);
         if (bh) {
+                struct osd_thread_info *oti = osd_oti_get(env);
+                struct timespec *ctime = &oti->oti_time;
+                struct timespec *mtime = &oti->oti_time2;
+
+                *ctime = dir->i_ctime;
+                *mtime = dir->i_mtime;
                 rc = ldiskfs_delete_entry(oh->ot_handle,
                                 dir, de, bh);
-                if (!rc)
-                        mark_inode_dirty(dir);
+                /* xtime should not be updated with server-side time. */
+                spin_lock(&obj->oo_guard);
+                dir->i_ctime = *ctime;
+                dir->i_mtime = *mtime;
+                spin_unlock(&obj->oo_guard);
+                mark_inode_dirty(dir);
                 brelse(bh);
         } else
                 rc = -ENOENT;
@@ -3109,7 +3116,7 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
         const char               *name  = (const char *)key;
         struct osd_object        *child;
 #ifdef HAVE_QUOTA_SUPPORT
-        cfs_cap_t              save = current->cap_effective;
+        cfs_cap_t                 save  = current->cap_effective;
 #endif
         int rc;
 
@@ -3126,6 +3133,13 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
                 RETURN(rc);
         child = osd_object_find(env, dt, fid);
         if (!IS_ERR(child)) {
+                struct inode *inode = obj->oo_inode;
+                struct osd_thread_info *oti = osd_oti_get(env);
+                struct timespec *ctime = &oti->oti_time;
+                struct timespec *mtime = &oti->oti_time2;
+
+                *ctime = inode->i_ctime;
+                *mtime = inode->i_mtime;
 #ifdef HAVE_QUOTA_SUPPORT
                 if (ignore_quota)
                         current->cap_effective |= CFS_CAP_SYS_RESOURCE_MASK;
@@ -3138,6 +3152,12 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
                 current->cap_effective = save;
 #endif
                 osd_object_put(env, child);
+                /* xtime should not be updated with server-side time. */
+                spin_lock(&obj->oo_guard);
+                inode->i_ctime = *ctime;
+                inode->i_mtime = *mtime;
+                spin_unlock(&obj->oo_guard);
+                mark_inode_dirty(inode);
         } else {
                 rc = PTR_ERR(child);
         }
index af9d7d3..52a165d 100644 (file)
@@ -170,9 +170,10 @@ struct osd_thread_info {
         struct lu_fid          oti_fid;
         struct osd_inode_id    oti_id;
         /*
-         * XXX temporary: fake dentry used by xattr calls.
+         * XXX temporary: for ->i_op calls.
          */
         struct timespec        oti_time;
+        struct timespec        oti_time2;
         /*
          * XXX temporary: fake struct file for osd_object_sync
          */
diff --git a/lustre/tests/cfg/insanity-lmv.sh b/lustre/tests/cfg/insanity-lmv.sh
deleted file mode 100644 (file)
index 9ef06ad..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-FSNAME=lustre
-
-# facet hosts
-mds_HOST=${mds_HOST:-`hostname`}
-mdsfailover_HOST=${mdsfailover_HOST}
-mgs_HOST=${mgs_HOST:-$mds_HOST}
-ost_HOST=${ost_HOST:-`hostname`}
-ostfailover_HOST=${ostfailover_HOST}
-
-mds1_HOST=${mds1_HOST:-$mds_HOST}
-mds2_HOST=$mds1_HOST
-mds3_HOST=$mds1_HOST
-ost2_HOST=${ost2_HOST:-$ost_HOST}
-gks_HOST=${gks_HOST:-$mds_HOST}
-LIVE_CLIENT=${LIVE_CLIENT:-`hostname`}
-# This should always be a list, not a regexp
-FAIL_CLIENTS=${FAIL_CLIENTS:-""}
-
-NETTYPE=${NETTYPE:-tcp}
-MGSNID=${MGSNID:-`h2$NETTYPE $mgs_HOST`}
-FSTYPE=${FSTYPE:-ldiskfs}
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-$((OSTCOUNT -1))}
-TIMEOUT=${TIMEOUT:-30}
-PTLDEBUG=${PTLDEBUG:-0x33f0404}
-SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
-
-TMP=${TMP:-/tmp}
-
-MDSCOUNT=${MDSCOUNT:-3}
-MDSDEVBASE=${MDSDEVBASE:-$TMP/${FSNAME}-mdt}
-MDSSIZE=${MDSSIZE:-100000}
-
-OSTCOUNT=${OSTCOUNT:-2}
-OSTDEVBASE=${OSTDEVBASE:-$TMP/${FSNAME}-ost}
-OSTSIZE=${OSTSIZE:-200000}
-
-#client
-MOUNT=${MOUNT:-/mnt/${FSNAME}}
-MOUNT1=${MOUNT1:-$MOUNT}
-MOUNT2=${MOUNT2:-${MOUNT}2}
-MOUNTOPT=${MOUNTOPT:-"user_xattr,"}
-[ "x$RMTCLIENT" != "x" ] &&
-       MOUNTOPT=$MOUNTOPT",remote_client"
-DIR=${DIR:-$MOUNT}
-DIR1=${DIR:-$MOUNT1}
-DIR2=${DIR2:-$MOUNT2}
-
-PDSH=${PDSH:-no_dsh}
-FAILURE_MODE=${FAILURE_MODE:-SOFT} # or HARD
-POWER_DOWN=${POWER_DOWN:-"powerman --off"}
-POWER_UP=${POWER_UP:-"powerman --on"}
-
-MKFSOPT=""
-MOUNTOPT=""
-[ "x$MDSJOURNALSIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -J size=$MDSJOURNALSIZE"
-[ "x$MDSISIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -i $MDSISIZE"
-[ "x$MKFSOPT" != "x" ] &&
-    MKFSOPT="--mkfsoptions=\"$MKFSOPT\""
-[ "x$SECLEVEL" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.sec_level=$SECLEVEL"
-[ "x$MDSCAPA" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.capa=$MDSCAPA"
-[ "x$mdsfailover_HOST" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --failnode=`h2$NETTYPE $mdsfailover_HOST`"
-[ "x$STRIPE_BYTES" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param lov.stripesize=$STRIPE_BYTES"
-[ "x$STRIPES_PER_OBJ" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param lov.stripecount=$STRIPES_PER_OBJ"
-[ "x$L_GETIDENTITY" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.identity_upcall=$L_GETIDENTITY"
-MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$MDSSIZE --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $MDSOPT"
-MDSn_MKFS_OPTS="--mgsnode=$MGSNID --mdt --fsname=$FSNAME --device-size=$MDSSIZE --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $MDSOPT"
-
-MKFSOPT=""
-MOUNTOPT=""
-[ "x$OSTJOURNALSIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -J size=$OSTJOURNALSIZE"
-[ "x$MKFSOPT" != "x" ] &&
-    MKFSOPT="--mkfsoptions=\"$MKFSOPT\""
-[ "x$SECLEVEL" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param ost.sec_level=$SECLEVEL"
-[ "x$OSSCAPA" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param ost.capa=$OSSCAPA"
-[ "x$ostfailover_HOST" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --failnode=`h2$NETTYPE $ostfailover_HOST`"
-OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $OSTOPT"
-
-MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"-o loop"}
-OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"-o loop"}
-
-SINGLEMDS=${SINGLEMDS:-"mds1"}
diff --git a/lustre/tests/cfg/lmv.sh b/lustre/tests/cfg/lmv.sh
deleted file mode 100644 (file)
index 3b573bc..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-FSNAME=lustre
-
-# facet hosts
-mds_HOST=${mds_HOST:-`hostname`}
-mdsfailover_HOST=${mdsfailover_HOST}
-mgs_HOST=${mgs_HOST:-$mds_HOST}
-ost_HOST=${ost_HOST:-`hostname`}
-ostfailover_HOST=${ostfailover_HOST}
-
-mds1_HOST=${mds1_HOST:-$mds_HOST}
-mds2_HOST=${mds2_HOST:-$mds_HOST}
-mds3_HOST=${mds3_HOST:-$mds_HOST}
-mds4_HOST=${mds4_HOST:-$mds_HOST}
-ost2_HOST=${ost2_HOST:-$ost_HOST}
-gks_HOST=${gks_HOST:-$mds_HOST}
-
-NETTYPE=${NETTYPE:-tcp}
-MGSNID=${MGSNID:-`h2$NETTYPE $mgs_HOST`}
-FSTYPE=${FSTYPE:-ldiskfs}
-STRIPE_BYTES=${STRIPE_BYTES:-1048576}
-STRIPES_PER_OBJ=${STRIPES_PER_OBJ:-$((OSTCOUNT -1))}
-TIMEOUT=${TIMEOUT:-20}
-PTLDEBUG=${PTLDEBUG:-0x33f0404}
-DEBUG_SIZE=${DEBUG_SIZE:-10}
-SUBSYSTEM=${SUBSYSTEM:-0xffb7e3ff}
-
-TMP=${TMP:-/tmp}
-
-MDSDEV=${MDSDEV:-$TMP/${FSNAME}-mdt1}
-MDSCOUNT=${MDSCOUNT:-3}
-test $MDSCOUNT -gt 4 && MDSCOUNT=4
-MDSCOUNT=1
-MDSDEVBASE=${MDSDEVBASE:-$TMP/${FSNAME}-mdt}
-MDSSIZE=${MDSSIZE:-100000}
-
-OSTCOUNT=${OSTCOUNT:-2}
-OSTDEVBASE=${OSTDEVBASE:-$TMP/${FSNAME}-ost}
-OSTSIZE=${OSTSIZE:-200000}
-
-#client
-MOUNT=${MOUNT:-/mnt/${FSNAME}}
-MOUNT1=${MOUNT1:-$MOUNT}
-MOUNT2=${MOUNT2:-${MOUNT}2}
-MOUNTOPT=${MOUNTOPT:-"user_xattr,"}
-[ "x$RMTCLIENT" != "x" ] &&
-       MOUNTOPT=$MOUNTOPT",remote_client"
-DIR=${DIR:-$MOUNT}
-DIR1=${DIR:-$MOUNT1}
-DIR2=${DIR2:-$MOUNT2}
-
-if [ $UID -ne 0 ]; then
-        log "running as non-root uid $UID"
-        RUNAS_ID="$UID"
-        RUNAS=""
-else
-        RUNAS_ID=${RUNAS_ID:-500}
-        RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
-fi
-
-PDSH=${PDSH:-no_dsh}
-FAILURE_MODE=${FAILURE_MODE:-SOFT} # or HARD
-POWER_DOWN=${POWER_DOWN:-"powerman --off"}
-POWER_UP=${POWER_UP:-"powerman --on"}
-
-MKFSOPT=""
-MOUNTOPT=""
-[ "x$MDSJOURNALSIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -J size=$MDSJOURNALSIZE"
-[ "x$MDSISIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -i $MDSISIZE"
-[ "x$MKFSOPT" != "x" ] &&
-    MKFSOPT="--mkfsoptions=\"$MKFSOPT\""
-[ "x$SECLEVEL" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.sec_level=$SECLEVEL"
-[ "x$MDSCAPA" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.capa=$MDSCAPA"
-[ "x$mdsfailover_HOST" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --failnode=`h2$NETTYPE $mdsfailover_HOST`"
-[ "x$STRIPE_BYTES" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param lov.stripesize=$STRIPE_BYTES"
-[ "x$STRIPES_PER_OBJ" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param lov.stripecount=$STRIPES_PER_OBJ"
-[ "x$L_GETIDENTITY" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param mdt.identity_upcall=$L_GETIDENTITY"
-MDS_MKFS_OPTS="--mgs --mdt --fsname=$FSNAME --device-size=$MDSSIZE --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $MDSOPT"
-MDSn_MKFS_OPTS="--mgsnode=$MGSNID --mdt --fsname=$FSNAME --device-size=$MDSSIZE --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $MDSOPT"
-
-MKFSOPT=""
-MOUNTOPT=""
-[ "x$OSTJOURNALSIZE" != "x" ] &&
-    MKFSOPT=$MKFSOPT" -J size=$OSTJOURNALSIZE"
-[ "x$MKFSOPT" != "x" ] &&
-    MKFSOPT="--mkfsoptions=\"$MKFSOPT\""
-[ "x$SECLEVEL" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param ost.sec_level=$SECLEVEL"
-[ "x$OSSCAPA" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --param ost.capa=$OSSCAPA"
-[ "x$ostfailover_HOST" != "x" ] &&
-    MOUNTOPT=$MOUNTOPT" --failnode=`h2$NETTYPE $ostfailover_HOST`"
-OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$TIMEOUT $MKFSOPT $MOUNTOPT $OSTOPT"
-
-MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"-o loop"}
-OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"-o loop"}
-
-SINGLEMDS=${SINGLEMDS:-"mds1"}
index b6f71a1..3fdb604 100644 (file)
@@ -89,8 +89,6 @@ MOUNT=${MOUNT:-/mnt/${FSNAME}}
 MOUNT1=${MOUNT1:-$MOUNT}
 MOUNT2=${MOUNT2:-${MOUNT}2}
 MOUNTOPT=${MOUNTOPT:-"user_xattr,acl"}
-[ "x$RMTCLIENT" != "x" ] &&
-       MOUNTOPT=$MOUNTOPT",remote_client"
 DIR=${DIR:-$MOUNT}
 DIR1=${DIR:-$MOUNT1}
 DIR2=${DIR2:-$MOUNT2}
index 60f880a..7ab509e 100644 (file)
@@ -12,7 +12,7 @@ set -e
 ONLY=${ONLY:-"$*"}
 
 # bug number for skipped test: 13739
-HEAD_EXCEPT="                  32a 32b"
+HEAD_EXCEPT="                  32a"
 
 # bug number for skipped test:                                 
 ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $HEAD_EXCEPT"
@@ -956,7 +956,7 @@ start32 () {
 }
 
 cleanup_nocli32 () {
-       stop32 mds -f
+       stop32 mds1 -f
        stop32 ost1 -f
        wait_exit_ST client
 }
@@ -1228,7 +1228,7 @@ test_35() { # bug 12459
        # contact after the connection loss
        $LCTL dk $TMP/lustre-log-$TESTNAME.log
        NEXTCONN=`awk "/${MSG}/ {start = 1;}
-                      /import_select_connection.$device-mdc.* using connection/ {
+                      /import_select_connection.*$device-mdc.* using connection/ {
                                if (start) {
                                        if (\\\$NF ~ /$FAKENID/)
                                                print \\\$NF;
index 41087cf..943b41d 100755 (executable)
@@ -1035,6 +1035,31 @@ of $NUM_FILES"
 }
 run_test 60 "Add Changelog entries during MDS failover"
 
+test_61()
+{
+       local cflags='osc.*-OST0000-osc-MDT*.connect_flags'
+       do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
+       [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
+
+       mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
+       # Set the default stripe of $DIR/$tdir to put the files to ost1
+       $LFS setstripe -c 1 --index 0 $DIR/$tdir
+
+       replay_barrier $SINGLEMDS
+       createmany -o $DIR/$tdir/$tfile-%d 10 
+       local oid=`do_facet ost1 "lctl get_param -n obdfilter.*OST0000.last_id"`
+
+       fail_abort $SINGLEMDS
+       
+       touch $DIR/$tdir/$tfile
+       local id=`$LFS getstripe $DIR/$tdir/$tfile |awk '$2 ~ /^[1-9]+/ {print $2}'`
+       [ $id -le $oid ] && error "the orphan objid was reused, failed"
+
+       # Cleanup
+       rm -rf $DIR/$tdir
+}
+run_test 61 "Verify to not reuse orphan objects - bug 17025"
+
 equals_msg `basename $0`: test complete, cleaning up
 check_and_cleanup_lustre
 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true
index cf4d8c7..512bfe6 100755 (executable)
@@ -107,24 +107,68 @@ test_4() {
 }
 run_test 4 "Fail OST during read, with verification"
 
+iozone_bg () {
+    local args=$@
+
+    local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
+    mkfifo $tmppipe
+
+    echo "+ iozone $args"
+    iozone $args > $tmppipe &
+
+    local pid=$!
+
+    echo "tmppipe=$tmppipe"
+    echo iozone pid=$pid
+
+    # iozone exit code is 0 even if iozone is not completed
+    # need to check iozone output  on "complete"
+    local iozonelog=$TMP/${TESTSUITE}.iozone.log
+    rm -f $iozonelog
+    cat $tmppipe | while read line ; do 
+        echo "$line"
+        echo "$line" >>$iozonelog
+    done;
+
+    local rc=0
+    wait $pid
+    rc=$?
+    if ! $(tail -1 $iozonelog | grep -q complete); then
+        echo iozone failed!
+        rc=1
+    fi
+    rm -f $tmppipe
+    rm -f $iozonelog
+    return $rc 
+}
+
 test_5() {
     [ -z "`which iozone 2> /dev/null`" ] && skip "iozone missing" && return 0
-    FREE=`df -P $TDIR | tail -n 1 | awk '{ print $4/2 }'`
-    GB=1048576  # 1048576KB == 1GB
-    if (( FREE > GB )); then
-        FREE=$GB
+
+    # striping is -c 1, get min of available
+    local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
+    local size=$(( minavail * 3/4 ))
+    local GB=1048576  # 1048576KB == 1GB
+
+    if (( size > GB )); then
+        size=$GB
     fi
-    IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
-    iozone $IOZONE_OPTS -f $TDIR/$tfile &
-    PID=$!
+    local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
+
+    iozone_bg $iozone_opts &
+    local pid=$!
+
+    echo iozone bg pid=$pid
     
     sleep 8
     fail ost1
-    wait $PID
-    RC=$?
-    log "iozone rc=$RC"
+    local rc=0
+    wait $pid
+    rc=$?
+    log "iozone rc=$rc"
     rm -f $TDIR/$tfile
-    [ $RC -ne 0 ] && return $RC || true
+    [ $rc -eq 0 ] || error "iozone failed"
+    return $rc
 }
 run_test 5 "Fail OST during iozone"
 
index 71d83a3..1042a93 100755 (executable)
@@ -1812,18 +1812,15 @@ test_70a () {
 run_test 70a "check multi client t-f"
 
 test_70b () {
-       [ -z "$CLIENTS" ] && \
-               { skip "Need two or more clients." && return; }
-       [ $CLIENTCOUNT -lt 2 ] && \
-               { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
+       local clients=${CLIENTS:-$HOSTNAME}
 
-       zconf_mount_clients $CLIENTS $DIR
+       zconf_mount_clients $clients $DIR
        
        local duration=120
        [ "$SLOW" = "no" ] && duration=60
        local cmd="rundbench 1 -t $duration"
        local PID=""
-       do_nodes $CLIENTS "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
+       do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
                PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
                DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
                LCTL=$LCTL $cmd" &
index 5e56c85..0444562 100644 (file)
@@ -17,7 +17,6 @@ SRCDIR=`dirname $0`
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 
 ONLY=${ONLY:-"$*"}
-# enable test_23 after bug 16542 fixed.
 ALWAYS_EXCEPT="10 $SANITY_QUOTA_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
@@ -119,26 +118,26 @@ set_file_unitsz() {
 }
 
 lustre_fail() {
-       local fail_node=$1
+        local fail_node=$1
        local fail_loc=$2
        local fail_val=${3:-0}
 
-       if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
-           if [ $((fail_loc & 0x10000000)) -ne 0  -a $fail_val -gt 0 ] || \
-               [ $((fail_loc)) -eq 0 ]; then
-               do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val"
-           fi
-           do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc"
-       fi
-       if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
-           for num in `seq $OSTCOUNT`; do
-               if [ $((fail_loc & 0x10000000)) -ne 0 -a $fail_val -gt 0 ] || \
-                   [ $((fail_loc)) -eq 0 ]; then
-                   do_facet ost$num "lctl set_param fail_val=$fail_val"
-               fi
-               do_facet ost$num "lctl set_param fail_loc=$fail_loc"
-           done
-       fi
+       if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
+           if [ $((fail_loc & 0x10000000)) -ne 0  -a $fail_val -gt 0 ] || \
+               [ $((fail_loc)) -eq 0 ]; then
+               do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val"
+           fi
+           do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc"
+       fi
+       if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
+           for num in `seq $OSTCOUNT`; do
+               if [ $((fail_loc & 0x10000000)) -ne 0 -a $fail_val -gt 0 ] || \
+                   [ $((fail_loc)) -eq 0 ]; then
+                   do_facet ost$num "lctl set_param fail_val=$fail_val"
+               fi
+               do_facet ost$num "lctl set_param fail_loc=$fail_loc"
+           done
+       fi
 }
 
 RUNAS="runas -u $TSTID -g $TSTID"
@@ -177,6 +176,43 @@ resetquota() {
        $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT || error "resetquota failed"
 }
 
+quota_error() {
+        LOCAL_UG=$1
+        LOCAL_ID=$2
+
+        if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "u" ]; then
+                log "Files for user ($LOCAL_ID):"
+                ($LFS find -user $LOCAL_ID $DIR | xargs stat 2>/dev/null)
+        fi
+
+        if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "g" ]; then
+                log "Files for group ($LOCAL_ID):"
+                ($LFS find -group $LOCAL_ID $DIR | xargs stat 2>/dev/null)
+        fi
+
+        shift 2
+        error "$*"
+}
+
+quota_show_check() {
+        LOCAL_BF=$1
+        LOCAL_UG=$2
+        LOCAL_ID=$3
+       PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
+
+        $LFS quota -v -$LOCAL_UG $LOCAL_ID $DIR
+
+        if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then
+               USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`"
+                [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+        fi
+
+        if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then
+               USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`"
+                [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+        fi
+}
+
 # set quota
 test_0() {
        $LFS quotaoff -ug $DIR
@@ -195,70 +231,70 @@ run_test_with_stat 0 "Set quota ============================="
 
 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
 test_1_sub() {
-       LIMIT=$1
+        LIMIT=$1
        mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
-       TESTFILE="$DIR/$tdir/$tfile-0"
+        TESTFILE="$DIR/$tdir/$tfile-0"
 
        wait_delete_completed
 
-       # test for user
-       log "  User quota (limit: $LIMIT kbytes)"
-       $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+        # test for user
+        log "  User quota (limit: $LIMIT kbytes)"
+        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
        sleep 3
-       $SHOW_QUOTA_USER
+       quota_show_check b u $TSTUSR
 
-       $LFS setstripe $TESTFILE -c 1
-       chown $TSTUSR.$TSTUSR $TESTFILE
+        $LFS setstripe $TESTFILE -c 1
+        chown $TSTUSR.$TSTUSR $TESTFILE
 
-       log "    Write ..."
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(usr) write failure, but expect success"
-       log "    Done"
-       log "    Write out of block quota ..."
+        log "    Write ..."
+       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error u $TSTUSR "(usr) write failure, but expect success"
+        log "    Done"
+        log "    Write out of block quota ..."
        # this time maybe cache write,  ignore it's failure
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
+        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
        # flush cache, ensure noquota flag is setted on client
-       cancel_lru_locks osc
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(usr) write success, but expect EDQUOT"
+        cancel_lru_locks osc
+       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error u $TSTUSR "(usr) write success, but expect EDQUOT"
 
-       rm -f $TESTFILE
+        rm -f $TESTFILE
        sync; sleep 1; sync;
        OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
        OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
        echo $OST0_QUOTA_USED
        [ $OST0_QUOTA_USED -ne 0 ] && \
-           ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+           ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
        $SHOW_QUOTA_USER
         resetquota -u $TSTUSR
 
-       # test for group
+        # test for group
        log "--------------------------------------"
-       log "  Group quota (limit: $LIMIT kbytes)"
-       $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+        log "  Group quota (limit: $LIMIT kbytes)"
+        $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
        sleep 3
-       $SHOW_QUOTA_GROUP
-       TESTFILE="$DIR/$tdir/$tfile-1"
+        quota_show_check b g $TSTUSR
+        TESTFILE="$DIR/$tdir/$tfile-1"
 
-       $LFS setstripe $TESTFILE -c 1
-       chown $TSTUSR.$TSTUSR $TESTFILE
+        $LFS setstripe $TESTFILE -c 1
+        chown $TSTUSR.$TSTUSR $TESTFILE
 
-       log "    Write ..."
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(grp) write failure, but expect success"
-       log "    Done"
-       log "    Write out of block quota ..."
+        log "    Write ..."
+       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error g $TSTUSR "(grp) write failure, but expect success"
+        log "    Done"
+        log "    Write out of block quota ..."
        # this time maybe cache write, ignore it's failure
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
-       cancel_lru_locks osc
-       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(grp) write success, but expect EDQUOT"
+        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
+        cancel_lru_locks osc
+       $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error g $TSTUSR "(grp) write success, but expect EDQUOT"
 
        # cleanup
-       rm -f $TESTFILE
+        rm -f $TESTFILE
        sync; sleep 1; sync;
        OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
        OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
        echo $OST0_QUOTA_USED
        [ $OST0_QUOTA_USED -ne 0 ] && \
-           ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+           ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
        $SHOW_QUOTA_GROUP
         resetquota -g $TSTUSR
 }
@@ -278,32 +314,32 @@ test_1() {
            echo "=================================================="
            set_blk_unitsz $((128 * 1024))
            set_blk_tunesz $((128 * 1024 / 2))
-       done
+        done
 }
 run_test_with_stat 1 "Block hard limit (normal use and out of quota) ==="
 
 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
 test_2_sub() {
-       LIMIT=$1
+        LIMIT=$1
        mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
-       TESTFILE="$DIR/$tdir/$tfile-0"
+        TESTFILE="$DIR/$tdir/$tfile-0"
 
        wait_delete_completed
 
-       # test for user
-       log "  User quota (limit: $LIMIT files)"
-       $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
+        # test for user
+        log "  User quota (limit: $LIMIT files)"
+        $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
        sleep 3
-       $SHOW_QUOTA_USER
+        quota_show_check f u $TSTUSR
 
        log "    Create $LIMIT files ..."
        $RUNAS createmany -m ${TESTFILE} $LIMIT || \
-               error "(usr) create failure, but expect success"
+               quota_error u $TSTUSR "(usr) create failure, but expect success"
        log "    Done"
        log "    Create out of file quota ..."
        $RUNAS touch ${TESTFILE}_xxx && \
-               error "(usr) touch success, but expect EDQUOT"
+               quota_error u $TSTUSR "(usr) touch success, but expect EDQUOT"
 
        unlinkmany ${TESTFILE} $LIMIT
        rm -f ${TESTFILE}_xxx
@@ -313,25 +349,25 @@ test_2_sub() {
        MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
        echo $MDS_QUOTA_USED
        [ $MDS_QUOTA_USED -ne 0 ] && \
-           ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+           ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
        $SHOW_QUOTA_USER
        resetquota -u $TSTUSR
 
-       # test for group
+        # test for group
        log "--------------------------------------"
-       log "  Group quota (limit: $LIMIT FILE)"
-       $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
+        log "  Group quota (limit: $LIMIT FILE)"
+        $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
        sleep 3
-       $SHOW_QUOTA_GROUP
-       TESTFILE=$DIR/$tdir/$tfile-1
+        quota_show_check f g $TSTUSR
+        TESTFILE=$DIR/$tdir/$tfile-1
 
        log "    Create $LIMIT files ..."
        $RUNAS createmany -m ${TESTFILE} $LIMIT || \
-               error "(usr) create failure, but expect success"
+               quota_error g $TSTUSR "(grp) create failure, but expect success"
        log "    Done"
        log "    Create out of file quota ..."
        $RUNAS touch ${TESTFILE}_xxx && \
-               error "(usr) touch success, but expect EDQUOT"
+               quota_error g $TSTUSR "(grp) touch success, but expect EDQUOT"
 
        unlinkmany ${TESTFILE} $LIMIT
        rm -f ${TESTFILE}_xxx
@@ -341,7 +377,7 @@ test_2_sub() {
        MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
        echo $MDS_QUOTA_USED
        [ $MDS_QUOTA_USED -ne 0 ] && \
-           ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+           ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
        $SHOW_QUOTA_GROUP
         resetquota -g $TSTUSR
 }
@@ -357,18 +393,18 @@ test_2() {
                # define ino_qunit is between 10 and 100
                ino_qunit=$(( $RANDOM % 90 + 10 ))
                ino_qtune=$(( $RANDOM % $ino_qunit ))
-               # RANDOM's maxium is 32767
+                # RANDOM's maxium is 32767
                i_limit=$(( $RANDOM % 990 + 10 ))
            fi
 
-           set_file_tunesz $ino_qtune
+            set_file_tunesz $ino_qtune
            set_file_unitsz $ino_qunit
            echo "cycle: $i(total $cycle) iunit:$ino_qunit, itune:$ino_qtune, ilimit:$i_limit"
            test_2_sub $i_limit
            echo "=================================================="
            set_file_unitsz 5120
            set_file_tunesz 2560
-       done
+        done
 }
 run_test_with_stat 2 "File hard limit (normal use and out of quota) ==="
 
@@ -382,9 +418,9 @@ test_block_soft() {
        echo "    Write to exceed soft limit"
        RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
        $RUNDD count=$((BUNIT_SZ+1)) || \
-               error "write failure, but expect success"
+               quota_error a $TSTUSR "write failure, but expect success"
        OFFSET=$((OFFSET + BUNIT_SZ + 1))
-       cancel_lru_locks osc
+        cancel_lru_locks osc
 
        $SHOW_QUOTA_USER
        $SHOW_QUOTA_GROUP
@@ -392,41 +428,41 @@ test_block_soft() {
 
        echo "    Write before timer goes off"
        $RUNDD count=$BUNIT_SZ seek=$OFFSET || \
-               error "write failure, but expect success"
+               quota_error a $TSTUSR "write failure, but expect success"
        OFFSET=$((OFFSET + BUNIT_SZ))
-       cancel_lru_locks osc
+        cancel_lru_locks osc
        echo "    Done"
 
-       echo "    Sleep $TIMER seconds ..."
-       sleep $TIMER
+        echo "    Sleep $TIMER seconds ..."
+        sleep $TIMER
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-       $SHOW_QUOTA_INFO
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_INFO
 
        echo "    Write after timer goes off"
        # maybe cache write, ignore.
        $RUNDD count=$BUNIT_SZ seek=$OFFSET || true
        OFFSET=$((OFFSET + BUNIT_SZ))
-       cancel_lru_locks osc
+        cancel_lru_locks osc
        $RUNDD count=$BUNIT_SZ seek=$OFFSET && \
-               error "write success, but expect EDQUOT"
+               quota_error a $TSTUSR "write success, but expect EDQUOT"
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-       $SHOW_QUOTA_INFO
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_INFO
 
        echo "    Unlink file to stop timer"
        rm -f $TESTFILE
        sync; sleep 1; sync
        echo "    Done"
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-       $SHOW_QUOTA_INFO
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_INFO
 
        echo "    Write ..."
-       $RUNDD count=$BUNIT_SZ || error "write failure, but expect success"
+       $RUNDD count=$BUNIT_SZ || quota_error a $TSTUSR "write failure, but expect success"
        echo "    Done"
 
        # cleanup
@@ -439,7 +475,7 @@ test_3() {
        mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
 
-       # 1 bunit on mds and 1 bunit on every ost
+        # 1 bunit on mds and 1 bunit on every ost
        LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) ))
        GRACE=10
 
@@ -478,13 +514,13 @@ test_file_soft() {
 
        echo "    Create files to exceed soft limit"
        $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) || \
-               error "create failure, but expect success"
+               quota_error a $TSTUSR "create failure, but expect success"
        sync; sleep 1; sync
        echo "    Done"
 
        echo "    Create file before timer goes off"
        $RUNAS touch ${TESTFILE}_before || \
-               error "failed create before timer expired, but expect success"
+               quota_error a $TSTUSR "failed create before timer expired, but expect success"
        sync; sleep 1; sync
        echo "    Done"
 
@@ -497,11 +533,11 @@ test_file_soft() {
 
        echo "    Create file after timer goes off"
        # the least of inode qunit is 2, so there are at most 3(qunit:2+qtune:1)
-       # inode quota left here
+        # inode quota left here
        $RUNAS touch ${TESTFILE}_after ${TESTFILE}_after1 ${TESTFILE}_after2 || true
        sync; sleep 1; sync
        $RUNAS touch ${TESTFILE}_after3 && \
-               error "create after timer expired, but expect EDQUOT"
+               quota_error a $TSTUSR "create after timer expired, but expect EDQUOT"
        sync; sleep 1; sync
 
        $SHOW_QUOTA_USER
@@ -514,7 +550,7 @@ test_file_soft() {
 
        echo "    Create file"
        $RUNAS touch ${TESTFILE}_xxx || \
-               error "touch after timer stop failure, but expect success"
+               quota_error a $TSTUSR "touch after timer stop failure, but expect success"
        sync; sleep 1; sync
        echo "    Done"
 
@@ -535,7 +571,7 @@ test_4a() { # was test_4
        echo "  User quota (soft limit: $LIMIT files  grace: $GRACE seconds)"
        $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
        $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
-       $SHOW_QUOTA_USER
+        quota_show_check f u $TSTUSR
 
        test_file_soft $TESTFILE $LIMIT $GRACE
        resetquota -u $TSTUSR
@@ -543,7 +579,7 @@ test_4a() { # was test_4
        echo "  Group quota (soft limit: $LIMIT files  grace: $GRACE seconds)"
        $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
        $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
-       $SHOW_QUOTA_GROUP
+        quota_show_check f g $TSTUSR
        TESTFILE=$DIR/$tdir/$tfile-1
 
        test_file_soft $TESTFILE $LIMIT $GRACE
@@ -556,30 +592,30 @@ test_4a() {       # was test_4
 run_test_with_stat 4a "File soft limit (start timer, timer goes off, stop timer) ==="
 
 test_4b() {    # was test_4a
-       GR_STR1="1w3d"
-       GR_STR2="1000s"
-       GR_STR3="5s"
-       GR_STR4="1w2d3h4m5s"
-       GR_STR5="5c"
-       GR_STR6="1111111111111111"
+        GR_STR1="1w3d"
+        GR_STR2="1000s"
+        GR_STR3="5s"
+        GR_STR4="1w2d3h4m5s"
+        GR_STR5="5c"
+        GR_STR6="1111111111111111"
 
        wait_delete_completed
 
-       # test of valid grace strings handling
-       echo "  Valid grace strings test"
-       $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace $GR_STR2 $DIR
-       $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
-       $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace $GR_STR4 $DIR
-       $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
-
-       # test of invalid grace strings handling
-       echo "  Invalid grace strings test"
-       ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
-       ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
-
-       # cleanup
-       $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
-       $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
+        # test of valid grace strings handling
+        echo "  Valid grace strings test"
+        $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace $GR_STR2 $DIR
+        $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
+        $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace $GR_STR4 $DIR
+        $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
+
+        # test of invalid grace strings handling
+        echo "  Invalid grace strings test"
+        ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
+        ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
+
+        # cleanup
+        $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
+        $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
 }
 run_test_with_stat 4b "Grace time strings handling ==="
 
@@ -594,8 +630,8 @@ test_5() {
        echo "  Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR"
        $LFS setquota -u $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
        $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
 
        echo "  Create more than $ILIMIT files and more than $BLIMIT kbytes ..."
        createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \
@@ -605,7 +641,7 @@ test_5() {
        echo "  Chown files to $TSTUSR.$TSTUSR ..."
        for i in `seq 0 $ILIMIT`; do
        chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \
-                       error "chown failure, but expect success"
+                       quota_error a $TSTUSR "chown failure, but expect success"
        done
 
        # cleanup
@@ -636,8 +672,8 @@ test_6() {
        echo "  Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
        $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        quota_show_check b u $TSTUSR
+        quota_show_check b g $TSTUSR
 
        echo "  Create filea on OST0 and fileb on OST1"
        $LFS setstripe $FILEA -i 0 -c 1
@@ -646,33 +682,33 @@ test_6() {
        chown $TSTUSR.$TSTUSR $FILEB
 
        echo "  Exceed quota limit ..."
-       RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
-       $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
-               error "write fileb failure, but expect success"
-
-       cancel_lru_locks osc
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-       $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
-               error "write fileb success, but expect EDQUOT"
-       cancel_lru_locks osc
+        RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
+        $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
+               quota_error a $TSTUSR "write fileb failure, but expect success"
+
+        cancel_lru_locks osc
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
+        $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
+               quota_error a $TSTUSR "write fileb success, but expect EDQUOT"
+        cancel_lru_locks osc
        echo "  Write to OST0 return EDQUOT"
        # this write maybe cache write, ignore it's failure
-       RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
-       $RUNDD count=$(($BUNIT_SZ * 2)) || true
-       cancel_lru_locks osc
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-       $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
-               error "write filea success, but expect EDQUOT"
+        RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
+        $RUNDD count=$(($BUNIT_SZ * 2)) || true
+        cancel_lru_locks osc
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
+        $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
+               quota_error a $TSTUSR "write filea success, but expect EDQUOT"
 
        echo "  Remove fileb to let OST1 release quota"
        rm -f $FILEB
-       sync; sleep 10; sync; # need to allow journal commit for small fs
+        sync; sleep 10; sync; # need to allow journal commit for small fs
 
        echo "  Write to OST0"
        $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
-               error "write filea failure, expect success"
+               quota_error a $TSTUSR "write filea failure, expect success"
        echo "  Done"
 
        # cleanup
@@ -703,9 +739,9 @@ test_7()
 
        echo "  Write to OST0..."
        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \
-               error "write failure, but expect success"
+               quota_error u $TSTUSR "write failure, but expect success"
 
-       #define OBD_FAIL_OBD_DQACQ             0x604
+       #define OBD_FAIL_OBD_DQACQ               0x604
        lustre_fail mds  0x604
        echo "  Remove files on OST0"
        rm -f $TESTFILE
@@ -726,8 +762,8 @@ test_7()
        [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!"
        echo "  total limits = $TOTAL_LIMIT"
 
-       OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
-       [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
+        OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
+        [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
        OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`"
        [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!"
        echo "  limits on $OST0_UUID = $OST0_LIMIT"
@@ -753,7 +789,7 @@ test_8() {
        chmod 0777 $DIR/$tdir
        local duration=""
        [ "$SLOW" = "no" ] && duration=" -t 120"
-       $RUNAS bash rundbench -D $DIR/$tdir 3 $duration || error "dbench failed!"
+       $RUNAS bash rundbench -D $DIR/$tdir 3 $duration || quota_error a $TSTUSR "dbench failed!"
 
        sync; sleep 3; sync;
 
@@ -791,45 +827,45 @@ test_9() {
 
        mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
-       TESTFILE="$DIR/$tdir/$tfile-0"
+        TESTFILE="$DIR/$tdir/$tfile-0"
 
-       BLK_LIMIT=$((100 * KB * KB)) # 100G
-       FILE_LIMIT=1000000
-       echo "  Set block limit $BLK_LIMIT kbytes to $TSTUSR.$TSTUSR"
+        BLK_LIMIT=$((100 * KB * KB)) # 100G
+        FILE_LIMIT=1000000
+        echo "  Set block limit $BLK_LIMIT kbytes to $TSTUSR.$TSTUSR"
 
-       log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
-       $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
-       log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
-       $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
+        log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
+        $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
+        log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
+        $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
 
-       echo "  Set stripe"
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
+
+        echo "  Set stripe"
        $LFS setstripe $TESTFILE -c 1
-       touch $TESTFILE
-       chown $TSTUSR.$TSTUSR $TESTFILE
+        touch $TESTFILE
+        chown $TSTUSR.$TSTUSR $TESTFILE
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        log "    Write the big file of 4.5G ..."
+        $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
+              quota_error a $TSTUSR "(usr) write 4.5G file failure, but expect success"
 
-       log "    Write the big file of 4.5G ..."
-       $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
-              error "(usr) write 4.5G file failure, but expect success"
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-
-       log "    delete the big file of 4.5G..."
-       $RUNAS rm -f $TESTFILE
+        log "    delete the big file of 4.5G..."
+        $RUNAS rm -f $TESTFILE
        sync; sleep 3; sync;
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
-       RC=$?
+        RC=$?
 
        set_blk_unitsz $((128 * 1024))
        set_blk_tunesz $((128 * 1024 / 2))
 
-       return $RC
+        return $RC
 }
 run_test_with_stat 9 "run for fixing bug10707(64bit) ==========="
 
@@ -858,27 +894,27 @@ test_10() {
        log "  Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
        $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
 
+        quota_show_check a u $TSTUSR
+        quota_show_check a g $TSTUSR
+
        echo "  Set stripe"
        $LFS setstripe $TESTFILE -c 1
        touch $TESTFILE
        chown $TSTUSR.$TSTUSR $TESTFILE
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        log "    Write the big file of 4.5 G ..."
+        $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
+               quota_error a $TSTUSR "(usr) write 4.5 G file failure, but expect success"
 
-       log "    Write the big file of 4.5 G ..."
-       $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$blksize count=$((size_file / blksize)) || \
-               error "(usr) write 4.5 G file failure, but expect success"
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-
-       log "    delete the big file of 4.5 G..."
-       $RUNAS rm -f $TESTFILE
+        log "    delete the big file of 4.5 G..."
+        $RUNAS rm -f $TESTFILE
        sync; sleep 3; sync;
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
        RC=$?
 
@@ -921,12 +957,12 @@ test_11() {
           echo -n "    create a file for uid "
           for j in `seq 1 30`; do
               echo -n "$j "
-              # 30MB per dd for a total of 900MB (if space even permits)
+               # 30MB per dd for a total of 900MB (if space even permits)
               runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile  bs=$blksize count=15 > /dev/null 2>&1 &
           done
           echo ""
           PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
-          LAST_USED=0
+           LAST_USED=0
           while [ $PROCS -gt 0 ]; do 
             sleep 20
             SECS=$((SECS + sleep))
@@ -940,7 +976,7 @@ test_11() {
                 RV=2
                 break
             fi
-            LAST_USED=$USED
+             LAST_USED=$USED
           done
           echo "    removing the test files..."
           rm -f $TESTDIR/$tfile
@@ -955,7 +991,7 @@ test_11() {
        sysctl -w vm.dirty_ratio=$orig_dr
        sysctl -w vm.dirty_writeback_centisecs=$orig_dwc
        if [ $RV -ne 0 ]; then
-          error "Nothing was written for $SECS sec ... aborting"
+           error "Nothing was written for $SECS sec ... aborting"
        fi
        return $RV
 }
@@ -982,11 +1018,11 @@ test_12() {
        $LFS setstripe $TESTFILE -i 0 -c 1
        chown $TSTUSR.$TSTUSR $TESTFILE
        $LFS setstripe $TESTFILE2 -i 0 -c 1
-       chown $TSTUSR2.$TSTUSR2 $TESTFILE2
+        chown $TSTUSR2.$TSTUSR2 $TESTFILE2
 
        #define OBD_FAIL_OST_HOLD_WRITE_RPC      0x21f
-       #define OBD_FAIL_SOME        0x10000000 /* fail N times */
-       lustre_fail ost $((0x0000021f | 0x10000000)) 1
+       #define OBD_FAIL_SOME        0x10000000 /* fail N times */
+       lustre_fail ost $((0x0000021f | 0x10000000)) 1
 
        echo "   step1: write out of block quota ..."
        $RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 &
@@ -1001,7 +1037,7 @@ test_12() {
            count=$[count+1]
            if [ $count -gt 64 ]; then
                lustre_fail ost 0
-               error "dd should be finished!"
+               quota_error u $TSTUSR2 "dd should be finished!"
            fi
            sleep 1
        done
@@ -1016,14 +1052,14 @@ test_12() {
            if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
            count=$[count+1]
            if [ $count -gt 150 ]; then
-               error "dd should be finished!"
+               quota_error u $TSTUSR "dd should be finished!"
            fi
            sleep 1
        done
        echo "(dd_pid=$DDPID, time=$count)successful"
 
        rm -f $TESTFILE $TESTFILE2
-       sync; sleep 3; sync;
+        sync; sleep 3; sync;
 
         resetquota -u $TSTUSR
 }
@@ -1040,12 +1076,12 @@ test_13() {
 
        echo "   User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
        $LFS setstripe $TESTFILE -i 0 -c 1
        chown $TSTUSR.$TSTUSR $TESTFILE
        $LFS setstripe $TESTFILE.2 -i 0 -c 1
-       chown $TSTUSR.$TSTUSR $TESTFILE.2
+        chown $TSTUSR.$TSTUSR $TESTFILE.2
 
        echo "   step1: write out of block quota ..."
        # one bunit will give mds
@@ -1060,7 +1096,7 @@ test_13() {
            if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
            count=$[count+1]
            if [ $count -gt 64 ]; then
-               error "dd should be finished!"
+               quota_error u $TSTUSR "dd should be finished!"
            fi
            sleep 1
        done
@@ -1071,7 +1107,7 @@ test_13() {
            if ! ps -p ${DDPID1} > /dev/null 2>&1 ; then break; fi
            count=$[count+1]
            if [ $count -gt 64 ]; then
-               error "dd should be finished!"
+               quota_error u $TSTUSR "dd should be finished!"
            fi
            sleep 1
        done
@@ -1084,7 +1120,7 @@ test_13() {
        fz2=`stat -c %s $TESTFILE.2`
        $SHOW_QUOTA_USER
        [ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
-               error "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
+                quota_error u $TSTUSR "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
 
        rm -f $TESTFILE $TESTFILE.2
        sync; sleep 3; sync;
@@ -1094,7 +1130,7 @@ test_13() {
 run_test_with_stat 13 "test multiple clients write block quota ==="
 
 check_if_quota_zero(){
-       line=`$LFS quota -v -$1 $2 $DIR | wc -l`
+        line=`$LFS quota -v -$1 $2 $DIR | wc -l`
        for i in `seq 3 $line`; do
            if [ $i -eq 3 ]; then
                field="3 4 6 7"
@@ -1103,7 +1139,7 @@ check_if_quota_zero(){
            fi
            for j in $field; do
                tmp=`$LFS quota -v -$1 $2 $DIR | sed -n ${i}p |
-                    awk  '{print $'"$j"'}'`
+                     awk  '{print $'"$j"'}'`
                [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -v -$1 $2 $DIR && \
                    error "quota on $2 isn't clean"
            done
@@ -1114,22 +1150,22 @@ check_if_quota_zero(){
 test_14a() {   # was test_14 b=12223 -- setting quota on root
        TESTFILE="$DIR/$tdir/$tfile"
 
-       # reboot the lustre
-       sync; sleep 5; sync
-       cleanup_and_setup_lustre
-       test_0
+        # reboot the lustre
+        sync; sleep 5; sync
+        cleanup_and_setup_lustre
+        test_0
 
        mkdir -p $DIR/$tdir
 
        # out of root's file and block quota
        $LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR
        createmany -m ${TESTFILE} 20 || \
-           error "unexpected: user(root) create files failly!"
+           quota_error u root "unexpected: user(root) create files failly!"
        dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
-           error "unexpected: user(root) write files failly!"
+           quota_error u root "unexpected: user(root) write files failly!"
        chmod 666 $TESTFILE
        $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
-           error "unexpected: user(quota_usr) write a file successfully!"
+           quota_error u root "unexpected: user(quota_usr) write a file successfully!"
 
        # trigger the llog
        chmod 777 $DIR
@@ -1150,42 +1186,42 @@ run_test_with_stat 14a "test setting quota on root ==="
 
 # save quota version (both administrative and operational quotas)
 quota_save_version() {
-       do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1"
-       do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$1"
-       sleep 5
+        do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1"
+        do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$1"
+        sleep 5
 }
 
 test_15(){
-       LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
-       PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
+        LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
+        PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
 
        wait_delete_completed
 
-       # test for user
-       $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-       TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
-       [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
-       echo "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
+        # test for user
+        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+        TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
+        [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
+        echo "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
         resetquota -u $TSTUSR
 
-       # test for group
-       $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-       TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
-       [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
-       echo "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
+        # test for group
+        $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
+        TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
+        [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
+        echo "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
         resetquota -g $TSTUSR
-       $LFS quotaoff -ug $DIR
-       do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
+        $LFS quotaoff -ug $DIR
+        do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
                 error "fail to set version for $SINGLEMDS"
-       for j in `seq $OSTCOUNT`; do
-               do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=ug" | grep "error writing" && \
+        for j in `seq $OSTCOUNT`; do
+                do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=ug" | grep "error writing" && \
                         error "fail to set version for ost$j"
-       done
+        done
 
-       echo "invalidating quota files"
-       $LFS quotainv -ug $DIR
-       $LFS quotainv -ugf $DIR
-       $LFS quotacheck -ug $DIR
+        echo "invalidating quota files"
+        $LFS quotainv -ug $DIR
+        $LFS quotainv -ugf $DIR
+        $LFS quotacheck -ug $DIR
 }
 run_test_with_stat 15 "set block quota more than 4T ==="
 
@@ -1200,10 +1236,10 @@ test_16_tub() {
        echo "  User quota (limit: $LIMIT kbytes)"
        if [ $1 == "u" ]; then
            $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-           $SHOW_QUOTA_USER
+            quota_show_check b u $TSTUSR
        else
            $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
-           $SHOW_QUOTA_GROUP
+            quota_show_check b g $TSTUSR
        fi
 
        $LFS setstripe $TESTFILE -c 1
@@ -1211,19 +1247,19 @@ test_16_tub() {
 
        echo "    Write ..."
        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
-           error "(usr) write failure, but expect success"
+           quota_error a $TSTUSR "(usr) write failure, but expect success"
        echo "    Done"
        echo "    Write out of block quota ..."
        # this time maybe cache write,  ignore it's failure
        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true
        # flush cache, ensure noquota flag is setted on client
-       cancel_lru_locks osc
+        cancel_lru_locks osc
        if [ $2 -eq 1 ]; then
            $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
-               error "(write failure, but expect success"
+               quota_error a $TSTUSR "(write failure, but expect success"
        else
            $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
-               error "(write success, but expect EDQUOT"
+               quota_error a $TSTUSR "(write success, but expect EDQUOT"
        fi
 
        rm -f $TESTFILE
@@ -1238,7 +1274,7 @@ test_16 () {
        set_blk_unitsz $((BUNIT_SZ * 4))
        for i in u g; do
            for j in 0 1; do
-               # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS    0xA01
+                # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS    0xA01
                echo " grp/usr: $i, adjust qunit: $j"
                echo "-------------------------------"
                [ $j -eq 1 ] && lustre_fail mds_ost 0
@@ -1258,7 +1294,7 @@ test_17() {
 
        wait_delete_completed
 
-       #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
+        #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
        lustre_fail ost 0x80000A02
 
        TESTFILE="$DIR/$tdir/$tfile-a"
@@ -1272,27 +1308,27 @@ test_17() {
        log "  Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
        $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
 
+        quota_show_check b u $TSTUSR
+        quota_show_check b g $TSTUSR
+
        touch $TESTFILE
        chown $TSTUSR.$TSTUSR $TESTFILE
        touch $TESTFILE2
        chown $TSTUSR.$TSTUSR $TESTFILE2
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
-
        log "    Write the test file1 ..."
        $RUNAS dd if=/dev/zero of=$TESTFILE  bs=$BLK_SZ count=$(( 10 * 1024 )) \
-           || echo "write 10M file failure"
+           || quota_error a $TSTUSR "write 10M file failure"
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
        log "    write the test file2 ..."
        $RUNAS dd if=/dev/zero of=$TESTFILE2  bs=$BLK_SZ count=$(( 10 * 1024 )) \
-           || error "write 10M file failure"
+           || quota_error a $TSTUSR "write 10M file failure"
 
-       $SHOW_QUOTA_USER
-       $SHOW_QUOTA_GROUP
+        $SHOW_QUOTA_USER
+        $SHOW_QUOTA_GROUP
 
        rm -f $TESTFILE $TESTFILE2
        RC=$?
@@ -1325,7 +1361,7 @@ test_18() {
 
        log "   User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
        $LFS setstripe $TESTFILE -i 0 -c 1
        chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1337,8 +1373,8 @@ test_18() {
        $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
        DDPID=$!
 
-       sleep 5
-       lustre_fail mds 0
+        sleep 5
+        lustre_fail mds 0
 
        echo  "   step2: testing ......"
        count=0
@@ -1351,15 +1387,15 @@ test_18() {
            if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
            count=$[count+1]
            if [ $count -gt $((4 * $timeout)) ]; then
-               error "count=$count dd should be finished!"
+               quota_error u $TSTUSR "count=$count dd should be finished!"
            fi
            sleep 1
        done
-       log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
+        log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
 
-       testfile_size=$(stat -c %s $TESTFILE)
-       [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
-           error "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
+        testfile_size=$(stat -c %s $TESTFILE)
+        [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
+           quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
        rm -f $TESTFILE
        sync; sleep 3; sync;
 
@@ -1372,7 +1408,7 @@ run_test_with_stat 18 "run for fixing bug14840 ==========="
 
 # test when mds drops a quota req, the ost still could work well b=14840
 test_18a() {
-       LIMIT=$((100 * 1024 * 1024)) # 100G
+        LIMIT=$((100 * 1024 * 1024)) # 100G
        TESTFILE="$DIR/$tdir/$tfile-a"
        mkdir -p $DIR/$tdir
 
@@ -1383,7 +1419,7 @@ test_18a() {
 
        log "   User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
        $LFS setstripe $TESTFILE -i 0 -c 1
        chown $TSTUSR.$TSTUSR $TESTFILE
@@ -1407,13 +1443,13 @@ test_18a() {
            count=$[count+1]
            if [ $count -gt $((6 * $timeout)) ]; then
                lustre_fail mds 0
-               error "count=$count dd should be finished!"
+               quota_error u $TSTUSR "count=$count dd should be finished!"
            fi
            sleep 1
        done
-       log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
+        log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
 
-       lustre_fail mds 0
+        lustre_fail mds 0
 
        rm -f $TESTFILE
        sync; sleep 3; sync;
@@ -1428,25 +1464,25 @@ run_test_with_stat 18a "run for fixing bug14840 ==========="
 # test when mds do failover, the ost still could work well without trigger
 # watchdog b=14840
 test_18bc_sub() {
-       type=$1
+        type=$1
 
-       LIMIT=$((110 * 1024 )) # 110M
-       TESTFILE="$DIR/$tdir/$tfile"
-       mkdir -p $DIR/$tdir
+        LIMIT=$((110 * 1024 )) # 110M
+        TESTFILE="$DIR/$tdir/$tfile"
+        mkdir -p $DIR/$tdir
 
-       wait_delete_completed
+        wait_delete_completed
 
-       set_blk_tunesz 512
-       set_blk_unitsz 1024
+        set_blk_tunesz 512
+        set_blk_unitsz 1024
 
-       log "   User quota (limit: $LIMIT kbytes)"
-       $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-       $SHOW_QUOTA_USER
+        log "   User quota (limit: $LIMIT kbytes)"
+        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
+        quota_show_check b u $TSTUSR
 
-       $LFS setstripe $TESTFILE -i 0 -c 1
-       chown $TSTUSR.$TSTUSR $TESTFILE
+        $LFS setstripe $TESTFILE -i 0 -c 1
+        chown $TSTUSR.$TSTUSR $TESTFILE
 
-       timeout=$(sysctl -n lustre.timeout)
+        timeout=$(sysctl -n lustre.timeout)
 
        if [ $type = "directio" ]; then
            log "   write 100M block(directio) ..."
@@ -1456,43 +1492,43 @@ test_18bc_sub() {
            $RUNAS dd if=/dev/zero of=$TESTFILE bs=$((BLK_SZ * 1024)) count=100 &
        fi
 
-       DDPID=$!
-       do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
+        DDPID=$!
+        do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
 
        log "failing mds for $((2 * timeout)) seconds"
-       fail $SINGLEMDS $((2 * timeout))
-
-       # check if quotaon successful
-       $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
-       if [ $? -eq 0 ]; then
-           error "quotaon failed!"
-           rm -rf $TESTFILE
-           return
-       fi
+        fail $SINGLEMDS $((2 * timeout))
+
+        # check if quotaon successful
+        $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
+        if [ $? -eq 0 ]; then
+            error "quotaon failed!"
+            rm -rf $TESTFILE
+            return
+        fi
 
-       count=0
-       if at_is_valid && at_is_enabled; then
+        count=0
+        if at_is_valid && at_is_enabled; then
            timeout=$(at_max_get mds)
-       else
+        else
            timeout=$(lctl get_param -n timeout)
-       fi
-       while [ true ]; do
+        fi
+        while [ true ]; do
            if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
-           if [ $((++count % (2 * timeout) )) -eq 0 ]; then
-               log "it took $count second"
-           fi
-           sleep 1
-       done
-       log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
-       sync; sleep 1; sync
-
-       testfile_size=$(stat -c %s $TESTFILE)
-       [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
-           error "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
-       $SHOW_QUOTA_USER
+            if [ $((++count % (2 * timeout) )) -eq 0 ]; then
+                log "it took $count second"
+            fi
+            sleep 1
+        done
+        log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
+        sync; sleep 1; sync
+
+        testfile_size=$(stat -c %s $TESTFILE)
+        [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
+           quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
+        $SHOW_QUOTA_USER
         resetquota -u $TSTUSR
-       rm -rf $TESTFILE
-       sync; sleep 1; sync
+        rm -rf $TESTFILE
+        sync; sleep 1; sync
 }
 
 # test when mds does failover, the ost still could work well
@@ -1501,13 +1537,13 @@ test_18b() {
        test_18bc_sub normal
        test_18bc_sub directio
        # check if watchdog is triggered
-       do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
-       watchdog=`awk '/test 18b/ {start = 1;}
-                      /Watchdog triggered/ {
-                              if (start) {
-                                      print;
-                              }
-                      }' $TMP/lustre-log-${TESTNAME}.log`
+       do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
+       watchdog=`awk '/test 18b/ {start = 1;}
+                      /Watchdog triggered/ {
+                              if (start) {
+                                      print;
+                              }
+                      }' $TMP/lustre-log-${TESTNAME}.log`
        [ `echo "$watchdog" | wc -l` -ge 3 ] && error "$watchdog"
        rm -f $TMP/lustre-log-${TESTNAME}.log
 }
@@ -1539,18 +1575,18 @@ run_to_block_limit() {
 
        echo "  User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
        echo "  Updating quota limits"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
        RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
-       $RUNDD count=$BUNIT_SZ || error "(usr) write failure, but expect success"
+       $RUNDD count=$BUNIT_SZ || quota_error u $TSTUSR "(usr) write failure, but expect success"
        # for now page cache of TESTFILE may still be dirty,
        # let's push it to the corresponding OST, this will also
        # cache NOQUOTA on the client from OST's reply
        cancel_lru_locks osc
-       $RUNDD seek=$BUNIT_SZ && error "(usr) write success, should be EDQUOT"
+       $RUNDD seek=$BUNIT_SZ && quota_error u $TSTUSR "(usr) write success, should be EDQUOT"
 }
 
 test_19() {
@@ -1573,20 +1609,20 @@ run_test_with_stat 19 "test if administrative limits updates do not zero operati
 
 test_20()
 {
-       LSTR=(1t 2g 3m 4k) # limits strings
-       LVAL=($[1*1024*1024*1024] $[2*1024*1024] $[3*1024*1024] $[4*1024]) # limits values
+        LSTR=(1t 2g 3m 4k) # limits strings
+        LVAL=($[1*1024*1024*1024] $[2*1024*1024] $[3*1024*1024] $[4*1024]) # limits values
 
-       $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
-                                $MOUNT || error "could not set quota limits"
+        $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
+                                 $MOUNT || error "could not set quota limits"
 
-       $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
-                                --inode-softlimit ${LSTR[2]} \
-                                --inode-hardlimit ${LSTR[3]} \
-                                $MOUNT || error "could not set quota limits"
+        $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
+                                 --inode-softlimit ${LSTR[2]} \
+                                 --inode-hardlimit ${LSTR[3]} \
+                                 $MOUNT || error "could not set quota limits"
 
-       ($LFS quota -v -u $TSTUSR $MOUNT  | \
-           grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
-                || error "lfs quota output is unexpected"
+        ($LFS quota -v -u $TSTUSR $MOUNT  | \
+            grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
+                 || error "lfs quota output is unexpected"
 
         resetquota -u $TSTUSR
 }
@@ -1644,7 +1680,7 @@ test_21() {
            if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
            count=$[count+1]
            if [ $count -gt 60 ]; then
-               error "dd should be finished!"
+               quota_error a $TSTUSR "dd should be finished!"
            fi
            sleep 1
        done
@@ -1655,7 +1691,7 @@ test_21() {
            if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
            count=$[count+1]
            if [ $count -gt 60 ]; then
-               error "dd should be finished!"
+               quota_error a $TSTUSR "dd should be finished!"
            fi
            sleep 1
        done
@@ -1671,25 +1707,25 @@ test_21() {
 run_test_with_stat 21 "run for fixing bug16053 ==========="
 
 test_22() {
-       local SAVEREFORMAT
+        local SAVEREFORMAT
 
-       SAVEREFORMAT=$REFORMAT
-       $LFS quotaoff -ug $DIR || error "could not turn quotas off"
+        SAVEREFORMAT=$REFORMAT
+        $LFS quotaoff -ug $DIR || error "could not turn quotas off"
 
-       quota_save_version "ug"
+        quota_save_version "ug"
 
-       REFORMAT="reformat"
-       stopall
-       mount
-       setupall
-       REFORMAT=$SAVEREFORMAT
+        REFORMAT="reformat"
+        stopall
+        mount
+        setupall
+        REFORMAT=$SAVEREFORMAT
 
-       echo "checking parameters"
+        echo "checking parameters"
 
-       do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure"
-       do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure"
+        do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure"
+        do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure"
 
-       run_test 0 "reboot lustre"
+        run_test 0 "reboot lustre"
 }
 run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
 
@@ -1707,20 +1743,20 @@ test_23_sub() {
        log "  User quota (limit: $LIMIT kbytes)"
        $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
        sleep 3
-       $SHOW_QUOTA_USER
+        quota_show_check b u $TSTUSR
 
        $LFS setstripe $TESTFILE -c 1
        chown $TSTUSR.$TSTUSR $TESTFILE
 
        log "    Step1: trigger quota with 0_DIRECT"
        log "      Write half of file"
-       $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || error "(1) write failure, but expect success: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT"
        log "      Write out of block quota ..."
-       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && error "(2) write success, but expect EDQUOT: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT"
        log "    Step1: done"
 
        log "    Step2: rewrite should succeed"
-       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || error "(3) write failure, but expect success: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT"
        log "    Step2: done"
 
        rm -f $TESTFILE
@@ -1729,7 +1765,7 @@ test_23_sub() {
        OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
        echo $OST0_QUOTA_USED
        [ $OST0_QUOTA_USED -ne 0 ] && \
-           ($SHOW_QUOTA_USER; error "quota deleted isn't released")
+           ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released")
        $SHOW_QUOTA_USER
        resetquota -u $TSTUSR
 }
@@ -1758,7 +1794,7 @@ test_24() {
 
        set_blk_unitsz $((128 * 1024))
        set_blk_tunesz $((128 * 1024 / 2))
-       
+        
 }
 run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
 
@@ -1791,13 +1827,21 @@ test_25_sub() {
         log "setquota for $TSTUSR"
        $LFS setquota $1 $TSTUSR -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
        sleep 3
-        show_quota $1 $TSTUSR
+        if [ "$1" == "-u" ]; then
+                quota_show_check a u $TSTUSR
+        else
+                quota_show_check a g $TSTUSR
+        fi
 
         # set quota for $TSTUSR2
         log "setquota for $TSTUSR2"
        $LFS setquota $1 $TSTUSR2 -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
        sleep 3
-        show_quota $1 $TSTUSR2
+        if [ "$1" == "-u" ]; then
+                quota_show_check a u $TSTUSR2
+        else
+                quota_show_check a g $TSTUSR2
+        fi
 
         # set stripe index to 0
         log "setstripe for $DIR/$tdir to 0"
@@ -1811,42 +1855,42 @@ test_25_sub() {
 
         # TSTUSR write 4M
         log "$TSTUSR write 4M to $TESTFILE"
-        $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || error "dd failed"
+        $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || quota_error a $TSTUSR "dd failed"
         sync
        show_quota $1 $TSTUSR
        show_quota $1 $TSTUSR2
        MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
         [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \
-                error "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
+                quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
        OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
         OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD))
         [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \
-                error "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
+                quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
 
         # chown/chgrp from $TSTUSR to $TSTUSR2
         if [ $1 = "-u" ]; then
                 log "chown from $TSTUSR to $TSTUSR2"
-                chown $TSTUSR2 $TESTFILE || error "chown failed"
+                chown $TSTUSR2 $TESTFILE || quota_error u $TSTUSR2 "chown failed"
         else
                 log "chgrp from $TSTUSR to $TSTUSR2"
-                chgrp $TSTUSR2 $TESTFILE || error "chgrp failed"
+                chgrp $TSTUSR2 $TESTFILE || quota_error g $TSTUSR2 "chgrp failed"
         fi
         sync
        show_quota $1 $TSTUSR
        show_quota $1 $TSTUSR2
        MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
         [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \
-                error "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
+                quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
        OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
         OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD))
         [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \
-                error "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
+                quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
        MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
         [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \
-                error "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
+                quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
        OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
         [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \
-                error "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
+                quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
 
        rm -f $TESTFILE
        wait_delete_completed
index 568620d..b7f4eaf 100644 (file)
@@ -2649,11 +2649,11 @@ test_56o() {
        setup_56 $NUMFILES $NUMDIRS
        TDIR=$DIR/${tdir}g
 
-       utime $TDIR/file1 > /dev/null || error
-       utime $TDIR/file2 > /dev/null || error
-       utime $TDIR/dir1 > /dev/null || error
-       utime $TDIR/dir2 > /dev/null || error
-       utime $TDIR/dir1/file1 > /dev/null || error
+       utime $TDIR/file1 > /dev/null || error "utime (1)"
+       utime $TDIR/file2 > /dev/null || error "utime (2)"
+       utime $TDIR/dir1 > /dev/null || error "utime (3)"
+       utime $TDIR/dir2 > /dev/null || error "utime (4)"
+       utime $TDIR/dir1/file1 > /dev/null || error "utime (5)"
 
        EXPECTED=5
        NUMS=`$LFIND -mtime +1 $TDIR | wc -l`
index 8bc5259..7923670 100644 (file)
@@ -66,9 +66,6 @@ int main(int argc, char *argv[])
        int rc;
         int c;
 
-       utb.actime = 200000;
-       utb.modtime = 100000;
-
         while ((c = getopt(argc, argv, "s:")) != -1) {
                 switch(c) {
                 case 's':
@@ -104,9 +101,9 @@ int main(int argc, char *argv[])
                }
 
                if (st.st_mtime < before_mknod || st.st_mtime > after_mknod) {
-                       fprintf(stderr,
-                               "%s: bad mknod times %lu <= %lu <= %lu false\n",
-                               prog, before_mknod, st.st_mtime, after_mknod);
+                       fprintf(stderr, "%s: bad mknod(%s) times %lu <= %lu <= "
+                                "%lu false\n", prog, filename, before_mknod,
+                                st.st_mtime, after_mknod);
                        return 4;
                }
 
@@ -126,9 +123,10 @@ int main(int argc, char *argv[])
 
                         if (st2.st_mtime < before_mknod || 
                             st2.st_mtime > after_mknod) {
-                                fprintf(stderr, "%s: bad mknod times %lu <= %lu"
-                                        " <= %lu false\n", prog, before_mknod,
-                                        st2.st_mtime, after_mknod);
+                                fprintf(stderr, "%s: bad mknod(%s) times %lu "
+                                        " <= %lu <= %lu false\n", prog,
+                                        filename, before_mknod, st2.st_mtime,
+                                        after_mknod);
                                 return 6;
                         }
 
@@ -139,7 +137,8 @@ int main(int argc, char *argv[])
                 }
        }
 
-       /* See above */
+       utb.actime = 200000;
+       utb.modtime = 100000;
        rc = utime(filename, &utb);
        if (rc) {
                fprintf(stderr, "%s: utime(%s) failed: rc %d: %s\n",
@@ -155,14 +154,14 @@ int main(int argc, char *argv[])
        }
 
        if (st.st_mtime != utb.modtime ) {
-               fprintf(stderr, "%s: bad utime mtime %lu should be  %lu\n",
-                       prog, st.st_mtime, utb.modtime);
+               fprintf(stderr, "%s: bad utime mtime(%s) %lu should be %lu\n",
+                       prog, filename, st.st_mtime, utb.modtime);
                return 9;
        }
 
        if (st.st_atime != utb.actime ) {
-               fprintf(stderr, "%s: bad utime atime %lu should be  %lu\n",
-                       prog, st.st_atime, utb.actime);
+               fprintf(stderr, "%s: bad utime atime(%s) %lu should be %lu\n",
+                       prog, filename, st.st_atime, utb.actime);
                return 10;
        }
 
@@ -181,14 +180,16 @@ int main(int argc, char *argv[])
        }
 
        if (st2.st_mtime != st.st_mtime) {
-               fprintf(stderr, "%s: not synced mtime between clients: %lu "
-                        "should be  %lu\n", prog, st2.st_mtime, st.st_mtime);
+               fprintf(stderr, "%s: not synced mtime(%s) between clients: "
+                        "%lu should be %lu\n", prog, secname,
+                        st2.st_mtime, st.st_mtime);
                return 13;
        }
 
        if (st2.st_ctime != st.st_ctime) {
-               fprintf(stderr, "%s: not synced ctime between clients: %lu "
-                        " should be  %lu\n", prog, st2.st_ctime, st.st_ctime);
+               fprintf(stderr, "%s: not synced ctime(%s) between clients: "
+                        "%lu should be %lu\n", prog, secname,
+                        st2.st_ctime, st.st_ctime);
                return 14;
        }
        
index 956af80..490c6a9 100644 (file)
@@ -217,6 +217,7 @@ static void check_obd_connect_data(void)
         CHECK_CDEFINE(OBD_CONNECT_AT);
         CHECK_CDEFINE(OBD_CONNECT_CANCELSET);
         CHECK_CDEFINE(OBD_CONNECT_LRU_RESIZE);
+        CHECK_CDEFINE(OBD_CONNECT_SKIP_ORPHAN);
 }
 
 static void