#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;
/* call per-transaction callbacks if any */
cfs_list_for_each_entry_safe(dcb, tmp, &oh->ot_dcb_list, dcb_linkage) {
+ LASSERTF(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC,
+ "commit callback entry: magic=%x name='%s'\n",
+ dcb->dcb_magic, dcb->dcb_name);
cfs_list_del_init(&dcb->dcb_linkage);
dcb->dcb_func(NULL, th, dcb, error);
}
* 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);
}
static int osd_trans_cb_add(struct thandle *th, struct dt_txn_commit_cb *dcb)
{
- struct osd_thandle *oh = container_of0(th, struct osd_thandle,
- ot_super);
+ struct osd_thandle *oh = container_of0(th, struct osd_thandle,
+ ot_super);
- cfs_list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
+ LASSERT(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC);
+ LASSERT(&dcb->dcb_func != NULL);
+ cfs_list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
- return 0;
+ return 0;
}
/*
ksfs = &osd_oti_get(env)->oti_ksfs;
}
- cfs_spin_lock(&osd->od_osfs_lock);
- /* cache 1 second */
- if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) {
- result = ll_do_statfs(sb, ksfs);
- if (likely(result == 0)) { /* N.B. statfs can't really fail */
- osd->od_osfs_age = cfs_time_current_64();
- statfs_pack(&osd->od_statfs, ksfs);
- }
- }
+ cfs_spin_lock(&osd->od_osfs_lock);
+ /* cache 1 second */
+ if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) {
+ result = sb->s_op->statfs(sb->s_root, ksfs);
+ if (likely(result == 0)) { /* N.B. statfs can't really fail */
+ osd->od_osfs_age = cfs_time_current_64();
+ statfs_pack(&osd->od_statfs, ksfs);
+ }
+ }
if (likely(result == 0))
*sfs = osd->od_statfs;
}
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;
}
attr->la_flags = LDISKFS_I(inode)->i_flags;
attr->la_nlink = inode->i_nlink;
attr->la_rdev = inode->i_rdev;
- attr->la_blksize = ll_inode_blksize(inode);
- attr->la_blkbits = inode->i_blkbits;
+ attr->la_blksize = 1 << inode->i_blkbits;
+ attr->la_blkbits = inode->i_blkbits;
}
static int osd_attr_get(const struct lu_env *env,
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);
static int osd_object_sync(const struct lu_env *env, struct dt_object *dt)
{
- struct osd_object *obj = osd_dt_obj(dt);
- struct inode *inode = obj->oo_inode;
- struct osd_thread_info *info = osd_oti_get(env);
- struct dentry *dentry = &info->oti_obj_dentry;
- struct file *file = &info->oti_file;
- int rc;
+ struct osd_object *obj = osd_dt_obj(dt);
+ struct inode *inode = obj->oo_inode;
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct dentry *dentry = &info->oti_obj_dentry;
+ struct file *file = &info->oti_file;
+ int rc;
- ENTRY;
+ ENTRY;
- dentry->d_inode = inode;
- file->f_dentry = dentry;
- file->f_mapping = inode->i_mapping;
- file->f_op = inode->i_fop;
- LOCK_INODE_MUTEX(inode);
- rc = file->f_op->fsync(file, dentry, 0);
- UNLOCK_INODE_MUTEX(inode);
- RETURN(rc);
+ dentry->d_inode = inode;
+ file->f_dentry = dentry;
+ file->f_mapping = inode->i_mapping;
+ file->f_op = inode->i_fop;
+ mutex_lock(&inode->i_mutex);
+ rc = file->f_op->fsync(file, dentry, 0);
+ mutex_unlock(&inode->i_mutex);
+ RETURN(rc);
}
static int osd_data_get(const struct lu_env *env, struct dt_object *dt,
it->oie_file.f_pos = 0;
it->oie_file.f_dentry = obj_dentry;
if (attr & LUDA_64BITHASH)
- it->oie_file.f_flags = O_64BITHASH;
+ it->oie_file.f_mode |= FMODE_64BITHASH;
else
- it->oie_file.f_flags = O_32BITHASH;
+ it->oie_file.f_mode |= FMODE_32BITHASH;
it->oie_file.f_mapping = obj->oo_inode->i_mapping;
it->oie_file.f_op = obj->oo_inode->i_fop;
it->oie_file.private_data = NULL;
it->oie_it_dirent++;
RETURN(0);
} else {
- if (it->oie_file.f_pos == LDISKFS_HTREE_EOF)
+ if (it->oie_file.f_pos == ldiskfs_get_htree_eof(&it->oie_file))
rc = +1;
else
rc = osd_ldiskfs_it_fill(env, di);
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 */