if (unlikely(lump->lum_magic != LMV_USER_MAGIC))
RETURN(-EINVAL);
- CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s"
+ CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s "
"stripe_offset %d, stripe_count: %u\n",
PFID(ll_inode2fid(parent)), parent, dirname,
(int)lump->lum_stripe_offset, lump->lum_stripe_count);
static int lmv_placement_policy(struct obd_device *obd,
struct md_op_data *op_data, u32 *mds)
{
- struct lmv_obd *lmv = &obd->u.lmv;
+ struct lmv_obd *lmv = &obd->u.lmv;
+ struct lmv_user_md *lum;
+
ENTRY;
LASSERT(mds != NULL);
RETURN(0);
}
- if (op_data->op_default_stripe_offset != -1) {
+ lum = op_data->op_data;
+ /* Choose MDS by
+ * 1. See if the stripe offset is specified by lum.
+ * 2. Then check if there is default stripe offset.
+ * 3. Finally choose MDS by name hash if the parent
+ * is striped directory. (see lmv_locate_mds()). */
+ if (op_data->op_cli_flags & CLI_SET_MEA && lum != NULL &&
+ le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) {
+ *mds = le32_to_cpu(lum->lum_stripe_offset);
+ } else if (op_data->op_default_stripe_offset != (__u32)-1) {
*mds = op_data->op_default_stripe_offset;
- RETURN(0);
- }
-
- /**
- * If stripe_offset is provided during setdirstripe
- * (setdirstripe -i xx), xx MDS will be choosen.
- */
- if (op_data->op_cli_flags & CLI_SET_MEA && op_data->op_data != NULL) {
- struct lmv_user_md *lum;
-
- lum = op_data->op_data;
-
- if (le32_to_cpu(lum->lum_stripe_offset) != (__u32)-1) {
- *mds = le32_to_cpu(lum->lum_stripe_offset);
- } else {
- /* -1 means default, which will be in the same MDT with
- * the stripe */
- *mds = op_data->op_mds;
- lum->lum_stripe_offset = cpu_to_le32(op_data->op_mds);
- }
+ op_data->op_mds = *mds;
+ /* Correct the stripe offset in lum */
+ if (lum != NULL)
+ lum->lum_stripe_offset = cpu_to_le32(*mds);
} else {
- /* Allocate new fid on target according to operation type and
- * parent home mds. */
*mds = op_data->op_mds;
}
mkdir $DIR/$tdir
mkdir $DIR/$tdir/normal_dir
+ #Checking when client cache stripe index
+ $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
+ $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
+ error "create striped_dir failed"
+
+ mkdir $DIR/$tdir/striped_dir/dir1 ||
+ error "create dir1 fails"
+ stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
+ [ $stripe_index -eq 1 ] ||
+ error "dir1 expect 1 got $stripe_index"
+
+ $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
+ error "create dir2 fails"
+ stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
+ [ $stripe_index -eq 2 ] ||
+ error "dir2 expect 2 got $stripe_index"
+
+ #check default stripe count/stripe index
test_300_check_default_striped_dir normal_dir $MDSCOUNT 1
test_300_check_default_striped_dir normal_dir 1 0
test_300_check_default_striped_dir normal_dir 2 1