-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
static int osd_root_get(const struct lu_env *env,
struct dt_device *dev, struct lu_fid *f)
{
- struct inode *inode;
-
- inode = osd_sb(osd_dt_dev(dev))->s_root->d_inode;
- LU_IGIF_BUILD(f, inode->i_ino, inode->i_generation);
+ lu_local_obj_fid(f, OSD_FS_ROOT_OID);
return 0;
}
LINVRNT(osd_invariant(obj));
LASSERT(obj->oo_inode == NULL);
- LASSERTF(fid_is_sane(fid) || osd_fid_is_root(fid), DFID, PFID(fid));
+ LASSERTF(fid_is_sane(fid) || fid_is_idif(fid), DFID, PFID(fid));
/*
* This assertion checks that osd layer sees only local
* fids. Unfortunately it is somewhat expensive (does a
dt_txn_hook_commit(th);
- /* call per-transaction callbacks if any */
- cfs_list_for_each_entry_safe(dcb, tmp, &oh->ot_dcb_list, dcb_linkage)
- dcb->dcb_func(NULL, th, dcb, error);
+ /* call per-transaction callbacks if any */
+ cfs_list_for_each_entry_safe(dcb, tmp, &oh->ot_dcb_list, dcb_linkage) {
+ cfs_list_del_init(&dcb->dcb_linkage);
+ dcb->dcb_func(NULL, th, dcb, error);
+ }
lu_ref_del_at(&lud->ld_reference, oh->ot_dev_link, "osd-tx", th);
lu_device_put(lud);
* IMPORTANT: we have to wait till any IO submited by the thread is
* completed otherwise iobuf may be corrupted by different request
*/
- cfs_wait_event(iobuf->dr_wait, cfs_atomic_read(&iobuf->dr_numreqs)==0);
+ cfs_wait_event(iobuf->dr_wait,
+ cfs_atomic_read(&iobuf->dr_numreqs) == 0);
if (!rc)
rc = iobuf->dr_error;
* Concurrency: shouldn't matter.
*/
int osd_statfs(const struct lu_env *env, struct dt_device *d,
- cfs_kstatfs_t *sfs)
+ struct obd_statfs *sfs)
{
- struct osd_device *osd = osd_dt_dev(d);
+ struct osd_device *osd = osd_dt_dev(d);
struct super_block *sb = osd_sb(osd);
+ struct kstatfs *ksfs;
int result = 0;
+ /* osd_lproc.c call this without env, allocate ksfs for that case */
+ if (unlikely(env == NULL)) {
+ OBD_ALLOC_PTR(ksfs);
+ if (ksfs == NULL)
+ return -ENOMEM;
+ } else {
+ 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, &osd->od_kstatfs);
- if (likely(result == 0)) /* N.B. statfs can't really fail */
+ 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);
+ }
}
if (likely(result == 0))
- *sfs = osd->od_kstatfs;
+ *sfs = osd->od_statfs;
cfs_spin_unlock(&osd->od_osfs_lock);
+ if (unlikely(env == NULL))
+ OBD_FREE_PTR(ksfs);
+
return result;
}
LASSERT(!(bits & LA_TYPE)); /* Huh? You want too much. */
-#ifdef HAVE_QUOTA_SUPPORT
- if ((bits & LA_UID && attr->la_uid != inode->i_uid) ||
- (bits & LA_GID && attr->la_gid != inode->i_gid)) {
- struct osd_ctxt *save = &osd_oti_get(env)->oti_ctxt;
- struct iattr iattr;
- int rc;
-
- iattr.ia_valid = 0;
- if (bits & LA_UID)
- iattr.ia_valid |= ATTR_UID;
- if (bits & LA_GID)
- iattr.ia_valid |= ATTR_GID;
- iattr.ia_uid = attr->la_uid;
- iattr.ia_gid = attr->la_gid;
- osd_push_ctxt(env, save);
- rc = ll_vfs_dq_transfer(inode, &iattr) ? -EDQUOT : 0;
- osd_pop_ctxt(save);
- if (rc != 0)
- return rc;
- }
-#endif
-
if (bits & LA_ATIME)
inode->i_atime = *osd_inode_time(env, inode, attr->la_atime);
if (bits & LA_CTIME)
struct lustre_capa *capa)
{
struct osd_object *obj = osd_dt_obj(dt);
+ struct inode *inode;
int rc;
LASSERT(handle != NULL);
OSD_EXEC_OP(handle, attr_set);
+ inode = obj->oo_inode;
+#ifdef HAVE_QUOTA_SUPPORT
+ if ((attr->la_valid & LA_UID && attr->la_uid != inode->i_uid) ||
+ (attr->la_valid & LA_GID && attr->la_gid != inode->i_gid)) {
+ struct osd_ctxt *save = &osd_oti_get(env)->oti_ctxt;
+ struct iattr iattr;
+ int rc;
+
+ iattr.ia_valid = 0;
+ if (attr->la_valid & LA_UID)
+ iattr.ia_valid |= ATTR_UID;
+ if (attr->la_valid & LA_GID)
+ iattr.ia_valid |= ATTR_GID;
+ iattr.ia_uid = attr->la_uid;
+ iattr.ia_gid = attr->la_gid;
+ osd_push_ctxt(env, save);
+ rc = ll_vfs_dq_transfer(inode, &iattr) ? -EDQUOT : 0;
+ osd_pop_ctxt(save);
+ if (rc != 0)
+ return rc;
+ }
+#endif
+
cfs_spin_lock(&obj->oo_guard);
- rc = osd_inode_setattr(env, obj->oo_inode, attr);
+ rc = osd_inode_setattr(env, inode, attr);
cfs_spin_unlock(&obj->oo_guard);
if (!rc)
- obj->oo_inode->i_sb->s_op->dirty_inode(obj->oo_inode);
+ inode->i_sb->s_op->dirty_inode(inode);
return rc;
}
int result;
struct osd_device *osd = osd_obj2dev(obj);
struct osd_thandle *oth;
- struct dt_object *parent;
+ struct dt_object *parent = NULL;
struct inode *inode;
#ifdef HAVE_QUOTA_SUPPORT
struct osd_ctxt *save = &info->oti_ctxt;
if (hint && hint->dah_parent)
parent = hint->dah_parent;
- else
- parent = osd->od_obj_area;
#ifdef HAVE_QUOTA_SUPPORT
osd_push_ctxt(info->oti_env, save);
#endif
inode = ldiskfs_create_inode(oth->ot_handle,
- parent ? osd_dt_obj(parent)->oo_inode :
- osd_sb(osd)->s_root->d_inode,
+ parent ? osd_dt_obj(parent)->oo_inode :
+ osd_sb(osd)->s_root->d_inode,
mode);
#ifdef HAVE_QUOTA_SUPPORT
osd_pop_ctxt(save);
OSD_EXEC_OP(th, create);
result = __osd_object_create(info, obj, attr, hint, dof, th);
-
/* objects under osd root shld have igif fid, so dont add fid EA */
if (result == 0 && fid_seq(fid) >= FID_SEQ_NORMAL)
result = osd_ea_fid_set(env, dt, fid);
inode->i_nlink == 2)
inode->i_nlink = 1;
}
- LASSERT(inode->i_nlink < LDISKFS_LINK_MAX);
+ LASSERT(inode->i_nlink <= LDISKFS_LINK_MAX);
cfs_spin_unlock(&obj->oo_guard);
inode->i_sb->s_op->dirty_inode(inode);
LINVRNT(osd_invariant(obj));
child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name));
+ /* XXX: remove fid_is_igif() check here.
+ * IGIF check is just to handle insertion of .. when it is 'ROOT',
+ * it is IGIF now but needs FID in dir entry as well for readdir
+ * to work.
+ * LU-838 should fix that and remove fid_is_igif() check */
if (fid_is_igif((struct lu_fid *)fid) ||
fid_is_norm((struct lu_fid *)fid)) {
ldp = (struct ldiskfs_dentry_param *)info->oti_ldp;
osd_get_ldiskfs_dirent_param(ldp, fid);
- child->d_fsdata = (void*) ldp;
- } else
+ child->d_fsdata = (void *)ldp;
+ } else {
child->d_fsdata = NULL;
+ }
rc = osd_ldiskfs_add_entry(oth->ot_handle, child, cinode, hlock);
RETURN(rc);
const struct dt_rec *dot_dot_fid,
struct thandle *th)
{
- struct inode *inode = dir->oo_inode;
+ struct inode *inode = dir->oo_inode;
struct ldiskfs_dentry_param *dot_ldp;
struct ldiskfs_dentry_param *dot_dot_ldp;
- struct osd_thandle *oth;
+ struct osd_thandle *oth;
int result = 0;
oth = container_of(th, struct osd_thandle, ot_super);
if (!dir->oo_compat_dot_created)
return -EINVAL;
- if (fid_seq((struct lu_fid *)dot_fid) >= FID_SEQ_NORMAL) {
+ if (!fid_is_igif((struct lu_fid *)dot_fid)) {
osd_get_ldiskfs_dirent_param(dot_ldp, dot_fid);
osd_get_ldiskfs_dirent_param(dot_dot_ldp, dot_dot_fid);
} else {
LU_TYPE_INIT_FINI(osd, &osd_key);
struct lu_context_key osd_key = {
- .lct_tags = LCT_DT_THREAD | LCT_MD_THREAD,
+ .lct_tags = LCT_DT_THREAD | LCT_MD_THREAD | LCT_MG_THREAD | LCT_LOCAL,
.lct_init = osd_key_init,
.lct_fini = osd_key_fini,
.lct_exit = osd_key_exit
static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
{
struct osd_thread_info *info = osd_oti_get(env);
+
ENTRY;
- if (o->od_obj_area != NULL) {
- lu_object_put(env, &o->od_obj_area->do_lu);
- o->od_obj_area = NULL;
- }
+
if (o->od_oi_table != NULL)
osd_oi_fini(info, o);
const char *dev = lustre_cfg_string(cfg, 0);
struct lustre_disk_data *ldd;
struct lustre_sb_info *lsi;
+ int rc = 0;
ENTRY;
LASSERT(lmi != NULL);
/* save lustre_mount_info in dt_device */
o->od_mount = lmi;
+ o->od_mnt = lmi->lmi_mnt;
lsi = s2lsi(lmi->lmi_sb);
ldd = lsi->lsi_ldd;
if (ldd->ldd_flags & LDD_F_IAM_DIR) {
o->od_iop_mode = 0;
- LCONSOLE_WARN("OSD: IAM mode enabled\n");
+ LCONSOLE_WARN("%s: OSD: IAM mode enabled\n", dev);
} else
o->od_iop_mode = 1;
- o->od_obj_area = NULL;
- RETURN(0);
+ if (ldd->ldd_flags & LDD_F_SV_TYPE_OST) {
+ rc = osd_compat_init(o);
+ if (rc)
+ CERROR("%s: can't initialize compats: %d\n", dev, rc);
+ }
+
+ RETURN(rc);
}
static struct lu_device *osd_device_fini(const struct lu_env *env,
int rc;
ENTRY;
+ osd_compat_fini(osd_dev(d));
+
shrink_dcache_sb(osd_sb(osd_dev(d)));
osd_sync(env, lu2dt_dev(d));
RETURN(0);
}
-static int osd_prepare(const struct lu_env *env,
- struct lu_device *pdev,
+static int osd_prepare(const struct lu_env *env, struct lu_device *pdev,
struct lu_device *dev)
{
- struct osd_device *osd = osd_dev(dev);
- struct lustre_sb_info *lsi;
- struct lustre_disk_data *ldd;
- struct lustre_mount_info *lmi;
+ struct osd_device *osd = osd_dev(dev);
struct osd_thread_info *oti = osd_oti_get(env);
- struct dt_object *d;
- int result;
+ int result;
ENTRY;
+
/* 1. initialize oi before any file create or file open */
result = osd_oi_init(oti, osd);
if (result < 0)
if (!lu_device_is_md(pdev))
RETURN(0);
- lmi = osd->od_mount;
- lsi = s2lsi(lmi->lmi_sb);
- ldd = lsi->lsi_ldd;
-
/* 2. setup local objects */
result = llo_local_objects_setup(env, lu2md_dev(pdev), lu2dt_dev(dev));
- if (result)
- goto out;
-
- /* 3. open remote object dir */
- d = dt_store_open(env, lu2dt_dev(dev), "",
- remote_obj_dir, &oti->oti_fid);
- if (!IS_ERR(d)) {
- osd->od_obj_area = d;
- result = 0;
- } else {
- result = PTR_ERR(d);
- osd->od_obj_area = NULL;
- }
-
-out:
RETURN(result);
}
.ldt_tags = LU_DEVICE_DT,
.ldt_name = LUSTRE_OSD_NAME,
.ldt_ops = &osd_device_type_ops,
- .ldt_ctx_tags = LCT_MD_THREAD|LCT_DT_THREAD
+ .ldt_ctx_tags = LCT_LOCAL,
};
/*
.o_owner = THIS_MODULE
};
-static struct lu_local_obj_desc llod_osd_rem_obj_dir = {
- .llod_name = remote_obj_dir,
- .llod_oid = OSD_REM_OBJ_DIR_OID,
- .llod_is_index = 1,
- .llod_feat = &dt_directory_features,
-};
-
static int __init osd_mod_init(void)
{
struct lprocfs_static_vars lvars;
osd_oi_mod_init();
- llo_local_obj_register(&llod_osd_rem_obj_dir);
lprocfs_osd_init_vars(&lvars);
return class_register_type(&osd_obd_device_ops, NULL, lvars.module_vars,
LUSTRE_OSD_NAME, &osd_device_type);
static void __exit osd_mod_exit(void)
{
- llo_local_obj_unregister(&llod_osd_rem_obj_dir);
class_unregister_type(LUSTRE_OSD_NAME);
}