- returned back sanity-cmobd.sh, whcih was lost after last merge.
- added sanity-fid.sh, which checks fid management correctness.
struct semaphore mds_orphan_recovery_sem;
int mds_num;
- struct lprocfs_stats *mds_counters;
int mds_config_version;
char *mds_lmv_name;
RETURN(rc);
}
-static inline int obd_prep_async_page(struct obd_export *exp,
- struct lov_stripe_md *lsm,
- struct lov_oinfo *loi,
- struct page *page, obd_off offset,
- struct obd_async_page_ops *ops,
- void *data, void **res)
+static inline int obd_prep_async_page(struct obd_export *exp,
+ struct lov_stripe_md *lsm,
+ struct lov_oinfo *loi,
+ struct page *page, obd_off offset,
+ struct obd_async_page_ops *ops,
+ void *data, void **res)
{
int ret;
ENTRY;
ENTRY;
LASSERT(!strcmp(obd->obd_type->typ_name, LUSTRE_MDS_NAME));
- MDS_UPDATE_COUNTER((&obd->u.mds), MDS_GETATTR_LOCK_COUNT);
+ MD_COUNTER_INCREMENT(obd, getattr_lock);
rsd = lustre_swab_mds_secdesc(req, MDS_REQ_SECDESC_OFF);
if (!rsd) {
static int mds_getattr(struct ptlrpc_request *req, int offset)
{
struct obd_device *obd = req->rq_export->exp_obd;
- struct mds_obd *mds = &obd->u.mds;
struct lvfs_run_ctxt saved;
struct dentry *de;
struct mds_req_sec_desc *rsd;
RETURN (-EFAULT);
}
- MDS_UPDATE_COUNTER(mds, MDS_GETATTR_COUNT);
+ MD_COUNTER_INCREMENT(obd, getattr);
rc = mds_init_ucred(&uc, rsd);
if (rc) {
GOTO(out, rc);
}
- MDS_UPDATE_COUNTER((&obd->u.mds), MDS_STATFS_COUNT);
+ OBD_COUNTER_INCREMENT(obd, statfs);
/* We call this so that we can cache a bit - 1 jiffie worth */
rc = mds_obd_statfs(obd, lustre_msg_buf(req->rq_repmsg, 0, size),
}
static char str[PTL_NALFMT_SIZE];
+
int mds_handle(struct ptlrpc_request *req)
{
int should_process, fail = OBD_FAIL_MDS_ALL_REPLY_NET;
"mds_ldlm_client", &obd->obd_ldlm_client);
obd->obd_replayable = 1;
- mds->mds_counters = lprocfs_alloc_mds_counters();
-
rc = mds_postsetup(obd);
if (rc)
GOTO(err_fs, rc);
ldlm_namespace_free(obd->obd_namespace, flags & OBD_OPT_FORCE);
- if (mds->mds_counters) {
- lprocfs_free_mds_counters(mds->mds_counters);
- }
-
spin_lock_bh(&obd->obd_processing_task_lock);
if (obd->obd_recovering) {
target_cancel_recovery_timer(obd);
ENTRY;
LASSERT(req != NULL);
+ MD_COUNTER_INCREMENT(req->rq_export->exp_obd, intent_lock);
if (req->rq_reqmsg->bufcount <= MDS_REQ_INTENT_IT_OFF) {
/* No intent was provided */
#include "mds_internal.h"
#ifndef LPROCFS
+
struct lprocfs_vars lprocfs_mds_obd_vars[] = { {0} };
struct lprocfs_vars lprocfs_mds_module_vars[] = { {0} };
struct lprocfs_vars lprocfs_mdt_obd_vars[] = { {0} };
struct lprocfs_vars lprocfs_mdt_module_vars[] = { {0} };
-atomic_t * lprocfs_alloc_mds_counters()
-{
- return NULL;
-}
-void lprocfs_free_mds_counters(atomic_t *ptr)
-{
- return;
-}
-
#else
-struct ll_mdscounters_opcode {
- __u32 opcode;
- const char *opname;
-} ll_mdscounters_opcode_table[MDS_LAST_OPC_COUNT] = {
- { MDS_OPEN_COUNT, "mds_open" },
- { MDS_CREATE_COUNT, "mds_create" },
- { MDS_CLOSE_COUNT, "mds_close" },
- { MDS_LINK_COUNT, "mds_link" },
- { MDS_UNLINK_COUNT, "mds_unlink" },
- { MDS_GETATTR_COUNT, "mds_getattr" },
- { MDS_GETATTR_LOCK_COUNT, "mds_getattr_lock" },
- { MDS_SETATTR_COUNT, "mds_setattr" },
- { MDS_RENAME_COUNT, "mds_rename" },
- { MDS_STATFS_COUNT, "mds_statfs" },
-};
-
-const char* ll_mds_count_opcode2str(__u32 opcode)
-{
- __u32 offset = opcode;
-
- LASSERT(offset < MDS_LAST_OPC_COUNT);
- LASSERT(ll_mdscounters_opcode_table[offset].opcode == opcode);
- return ll_mdscounters_opcode_table[offset].opname;
-}
-
-struct lprocfs_stats * lprocfs_alloc_mds_counters()
-{
- struct lprocfs_stats *counters;
- int i;
-
- counters = lprocfs_alloc_stats(MDS_LAST_OPC_COUNT);
-
- for (i = 0; i < MDS_LAST_OPC_COUNT; i ++) {
- lprocfs_counter_init(counters, i, 0,
- (char *)ll_mds_count_opcode2str(i), "reqs");
- }
- return counters;
-}
-
-void lprocfs_free_mds_counters(struct lprocfs_stats *ptr)
-{
- lprocfs_free_stats(ptr);
-}
-
-static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count,
- int *eof, void *data)
+static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
struct obd_device* obd = (struct obd_device *)data;
LASSERT(obd->u.mds.mds_vfsmnt->mnt_devname);
*eof = 1;
- return snprintf(page, count, "%s\n",obd->u.mds.mds_vfsmnt->mnt_devname);
-}
-
-static int lprocfs_rd_mds_counters(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device* obd = (struct obd_device *)data;
- int len = 0, n, i, j;
- struct lprocfs_counter t, ret = { .lc_min = ~(__u64)0 };
- struct lprocfs_stats *stats;
- struct timeval now;
-
- LASSERT(obd != NULL);
- if (obd->u.mds.mds_counters == NULL)
- return 0;
-
- do_gettimeofday(&now);
-
- n = snprintf(page, count, "%-25s %lu.%lu secs.usecs\n",
- "snapshot_time", now.tv_sec, now.tv_usec);
- page += n; len +=n; count -=n;
-
- stats = obd->u.mds.mds_counters;
-
- *eof = 1;
- for (i = 0; i < MDS_LAST_OPC_COUNT; i ++) {
- ret.lc_count = 0;
- for (j = 0; j < num_online_cpus(); j++) {
- struct lprocfs_counter *percpu_cntr =
- &(stats->ls_percpu[j])->lp_cntr[i];
- int centry;
- do {
- centry =
- atomic_read(&percpu_cntr->lc_cntl.la_entry);
- t.lc_count = percpu_cntr->lc_count;
- } while (centry !=
- atomic_read(&percpu_cntr->lc_cntl.la_entry) &&
- centry !=
- atomic_read(&percpu_cntr->lc_cntl.la_exit));
- ret.lc_count += t.lc_count;
- }
- n = snprintf(page, count, "%-25s "LPU64" \n",
- ll_mds_count_opcode2str(i), ret.lc_count);
- page += n; len +=n; count -=n;
- }
- return (len);
+ return snprintf(page, count, "%s\n",
+ obd->u.mds.mds_vfsmnt->mnt_devname);
}
static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
RETURN(mds_lov_update_config(obd, 0));
}
+static int lprocfs_rd_last_fid(char *page, char **start, off_t off,
+ unsigned long count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct mds_obd *mds = &obd->u.mds;
+ __u64 last_fid;
+
+ down(&mds->mds_last_fid_sem);
+ last_fid = mds->mds_last_fid;
+ up(&mds->mds_last_fid_sem);
+
+ *eof = 1;
+ return snprintf(page, count, LPD64"\n", last_fid);
+}
+
+static int lprocfs_rd_group(char *page, char **start, off_t off,
+ unsigned long count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+ struct mds_obd *mds = &obd->u.mds;
+ __u64 last_fid;
+
+ *eof = 1;
+ return snprintf(page, count, LPD64"\n", mds->mds_num);
+}
+
struct lprocfs_vars lprocfs_mds_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "blocksize", lprocfs_rd_blksize, 0, 0 },
{ "filestotal", lprocfs_rd_filestotal, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 },
{ "mntdev", lprocfs_mds_rd_mntdev, 0, 0 },
+ { "last_fid", lprocfs_rd_last_fid, 0, 0 },
+ { "group", lprocfs_rd_group, 0, 0 },
{ "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
{ "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
{ "config_update", 0, lprocfs_mds_wr_config_update, 0 },
{ "num_exports", lprocfs_rd_num_exports, 0, 0 },
- { "counters", lprocfs_rd_mds_counters, 0, 0 },
{ 0 }
};
OBD_FREE(gids, param.ngroups * sizeof(gid_t));
return count;
}
+
static int lprocfs_rd_expire(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
*eof = 1;
return snprintf(page, count, "%d\n", hash->gh_entry_expire);
}
+
static int lprocfs_wr_expire(struct file *file, const char *buffer,
unsigned long count, void *data)
{
sscanf(buf, "%d", &hash->gh_entry_expire);
return count;
}
+
static int lprocfs_rd_ac_expire(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
*eof = 1;
return snprintf(page, count, "%d\n", hash->gh_acquire_expire);
}
+
static int lprocfs_wr_ac_expire(struct file *file, const char *buffer,
unsigned long count, void *data)
{
sscanf(buf, "%d", &hash->gh_acquire_expire);
return count;
}
+
static int lprocfs_rd_hash_upcall(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
*eof = 1;
return snprintf(page, count, "%s\n", hash->gh_upcall);
}
+
static int lprocfs_wr_hash_upcall(struct file *file, const char *buffer,
unsigned long count, void *data)
{
}
return count;
}
+
static int lprocfs_wr_hash_flush(struct file *file, const char *buffer,
unsigned long count, void *data)
{
mds_group_hash_flush_idle();
return count;
}
+
static int lprocfs_rd_allow_setgroups(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
*eof = 1;
return snprintf(page, count, "%d\n", hash->gh_allow_setgroups);
}
+
static int lprocfs_wr_allow_setgroups(struct file *file, const char *buffer,
unsigned long count, void *data)
{
}
struct lprocfs_vars lprocfs_mds_module_vars[] = {
- { "num_refs", lprocfs_rd_numrefs, 0, 0 },
- { "grp_hash_expire_interval", lprocfs_rd_expire, lprocfs_wr_expire, 0},
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { "grp_hash_expire_interval",lprocfs_rd_expire,
+ lprocfs_wr_expire, 0},
{ "grp_hash_acquire_expire", lprocfs_rd_ac_expire,
- lprocfs_wr_ac_expire, 0},
- { "grp_hash_upcall", lprocfs_rd_hash_upcall, lprocfs_wr_hash_upcall, 0},
+ lprocfs_wr_ac_expire, 0},
+ { "grp_hash_upcall", lprocfs_rd_hash_upcall,
+ lprocfs_wr_hash_upcall, 0},
{ "grp_hash_flush", 0, lprocfs_wr_hash_flush, 0},
- { "group_info", 0, lprocfs_wr_group_info, 0 },
+ { "group_info", 0, lprocfs_wr_group_info, 0 },
{ "allow_setgroups", lprocfs_rd_allow_setgroups,
- lprocfs_wr_allow_setgroups, 0},
+ lprocfs_wr_allow_setgroups, 0},
{ 0 }
};
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ 0 }
};
-
#endif /* LPROCFS */
struct lprocfs_static_vars lprocfs_array_vars[] = { {lprocfs_mds_module_vars,
return req->rq_export->exp_obd;
}
-typedef enum {
- MDS_OPEN_COUNT = 0,
- MDS_CREATE_COUNT = 1,
- MDS_CLOSE_COUNT = 2,
- MDS_LINK_COUNT = 3,
- MDS_UNLINK_COUNT = 4,
- MDS_GETATTR_COUNT = 5,
- MDS_GETATTR_LOCK_COUNT = 6,
- MDS_SETATTR_COUNT = 7,
- MDS_RENAME_COUNT = 8,
- MDS_STATFS_COUNT = 9,
- MDS_LAST_OPC_COUNT = 10
-} mds_counters_t;
-
-struct lprocfs_stats * lprocfs_alloc_mds_counters(void);
-void lprocfs_free_mds_counters(struct lprocfs_stats *ptr);
-
-#ifndef LPROCFS
-#define MDS_UPDATE_COUNTER(mds, opcode) do {} while (0)
-#else
-
-#define MDS_UPDATE_COUNTER(mds, opcode) \
- LASSERT( opcode < MDS_LAST_OPC_COUNT); \
- LASSERT( mds->mds_counters != NULL); \
- lprocfs_counter_incr(mds->mds_counters, opcode);
-#endif
-
#ifdef __KERNEL__
/* Open counts for files. No longer atomic, must hold inode->i_sem */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
}
MDS_CHECK_RESENT(req, reconstruct_open(rec, offset, req, child_lockh));
- MDS_UPDATE_COUNTER(mds, MDS_OPEN_COUNT);
/*
* Step 0: If we are passed a id, then we assume the client already
rc = fsfilt_setattr(obd, dparent, handle, &iattr, 0);
if (rc)
CERROR("error on parent setattr: rc = %d\n", rc);
- else
- MDS_UPDATE_COUNTER(mds, MDS_CREATE_COUNT);
+ else {
+ MD_COUNTER_INCREMENT(obd, create);
+ }
down(&dchild->d_inode->i_sem);
if (ino) {
/*we are trying to create or write a exist dir*/
GOTO(cleanup, rc = -EISDIR);
}
- if (ll_permission(dchild->d_inode, acc_mode, NULL)) {
+ if (ll_permission(dchild->d_inode, acc_mode, NULL))
GOTO(cleanup, rc = -EACCES);
- }
+
if (is_mount_object(dchild)) {
CERROR("Found possible GNS mount object %*s; not "
"opening.\n", dchild->d_name.len,
obd->u.mds.mds_max_mdsize,
obd->u.mds.mds_max_cookiesize};
ENTRY;
-
- MDS_UPDATE_COUNTER((&obd->u.mds), MDS_CLOSE_COUNT);
+ MD_COUNTER_INCREMENT(obd, close);
rc = lustre_pack_reply(req, 3, repsize, NULL);
if (rc) {
rec->ur_iattr.ia_valid);
MDS_CHECK_RESENT(req, reconstruct_reint_setattr(rec, offset, req));
-
- MDS_UPDATE_COUNTER(mds, MDS_SETATTR_COUNT);
+ MD_COUNTER_INCREMENT(obd, setattr);
if (rec->ur_iattr.ia_valid & ATTR_FROM_OPEN) {
de = mds_id2dentry(obd, rec->ur_id1, NULL);
if (rc)
CERROR("error on parent setattr: rc = %d\n", rc);
else
- MDS_UPDATE_COUNTER(mds, MDS_CREATE_COUNT);
+ MD_COUNTER_INCREMENT(obd, create);
body = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*body));
mds_pack_inode2body(obd, body, inode, 1);
req->rq_repmsg->buflens[2]);
}
- MDS_UPDATE_COUNTER(mds, MDS_UNLINK_COUNT);
+ MD_COUNTER_INCREMENT(obd, unlink);
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNLINK))
GOTO(cleanup, rc = -ENOENT);
rec->ur_name);
MDS_CHECK_RESENT(req, mds_reconstruct_generic(req));
- MDS_UPDATE_COUNTER(mds, MDS_LINK_COUNT);
+ MD_COUNTER_INCREMENT(obd, link);
// memset(tgt_dir_lockh, 0, 2*sizeof(tgt_dir_lockh[0]));
if (OBD_FAIL_CHECK(OBD_FAIL_MDS_REINT_LINK))
req->rq_repmsg->buflens[2]);
}
- MDS_UPDATE_COUNTER(mds, MDS_RENAME_COUNT);
+ MD_COUNTER_INCREMENT(obd, rename);
if (rec->ur_namelen == 1) {
rc = mds_reint_rename_create_name(rec, offset, req);
--- /dev/null
+#!/bin/bash
+set -e
+
+ONLY=${ONLY:-"$*"}
+# bug number for skipped test:
+ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
+
+SRCDIR=`dirname $0`
+export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
+
+TMP=${TMP:-/tmp}
+FSTYPE=${FSTYPE:-ext3}
+
+CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
+CREATETEST=${CREATETEST:-createtest}
+LFS=${LFS:-lfs}
+LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
+LFIND=${LFIND:-"$LFS find"}
+LVERIFY=${LVERIFY:-ll_dirstripe_verify}
+LCTL=${LCTL:-lctl}
+MCREATE=${MCREATE:-mcreate}
+OPENFILE=${OPENFILE:-openfile}
+OPENUNLINK=${OPENUNLINK:-openunlink}
+TOEXCL=${TOEXCL:-toexcl}
+TRUNCATE=${TRUNCATE:-truncate}
+MUNLINK=${MUNLINK:-munlink}
+SOCKETSERVER=${SOCKETSERVER:-socketserver}
+SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
+IOPENTEST1=${IOPENTEST1:-iopentest1}
+IOPENTEST2=${IOPENTEST2:-iopentest2}
+PTLDEBUG=${PTLDEBUG:-0}
+MODE=${MODE:mds}
+
+if [ $UID -ne 0 ]; then
+ RUNAS_ID="$UID"
+ RUNAS=""
+else
+ RUNAS_ID=${RUNAS_ID:-500}
+ RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+fi
+
+export NAME=${NAME:-cmobd}
+
+SAVE_PWD=$PWD
+
+clean() {
+ echo -n "cln.."
+ sh llmountcleanup.sh > /dev/null || exit 20
+ I_MOUNTED=no
+}
+CLEAN=${CLEAN:-clean}
+
+start() {
+ echo -n "mnt.."
+ sh llrmount.sh > /dev/null || exit 10
+ I_MOUNTED=yes
+ echo "done"
+}
+START=${START:-start}
+
+log() {
+ echo "$*"
+ lctl mark "$*" 2> /dev/null || true
+}
+
+trace() {
+ log "STARTING: $*"
+ strace -o $TMP/$1.strace -ttt $*
+ RC=$?
+ log "FINISHED: $*: rc $RC"
+ return 1
+}
+TRACE=${TRACE:-""}
+
+check_kernel_version() {
+ VERSION_FILE=/proc/fs/lustre/kernel_version
+ WANT_VER=$1
+ [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
+ GOT_VER=`cat $VERSION_FILE`
+ [ $GOT_VER -ge $WANT_VER ] && return 0
+ log "test needs at least kernel version $WANT_VER, running $GOT_VER"
+ return 1
+}
+
+run_one() {
+ if ! mount | grep -q $DIR; then
+ $START
+ fi
+ echo $PTLDEBUG >/proc/sys/portals/debug
+ log "== test $1: $2"
+ export TESTNAME=test_$1
+ test_$1 || error "test_$1: exit with rc=$?"
+ unset TESTNAME
+ pass
+ cd $SAVE_PWD
+ $CLEAN
+}
+
+build_test_filter() {
+ for O in $ONLY; do
+ eval ONLY_${O}=true
+ done
+ for E in $EXCEPT $ALWAYS_EXCEPT; do
+ eval EXCEPT_${E}=true
+ done
+}
+
+_basetest() {
+ echo $*
+}
+
+basetest() {
+ IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
+}
+
+run_test() {
+ base=`basetest $1`
+ if [ "$ONLY" ]; then
+ testname=ONLY_$1
+ if [ ${!testname}x != x ]; then
+ run_one $1 "$2"
+ return $?
+ fi
+ testname=ONLY_$base
+ if [ ${!testname}x != x ]; then
+ run_one $1 "$2"
+ return $?
+ fi
+ echo -n "."
+ return 0
+ fi
+ testname=EXCEPT_$1
+ if [ ${!testname}x != x ]; then
+ echo "skipping excluded test $1"
+ return 0
+ fi
+ testname=EXCEPT_$base
+ if [ ${!testname}x != x ]; then
+ echo "skipping excluded test $1 (base $base)"
+ return 0
+ fi
+ run_one $1 "$2"
+ return $?
+}
+
+[ "$SANITYLOG" ] && rm -f $SANITYLOG || true
+
+error() {
+ log "FAIL: $@"
+ if [ "$SANITYLOG" ]; then
+ echo "FAIL: $TESTNAME $@" >> $SANITYLOG
+ else
+ exit 1
+ fi
+}
+
+pass() {
+ echo PASS
+}
+
+MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
+if [ -z "$MOUNT" ]; then
+ sh llmount.sh
+ MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
+ [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
+ I_MOUNTED=yes
+fi
+
+[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
+
+DIR=${DIR:-$MOUNT}
+[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
+
+rm -rf $DIR/[Rdfs][1-9]*
+
+build_test_filter
+
+echo preparing for tests involving mounts
+EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
+touch $EXT2_DEV
+mke2fs -j -F $EXT2_DEV 8000 > /dev/null
+
+lsync() {
+ name=$1
+ device=`$LCTL device_list | grep " $name " | awk '{print $1}'`
+
+ [ -z $device ] && {
+ echo "Can't find device $name"
+ return 1
+ }
+
+${LCTL} << EOF
+device $device
+lsync
+EOF
+ return $?
+}
+
+test_1a() {
+ rm -fr $DIR/1a0 > /dev/null
+
+ echo "mkdir $DIR/1a0"
+ mkdir $DIR/1a0 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "touch $DIR/1a0/f0"
+ touch $DIR/1a0/f0 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "chmod +x $DIR/1a0/f0"
+ chmod +x $DIR/1a0/f0 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "mv $DIR/1a0/f0 $DIR/1a0/f01"
+ mv $DIR/1a0/f0 $DIR/1a0/f01 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "rm $DIR/1a0/f01"
+ rm $DIR/1a0/f01 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "touch $DIR/1a0/f01"
+ touch $DIR/1a0/f01 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "ln $DIR/1a0/f01 $DIR/1a0/f01h"
+ ln $DIR/1a0/f01 $DIR/1a0/f01h || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+
+ echo "ln -s $DIR/1a0/f01 $DIR/1a0/f01s"
+ ln -s $DIR/1a0/f01 $DIR/1a0/f01s || error
+
+ rm -fr $DIR/1a0 > /dev/null
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+}
+run_test 1a " WB test (lsync after each MD operation)============="
+
+test_1b() {
+ echo "mkdir $DIR/1b0"
+ mkdir $DIR/1b0 || error
+ echo "touch $DIR/1b0/f0"
+ touch $DIR/1b0/f0 || error
+ echo "chmod +x $DIR/1b0/f0"
+ chmod +x $DIR/1b0/f0 || error
+ echo "mv $DIR/1b0/f0 $DIR/1b0/f01"
+ mv $DIR/1b0/f0 $DIR/1b0/f01 || error
+ echo "rm $DIR/1b0/f01"
+ rm $DIR/1b0/f01 || error
+ echo "touch $DIR/1b0/f01"
+ touch $DIR/1b0/f01 || error
+ echo "ln $DIR/1b0/f01 $DIR/1b0/f01h"
+ ln $DIR/1b0/f01 $DIR/1b0/f01h || error
+ echo "ln -s $DIR/1b0/f01 $DIR/1b0/f01s"
+ ln -s $DIR/1b0/f01 $DIR/1b0/f01s || error
+
+ rm -fr $DIR/1b0 > /dev/null
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+}
+run_test 1b " WB test (lsync after bunch of MD operarions)============="
+
+test_2a() {
+ echo "mkdir $DIR/2a0"
+ mkdir $DIR/2a0 || error
+ echo "createmany -o $DIR/2a0/f 4000"
+ createmany -o $DIR/2a0/f 4000
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+}
+
+test_2b() {
+ echo "find $DIR/2a0 -type f -exec rm -f {} \;"
+ find $DIR/2a0 -type f -exec rm -f {} \;
+ rmdir $DIR/2a0 || error
+ echo "cache flush on $NAME"
+ lsync $NAME >/dev/null || error
+}
+
+[ "x$MODE" = "xlmv" ] && {
+run_test 2a " WB test (flush createmany on master LMV) ======================"
+run_test 2b " WB test (flush delmany on master LMV) ========================="
+}
+
+TMPDIR=$OLDTMPDIR
+TMP=$OLDTMP
+HOME=$OLDHOME
+
+log "cleanup: ========================================================"
+if [ "`mount | grep ^$NAME`" ]; then
+ rm -rf $DIR/[Rdfs][1-9]*
+ if [ "$I_MOUNTED" = "yes" ]; then
+ sh llmountcleanup.sh || error
+ fi
+fi
+
+echo "=========================== finished ============================"
+[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
--- /dev/null
+#!/bin/bash
+set -e
+
+ONLY=${ONLY:-"$*"}
+# bug number for skipped test:
+ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
+# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
+
+[ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
+
+SRCDIR=`dirname $0`
+export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
+
+TMP=${TMP:-/tmp}
+FSTYPE=${FSTYPE:-ext3}
+
+CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
+CREATETEST=${CREATETEST:-createtest}
+LFS=${LFS:-lfs}
+LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
+LFIND=${LFIND:-"$LFS find"}
+LVERIFY=${LVERIFY:-ll_dirstripe_verify}
+LCTL=${LCTL:-lctl}
+MCREATE=${MCREATE:-mcreate}
+OPENFILE=${OPENFILE:-openfile}
+OPENUNLINK=${OPENUNLINK:-openunlink}
+TOEXCL=${TOEXCL:-toexcl}
+TRUNCATE=${TRUNCATE:-truncate}
+MUNLINK=${MUNLINK:-munlink}
+SOCKETSERVER=${SOCKETSERVER:-socketserver}
+SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
+IOPENTEST1=${IOPENTEST1:-iopentest1}
+IOPENTEST2=${IOPENTEST2:-iopentest2}
+PTLDEBUG=${PTLDEBUG:-0}
+MODE=${MODE:mds}
+
+if [ $UID -ne 0 ]; then
+ RUNAS_ID="$UID"
+ RUNAS=""
+else
+ RUNAS_ID=${RUNAS_ID:-500}
+ RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+fi
+
+export NAME=${NAME:-local}
+
+SAVE_PWD=$PWD
+
+clean() {
+ echo -n "cln.."
+ sh llmountcleanup.sh > /dev/null || exit 20
+ I_MOUNTED=no
+}
+CLEAN=${CLEAN:-clean}
+
+start() {
+ echo -n "mnt.."
+ sh llrmount.sh > /dev/null || exit 10
+ I_MOUNTED=yes
+ echo "done"
+}
+START=${START:-start}
+
+log() {
+ echo "$*"
+ lctl mark "$*" 2> /dev/null || true
+}
+
+trace() {
+ log "STARTING: $*"
+ strace -o $TMP/$1.strace -ttt $*
+ RC=$?
+ log "FINISHED: $*: rc $RC"
+ return 1
+}
+TRACE=${TRACE:-""}
+
+check_kernel_version() {
+ VERSION_FILE=/proc/fs/lustre/kernel_version
+ WANT_VER=$1
+ [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
+ GOT_VER=`cat $VERSION_FILE`
+ [ $GOT_VER -ge $WANT_VER ] && return 0
+ log "test needs at least kernel version $WANT_VER, running $GOT_VER"
+ return 1
+}
+
+run_one() {
+ if ! mount | grep -q $DIR; then
+ $START
+ fi
+ echo $PTLDEBUG >/proc/sys/portals/debug
+ log "== test $1: $2"
+ export TESTNAME=test_$1
+ test_$1 || error "test_$1: exit with rc=$?"
+ unset TESTNAME
+ pass
+ cd $SAVE_PWD
+ $CLEAN
+}
+
+build_test_filter() {
+ for O in $ONLY; do
+ eval ONLY_${O}=true
+ done
+ for E in $EXCEPT $ALWAYS_EXCEPT; do
+ eval EXCEPT_${E}=true
+ done
+}
+
+_basetest() {
+ echo $*
+}
+
+basetest() {
+ IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
+}
+
+run_test() {
+ base=`basetest $1`
+ if [ "$ONLY" ]; then
+ testname=ONLY_$1
+ if [ ${!testname}x != x ]; then
+ run_one $1 "$2"
+ return $?
+ fi
+ testname=ONLY_$base
+ if [ ${!testname}x != x ]; then
+ run_one $1 "$2"
+ return $?
+ fi
+ echo -n "."
+ return 0
+ fi
+ testname=EXCEPT_$1
+ if [ ${!testname}x != x ]; then
+ echo "skipping excluded test $1"
+ return 0
+ fi
+ testname=EXCEPT_$base
+ if [ ${!testname}x != x ]; then
+ echo "skipping excluded test $1 (base $base)"
+ return 0
+ fi
+ run_one $1 "$2"
+ return $?
+}
+
+[ "$SANITYLOG" ] && rm -f $SANITYLOG || true
+
+error() {
+ log "FAIL: $@"
+ if [ "$SANITYLOG" ]; then
+ echo "FAIL: $TESTNAME $@" >> $SANITYLOG
+ else
+ exit 1
+ fi
+}
+
+pass() {
+ echo PASS
+}
+
+MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
+if [ -z "$MOUNT" ]; then
+ sh llmount.sh
+ MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
+ [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
+ I_MOUNTED=yes
+fi
+
+[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
+
+DIR=${DIR:-$MOUNT}
+[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
+
+rm -rf $DIR/[Rdfs][1-9]*
+
+build_test_filter
+
+echo preparing for tests involving mounts
+EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
+touch $EXT2_DEV
+mke2fs -j -F $EXT2_DEV 8000 > /dev/null
+
+test_1a() {
+ rm -fr $DIR/1a0 > /dev/null
+ MDS=`find /proc/fs/lustre/mds/* -type d | head -n1 | sed 's/.*\///'`
+ [ -z "$MDS" ] && {
+ echo "no MDS available, skipping test"
+ return 0
+ }
+ count=`find /proc/fs/lustre/mds/* -type d | wc -l`
+ [ $count -gt 1 ] && {
+ echo "more than 1 MDS is found, skipping test"
+ return 0
+ }
+
+ mkdir $DIR/1a0 || error
+ old_last_fid=`cat /proc/fs/lustre/mds/$MDS/last_fid`
+ createmany -o $DIR/1a0/f 5000
+ new_last_fid=`cat /proc/fs/lustre/mds/$MDS/last_fid`
+
+ diff=$(($new_last_fid-$old_last_fid))
+ [ $diff -ne 5000 ] && {
+ echo "invalid fid management: \
+ old $old_last_fid, new $new_last_fid"
+ error
+ }
+ rm -fr $DIR/1a0 || error
+}
+run_test 1a " fid managing correctness ============="
+
+TMPDIR=$OLDTMPDIR
+TMP=$OLDTMP
+HOME=$OLDHOME
+
+log "cleanup: ========================================================"
+if [ "`mount | grep ^$NAME`" ]; then
+ rm -rf $DIR/[Rdfs][1-9]*
+ if [ "$I_MOUNTED" = "yes" ]; then
+ sh llmountcleanup.sh || error
+ fi
+fi
+
+echo "=========================== finished ============================"
+[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true