/* Check whether the fid is for LAST_ID */
static inline bool fid_is_last_id(const struct lu_fid *fid)
{
- return !fid_oid(fid) && fid_seq(fid) != FID_SEQ_UPDATE_LOG &&
- fid_seq(fid) != FID_SEQ_UPDATE_LOG_DIR;
+ if (fid_oid(fid) != 0)
+ return false;
+
+ if (fid_is_idif(fid) && ((fid_seq(fid) & 0xFFFF) != 0))
+ return false;
+
+ if (fid_seq(fid) == FID_SEQ_UPDATE_LOG ||
+ fid_seq(fid) == FID_SEQ_UPDATE_LOG_DIR)
+ return false;
+
+ return true;
}
/**
struct lfsck_instance *lfsck = com->lc_lfsck;
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct lfsck_thread_info *info = lfsck_env_info(env);
- struct ost_id *oi = &info->lti_oi;
struct lu_fid *fid = &info->lti_fid;
struct dt_object *obj;
const struct dt_it_ops *iops;
RETURN(0);
}
- ostid_set_seq(oi, FID_SEQ_IDIF);
- rc = ostid_set_id(oi, 0);
- if (rc)
- GOTO(log, rc);
-
- rc = ostid_to_fid(fid, oi, ltd->ltd_index);
- if (rc != 0)
- GOTO(log, rc);
+ fid->f_seq = fid_idif_seq(0, ltd->ltd_index);
+ fid->f_oid = fid->f_ver = 0;
obj = lfsck_object_find_by_dev(env, ltd->ltd_tgt, fid);
if (unlikely(IS_ERR(obj)))
{
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ struct lu_fid *fid;
+ __u64 id;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
- seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1);
+ fid = &osp->opd_pre_used_fid;
+ if (fid_is_idif(fid)) {
+ id = fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid));
+ id++;
+ } else {
+ id = unlikely(fid_oid(fid) == LUSTRE_DATA_SEQ_MAX_WIDTH) ?
+ 1 : fid_oid(fid) + 1;
+ }
+
+ seq_printf(m, "%llu\n", id);
return 0;
}
LPROC_SEQ_FOPS_RO(osp_prealloc_next_id);
{
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ struct lu_fid *fid;
+ __u64 id;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
+ fid = &osp->opd_pre_last_created_fid;
+ id = fid_is_idif(fid) ?
+ fid_idif_id(fid_seq(fid), fid_oid(fid), fid_ver(fid)) :
+ fid_oid(fid);
- seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid));
+ seq_printf(m, "%llu\n", id);
return 0;
}
LPROC_SEQ_FOPS_RO(osp_prealloc_last_id);
{
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ struct lu_fid *fid;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
- seq_printf(m, "%#llx\n", fid_seq(&osp->opd_pre_used_fid));
+ fid = &osp->opd_pre_used_fid;
+ seq_printf(m, "%#llx\n", fid_is_idif(fid) ?
+ fid_seq(fid) & (~0xffff) : fid_seq(fid));
+
return 0;
}
LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq);
{
struct obd_device *obd = m->private;
struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev);
+ struct lu_fid *fid;
if (osp == NULL || osp->opd_pre == NULL)
return 0;
- seq_printf(m, "%#llx\n",
- fid_seq(&osp->opd_pre_last_created_fid));
+ fid = &osp->opd_pre_last_created_fid;
+ seq_printf(m, "%#llx\n", fid_is_idif(fid) ?
+ fid_seq(fid) & (~0xffff) : fid_seq(fid));
+
return 0;
}
LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq);
/* object will be released in device cleanup path */
if (osi->osi_attr.la_size >=
sizeof(osi->osi_id) * (osp->opd_index + 1)) {
- osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &fid->f_oid,
+ osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &osi->osi_id,
osp->opd_index);
rc = dt_record_read(env, dto, &osi->osi_lb, &osi->osi_off);
if (rc != 0 && rc != -EFAULT)
GOTO(out, rc);
+ /* In case of idif bits 32-48 go to f_seq
+ * (see osp_init_last_seq). So don't care
+ * about u64->u32 convertion. */
+ fid->f_oid = osi->osi_id;
}
if (rc == -EFAULT) { /* fresh LAST_ID */
+ osi->osi_id = 0;
fid->f_oid = 0;
- osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &fid->f_oid,
+ osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off, &osi->osi_id,
osp->opd_index);
rc = osp_write_local_file(env, osp, dto, &osi->osi_lb,
osi->osi_off);
rc = dt_record_read(env, dto, &osi->osi_lb, &osi->osi_off);
if (rc != 0 && rc != -EFAULT)
GOTO(out, rc);
+ if (fid_is_idif(fid))
+ fid->f_seq = fid_idif_seq(osi->osi_id, osp->opd_index);
}
if (rc == -EFAULT) { /* fresh OSP */
rc = osp_init_last_seq(env, osp);
if (rc < 0) {
- CERROR("%s: Can not get ids %d from old objid!\n",
+ CERROR("%s: Can not get sequence %d from old objseq!\n",
osp->opd_obd->obd_name, rc);
GOTO(out, rc);
}
}
static inline void osp_objid_buf_prep(struct lu_buf *buf, loff_t *off,
- __u32 *id, int index)
+ __u64 *id, int index)
{
/* Note: through id is only 32 bits, it will also write 64 bits
* for oid to keep compatibility with the previous version. */
static inline void osp_update_last_fid(struct osp_device *d, struct lu_fid *fid)
{
int diff = osp_fid_diff(fid, &d->opd_last_used_fid);
+ struct lu_fid *gap_start = &d->opd_gap_start_fid;
/*
* we might have lost precreated objects due to VBR and precreate
* orphans, the gap in objid can be calculated properly only here
if (diff > 0) {
if (diff > 1) {
d->opd_gap_start_fid = d->opd_last_used_fid;
- d->opd_gap_start_fid.f_oid++;
+ if (fid_oid(gap_start) == LUSTRE_DATA_SEQ_MAX_WIDTH) {
+ gap_start->f_seq++;
+ gap_start->f_oid = fid_is_idif(gap_start) ?
+ 0 : 1;
+ } else {
+ gap_start->f_oid++;
+ }
d->opd_gap_count = diff - 1;
CDEBUG(D_HA, "Gap in objids: start="DFID", count =%d\n",
PFID(&d->opd_gap_start_fid), d->opd_gap_count);
int rc = 0;
struct lu_fid *fid = &osi->osi_fid;
struct thandle *local_th;
+ struct lu_fid *last_fid = &d->opd_last_used_fid;
ENTRY;
if (is_only_remote_trans(th) &&
/* Only need update last_used oid file, seq file will only be update
* during seq rollover */
+ if (fid_is_idif((last_fid)))
+ osi->osi_id = fid_idif_id(fid_seq(last_fid),
+ fid_oid(last_fid), fid_ver(last_fid));
+ else
+ osi->osi_id = fid_oid(last_fid);
osp_objid_buf_prep(&osi->osi_lb, &osi->osi_off,
- &d->opd_last_used_fid.f_oid, d->opd_index);
+ &osi->osi_id, d->opd_index);
rc = dt_record_write(env, d->opd_last_used_oid_file, &osi->osi_lb,
&osi->osi_off, local_th);
int osp_precreate_get_fid(const struct lu_env *env, struct osp_device *d,
struct lu_fid *fid)
{
+ struct lu_fid *pre_used_fid = &d->opd_pre_used_fid;
/* grab next id from the pool */
spin_lock(&d->opd_pre_lock);
PFID(&d->opd_pre_used_fid),
PFID(&d->opd_pre_last_created_fid));
+ /*
+ * When sequence is used up, new one should be allocated in
+ * osp_precreate_rollover_new_seq. So ASSERT here to avoid
+ * objid overflow.
+ */
+ LASSERTF(osp_fid_end_seq(env, pre_used_fid) == 0,
+ "next fid "DFID" last created fid "DFID"\n",
+ PFID(&d->opd_pre_used_fid),
+ PFID(&d->opd_pre_last_created_fid));
+ /* Non IDIF fids shoulnd't get here with oid == 0xFFFFFFFF. */
+ if (fid_is_idif(pre_used_fid) &&
+ unlikely(fid_oid(pre_used_fid) == LUSTRE_DATA_SEQ_MAX_WIDTH))
+ pre_used_fid->f_seq++;
+
d->opd_pre_used_fid.f_oid++;
memcpy(fid, &d->opd_pre_used_fid, sizeof(*fid));
d->opd_pre_reserved--;