From d2e9b10f49712ca19a827587574d2ae46d92e166 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 13 Apr 2009 11:13:11 +0000 Subject: [PATCH] - introduction of lu_target in ofd --- lustre/ofd/ofd_clients.c | 4 ---- lustre/ofd/ofd_dev.c | 13 ++++++++++--- lustre/ofd/ofd_fs.c | 39 +++++++-------------------------------- lustre/ofd/ofd_grant.c | 1 - lustre/ofd/ofd_internal.h | 12 +++++++----- lustre/ofd/ofd_objects.c | 4 +--- lustre/ofd/ofd_recovery.c | 21 --------------------- 7 files changed, 25 insertions(+), 69 deletions(-) diff --git a/lustre/ofd/ofd_clients.c b/lustre/ofd/ofd_clients.c index 18e0229..7a2e0af 100644 --- a/lustre/ofd/ofd_clients.c +++ b/lustre/ofd/ofd_clients.c @@ -82,7 +82,6 @@ repeat: fed->fed_lr_idx = cl_idx; fed->fed_lr_off = ofd->ofd_fsd.lsd_client_start + cl_idx * ofd->ofd_fsd.lsd_client_size; - init_mutex(&fed->fed_lastrcvd_lock); LASSERTF(fed->fed_lr_off > 0, "fed_lr_off = %llu\n", fed->fed_lr_off); CDEBUG(D_INFO, "client at index %d (%llu) with UUID '%s' added\n", @@ -146,7 +145,6 @@ int filter_client_add(const struct lu_env *env, struct filter_device *ofd, fed->fed_lr_idx = cl_idx; fed->fed_lr_off = ofd->ofd_fsd.lsd_client_start + cl_idx * ofd->ofd_fsd.lsd_client_size; - init_mutex(&fed->fed_lastrcvd_lock); LASSERTF(fed->fed_lr_off > 0, "fed_lr_off = %llu\n", fed->fed_lr_off); CDEBUG(D_INFO, "client at index %d (%llu) with UUID '%s' added\n", @@ -200,12 +198,10 @@ int filter_client_free(struct lu_env *env, struct obd_export *exp) rc = filter_trans_start(env, ofd, th); if (rc) GOTO(free, rc); - mutex_down(&fed->fed_lastrcvd_lock); memset(lcd, 0, sizeof(*lcd)); /* off is changed after write, use tmp value */ off = fed->fed_lr_off; rc = filter_last_rcvd_write(env, ofd, lcd, &off, th); - mutex_up(&fed->fed_lastrcvd_lock); LASSERT(rc == 0); /* update server's transno */ diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index f895899..f05cfa2 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -616,7 +616,7 @@ static int filter_init0(const struct lu_env *env, struct filter_device *m, } spin_lock_init(&m->ofd_transno_lock); - spin_lock_init(&m->ofd_client_bitmap_lock); + //spin_lock_init(&m->ofd_client_bitmap_lock); m->ofd_fmd_max_num = FILTER_FMD_MAX_NUM_DEFAULT; m->ofd_fmd_max_age = FILTER_FMD_MAX_AGE_DEFAULT; @@ -718,10 +718,14 @@ static int filter_init0(const struct lu_env *env, struct filter_device *m, if (rc) GOTO(err_free_ns, rc); + rc = lut_init(env, &m->ofd_lut, obd, NULL); + if (rc) + GOTO(err_fs_cleanup, rc); + rc = obd_llog_init(obd, &obd->obd_olg, obd, 1, NULL, NULL); if (rc) { CERROR("failed to setup llogging subsystems\n"); - GOTO(err_fs_cleanup, rc); + GOTO(err_lut_fini, rc); } @@ -733,7 +737,7 @@ static int filter_init0(const struct lu_env *env, struct filter_device *m, LASSERT(rc == 0); #endif - target_recovery_init(obd, ost_handle); + target_recovery_init(&m->ofd_lut, ost_handle); rc = lu_site_init_finish(s); if (rc) @@ -750,6 +754,8 @@ static int filter_init0(const struct lu_env *env, struct filter_device *m, err_fs_cleanup: target_recovery_fini(obd); filter_fs_cleanup(env, m); +err_lut_fini: + lut_fini(env, &m->ofd_lut); err_free_ns: ldlm_namespace_free(m->ofd_namespace, 0, obd->obd_force); obd->obd_namespace = m->ofd_namespace = NULL; @@ -799,6 +805,7 @@ static void filter_fini(const struct lu_env *env, struct filter_device *m) #endif obd_zombie_barrier(); + lut_fini(env, &m->ofd_lut); filter_fs_cleanup(env, m); if (m->ofd_namespace != NULL) { diff --git a/lustre/ofd/ofd_fs.c b/lustre/ofd/ofd_fs.c index d4038c4..1c99273 100644 --- a/lustre/ofd/ofd_fs.c +++ b/lustre/ofd/ofd_fs.c @@ -84,7 +84,7 @@ int filter_last_id_read(const struct lu_env *env, struct filter_device *ofd, buf.lb_len = sizeof(tmp); off = group * sizeof(tmp); - rc = dt_record_read(env, ofd->ofd_groups_file, &buf, &off, NULL); + rc = dt_record_read(env, ofd->ofd_groups_file, &buf, &off); if (rc >= 0) { filter_last_id_set(ofd, le64_to_cpu(tmp), group); CDEBUG(D_INODE, "%s: read last_objid for group "LPU64": " @@ -126,8 +126,7 @@ int filter_last_id_write(const struct lu_env *env, struct filter_device *ofd, if (rc) RETURN(rc); - rc = dt_record_write(env, ofd->ofd_groups_file, &buf, &off, - th, BYPASS_CAPA, 1); + rc = dt_record_write(env, ofd->ofd_groups_file, &buf, &off, th); if (rc) CERROR("write group "LPU64" last objid: rc = %d\n", group, rc); @@ -171,7 +170,7 @@ int filter_groups_init(const struct lu_env *env, struct filter_device *ofd) off = 0; buf.lb_buf = &ofd->ofd_last_objids; buf.lb_len = sizeof(lastid) * ofd->ofd_max_group; - rc = dt_record_read(env, ofd->ofd_groups_file, &buf, &off, NULL); + rc = dt_record_read(env, ofd->ofd_groups_file, &buf, &off); if (rc) { CERROR("can't initialize last_ids: %d\n", rc); RETURN(rc); @@ -231,28 +230,6 @@ static inline void fsd_cpu_to_le(struct lr_server_data *lsd, buf->lsd_mdt_index = cpu_to_le32(lsd->lsd_mdt_index); } -static inline void lcd_le_to_cpu(struct lsd_client_data *buf, - struct lsd_client_data *lcd) -{ - memcpy(lcd->lcd_uuid, buf->lcd_uuid, sizeof (lcd->lcd_uuid)); - lcd->lcd_last_transno = le64_to_cpu(buf->lcd_last_transno); - lcd->lcd_last_xid = le64_to_cpu(buf->lcd_last_xid); -#if 0 - lcd->lcd_group = le32_to_cpu(buf->lcd_group); -#endif -} - -static inline void lcd_cpu_to_le(struct lsd_client_data *lcd, - struct lsd_client_data *buf) -{ - memcpy(buf->lcd_uuid, lcd->lcd_uuid, sizeof (lcd->lcd_uuid)); - buf->lcd_last_transno = cpu_to_le64(lcd->lcd_last_transno); - buf->lcd_last_xid = cpu_to_le64(lcd->lcd_last_xid); -#if 0 - buf->lcd_group = cpu_to_le32(lcd->lcd_group); -#endif -} - static int filter_last_rcvd_header_read(const struct lu_env *env, struct filter_device *ofd) { @@ -265,7 +242,7 @@ static int filter_last_rcvd_header_read(const struct lu_env *env, buf.lb_buf = &info->fti_fsd; buf.lb_len = sizeof(info->fti_fsd); - rc = dt_record_read(env, ofd->ofd_last_rcvd, &buf, &off, BYPASS_CAPA); + rc = dt_record_read(env, ofd->ofd_last_rcvd, &buf, &off); if (rc == 0) fsd_le_to_cpu(&info->fti_fsd, &ofd->ofd_fsd); return rc; @@ -290,8 +267,7 @@ int filter_last_rcvd_header_write(const struct lu_env *env, fsd_cpu_to_le(&ofd->ofd_fsd, &info->fti_fsd); - rc = dt_record_write(env, ofd->ofd_last_rcvd, &buf, - &off, th, BYPASS_CAPA, 1); + rc = dt_record_write(env, ofd->ofd_last_rcvd, &buf, &off, th); CDEBUG(D_INFO, "write last_rcvd header rc = %d:\n" "uuid = %s\nlast_transno = "LPU64"\n", rc, ofd->ofd_fsd.lsd_uuid, ofd->ofd_fsd.lsd_last_transno); @@ -310,7 +286,7 @@ static int filter_last_rcvd_read(const struct lu_env *env, buf.lb_buf = &info->fti_fsd; buf.lb_len = sizeof(info->fti_fsd); - rc = dt_record_read(env, ofd->ofd_last_rcvd, &buf, off, BYPASS_CAPA); + rc = dt_record_read(env, ofd->ofd_last_rcvd, &buf, off); if (rc == 0) lcd_le_to_cpu((struct lsd_client_data *) &info->fti_fsd, lcd); return rc; @@ -330,8 +306,7 @@ int filter_last_rcvd_write(const struct lu_env *env, buf.lb_buf = &info->fti_fsd; buf.lb_len = sizeof(info->fti_fsd); - rc = dt_record_write(env, ofd->ofd_last_rcvd, &buf, - off, th, BYPASS_CAPA, 1); + rc = dt_record_write(env, ofd->ofd_last_rcvd, &buf, off, th); return rc; } diff --git a/lustre/ofd/ofd_grant.c b/lustre/ofd/ofd_grant.c index 8a5dd51..0b2f54f 100644 --- a/lustre/ofd/ofd_grant.c +++ b/lustre/ofd/ofd_grant.c @@ -470,7 +470,6 @@ long _filter_grant(const struct lu_env *env, struct obd_export *exp, #if 0 grant = (min(want, fs_space_left >> 3) / frsize) * frsize; #else - CERROR("not implemented yet\n"); grant = min(want, fs_space_left >> 3); #endif if (grant) { diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 4ee393c..3c29493 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -8,10 +8,11 @@ #ifdef __KERNEL__ # include #endif +#include #include #include -#include #include +#include #include #include #include @@ -136,10 +137,8 @@ struct filter_device { __u64 ofd_last_transno; /* last_rcvd file */ - struct dt_object *ofd_last_rcvd; + struct lu_target ofd_lut; struct dt_object *ofd_groups_file; - struct lr_server_data ofd_fsd; - spinlock_t ofd_client_bitmap_lock; unsigned long *ofd_last_rcvd_slots; int ofd_subdir_count; @@ -176,6 +175,9 @@ struct filter_device { struct hlist_head *ofd_capa_hash; }; +#define ofd_last_rcvd ofd_lut.lut_last_rcvd +#define ofd_fsd ofd_lut.lut_lsd + static inline struct filter_device *filter_dev(struct lu_device *d) { return container_of0(d, struct filter_device, ofd_dt_dev.dd_lu_dev); @@ -345,7 +347,7 @@ static inline void filter_trans_add_cb(const struct thandle *th, extern void target_recovery_fini(struct obd_device *obd); -extern void target_recovery_init(struct obd_device *obd, +extern void target_recovery_init(struct lu_target *lut, svc_handler_t handler); static inline int filter_export_stats_init(struct filter_device *ofd, diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index f3c83a5..e273b76 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -192,14 +192,12 @@ int filter_precreate_object(const struct lu_env *env, struct filter_device *ofd, filter_last_id_set(ofd, id, group); tmp = cpu_to_le64(filter_last_id(ofd, group)); - rc = dt_record_write(env, ofd->ofd_groups_file, &buf, &off, - th, BYPASS_CAPA, 1); + rc = dt_record_write(env, ofd->ofd_groups_file, &buf, &off, th); out_unlock: filter_write_unlock(env, fo); trans_stop: filter_trans_stop(env, ofd, th); -out: filter_object_put(env, fo); RETURN(rc); } diff --git a/lustre/ofd/ofd_recovery.c b/lustre/ofd/ofd_recovery.c index 24060f7..6f9e45c 100644 --- a/lustre/ofd/ofd_recovery.c +++ b/lustre/ofd/ofd_recovery.c @@ -141,8 +141,6 @@ static int filter_last_rcvd_update(struct filter_thread_info *info, LASSERT(lcd); off = fed->fed_lr_off; - mutex_down(&fed->fed_lastrcvd_lock); - transno_p = &lcd->lcd_last_transno; lcd->lcd_last_xid = info->fti_xid; @@ -164,7 +162,6 @@ static int filter_last_rcvd_update(struct filter_thread_info *info, LASSERT(fed->fed_lr_off > 0); err = filter_last_rcvd_write(info->fti_env, ofd, lcd, &off, th); - mutex_up(&fed->fed_lastrcvd_lock); RETURN(err); } @@ -237,25 +234,11 @@ static int filter_txn_commit_cb(const struct lu_env *env, struct thandle *txn, void *cookie) { struct filter_device *ofd = cookie; - struct obd_device *obd = filter_obd(ofd); struct filter_txn_info *txi; int i; txi = lu_context_key_get(&txn->th_ctx, &filter_txn_thread_key); - /* copy of obd_transno_commit_cb() but with locking */ - spin_lock(&ofd->ofd_transno_lock); - if (txi->txi_transno > obd->obd_last_committed) { - obd->obd_last_committed = txi->txi_transno; - spin_unlock(&ofd->ofd_transno_lock); - ptlrpc_commit_replies(obd); - } else - spin_unlock(&ofd->ofd_transno_lock); - - if (txi->txi_transno) - CDEBUG(D_HA, "%s: transno "LPD64" is committed\n", - obd->obd_name, txi->txi_transno); - /* iterate through all additional callbacks */ for (i = 0; i < txi->txi_cb_count; i++) { txi->txi_cb[i].filter_cb_func(ofd, txi->txi_transno, @@ -339,10 +322,6 @@ void filter_fs_cleanup(const struct lu_env *env, struct filter_device *ofd) /* Remove transaction callback */ dt_txn_callback_del(ofd->ofd_osd, &ofd->ofd_txn_cb); - if (ofd->ofd_last_rcvd) - lu_object_put(env, &ofd->ofd_last_rcvd->do_lu); - ofd->ofd_last_rcvd = NULL; - if (ofd->ofd_groups_file) lu_object_put(env, &ofd->ofd_groups_file->do_lu); ofd->ofd_groups_file = NULL; -- 1.8.3.1