#include <obd.h>
#include <obd_support.h>
+#include <lu_target.h>
#include <lustre_fid.h>
#include <lustre_fld.h>
#include <lustre_req_layout.h>
#ifndef _LUSTRE_LU_TARGET_H
#define _LUSTRE_LU_TARGET_H
-#include <dt_object.h>
+#include <lustre_quota.h>
#include <lustre_export.h>
#include <lustre_update.h>
#include <lustre_disk.h>
#include <linux/quota.h>
#include <linux/quotaops.h>
#include <linux/sort.h>
-#include <dt_object.h>
#include <lustre_fid.h>
#include <lustre_dlm.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <lustre_lib.h>
-#ifdef HAVE_SERVER_SUPPORT
-# include <lu_target.h>
-# include <obd_target.h>
-# include <lustre_quota.h>
-#endif
#include <lu_ref.h>
#include <lustre_export.h>
#include <lustre_fid.h>
struct list_head obd_final_req_queue;
union {
-#ifdef HAVE_SERVER_SUPPORT
- struct obd_device_target obt;
- struct filter_obd filter;
- struct ost_obd ost;
- struct echo_obd echo;
-#endif
struct client_obd cli;
struct echo_client_obd echo_client;
struct lov_obd lov;
#include <lustre_lib.h>
#include <uapi/linux/lustre/lustre_idl.h>
#include <lprocfs_status.h>
+#ifdef HAVE_SERVER_SUPPORT
+#include <lu_target.h>
+#include <obd_target.h>
#include <dt_object.h>
+#endif
#define OBD_STATFS_NODELAY 0x0001 /* requests should be send without delay
* and resends for avoid deadlocks */
#ifdef HAVE_SERVER_SUPPORT
static inline struct lu_target *class_exp2tgt(struct obd_export *exp)
{
- LASSERT(exp->exp_obd);
- if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC)
+ struct obd_device_target *obt;
+
+ LASSERT(exp->exp_obd);
+ obt = (void *)&exp->exp_obd->u;
+ if (obt->obt_magic != OBT_MAGIC)
return NULL;
- return exp->exp_obd->u.obt.obt_lut;
+ return obt->obt_lut;
}
static inline struct lr_server_data *class_server_data(struct obd_device *obd)
{
- LASSERT(obd->u.obt.obt_lut);
- return &obd->u.obt.obt_lut->lut_lsd;
+ struct obd_device_target *obt = obd2obt(obd);
+
+ LASSERT(obt);
+ return &obt->obt_lut->lut_lsd;
}
#endif
if (!IS_ERR(dev)) {
obd->obd_lu_dev = dev;
dev->ld_obd = obd;
+#ifdef HAVE_SERVER_SUPPORT
if (lu_device_is_dt(dev) &&
lu2dt_dev(dev)->dd_rdonly)
obd->obd_read_only = 1;
+#endif
rc = 0;
} else
rc = PTR_ERR(dev);
#ifndef __OBD_TARGET_H
#define __OBD_TARGET_H
#include <lprocfs_status.h>
+#include <obd.h>
/* server-side individual type definitions */
#define OBJ_SUBDIR_COUNT 32 /* set to zero for no subdirs */
-struct filter_obd {
- /* NB this field MUST be first */
- struct obd_device_target fo_obt;
-};
-
struct echo_obd {
struct obd_device_target eo_obt;
struct obdo eo_oa;
struct mutex ost_health_mutex;
};
+static inline struct obd_device_target *obd2obt(struct obd_device *obd)
+{
+ struct obd_device_target *obt;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*obt));
+
+ if (!obd)
+ return NULL;
+ obt = (void *)&obd->u;
+ LASSERT(obt->obt_magic == OBT_MAGIC);
+ return obt;
+}
+
+static inline struct obd_device_target *obd_obt_init(struct obd_device *obd)
+{
+ struct obd_device_target *obt;
+
+ obt = (void *)&obd->u;
+ obt->obt_magic = OBT_MAGIC;
+ obt->obt_instance = 0;
+
+ return obt;
+}
+
+static inline struct echo_obd *obd2echo(struct obd_device *obd)
+{
+ struct echo_obd *echo;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*echo));
+
+ if (!obd)
+ return NULL;
+ echo = (void *)&obd->u;
+
+ return echo;
+}
+
+static inline struct ost_obd *obd2ost(struct obd_device *obd)
+{
+ struct ost_obd *ost;
+
+ BUILD_BUG_ON(sizeof(obd->u) < sizeof(*ost));
+
+ if (!obd)
+ return NULL;
+ ost = (void *)&obd->u;
+
+ return ost;
+}
+
#endif /* __OBD_TARGET_H */
if (rc)
GOTO(out, rc);
- LASSERT(target->u.obt.obt_magic == OBT_MAGIC);
- data->ocd_instance = target->u.obt.obt_instance;
+ data->ocd_instance = obd2obt(target)->obt_instance;
/*
* Return only the parts of obd_connect_data that we understand, so the
int new_client)
{
timeout_t service_timeout = lustre_msg_get_service_timeout(req->rq_reqmsg);
- struct obd_device_target *obt = &obd->u.obt;
+ struct obd_device_target *obt = obd2obt(obd);
if (!new_client && service_timeout)
/*
#include <lu_object.h>
#include <dt_object.h>
#include <lustre_fid.h>
+#include <lu_target.h>
#include "lfsck_internal.h"
#include <lustre_lib.h>
#include <lustre_net.h>
#include <lustre_lfsck.h>
+#include <lu_target.h>
#include "lfsck_internal.h"
#include <lustre_fid.h>
#include <lustre_lib.h>
#include <lustre_net.h>
+#include <lu_target.h>
#include "lfsck_internal.h"
mdd_changelog_fini(env, m);
mdd_orphan_index_fini(env, m);
mdd_dot_lustre_cleanup(env, m);
- if (mdd2obd_dev(m)->u.obt.obt_nodemap_config_file) {
+ if (obd2obt(mdd2obd_dev(m))->obt_nodemap_config_file) {
+ struct obd_device_target *obt = obd2obt(mdd2obd_dev(m));
+
nm_config_file_deregister_tgt(env,
- mdd2obd_dev(m)->u.obt.obt_nodemap_config_file);
- mdd2obd_dev(m)->u.obt.obt_nodemap_config_file = NULL;
+ obt->obt_nodemap_config_file);
+ obt->obt_nodemap_config_file = NULL;
}
if (m->mdd_los != NULL) {
local_oid_storage_fini(env, m->mdd_los);
struct mdd_device *mdd = lu2mdd_dev(cdev);
struct lu_device *next = &mdd->mdd_child->dd_lu_dev;
struct nm_config_file *nodemap_config;
- struct obd_device_target *obt = &mdd2obd_dev(mdd)->u.obt;
+ struct obd_device_target *obt = obd2obt(mdd2obd_dev(mdd));
struct dt_object *root = NULL;
struct thandle *th = NULL;
struct lu_fid fid;
const struct lu_object_header *hdr,
struct lu_device *d)
{
+ struct mdd_device *mdd = lu2mdd_dev(d);
struct mdd_object *mdd_obj;
struct lu_object *o;
mdd_obj->mod_obj.mo_ops = &mdd_obj_ops;
mdd_obj->mod_obj.mo_dir_ops = &mdd_dir_ops;
mdd_obj->mod_count = 0;
+ obd_obt_init(mdd2obd_dev(mdd));
o->lo_ops = &mdd_lu_obj_ops;
INIT_LIST_HEAD(&mdd_obj->mod_users);
if (rc)
RETURN(rc);
- obd->u.obt.obt_magic = OBT_MAGIC;
+ obd_obt_init(obd);
if (lsi->lsi_lmd->lmd_flags & LMD_FLG_SKIP_LFSCK)
m->mdt_skip_lfsck = 1;
}
*/
tgt_grant_discard(exp);
if (exp_connect_flags(exp) & OBD_CONNECT_GRANT)
- exp->exp_obd->u.obt.obt_lut->lut_tgd.tgd_tot_granted_clients--;
+ obd2obt(exp->exp_obd)->obt_lut->lut_tgd.tgd_tot_granted_clients--;
if (!(exp->exp_flags & OBD_OPT_FORCE))
tgt_grant_sanity_check(exp->exp_obd, __func__);
obd_kset.kobj);
return scnprintf(buf, PAGE_SIZE, "%u\n",
- obd->u.obt.obt_lut->lut_local_recovery);
+ obd2obt(obd)->obt_lut->lut_local_recovery);
}
static ssize_t local_recovery_store(struct kobject *kobj,
if (rc)
return rc;
- obd->u.obt.obt_lut->lut_local_recovery = !!val;
+ obd2obt(obd)->obt_lut->lut_local_recovery = !!val;
return count;
}
LUSTRE_RW_ATTR(local_recovery);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *tgt = obd->u.obt.obt_lut;
+ struct lu_target *tgt = obd2obt(obd)->obt_lut;
return scnprintf(buf, PAGE_SIZE, "%d\n",
atomic_read(&tgt->lut_sync_count));
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *tgt = obd->u.obt.obt_lut;
+ struct lu_target *tgt = obd2obt(obd)->obt_lut;
int val;
int rc;
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
return scnprintf(buf, PAGE_SIZE, "%u\n", lut->lut_cksum_t10pi_enforce);
}
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
bool enforce;
int rc;
if (!obd)
return 0;
- lut = obd->u.obt.obt_lut;
-
+ lut = obd2obt(obd)->obt_lut;
/* select fastest checksum type on the server */
pref = obd_cksum_type_select(obd->obd_name,
lut->lut_cksum_types_supported, 0);
if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
lprocfs_counter_add(exp->exp_nid_stats->nid_stats, opcode,
amount);
- if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash &&
+ if (exp->exp_obd && obd2obt(exp->exp_obd)->obt_jobstats.ojs_hash &&
(exp_connect_flags(exp) & OBD_CONNECT_JOBSTATS))
lprocfs_job_stats_log(exp->exp_obd,
lustre_msg_get_jobid(req->rq_reqmsg),
mgs->mgs_obd->obd_name, PTR_ERR(nm_config_file));
GOTO(out_configs, rc = PTR_ERR(nm_config_file));
}
- mgs->mgs_obd->u.obt.obt_nodemap_config_file = nm_config_file;
+ obd2obt(mgs->mgs_obd)->obt_nodemap_config_file = nm_config_file;
/* create directory to store nid table versions */
o = local_file_find_or_create(env, mgs->mgs_los, root, MGS_NIDTBL_DIR,
out_nm:
if (rc < 0) {
nm_config_file_deregister_mgs(env, nm_config_file);
- mgs->mgs_obd->u.obt.obt_nodemap_config_file = NULL;
+ obd2obt(mgs->mgs_obd)->obt_nodemap_config_file = NULL;
}
out_configs:
if (rc < 0) {
dt_object_put(env, mgs->mgs_nidtbl_dir);
mgs->mgs_nidtbl_dir = NULL;
}
- if (mgs->mgs_obd->u.obt.obt_nodemap_config_file != NULL) {
+ if (obd2obt(mgs->mgs_obd)->obt_nodemap_config_file != NULL) {
struct nm_config_file *ncf;
- ncf = mgs->mgs_obd->u.obt.obt_nodemap_config_file;
+ ncf = obd2obt(mgs->mgs_obd)->obt_nodemap_config_file;
nm_config_file_deregister_mgs(env, ncf);
- mgs->mgs_obd->u.obt.obt_nodemap_config_file = NULL;
+ obd2obt(mgs->mgs_obd)->obt_nodemap_config_file = NULL;
}
if (mgs->mgs_los) {
mgs->mgs_obd = obd;
mgs->mgs_obd->obd_lu_dev = &mgs->mgs_dt_dev.dd_lu_dev;
- obd->u.obt.obt_magic = OBT_MAGIC;
- obd->u.obt.obt_instance = 0;
+ obd_obt_init(obd);
/* namespace for mgs llog */
obd->obd_namespace = ldlm_namespace_new(obd ,"MGS",
int lprocfs_job_stats_log(struct obd_device *obd, char *jobid,
int event, long amount)
{
- struct obd_job_stats *stats = &obd->u.obt.obt_jobstats;
+ struct obd_job_stats *stats = &obd2obt(obd)->obt_jobstats;
struct job_stat *job, *job2;
ENTRY;
void lprocfs_job_stats_fini(struct obd_device *obd)
{
- struct obd_job_stats *stats = &obd->u.obt.obt_jobstats;
+ struct obd_job_stats *stats = &obd2obt(obd)->obt_jobstats;
if (stats->ojs_hash == NULL)
return;
obd->obd_name, obd->obd_type->typ_name, -EINVAL);
RETURN(-EINVAL);
}
- stats = &obd->u.obt.obt_jobstats;
+ stats = &obd2obt(obd)->obt_jobstats;
LASSERT(stats->ojs_hash == NULL);
stats->ojs_hash = cfs_hash_create("JOB_STATS",
struct obd_job_stats *stats;
struct timespec64 ts;
- stats = &obd->u.obt.obt_jobstats;
+ stats = &obd2obt(obd)->obt_jobstats;
ts = ktime_to_timespec64(stats->ojs_cleanup_interval);
return scnprintf(buf, PAGE_SIZE, "%lld\n", (long long)ts.tv_sec * 2);
unsigned int val;
int rc;
- stats = &obd->u.obt.obt_jobstats;
+ stats = &obd2obt(obd)->obt_jobstats;
rc = kstrtouint(buffer, 0, &val);
if (rc)
goto out;
}
- tdtd = obd->u.obt.obt_lut->lut_tdtd;
+ tdtd = obd2obt(obd)->obt_lut->lut_tdtd;
if (tdtd && tdtd->tdtd_show_update_logs_retrievers) {
char *buf;
int size = 0;
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct obd_device_target *target = &obd->u.obt;
+ struct obd_device_target *target = obd2obt(obd);
LASSERT(target->obt_magic == OBT_MAGIC);
- return scnprintf(buf, PAGE_SIZE, "%u\n", obd->u.obt.obt_instance);
+ return scnprintf(buf, PAGE_SIZE, "%u\n", obd2obt(obd)->obt_instance);
}
EXPORT_SYMBOL(instance_show);
static u64 echo_next_id(struct obd_device *obd)
{
u64 id;
+ struct echo_obd *echo = obd2echo(obd);
- spin_lock(&obd->u.echo.eo_lock);
- id = ++obd->u.echo.eo_lastino;
- spin_unlock(&obd->u.echo.eo_lock);
+ spin_lock(&echo->eo_lock);
+ id = ++echo->eo_lastino;
+ spin_unlock(&echo->eo_lock);
return id;
}
}
}
- atomic_add(*pages, &obd->u.echo.eo_prep);
+ atomic_add(*pages, &obd2echo(obd)->eo_prep);
if (cmd & OBD_BRW_READ)
lprocfs_counter_add(obd->obd_stats, LPROC_ECHO_READ_BYTES,
tot_bytes);
CDEBUG(D_PAGE, "%d pages allocated after prep\n",
- atomic_read(&obd->u.echo.eo_prep));
+ atomic_read(&obd2echo(obd)->eo_prep));
RETURN(0);
*/
__free_page(res[i].lnb_page);
res[i].lnb_page = NULL;
- atomic_dec(&obd->u.echo.eo_prep);
+ atomic_dec(&obd2echo(obd)->eo_prep);
}
return rc;
}
}
- atomic_sub(pgs, &obd->u.echo.eo_prep);
+ atomic_sub(pgs, &obd2echo(obd)->eo_prep);
CDEBUG(D_PAGE, "%d pages remain after commit\n",
- atomic_read(&obd->u.echo.eo_prep));
+ atomic_read(&obd2echo(obd)->eo_prep));
RETURN(rc);
commitrw_cleanup:
- atomic_sub(pgs, &obd->u.echo.eo_prep);
+ atomic_sub(pgs, &obd2echo(obd)->eo_prep);
CERROR("cleaning up %d pages (%d obdos)\n",
niocount - pgs - 1, objcount);
/* NB see comment above regarding persistent pages */
__free_page(page);
- atomic_dec(&obd->u.echo.eo_prep);
+ atomic_dec(&obd2echo(obd)->eo_prep);
}
return rc;
}
repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY);
- if (ostid_id(&oa->o_oi) > obd->u.echo.eo_lastino ||
+ if (ostid_id(&oa->o_oi) > obd2echo(obd)->eo_lastino ||
ostid_id(&oa->o_oi) < ECHO_INIT_OID) {
CERROR("%s: bad objid to destroy: "DOSTID"\n",
tsi->tsi_exp->exp_obd->obd_name, POSTID(&oa->o_oi));
repbody->oa.o_oi = oa->o_oi;
repbody->oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
- obdo_cpy_md(&repbody->oa, &obd->u.echo.eo_oa, oa->o_valid);
+ obdo_cpy_md(&repbody->oa, &obd2echo(obd)->eo_oa, oa->o_valid);
repbody->oa.o_valid |= OBD_MD_FLFLAGS;
repbody->oa.o_flags = OBD_FL_FLUSH;
repbody->oa.o_oi = body->oa.o_oi;
repbody->oa.o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
- obd->u.echo.eo_oa = body->oa;
+ obd2echo(obd)->eo_oa = body->oa;
RETURN(0);
}
RETURN(-ENODEV);
}
- spin_lock_init(&obd->u.echo.eo_lock);
- obd->u.echo.eo_lastino = ECHO_INIT_OID;
+ spin_lock_init(&obd2echo(obd)->eo_lock);
+ obd2echo(obd)->eo_lastino = ECHO_INIT_OID;
esd->esd_dev.ld_ops = &echo_srv_lu_ops;
esd->esd_dev.ld_obd = obd;
lprocfs_obd_cleanup(obd);
lprocfs_free_obd_stats(obd);
- leaked = atomic_read(&obd->u.echo.eo_prep);
+ leaked = atomic_read(&obd2echo(obd)->eo_prep);
if (leaked != 0)
CERROR("%d prep/commitrw pages leaked\n", leaked);
if (!obd)
return 0;
- lut = obd->u.obt.obt_lut;
-
+ lut = obd2obt(obd)->obt_lut;
/* select fastest checksum type on the server */
pref = obd_cksum_type_select(obd->obd_name,
lut->lut_cksum_types_supported, 0);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
return scnprintf(buf, PAGE_SIZE, "%u\n", lut->lut_cksum_t10pi_enforce);
}
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
bool enforce;
int rc;
if (rc != 0)
RETURN(rc);
- obt = &obd->u.obt;
- obt->obt_magic = OBT_MAGIC;
+ obt = obd_obt_init(obd);
spin_lock_init(&m->ofd_flags_lock);
m->ofd_raid_degraded = 0;
ofd_stop_inconsistency_verification_thread(m);
lfsck_degister(env, m->ofd_osd);
ofd_fs_cleanup(env, m);
- nm_config_file_deregister_tgt(env, obd->u.obt.obt_nodemap_config_file);
- obd->u.obt.obt_nodemap_config_file = NULL;
+ nm_config_file_deregister_tgt(env,
+ obd2obt(obd)->obt_nodemap_config_file);
+ obd2obt(obd)->obt_nodemap_config_file = NULL;
if (m->ofd_namespace != NULL) {
ldlm_namespace_free_post(m->ofd_namespace);
if (exp->exp_obd && exp->exp_obd->obd_stats)
lprocfs_counter_add(exp->exp_obd->obd_stats, opcode, amount);
- if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash &&
+ if (exp->exp_obd && obd2obt(exp->exp_obd)->obt_jobstats.ojs_hash &&
(exp_connect_flags(exp) & OBD_CONNECT_JOBSTATS))
lprocfs_job_stats_log(exp->exp_obd, jobid, opcode, amount);
static int ost_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
static struct ptlrpc_service_conf svc_conf;
- struct ost_obd *ost = &obd->u.ost;
+ struct ost_obd *ost = obd2ost(obd);
nodemask_t *mask;
int rc;
static int ost_cleanup(struct obd_device *obd)
{
- struct ost_obd *ost = &obd->u.ost;
+ struct ost_obd *ost = obd2ost(obd);
int err = 0;
ENTRY;
static int ost_health_check(const struct lu_env *env, struct obd_device *obd)
{
- struct ost_obd *ost = &obd->u.ost;
+ struct ost_obd *ost = obd2ost(obd);
int rc = 0;
mutex_lock(&ost->ost_health_mutex);
nodemap_ii.ii_attrs = body->mcb_nm_cur_pass;
bytes = nodemap_index_read(req->rq_svc_thread->t_env,
- mgs_obd->u.obt.obt_nodemap_config_file,
+ obd2obt(mgs_obd)->obt_nodemap_config_file,
&nodemap_ii, &rdpg);
if (bytes < 0)
GOTO(out, rc = bytes);
*/
#include <obd.h>
+#include <dt_object.h>
#include <lustre_quota.h>
#ifndef _LQUOTA_INTERNAL_H
struct tgt_fmd_data *keep)
{
struct tg_export_data *ted = &exp->exp_target_data;
- struct lu_target *lut = exp->exp_obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(exp->exp_obd)->obt_lut;
time64_t now = ktime_get_seconds();
struct tgt_fmd_data *fmd, *tmp;
{
struct tg_export_data *ted = &exp->exp_target_data;
struct tgt_fmd_data *found = NULL, *fmd;
- struct lu_target *lut = exp->exp_obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(exp->exp_obd)->obt_lut;
time64_t now = ktime_get_seconds();
assert_spin_locked(&ted->ted_fmd_lock);
*/
void tgt_grant_sanity_check(struct obd_device *obd, const char *func)
{
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
struct obd_export *exp;
struct tg_export_data *ted;
int force, int *from_cache)
{
struct obd_device *obd = exp->exp_obd;
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
struct tgt_thread_info *tti;
struct obd_statfs *osfs;
static u64 tgt_grant_space_left(struct obd_export *exp)
{
struct obd_device *obd = exp->exp_obd;
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
u64 tot_granted;
u64 left;
{
struct tg_export_data *ted = &exp->exp_target_data;
struct obd_device *obd = exp->exp_obd;
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(obd)->obt_lut->lut_tgd;
long long dirty, dropped;
ENTRY;
{
struct tg_export_data *ted = &exp->exp_target_data;
struct obd_device *obd = exp->exp_obd;
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(obd)->obt_lut->lut_tgd;
long grant_shrink;
assert_spin_locked(&tgd->tgd_grant_lock);
{
struct tg_export_data *ted = &exp->exp_target_data;
struct obd_device *obd = exp->exp_obd;
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
unsigned long ungranted = 0;
unsigned long granted = 0;
bool conservative)
{
struct obd_device *obd = exp->exp_obd;
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(obd)->obt_lut->lut_tgd;
struct tg_export_data *ted = &exp->exp_target_data;
u64 grant;
void tgt_grant_connect(const struct lu_env *env, struct obd_export *exp,
struct obd_connect_data *data, bool new_conn)
{
- struct lu_target *lut = exp->exp_obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(exp->exp_obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
struct tg_export_data *ted = &exp->exp_target_data;
u64 left = 0;
void tgt_grant_prepare_read(const struct lu_env *env,
struct obd_export *exp, struct obdo *oa)
{
- struct lu_target *lut = exp->exp_obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(exp->exp_obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
int do_shrink;
u64 left = 0;
struct niobuf_remote *rnb, int niocount)
{
struct obd_device *obd = exp->exp_obd;
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
u64 left;
int from_cache;
*/
long tgt_grant_create(const struct lu_env *env, struct obd_export *exp, s64 *nr)
{
- struct lu_target *lut = exp->exp_obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(exp->exp_obd)->obt_lut;
struct tg_grants_data *tgd = &lut->lut_tgd;
struct tg_export_data *ted = &exp->exp_target_data;
u64 left = 0;
void tgt_grant_commit(struct obd_export *exp, unsigned long pending,
int rc)
{
- struct tg_grants_data *tgd = &exp->exp_obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(exp->exp_obd)->obt_lut->lut_tgd;
ENTRY;
obd_kset.kobj);
struct tg_grants_data *tgd;
- tgd = &obd->u.obt.obt_lut->lut_tgd;
+ tgd = &obd2obt(obd)->obt_lut->lut_tgd;
return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_dirty);
}
EXPORT_SYMBOL(tot_dirty_show);
obd_kset.kobj);
struct tg_grants_data *tgd;
- tgd = &obd->u.obt.obt_lut->lut_tgd;
+ tgd = &obd2obt(obd)->obt_lut->lut_tgd;
return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_granted);
}
EXPORT_SYMBOL(tot_granted_show);
obd_kset.kobj);
struct tg_grants_data *tgd;
- tgd = &obd->u.obt.obt_lut->lut_tgd;
+ tgd = &obd2obt(obd)->obt_lut->lut_tgd;
return scnprintf(buf, PAGE_SIZE, "%llu\n", tgd->tgd_tot_pending);
}
EXPORT_SYMBOL(tot_pending_show);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(obd)->obt_lut->lut_tgd;
return scnprintf(buf, PAGE_SIZE, "%u\n", tgd->tgd_grant_compat_disable);
}
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ struct tg_grants_data *tgd = &obd2obt(obd)->obt_lut->lut_tgd;
bool val;
int rc;
/* Target may have been freed (see LU-7430)
* Slot may be not yet assigned */
- if (exp->exp_obd->u.obt.obt_magic != OBT_MAGIC ||
+ if (((struct obd_device_target *)(&exp->exp_obd->u))->obt_magic !=
+ OBT_MAGIC ||
ted->ted_lr_idx < 0)
return;
CDEBUG(D_SUPER,
"%s: mount_count is %llu, last_transno is %llu\n",
- tgt->lut_lsd.lsd_uuid, tgt->lut_obd->u.obt.obt_mount_count,
+ tgt->lut_lsd.lsd_uuid, obd2obt(tgt->lut_obd)->obt_mount_count,
tgt->lut_last_transno);
/* Always save latest transno to keep it fresh */
tgt->lut_obd->obd_last_committed = tgt->lut_last_transno;
spin_unlock(&tgt->lut_translock);
- tgt->lut_obd->u.obt.obt_mount_count = lsd->lsd_mount_count;
- tgt->lut_obd->u.obt.obt_instance = (__u32)lsd->lsd_mount_count;
+ obd2obt(tgt->lut_obd)->obt_mount_count = lsd->lsd_mount_count;
+ obd2obt(tgt->lut_obd)->obt_instance = (__u32)lsd->lsd_mount_count;
/* save it, so mount count and last_transno is current */
rc = tgt_server_data_update(env, tgt, 0);
#define DEBUG_SUBSYSTEM S_CLASS
#include <obd.h>
+#include <obd_target.h>
#include <obd_cksum.h>
#include "tgt_internal.h"
#include "../ptlrpc/ptlrpc_internal.h"
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *tgt = obd->u.obt.obt_lut;
+ struct lu_target *tgt = obd2obt(obd)->obt_lut;
return sprintf(buf, "%s\n",
sync_lock_cancel_states[tgt->lut_sync_lock_cancel]);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *tgt = obd->u.obt.obt_lut;
+ struct lu_target *tgt = obd2obt(obd)->obt_lut;
int val = -1;
enum tgt_sync_lock_cancel slc;
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
return sprintf(buf, "%u\n", lut->lut_fmd_max_num);
}
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
int val, rc;
rc = kstrtoint(buffer, 0, &val);
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
return sprintf(buf, "%lld\n", lut->lut_fmd_max_age);
}
{
struct obd_device *obd = container_of(kobj, struct obd_device,
obd_kset.kobj);
- struct lu_target *lut = obd->u.obt.obt_lut;
+ struct lu_target *lut = obd2obt(obd)->obt_lut;
time64_t val;
int rc;
struct dt_object *o;
struct tg_grants_data *tgd = &lut->lut_tgd;
struct obd_statfs *osfs;
+ struct obd_device_target *obt;
int i, rc = 0;
ENTRY;
atomic_set(&lut->lut_client_generation, 0);
lut->lut_reply_data = NULL;
lut->lut_reply_bitmap = NULL;
- obd->u.obt.obt_lut = lut;
- obd->u.obt.obt_magic = OBT_MAGIC;
+ obt = obd_obt_init(obd);
+ obt->obt_lut = lut;
/* set request handler slice and parameters */
lut->lut_slice = slice;
out:
dt_txn_callback_del(lut->lut_bottom, &lut->lut_txn_cb);
out_put:
- obd->u.obt.obt_magic = 0;
- obd->u.obt.obt_lut = NULL;
+ obd2obt(obd)->obt_lut = NULL;
+ obd2obt(obd)->obt_magic = 0;
if (lut->lut_last_rcvd != NULL) {
dt_object_put(env, lut->lut_last_rcvd);
lut->lut_last_rcvd = NULL;
if (rc < 0)
GOTO(out, rc);
- mti->mti_instance = obd->u.obt.obt_instance;
+ mti->mti_instance = obd2obt(obd)->obt_instance;
mti->mti_flags |= LDD_F_OPC_READY;
/* FIXME use mgc_process_config instead */