From 6459fa2b458612b5213b3b70839e340efff7aebc Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Thu, 31 Jan 2019 16:15:28 +0300 Subject: [PATCH] LU-10496 ofd: move FMD to the target code - make FMD structures common for all targets - adapt FMD functionality to be isolated from OFD for further move to the target code. Signed-off-by: Mikhail Pershin Change-Id: I9f67f14e4132205cca67aa778b990bb3b45c30be Reviewed-on: https://review.whamcloud.com/34176 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev --- lustre/include/lu_target.h | 13 +++ lustre/include/lustre_export.h | 10 ++- lustre/ofd/lproc_ofd.c | 16 ++-- lustre/ofd/ofd_dev.c | 17 ++-- lustre/ofd/ofd_fmd.c | 191 ++++++++++++++++++++++------------------- lustre/ofd/ofd_internal.h | 21 +---- lustre/ofd/ofd_io.c | 21 ++--- lustre/ofd/ofd_obd.c | 6 +- lustre/ofd/ofd_objects.c | 45 ++++------ lustre/target/tgt_internal.h | 1 + lustre/target/tgt_main.c | 7 +- 11 files changed, 172 insertions(+), 176 deletions(-) diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index c698a8f..4ba3fe1 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -204,8 +204,15 @@ struct lu_target { /* target grants fields */ struct tg_grants_data lut_tgd; + + /* FMD (file modification data) values */ + int lut_fmd_max_num; + time64_t lut_fmd_max_age; }; +#define LUT_FMD_MAX_NUM_DEFAULT 128 +#define LUT_FMD_MAX_AGE_DEFAULT (obd_timeout + 10) + /* number of slots in reply bitmap */ #define LUT_REPLY_SLOTS_PER_CHUNK (1<<20) #define LUT_REPLY_SLOTS_MAX_CHUNKS 16 @@ -530,6 +537,12 @@ ssize_t tgt_grant_compat_disable_seq_write(struct file *file, const char __user *buffer, size_t count, loff_t *off); +/* FMD */ +void tgt_fmd_update(struct obd_export *exp, const struct lu_fid *fid, + __u64 xid); +bool tgt_fmd_check(struct obd_export *exp, const struct lu_fid *fid, + __u64 xid); + /* target/update_trans.c */ int distribute_txn_init(const struct lu_env *env, struct lu_target *lut, diff --git a/lustre/include/lustre_export.h b/lustre/include/lustre_export.h index 58f2764..50c427b 100644 --- a/lustre/include/lustre_export.h +++ b/lustre/include/lustre_export.h @@ -101,6 +101,13 @@ struct tg_export_data { long ted_grant; /* in bytes */ long ted_pending; /* bytes just being written */ __u8 ted_pagebits; /* log2 of client page size */ + + /** + * File Modification Data (FMD) tracking + */ + spinlock_t ted_fmd_lock; /* protects ted_fmd_list */ + struct list_head ted_fmd_list; /* FIDs being modified */ + int ted_fmd_count;/* items in ted_fmd_list */ }; /** @@ -121,13 +128,10 @@ struct ec_export_data { /* echo client */ /** Filter (oss-side) specific import data */ struct filter_export_data { struct tg_export_data fed_ted; - spinlock_t fed_lock; /**< protects fed_mod_list */ __u64 fed_lastid_gen; - struct list_head fed_mod_list; /* files being modified */ /* count of SOFT_SYNC RPCs, which will be reset after * ofd_soft_sync_limit number of RPCs, and trigger a sync. */ atomic_t fed_soft_sync_count; - int fed_mod_count;/* items in fed_writing list */ __u32 fed_group; }; diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index bd07ca9..d3905fd 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -197,9 +197,9 @@ static ssize_t client_cache_count_show(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); - struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_target *lut = obd->u.obt.obt_lut; - return sprintf(buf, "%u\n", ofd->ofd_fmd_max_num); + return sprintf(buf, "%u\n", lut->lut_fmd_max_num); } /** @@ -221,7 +221,7 @@ static ssize_t client_cache_count_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); - struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_target *lut = obd->u.obt.obt_lut; int val; int rc; @@ -232,7 +232,7 @@ static ssize_t client_cache_count_store(struct kobject *kobj, if (val < 1 || val > 65536) return -EINVAL; - ofd->ofd_fmd_max_num = val; + lut->lut_fmd_max_num = val; return count; } LUSTRE_RW_ATTR(client_cache_count); @@ -252,9 +252,9 @@ static ssize_t client_cache_seconds_show(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); - struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_target *lut = obd->u.obt.obt_lut; - return sprintf(buf, "%lld\n", ofd->ofd_fmd_max_age); + return sprintf(buf, "%lld\n", lut->lut_fmd_max_age); } /** @@ -276,7 +276,7 @@ static ssize_t client_cache_seconds_store(struct kobject *kobj, { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); - struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_target *lut = obd->u.obt.obt_lut; time64_t val; int rc; @@ -287,7 +287,7 @@ static ssize_t client_cache_seconds_store(struct kobject *kobj, if (val < 1 || val > 65536) /* ~ 18 hour max */ return -EINVAL; - ofd->ofd_fmd_max_age = val; + lut->lut_fmd_max_age = val; return count; } LUSTRE_RW_ATTR(client_cache_seconds); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index af33796..8eead96 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -82,6 +82,7 @@ /* Slab for OFD object allocation */ static struct kmem_cache *ofd_object_kmem; +struct kmem_cache *tgt_fmd_kmem; static struct lu_kmem_descr ofd_caches[] = { { @@ -90,6 +91,11 @@ static struct lu_kmem_descr ofd_caches[] = { .ckd_size = sizeof(struct ofd_object) }, { + .ckd_cache = &tgt_fmd_kmem, + .ckd_name = "ll_fmd_cache", + .ckd_size = sizeof(struct tgt_fmd_data) + }, + { .ckd_cache = NULL } }; @@ -2850,9 +2856,6 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m, obt = &obd->u.obt; obt->obt_magic = OBT_MAGIC; - m->ofd_fmd_max_num = OFD_FMD_MAX_NUM_DEFAULT; - m->ofd_fmd_max_age = OFD_FMD_MAX_AGE_DEFAULT; - spin_lock_init(&m->ofd_flags_lock); m->ofd_raid_degraded = 0; m->ofd_checksum_t10pi_enforce = 0; @@ -3149,13 +3152,6 @@ static int __init ofd_init(void) rc = lu_kmem_init(ofd_caches); if (rc) return rc; - - rc = ofd_fmd_init(); - if (rc) { - lu_kmem_fini(ofd_caches); - return(rc); - } - rc = class_register_type(&ofd_obd_ops, NULL, true, NULL, LUSTRE_OST_NAME, &ofd_device_type); return rc; @@ -3169,7 +3165,6 @@ static int __init ofd_init(void) */ static void __exit ofd_exit(void) { - ofd_fmd_exit(); lu_kmem_fini(ofd_caches); class_unregister_type(LUSTRE_OST_NAME); } diff --git a/lustre/ofd/ofd_fmd.c b/lustre/ofd/ofd_fmd.c index 859f894..8c8e263 100644 --- a/lustre/ofd/ofd_fmd.c +++ b/lustre/ofd/ofd_fmd.c @@ -50,47 +50,40 @@ #include "ofd_internal.h" -static struct kmem_cache *ll_fmd_cachep; - /** * Drop FMD reference and free it if reference drops to zero. * - * Must be called with fed_lock held. + * Must be called with ted_fmd_lock held. * * \param[in] exp OBD export * \param[in] fmd FMD to put */ static inline void ofd_fmd_put_nolock(struct obd_export *exp, - struct ofd_mod_data *fmd) + struct tgt_fmd_data *fmd) { - struct filter_export_data *fed = &exp->exp_filter_data; + struct tg_export_data *ted = &exp->exp_target_data; - assert_spin_locked(&fed->fed_lock); + assert_spin_locked(&ted->ted_fmd_lock); if (--fmd->fmd_refcount == 0) { - /* XXX when we have persistent reservations and the handle - * is stored herein we need to drop it here. */ - fed->fed_mod_count--; + ted->ted_fmd_count--; list_del(&fmd->fmd_list); - OBD_SLAB_FREE(fmd, ll_fmd_cachep, sizeof(*fmd)); + OBD_SLAB_FREE_PTR(fmd, tgt_fmd_kmem); } } /** - * Wrapper to drop FMD reference with fed_lock held. + * Wrapper to drop FMD reference with ted_fmd_lock held. * * \param[in] exp OBD export * \param[in] fmd FMD to put */ -void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd) +void ofd_fmd_put(struct obd_export *exp, struct tgt_fmd_data *fmd) { - struct filter_export_data *fed = &exp->exp_filter_data; - - if (fmd == NULL) - return; + struct tg_export_data *ted = &exp->exp_target_data; - spin_lock(&fed->fed_lock); + spin_lock(&ted->ted_fmd_lock); ofd_fmd_put_nolock(exp, fmd); /* caller reference */ - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); } /** @@ -99,7 +92,7 @@ void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd) * Expire entries from the FMD list if there are too many * of them or they are too old. * - * This function must be called with fed_lock held. + * This function must be called with ted_fmd_lock held. * * The \a keep FMD is not to be expired in any case. This parameter is used * by ofd_fmd_find_nolock() to prohibit a FMD that was just found from @@ -109,19 +102,19 @@ void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd) * \param[in] keep FMD to keep always */ static void ofd_fmd_expire_nolock(struct obd_export *exp, - struct ofd_mod_data *keep) + struct tgt_fmd_data *keep) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_device *ofd = ofd_exp(exp); + struct tg_export_data *ted = &exp->exp_target_data; + struct lu_target *lut = exp->exp_obd->u.obt.obt_lut; time64_t now = ktime_get_seconds(); - struct ofd_mod_data *fmd, *tmp; + struct tgt_fmd_data *fmd, *tmp; - list_for_each_entry_safe(fmd, tmp, &fed->fed_mod_list, fmd_list) { + list_for_each_entry_safe(fmd, tmp, &ted->ted_fmd_list, fmd_list) { if (fmd == keep) break; if (now < fmd->fmd_expire && - fed->fed_mod_count < ofd->ofd_fmd_max_num) + ted->ted_fmd_count < lut->lut_fmd_max_num) break; list_del_init(&fmd->fmd_list); @@ -138,42 +131,41 @@ static void ofd_fmd_expire_nolock(struct obd_export *exp, */ void ofd_fmd_expire(struct obd_export *exp) { - struct filter_export_data *fed = &exp->exp_filter_data; + struct tg_export_data *ted = &exp->exp_target_data; - spin_lock(&fed->fed_lock); + spin_lock(&ted->ted_fmd_lock); ofd_fmd_expire_nolock(exp, NULL); - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); } /** * Find FMD by specified FID. * - * Function finds FMD entry by FID in the filter_export_data::fed_fmd_list. + * Function finds FMD entry by FID in the tg_export_data::ted_fmd_list. * - * Caller must hold filter_export_data::fed_lock and take FMD reference. + * Caller must hold tg_export_data::ted_fmd_lock and take FMD reference. * * \param[in] exp OBD export * \param[in] fid FID of FMD to find * - * \retval struct ofd_mod_data found by FID + * \retval struct tgt_fmd_data found by FID * \retval NULL is FMD is not found */ -static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp, +static struct tgt_fmd_data *ofd_fmd_find_nolock(struct obd_export *exp, const struct lu_fid *fid) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_mod_data *found = NULL, *fmd; - struct ofd_device *ofd = ofd_exp(exp); - time64_t now = ktime_get_seconds(); + 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; - assert_spin_locked(&fed->fed_lock); + assert_spin_locked(&ted->ted_fmd_lock); - list_for_each_entry_reverse(fmd, &fed->fed_mod_list, fmd_list) { + list_for_each_entry_reverse(fmd, &ted->ted_fmd_list, fmd_list) { if (lu_fid_eq(&fmd->fmd_fid, fid)) { found = fmd; - list_del(&fmd->fmd_list); - list_add_tail(&fmd->fmd_list, &fed->fed_mod_list); - fmd->fmd_expire = now + ofd->ofd_fmd_max_age; + list_move_tail(&fmd->fmd_list, &ted->ted_fmd_list); + fmd->fmd_expire = ktime_get_seconds() + + lut->lut_fmd_max_age; break; } } @@ -191,20 +183,20 @@ static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp, * \param[in] exp OBD export * \param[in] fid FID of FMD to find * - * \retval struct ofd_mod_data found by FID + * \retval struct tgt_fmd_data found by FID * \retval NULL indicates FMD is not found */ -struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, +struct tgt_fmd_data *ofd_fmd_find(struct obd_export *exp, const struct lu_fid *fid) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_mod_data *fmd; + struct tg_export_data *ted = &exp->exp_target_data; + struct tgt_fmd_data *fmd; - spin_lock(&fed->fed_lock); + spin_lock(&ted->ted_fmd_lock); fmd = ofd_fmd_find_nolock(exp, fid); if (fmd) fmd->fmd_refcount++; /* caller reference */ - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); return fmd; } @@ -220,38 +212,40 @@ struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, * \param[in] exp OBD export * \param[in] fid FID of FMD to find * - * \retval struct ofd_mod_data found by FID + * \retval struct tgt_fmd_data found by FID * \retval NULL indicates FMD is not found */ -struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fid) +struct tgt_fmd_data *ofd_fmd_get(struct obd_export *exp, + const struct lu_fid *fid) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_mod_data *found = NULL, *fmd_new = NULL; - time64_t now = ktime_get_seconds(); + struct tg_export_data *ted = &exp->exp_target_data; + struct tgt_fmd_data *found = NULL, *fmd_new = NULL; - OBD_SLAB_ALLOC_PTR(fmd_new, ll_fmd_cachep); + OBD_SLAB_ALLOC_PTR(fmd_new, tgt_fmd_kmem); - spin_lock(&fed->fed_lock); + spin_lock(&ted->ted_fmd_lock); found = ofd_fmd_find_nolock(exp, fid); if (fmd_new) { if (found == NULL) { - list_add_tail(&fmd_new->fmd_list, - &fed->fed_mod_list); + list_add_tail(&fmd_new->fmd_list, &ted->ted_fmd_list); fmd_new->fmd_fid = *fid; fmd_new->fmd_refcount++; /* list reference */ found = fmd_new; - fed->fed_mod_count++; + ted->ted_fmd_count++; } else { - OBD_SLAB_FREE_PTR(fmd_new, ll_fmd_cachep); + OBD_SLAB_FREE_PTR(fmd_new, tgt_fmd_kmem); } } if (found) { found->fmd_refcount++; /* caller reference */ - found->fmd_expire = now + ofd->ofd_fmd_max_age; + found->fmd_expire = ktime_get_seconds() + + class_exp2tgt(exp)->lut_fmd_max_age; + } else { + LCONSOLE_WARN("%s: cannot allocate FMD for "DFID + ", timestamps may be out of sync\n", + exp->exp_obd->obd_name, PFID(fid)); } - - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); return found; } @@ -274,16 +268,16 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fi */ void ofd_fmd_drop(struct obd_export *exp, const struct lu_fid *fid) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_mod_data *found = NULL; + struct tg_export_data *ted = &exp->exp_target_data; + struct tgt_fmd_data *found = NULL; - spin_lock(&fed->fed_lock); + spin_lock(&ted->ted_fmd_lock); found = ofd_fmd_find_nolock(exp, fid); if (found) { list_del_init(&found->fmd_list); ofd_fmd_put_nolock(exp, found); } - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); } #endif @@ -296,48 +290,65 @@ void ofd_fmd_drop(struct obd_export *exp, const struct lu_fid *fid) */ void ofd_fmd_cleanup(struct obd_export *exp) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_mod_data *fmd = NULL, *tmp; + struct tg_export_data *ted = &exp->exp_target_data; + struct tgt_fmd_data *fmd = NULL, *tmp; - spin_lock(&fed->fed_lock); - list_for_each_entry_safe(fmd, tmp, &fed->fed_mod_list, fmd_list) { + spin_lock(&ted->ted_fmd_lock); + list_for_each_entry_safe(fmd, tmp, &ted->ted_fmd_list, fmd_list) { list_del_init(&fmd->fmd_list); if (fmd->fmd_refcount > 1) { - CDEBUG(D_INFO, "fmd %p still referenced (refcount = %d)\n", + CDEBUG(D_INFO, + "fmd %p is still referenced (refcount = %d)\n", fmd, fmd->fmd_refcount); } ofd_fmd_put_nolock(exp, fmd); } - spin_unlock(&fed->fed_lock); + spin_unlock(&ted->ted_fmd_lock); } /** - * Initialize FMD subsystem. + * Update FMD with the latest request XID. * - * This function is called upon OFD setup and initialize memory to be used - * by FMD entries. + * Save a new setattr/punch XID in FMD if exists. + * + * \param[in] exp OBD export + * \param[in] fid FID of FMD to find + * \param[in] xid request XID */ -int ofd_fmd_init(void) +void tgt_fmd_update(struct obd_export *exp, const struct lu_fid *fid, __u64 xid) { - ll_fmd_cachep = kmem_cache_create("ll_fmd_cache", - sizeof(struct ofd_mod_data), - 0, 0, NULL); - if (!ll_fmd_cachep) - return -ENOMEM; - else - return 0; + struct tgt_fmd_data *fmd; + + fmd = ofd_fmd_get(exp, fid); + if (fmd) { + if (fmd->fmd_mactime_xid < xid) + fmd->fmd_mactime_xid = xid; + ofd_fmd_put(exp, fmd); + } } /** - * Stop FMD subsystem. + * Chech that time can be updated by the request with given XID. + * + * Check FMD XID if exists to be less than supplied XID + * + * \param[in] exp OBD export + * \param[in] fid FID of FMD to find + * \param[in] xid request XID * - * This function is called upon OFD cleanup and destroy memory used - * by FMD entries. + * \retval true if FMD has no greater XID, so time attr can be updated */ -void ofd_fmd_exit(void) +bool tgt_fmd_check(struct obd_export *exp, const struct lu_fid *fid, __u64 xid) { - if (ll_fmd_cachep) { - kmem_cache_destroy(ll_fmd_cachep); - ll_fmd_cachep = NULL; + struct tgt_fmd_data *fmd; + bool can_update = true; + + fmd = ofd_fmd_find(exp, fid); + if (fmd) { + can_update = fmd->fmd_mactime_xid < xid; + ofd_fmd_put(exp, fmd); } + + return can_update; } + diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index afc210b9..b9e022a 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -51,18 +51,15 @@ #define OFD_VALID_FLAGS (LA_TYPE | LA_MODE | LA_SIZE | LA_BLOCKS | \ LA_BLKSIZE | LA_ATIME | LA_MTIME | LA_CTIME) -/* per-client-per-object persistent state (LRU) */ -struct ofd_mod_data { - struct list_head fmd_list; /* linked to fed_mod_list */ +/* FMD tracking data */ +struct tgt_fmd_data { + struct list_head fmd_list; /* linked to tgt_fmd_list */ struct lu_fid fmd_fid; /* FID being written to */ __u64 fmd_mactime_xid; /* xid highest {m,a,c}time setattr */ time64_t fmd_expire; /* time when the fmd should expire */ int fmd_refcount; /* reference counter - list holds 1 */ }; -#define OFD_FMD_MAX_NUM_DEFAULT 128 -#define OFD_FMD_MAX_AGE_DEFAULT (obd_timeout + 10) - #define OFD_SOFT_SYNC_LIMIT_DEFAULT 16 /* request stats */ @@ -136,10 +133,6 @@ struct ofd_device { /* checksum types supported on this node */ enum cksum_types ofd_cksum_types_supported; - /* ofd mod data: ofd_device wide values */ - int ofd_fmd_max_num; /* per ofd ofd_mod_data */ - time64_t ofd_fmd_max_age; /* time to fmd expiry */ - spinlock_t ofd_flags_lock; unsigned long ofd_raid_degraded:1, /* sync journal on writes */ @@ -404,13 +397,7 @@ struct ofd_object *ofd_object_find_exists(const struct lu_env *env, } /* ofd_fmd.c */ -int ofd_fmd_init(void); -void ofd_fmd_exit(void); -struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp, - const struct lu_fid *fid); -struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, - const struct lu_fid *fid); -void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd); +extern struct kmem_cache *tgt_fmd_kmem; void ofd_fmd_expire(struct obd_export *exp); void ofd_fmd_cleanup(struct obd_export *exp); #ifdef DO_FMD_DROP diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index 908613f..78c1a08 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -1268,12 +1268,11 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct niobuf_remote *rnb, int npages, struct niobuf_local *lnb, int old_rc) { - struct ofd_thread_info *info = ofd_info(env); - struct ofd_mod_data *fmd; - __u64 valid; - struct ofd_device *ofd = ofd_exp(exp); - const struct lu_fid *fid = &oa->o_oi.oi_fid; - int rc = 0; + struct ofd_thread_info *info = ofd_info(env); + struct ofd_device *ofd = ofd_exp(exp); + const struct lu_fid *fid = &oa->o_oi.oi_fid; + __u64 valid; + int rc = 0; LASSERT(npages > 0); @@ -1282,17 +1281,11 @@ int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, /* Don't update timestamps if this write is older than a * setattr which modifies the timestamps. b=10150 */ - - /* XXX when we start having persistent reservations this needs - * to be changed to ofd_fmd_get() to create the fmd if it - * doesn't already exist so we can store the reservation handle - * there. */ valid = OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLPROJID; - fmd = ofd_fmd_find(exp, fid); - if (!fmd || fmd->fmd_mactime_xid < info->fti_xid) + if (tgt_fmd_check(exp, fid, info->fti_xid)) valid |= OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME; - ofd_fmd_put(exp, fmd); + la_from_obdo(&info->fti_attr, oa, valid); rc = ofd_commitrw_write(env, exp, ofd, fid, &info->fti_attr, diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index f67ad47..b717ad4 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -546,8 +546,8 @@ static int ofd_init_export(struct obd_export *exp) { int rc; - spin_lock_init(&exp->exp_filter_data.fed_lock); - INIT_LIST_HEAD(&exp->exp_filter_data.fed_mod_list); + spin_lock_init(&exp->exp_target_data.ted_fmd_lock); + INIT_LIST_HEAD(&exp->exp_target_data.ted_fmd_list); atomic_set(&exp->exp_filter_data.fed_soft_sync_count, 0); spin_lock(&exp->exp_lock); exp->exp_connecting = 1; @@ -603,7 +603,6 @@ static int ofd_destroy_export(struct obd_export *exp) * interaction with the client is possible */ tgt_grant_discard(exp); - ofd_fmd_cleanup(exp); if (exp_connect_flags(exp) & OBD_CONNECT_GRANT) ofd->ofd_lut.lut_tgd.tgd_tot_granted_clients--; @@ -611,7 +610,6 @@ static int ofd_destroy_export(struct obd_export *exp) if (!(exp->exp_flags & OBD_OPT_FORCE)) tgt_grant_sanity_check(exp->exp_obd, __func__); - LASSERT(list_empty(&exp->exp_filter_data.fed_mod_list)); return 0; } diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 7605de4..f0092c5 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -585,26 +585,21 @@ int ofd_object_ff_update(const struct lu_env *env, struct ofd_object *fo, int ofd_attr_set(const struct lu_env *env, struct ofd_object *fo, struct lu_attr *la, struct obdo *oa) { - struct ofd_thread_info *info = ofd_info(env); - struct ofd_device *ofd = ofd_obj2dev(fo); - struct filter_fid *ff = &info->fti_mds_fid; - struct thandle *th; - struct ofd_mod_data *fmd; - int fl; - int rc; - int rc2; + struct ofd_thread_info *info = ofd_info(env); + struct ofd_device *ofd = ofd_obj2dev(fo); + struct filter_fid *ff = &info->fti_mds_fid; + struct thandle *th; + int fl, rc, rc2; + ENTRY; ofd_write_lock(env, fo); if (!ofd_object_exists(fo)) GOTO(unlock, rc = -ENOENT); - if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME)) { - fmd = ofd_fmd_get(info->fti_exp, &fo->ofo_header.loh_fid); - if (fmd && fmd->fmd_mactime_xid < info->fti_xid) - fmd->fmd_mactime_xid = info->fti_xid; - ofd_fmd_put(info->fti_exp, fmd); - } + if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME)) + tgt_fmd_update(info->fti_exp, &fo->ofo_header.loh_fid, + info->fti_xid); /* VBR: version recovery check */ rc = ofd_version_get_check(info, fo); @@ -700,15 +695,12 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo, __u64 start, __u64 end, struct lu_attr *la, struct obdo *oa) { - struct ofd_thread_info *info = ofd_info(env); - struct ofd_device *ofd = ofd_obj2dev(fo); - struct ofd_mod_data *fmd; - struct dt_object *dob = ofd_object_child(fo); - struct filter_fid *ff = &info->fti_mds_fid; - struct thandle *th; - int fl; - int rc; - int rc2; + struct ofd_thread_info *info = ofd_info(env); + struct ofd_device *ofd = ofd_obj2dev(fo); + struct dt_object *dob = ofd_object_child(fo); + struct filter_fid *ff = &info->fti_mds_fid; + struct thandle *th; + int fl, rc, rc2; ENTRY; @@ -716,10 +708,9 @@ int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo, LASSERT(end == OBD_OBJECT_EOF); ofd_write_lock(env, fo); - fmd = ofd_fmd_get(info->fti_exp, &fo->ofo_header.loh_fid); - if (fmd && fmd->fmd_mactime_xid < info->fti_xid) - fmd->fmd_mactime_xid = info->fti_xid; - ofd_fmd_put(info->fti_exp, fmd); + if (la->la_valid & (LA_ATIME | LA_MTIME | LA_CTIME)) + tgt_fmd_update(info->fti_exp, &fo->ofo_header.loh_fid, + info->fti_xid); if (!ofd_object_exists(fo)) GOTO(unlock, rc = -ENOENT); diff --git a/lustre/target/tgt_internal.h b/lustre/target/tgt_internal.h index 5374abc..9539da0 100644 --- a/lustre/target/tgt_internal.h +++ b/lustre/target/tgt_internal.h @@ -287,4 +287,5 @@ int top_trans_create_tmt(const struct lu_env *env, void tgt_cancel_slc_locks(struct lu_target *tgt, __u64 transno); void barrier_init(void); void barrier_fini(void); + #endif /* _TG_INTERNAL_H */ diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index b767d1d..cdc1a53 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -259,6 +259,11 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut, dt_txn_callback_add(lut->lut_bottom, &lut->lut_txn_cb); lut->lut_bottom->dd_lu_dev.ld_site->ls_tgt = lut; + lut->lut_fmd_max_num = LUT_FMD_MAX_NUM_DEFAULT; + lut->lut_fmd_max_age = LUT_FMD_MAX_AGE_DEFAULT; + + atomic_set(&lut->lut_sync_count, 0); + /* reply_data is supported by MDT targets only for now */ if (strncmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME, 3) != 0) RETURN(0); @@ -288,8 +293,6 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut, if (rc < 0) GOTO(out, rc); - atomic_set(&lut->lut_sync_count, 0); - RETURN(0); out: -- 1.8.3.1