static const struct lu_object_operations osd_lu_obj_ops;
static const struct dt_object_operations osd_obj_ops;
static const struct dt_object_operations osd_obj_ea_ops;
+static const struct dt_object_operations osd_obj_otable_it_ops;
static const struct dt_index_operations osd_index_iam_ops;
static const struct dt_index_operations osd_index_ea_ops;
#ifdef HAVE_QUOTA_SUPPORT
static inline void
-osd_push_ctxt(const struct lu_env *env, struct osd_ctxt *save)
+osd_push_ctxt(const struct lu_env *env, struct osd_ctxt *save, bool is_md)
{
- struct md_ucred *uc = md_ucred(env);
+ struct md_ucred *uc;
struct cred *tc;
+ if (!is_md)
+ /* OFD support */
+ return;
+
+ uc = md_ucred(env);
+
LASSERT(uc != NULL);
save->oc_uid = current_fsuid();
}
static inline void
-osd_pop_ctxt(struct osd_ctxt *save)
+osd_pop_ctxt(struct osd_ctxt *save, bool is_md)
{
struct cred *tc;
+ if (!is_md)
+ /* OFD support */
+ return;
+
if ((tc = prepare_creds())) {
tc->fsuid = save->oc_uid;
tc->fsgid = save->oc_gid;
struct inode *inode;
struct osd_scrub *scrub;
struct scrub_file *sf;
- int result;
+ int result;
int verify = 0;
ENTRY;
}
fid_zero(&oic->oic_fid);
- /* Search order: 3. OI files. */
- result = osd_oi_lookup(info, dev, fid, id);
- if (result != 0 && result != -ENOENT)
- GOTO(out, result);
- /* If fid wasn't found in oi, inode-less object is created,
- * for which lu_object_exists() returns false. This is used
- * in a (frequent) case when objects are created as locking
- * anchors or place holders for objects yet to be created. */
- if (conf != NULL && conf->loc_flags & LOC_F_NEW) {
- if (unlikely(result == 0))
- GOTO(out, result = -EEXIST);
- else
- GOTO(out, result = 0);
- }
+ /*
+ * Objects are created as locking anchors or place holders for objects
+ * yet to be created. No need to osd_oi_lookup() at here because FID
+ * shouldn't never be re-used, if it's really a duplicate FID from
+ * unexpected reason, we should be able to detect it later by calling
+ * do_create->osd_oi_insert()
+ */
+ if (conf != NULL && (conf->loc_flags & LOC_F_NEW) != 0)
+ GOTO(out, result = 0);
+ /* Search order: 3. OI files. */
+ result = osd_oi_lookup(info, dev, fid, id);
if (result == -ENOENT) {
if (!fid_is_norm(fid) ||
!ldiskfs_test_bit(osd_oi_fid2idx(dev,fid),
goto trigger;
}
+ if (result != 0)
+ GOTO(out, result);
+
iget:
if (verify == 0)
inode = osd_iget(info, dev, id);
LINVRNT(osd_invariant(obj));
result = osd_fid_lookup(env, obj, lu_object_fid(l), conf);
- obj->oo_dt.do_body_ops = &osd_body_ops_new;
- if (result == 0) {
- if (obj->oo_inode != NULL)
- osd_object_init0(obj);
- }
- LINVRNT(osd_invariant(obj));
- return result;
+ obj->oo_dt.do_body_ops = &osd_body_ops_new;
+ if (result == 0) {
+ if (obj->oo_inode != NULL) {
+ osd_object_init0(obj);
+ } else if (fid_is_otable_it(&l->lo_header->loh_fid)) {
+ obj->oo_dt.do_ops = &osd_obj_otable_it_ops;
+ /* LFSCK iterator object is special without inode */
+ l->lo_header->loh_attr |= LOHA_EXISTS;
+ }
+ }
+ LINVRNT(osd_invariant(obj));
+ return result;
}
/*
* data (ofd) and reverse ordering for metadata
* (mdd). then at some point we'll fix the latter
*/
- if (lu_device_is_md(&d->dd_lu_dev)) {
+ if (dev->od_is_md) {
LASSERT(oti->oti_r_locks == 0);
LASSERT(oti->oti_w_locks == 0);
}
* data (ofd) and reverse ordering for metadata
* (mdd). then at some point we'll fix the latter
*/
- if (lu_device_is_md(&th->th_dev->dd_lu_dev)) {
+ if (osd_dt_dev(th->th_dev)->od_is_md) {
LASSERT(oti->oti_r_locks == 0);
LASSERT(oti->oti_w_locks == 0);
}
struct kstatfs *ksfs;
int result = 0;
+ if (unlikely(osd->od_mount == NULL))
+ return -EINPROGRESS;
+
/* osd_lproc.c call this without env, allocate ksfs for that case */
if (unlikely(env == NULL)) {
OBD_ALLOC_PTR(ksfs);
}
static struct timespec *osd_inode_time(const struct lu_env *env,
- struct inode *inode, __u64 seconds)
+ struct inode *inode, __u64 seconds)
{
- struct osd_thread_info *oti = osd_oti_get(env);
- struct timespec *t = &oti->oti_time;
+ struct osd_thread_info *oti = osd_oti_get(env);
+ struct timespec *t = &oti->oti_time;
- t->tv_sec = seconds;
- t->tv_nsec = 0;
- *t = timespec_trunc(*t, get_sb_time_gran(inode->i_sb));
- return t;
+ t->tv_sec = seconds;
+ t->tv_nsec = 0;
+ *t = timespec_trunc(*t, inode->i_sb->s_time_gran);
+ return t;
}
OSD_EXEC_OP(handle, attr_set);
inode = obj->oo_inode;
- if (LDISKFS_HAS_RO_COMPAT_FEATURE(inode->i_sb,
- LDISKFS_FEATURE_RO_COMPAT_QUOTA)) {
+ if (!osd_dt_dev(handle->th_dev)->od_is_md) {
+ /* OFD support */
rc = osd_quota_transfer(inode, attr);
if (rc)
return rc;
iattr.ia_valid |= ATTR_GID;
iattr.ia_uid = attr->la_uid;
iattr.ia_gid = attr->la_gid;
- osd_push_ctxt(env, save);
+ osd_push_ctxt(env, save, 1);
rc = ll_vfs_dq_transfer(inode, &iattr) ? -EDQUOT : 0;
- osd_pop_ctxt(save);
+ osd_pop_ctxt(save, 1);
if (rc != 0)
return rc;
}
parent = hint->dah_parent;
#ifdef HAVE_QUOTA_SUPPORT
- osd_push_ctxt(info->oti_env, save);
+ osd_push_ctxt(info->oti_env, save, osd_dt_dev(th->th_dev)->od_is_md);
#endif
inode = ldiskfs_create_inode(oth->ot_handle,
parent ? osd_dt_obj(parent)->oo_inode :
osd_sb(osd)->s_root->d_inode,
mode);
#ifdef HAVE_QUOTA_SUPPORT
- osd_pop_ctxt(save);
+ osd_pop_ctxt(save, osd_dt_dev(th->th_dev)->od_is_md);
#endif
if (!IS_ERR(inode)) {
/* Do not update file c/mtime in ldiskfs.
if ((valid & LA_MTIME) && (attr->la_mtime == LTIME_S(inode->i_mtime)))
attr->la_valid &= ~LA_MTIME;
- if (LDISKFS_HAS_RO_COMPAT_FEATURE(inode->i_sb,
- LDISKFS_FEATURE_RO_COMPAT_QUOTA)) {
+ if (!osd_obj2dev(obj)->od_is_md) {
+ /* OFD support */
result = osd_quota_transfer(inode, attr);
if (result)
return;
struct osd_thread_info *info = osd_oti_get(env);
struct osd_inode_id *id = &info->oti_id;
struct osd_device *osd = osd_obj2dev(obj);
- struct md_ucred *uc = md_ucred(env);
LASSERT(obj->oo_inode != NULL);
- LASSERT(uc != NULL);
+
+ if (osd->od_is_md) {
+ struct md_ucred *uc = md_ucred(env);
+ LASSERT(uc != NULL);
+ }
osd_id_gen(id, obj->oo_inode->i_ino, obj->oo_inode->i_generation);
return osd_oi_insert(info, osd, fid, id, th);
return result;
}
+static int osd_otable_it_attr_get(const struct lu_env *env,
+ struct dt_object *dt,
+ struct lu_attr *attr,
+ struct lustre_capa *capa)
+{
+ attr->la_valid = 0;
+ return 0;
+}
+
static const struct dt_object_operations osd_obj_ops = {
.do_read_lock = osd_object_read_lock,
.do_write_lock = osd_object_write_lock,
.do_data_get = osd_data_get,
};
+static const struct dt_object_operations osd_obj_otable_it_ops = {
+ .do_attr_get = osd_otable_it_attr_get,
+ .do_index_try = osd_index_try,
+};
+
static int osd_index_declare_iam_delete(const struct lu_env *env,
struct dt_object *dt,
const struct dt_key *key,
err = osd_mount(env, o, cfg);
break;
case LCFG_CLEANUP:
+ lu_dev_del_linkage(d->ld_site, d);
err = osd_shutdown(env, o);
break;
default:
RETURN(result);
}
- if (!lu_device_is_md(pdev))
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,3,50,0)
+ /* Unfortunately, the current MDD implementation relies on some specific
+ * code to be executed in the OSD layer. Since OFD now also uses the OSD
+ * module, we need a way to skip the metadata-specific code when running
+ * with OFD.
+ * The hack here is to check the type of the parent device which is
+ * either MD (i.e. MDD device) with the current MDT stack or DT (i.e.
+ * OFD device) on an OST. As a reminder, obdfilter does not use the OSD
+ * layer and still relies on lvfs. This hack won't work any more when
+ * LOD is landed since LOD is of DT type.
+ * This code should be removed once the orion MDT changes (LOD/OSP, ...)
+ * have been landed */
+ osd->od_is_md = lu_device_is_md(pdev);
+#else
+#warning "all is_md checks must be removed from osd-ldiskfs"
+#endif
+
+ if (!osd->od_is_md)
RETURN(0);
/* 3. setup local objects */