1. MDT0 will only create IDIF fids, so old clients, who
only know IDIF, can still access files on MDT0.
2. Using fid_ostid_pack to pack the FID into ostid, otherwise
IDIF will be packed wrongly and caused the panic on the OST0.
3. Add dd into compatible tests of conf-sanity.sh(32) to
check OST fids on the upgrade FS.
Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ic9322bd1c66e5fedec68c10aa2f300d5ecb3b6db
Reviewed-on: http://review.whamcloud.com/5307
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
};
extern void lustre_hsm_swab(struct hsm_attrs *attrs);
};
extern void lustre_hsm_swab(struct hsm_attrs *attrs);
+struct ost_id {
+ obd_id oi_id;
+ obd_seq oi_seq;
+};
+
+static inline void ostid_cpu_to_le(struct ost_id *src_oi,
+ struct ost_id *dst_oi)
+{
+ dst_oi->oi_id = cpu_to_le64(src_oi->oi_id);
+ dst_oi->oi_seq = cpu_to_le64(src_oi->oi_seq);
+}
+
+static inline void ostid_le_to_cpu(struct ost_id *src_oi,
+ struct ost_id *dst_oi)
+{
+ dst_oi->oi_id = le64_to_cpu(src_oi->oi_id);
+ dst_oi->oi_seq = le64_to_cpu(src_oi->oi_seq);
+}
+
+extern void lustre_swab_ost_id(struct ost_id *oid);
+
return fid_seq_is_idif(fid_seq(fid));
}
return fid_seq_is_idif(fid_seq(fid));
}
-struct ost_id {
- obd_id oi_id;
- obd_seq oi_seq;
-};
-
static inline int fid_is_local_file(const struct lu_fid *fid)
{
return fid_seq_is_local_file(fid_seq(fid));
static inline int fid_is_local_file(const struct lu_fid *fid)
{
return fid_seq_is_local_file(fid_seq(fid));
}
/* pack a non-IDIF FID into an ostid (id/seq) for the wire/disk */
}
/* pack a non-IDIF FID into an ostid (id/seq) for the wire/disk */
-static inline void ostid_fid_pack(const struct lu_fid *fid,
+static inline void ostid_normal_fid_pack(const struct lu_fid *fid,
struct ost_id *ostid)
{
ostid->oi_seq = fid_seq(fid);
struct ost_id *ostid)
{
ostid->oi_seq = fid_seq(fid);
static inline int fid_ostid_pack(const struct lu_fid *fid,
struct ost_id *ostid)
{
static inline int fid_ostid_pack(const struct lu_fid *fid,
struct ost_id *ostid)
{
- if (unlikely(fid_seq_is_igif(fid->f_seq))) {
- CERROR("bad IGIF, "DFID"\n", PFID(fid));
- return -EBADF;
- }
+ if (unlikely(fid_seq_is_igif(fid->f_seq))) {
+ CERROR("bad IGIF, "DFID"\n", PFID(fid));
+ return -EBADF;
+ }
- if (fid_is_idif(fid))
- ostid_idif_pack(fid, ostid);
- else
- ostid_fid_pack(fid, ostid);
+ if (fid_is_idif(fid))
+ ostid_idif_pack(fid, ostid);
+ else
+ ostid_normal_fid_pack(fid, ostid);
}
/* extract OST sequence (group) from a wire ost_id (id/seq) pair */
}
/* extract OST sequence (group) from a wire ost_id (id/seq) pair */
extern struct req_msg_field RMF_RCS;
extern struct req_msg_field RMF_FIEMAP_KEY;
extern struct req_msg_field RMF_FIEMAP_VAL;
extern struct req_msg_field RMF_RCS;
extern struct req_msg_field RMF_FIEMAP_KEY;
extern struct req_msg_field RMF_FIEMAP_VAL;
+extern struct req_msg_field RMF_OST_ID;
/* MGS config read message format */
extern struct req_msg_field RMF_MGS_CONFIG_BODY;
/* MGS config read message format */
extern struct req_msg_field RMF_MGS_CONFIG_BODY;
-#define POSTID LPU64":"LPU64
+#define POSTID LPU64":"LPX64
struct ofd_seq {
cfs_list_t os_list;
struct ofd_seq {
cfs_list_t os_list;
- obd_id os_last_oid;
- obd_seq os_seq;
spinlock_t os_last_oid_lock;
struct mutex os_create_lock;
cfs_atomic_t os_refc;
spinlock_t os_last_oid_lock;
struct mutex os_create_lock;
cfs_atomic_t os_refc;
unsigned long os_destroys_in_progress:1;
};
unsigned long os_destroys_in_progress:1;
};
+#define os_seq os_oi.oi_seq
+#define os_last_oid os_oi.oi_id
+
struct ofd_device {
struct dt_device ofd_dt_dev;
struct dt_device *ofd_osd;
struct ofd_device {
struct dt_device ofd_dt_dev;
struct dt_device *ofd_osd;
*((__u32 *) val) = ofd->ofd_sync_lock_cancel;
*vallen = sizeof(__u32);
} else if (KEY_IS(KEY_LAST_FID)) {
*((__u32 *) val) = ofd->ofd_sync_lock_cancel;
*vallen = sizeof(__u32);
} else if (KEY_IS(KEY_LAST_FID)) {
- struct lu_env env;
- struct ofd_device *ofd = ofd_exp(exp);
- struct ofd_seq *oseq;
- struct lu_fid *last_fid = val;
- int rc;
-
- if (last_fid == NULL) {
- *vallen = sizeof(struct lu_fid);
+ struct lu_env env;
+ struct ofd_device *ofd = ofd_exp(exp);
+ struct ofd_seq *oseq;
+ struct ost_id *oid = val;
+ int rc;
+
+ if (oid == NULL) {
+ *vallen = sizeof(struct ost_id);
- if (*vallen < sizeof(*last_fid))
+ if (*vallen < sizeof(*oid))
RETURN(-EOVERFLOW);
rc = lu_env_init(&env, LCT_DT_THREAD);
if (rc != 0)
RETURN(rc);
ofd_info_init(&env, exp);
RETURN(-EOVERFLOW);
rc = lu_env_init(&env, LCT_DT_THREAD);
if (rc != 0)
RETURN(rc);
ofd_info_init(&env, exp);
- fid_le_to_cpu(last_fid, last_fid);
- oseq = ofd_seq_load(&env, ofd, fid_seq(last_fid));
+
+ ostid_le_to_cpu(oid, oid);
+ CDEBUG(D_HA, "Get LAST FID for seq "LPX64"\n", oid->oi_seq);
+
+ oseq = ofd_seq_load(&env, ofd, oid->oi_seq);
- GOTO(out_fid, rc = PTR_ERR(oseq));
+ GOTO(out_fini, rc = PTR_ERR(oseq));
- last_fid->f_seq = oseq->os_seq;
- last_fid->f_oid = oseq->os_last_oid;
- fid_cpu_to_le(last_fid, last_fid);
+ CDEBUG(D_HA, "LAST FID is "POSTID"\n", oseq->os_last_oid,
+ oseq->os_seq);
- *vallen = sizeof(*last_fid);
+ *oid = oseq->os_oi;
+ *vallen = sizeof(*oid);
lu_env_fini(&env);
} else {
CERROR("Not supported key %s\n", (char*)key);
lu_env_fini(&env);
} else {
CERROR("Not supported key %s\n", (char*)key);
body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
LASSERT(body);
body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
LASSERT(body);
+ *fid = d->opd_pre_last_created_fid;
rc = osp_precreate_fids(env, d, fid, &grow);
if (rc == 1) {
/* Current seq has been used up*/
rc = osp_precreate_fids(env, d, fid, &grow);
if (rc == 1) {
/* Current seq has been used up*/
- ostid_fid_pack(fid, &body->oa.o_oi);
+ fid_ostid_pack(fid, &body->oa.o_oi);
body->oa.o_valid = OBD_MD_FLGROUP;
ptlrpc_request_set_replen(req);
body->oa.o_valid = OBD_MD_FLGROUP;
ptlrpc_request_set_replen(req);
-static int osp_get_lastfid_from_ost(struct osp_device *d)
+static int osp_get_lastfid_from_ost(const struct lu_env *env,
+ struct osp_device *d)
+ struct ost_id *oi = &osp_env_info(env)->osi_oi;
struct ptlrpc_request *req = NULL;
struct obd_import *imp;
struct lu_fid *last_fid = &d->opd_last_used_fid;
struct ptlrpc_request *req = NULL;
struct obd_import *imp;
struct lu_fid *last_fid = &d->opd_last_used_fid;
if (req == NULL)
RETURN(-ENOMEM);
if (req == NULL)
RETURN(-ENOMEM);
- req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
- RCL_CLIENT, sizeof(KEY_LAST_FID));
+ req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT,
+ sizeof(KEY_LAST_FID));
- req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
- RCL_CLIENT, sizeof(*last_fid));
+ req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL, RCL_CLIENT,
+ sizeof(*oi));
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO);
if (rc) {
rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO);
if (rc) {
memcpy(tmp, KEY_LAST_FID, sizeof(KEY_LAST_FID));
req->rq_no_delay = req->rq_no_resend = 1;
memcpy(tmp, KEY_LAST_FID, sizeof(KEY_LAST_FID));
req->rq_no_delay = req->rq_no_resend = 1;
- fid_cpu_to_le(last_fid, last_fid);
+ fid_ostid_pack(last_fid, oi);
+ ostid_cpu_to_le(oi, oi);
tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
- memcpy(tmp, last_fid, sizeof(*last_fid));
+ memcpy(tmp, oi, sizeof(*oi));
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
- last_fid = req_capsule_server_get(&req->rq_pill, &RMF_FID);
- if (last_fid == NULL || !fid_is_sane(last_fid)) {
+ oi = req_capsule_server_get(&req->rq_pill, &RMF_OST_ID);
+ if (oi == NULL) {
+ CERROR("%s: Got last_fid failed.\n", d->opd_obd->obd_name);
+ GOTO(out, rc = -EPROTO);
+ }
+
+ rc = fid_ostid_unpack(last_fid, oi, d->opd_index);
+ if (rc != 0 || !fid_is_sane(last_fid)) {
CERROR("%s: Got insane last_fid "DFID"\n",
d->opd_obd->obd_name, PFID(last_fid));
GOTO(out, rc = -EPROTO);
CERROR("%s: Got insane last_fid "DFID"\n",
d->opd_obd->obd_name, PFID(last_fid));
GOTO(out, rc = -EPROTO);
if (fid_oid(last_fid) > 0)
d->opd_last_used_fid = *last_fid;
if (fid_oid(last_fid) > 0)
d->opd_last_used_fid = *last_fid;
- CDEBUG(D_HA, "%s: Got insane last_fid "DFID"\n", d->opd_obd->obd_name,
+ CDEBUG(D_HA, "%s: Got last_fid "DFID"\n", d->opd_obd->obd_name,
LASSERT(!fid_is_zero(last_fid));
if (fid_oid(&d->opd_last_used_fid) < 2) {
/* lastfid looks strange... ask OST */
LASSERT(!fid_is_zero(last_fid));
if (fid_oid(&d->opd_last_used_fid) < 2) {
/* lastfid looks strange... ask OST */
- rc = osp_get_lastfid_from_ost(d);
+ rc = osp_get_lastfid_from_ost(env, d);
body->oa.o_flags = OBD_FL_DELORPHAN;
body->oa.o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
body->oa.o_flags = OBD_FL_DELORPHAN;
body->oa.o_valid = OBD_MD_FLFLAGS | OBD_MD_FLGROUP;
- if (osp_is_fid_client(d))
- body->oa.o_seq = fid_seq(&d->opd_last_used_fid);
- else
- body->oa.o_seq = 0;
- /* remove from NEXT after used one */
- body->oa.o_id = fid_oid(&d->opd_last_used_fid);
+
+ fid_ostid_pack(&d->opd_last_used_fid, &body->oa.o_oi);
ptlrpc_request_set_replen(req);
ptlrpc_request_set_replen(req);
last_fid = &osi->osi_fid;
fid_zero(last_fid);
/* For a freshed fs, it will allocate a new sequence first */
last_fid = &osi->osi_fid;
fid_zero(last_fid);
/* For a freshed fs, it will allocate a new sequence first */
- if (osp_is_fid_client(osp)) {
+ if (osp_is_fid_client(osp) && osp->opd_group != 0) {
cli_seq = osp->opd_obd->u.cli.cl_seq;
rc = seq_client_get_seq(&env, cli_seq, &last_fid->f_seq);
if (rc != 0) {
cli_seq = osp->opd_obd->u.cli.cl_seq;
rc = seq_client_get_seq(&env, cli_seq, &last_fid->f_seq);
if (rc != 0) {
GOTO(out, rc);
}
} else {
GOTO(out, rc);
}
} else {
- last_fid->f_seq = fid_idif_seq(1, osp->opd_index);
+ last_fid->f_seq = fid_idif_seq(0, osp->opd_index);
}
last_fid->f_oid = 1;
last_fid->f_ver = 0;
}
last_fid->f_oid = 1;
last_fid->f_ver = 0;
oa->o_id, oa->o_seq);
return -EPROTO;
}
oa->o_id, oa->o_seq);
return -EPROTO;
}
- ioobj_from_obdo(ioobj, oa);
+ ioobj_from_obdo(ioobj, oa);
static const struct req_msg_field *ost_get_last_fid_server[] = {
&RMF_PTLRPC_BODY,
static const struct req_msg_field *ost_get_last_fid_server[] = {
&RMF_PTLRPC_BODY,
};
static const struct req_msg_field *ost_get_fiemap_client[] = {
};
static const struct req_msg_field *ost_get_fiemap_client[] = {
sizeof(struct lu_fid), lustre_swab_lu_fid, NULL);
EXPORT_SYMBOL(RMF_FID);
sizeof(struct lu_fid), lustre_swab_lu_fid, NULL);
EXPORT_SYMBOL(RMF_FID);
+struct req_msg_field RMF_OST_ID =
+ DEFINE_MSGF("ost_id", 0,
+ sizeof(struct ost_id), lustre_swab_ost_id, NULL);
+EXPORT_SYMBOL(RMF_OST_ID);
+
struct req_msg_field RMF_FIEMAP_KEY =
DEFINE_MSGF("fiemap", 0, sizeof(struct ll_fiemap_info_key),
lustre_swab_fiemap, NULL);
struct req_msg_field RMF_FIEMAP_KEY =
DEFINE_MSGF("fiemap", 0, sizeof(struct ll_fiemap_info_key),
lustre_swab_fiemap, NULL);
CLASSERT(offsetof(typeof(*ocd), paddingF) != 0);
}
CLASSERT(offsetof(typeof(*ocd), paddingF) != 0);
}
+void lustre_swab_ost_id(struct ost_id *oid)
+{
+ __swab64s(&oid->oi_id);
+ __swab64s(&oid->oi_seq);
+}
+EXPORT_SYMBOL(lustre_swab_ost_id);
+
void lustre_swab_obdo (struct obdo *o)
{
__swab64s (&o->o_valid);
void lustre_swab_obdo (struct obdo *o)
{
__swab64s (&o->o_valid);
- __swab64s (&o->o_id);
- __swab64s (&o->o_seq);
+ lustre_swab_ost_id(&o->o_oi);
__swab64s (&o->o_parent_seq);
__swab64s (&o->o_size);
__swab64s (&o->o_mtime);
__swab64s (&o->o_parent_seq);
__swab64s (&o->o_size);
__swab64s (&o->o_mtime);
+ dd if=/dev/zero of=$tmp/mnt/lustre/tmp_file bs=10k count=10 || {
+ error_noexit "dd failed"
+ return 1
+ }
+ rm -rf $tmp/mnt/lustre/tmp_file || {
+ error_noexit "rm failed"
+ return 1
+ }
+
if $r test -f $tmp/sha1sums; then
# LU-2393 - do both sorts on same node to ensure locale
# is identical
if $r test -f $tmp/sha1sums; then
# LU-2393 - do both sorts on same node to ensure locale
# is identical
#define lustre_swab_mgs_config_res NULL
#define lustre_swab_swap_layouts NULL
#define lustre_swab_lu_fid NULL
#define lustre_swab_mgs_config_res NULL
#define lustre_swab_swap_layouts NULL
#define lustre_swab_lu_fid NULL
+#define lustre_swab_ost_id NULL
#define lustre_swab_hsm_progress_kernel NULL
#define lustre_swab_hsm_user_item NULL
#define lustre_swab_hsm_user_state NULL
#define lustre_swab_hsm_progress_kernel NULL
#define lustre_swab_hsm_user_item NULL
#define lustre_swab_hsm_user_state NULL