From 8daba6a7381a2fb8cc933f7e9486f60e659465d4 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 16 Jan 2015 13:33:46 -0600 Subject: [PATCH] LU-6047 mdt: remove Size on MDS support Remove size on MDS support from lustre/mdt/. In struct mdt_object change the struct mutex mot_ioepoch_mutex member to spinlock_t mot_write_lock and rename mot_writecount to mot_write_count. Signed-off-by: John L. Hammond Change-Id: I271117618f7b88a22ddbcca4db5a4723ab48e3ea Reviewed-on: http://review.whamcloud.com/13442 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_handler.c | 82 +------ lustre/mdt/mdt_hsm.c | 2 +- lustre/mdt/mdt_internal.h | 65 +---- lustre/mdt/mdt_lib.c | 34 +-- lustre/mdt/mdt_lproc.c | 64 ----- lustre/mdt/mdt_open.c | 610 +++++----------------------------------------- lustre/mdt/mdt_recovery.c | 18 +- lustre/mdt/mdt_reint.c | 76 +----- 8 files changed, 105 insertions(+), 846 deletions(-) diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 0e26b18..cf82eb0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -362,33 +362,6 @@ out: RETURN(rc); } -/** - * Pack SOM attributes into the reply. - * Call under a DLM UPDATE lock. - */ -static void mdt_pack_size2body(struct mdt_thread_info *info, - struct mdt_object *mo) -{ - struct mdt_body *b; - struct md_attr *ma = &info->mti_attr; - - LASSERT(ma->ma_attr.la_valid & LA_MODE); - b = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY); - - /* Check if Size-on-MDS is supported, if this is a regular file, - * if SOM is enabled on the object and if SOM cache exists and valid. - * Otherwise do not pack Size-on-MDS attributes to the reply. */ - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM) || - !S_ISREG(ma->ma_attr.la_mode) || - !mdt_object_is_som_enabled(mo) || - !(ma->ma_valid & MA_SOM)) - return; - - b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - b->mbo_size = ma->ma_som->msd_size; - b->mbo_blocks = ma->ma_som->msd_blocks; -} - #ifdef CONFIG_FS_POSIX_ACL /* * Pack ACL data into the reply. UIDs/GIDs are mapped and filtered by nodemap. @@ -814,19 +787,6 @@ int mdt_attr_get_complex(struct mdt_thread_info *info, GOTO(out, rc); } - if (need & MA_SOM && S_ISREG(mode)) { - buf->lb_buf = info->mti_xattr_buf; - buf->lb_len = sizeof(info->mti_xattr_buf); - CLASSERT(sizeof(struct som_attrs) <= - sizeof(info->mti_xattr_buf)); - rc2 = mo_xattr_get(info->mti_env, next, buf, XATTR_NAME_SOM); - rc2 = lustre_buf2som(info->mti_xattr_buf, rc2, ma->ma_som); - if (rc2 == 0) - ma->ma_valid |= MA_SOM; - else if (rc2 < 0 && rc2 != -ENODATA) - GOTO(out, rc = rc2); - } - if (need & MA_HSM && S_ISREG(mode)) { buf->lb_buf = info->mti_xattr_buf; buf->lb_len = sizeof(info->mti_xattr_buf); @@ -941,8 +901,6 @@ static int mdt_getattr_internal(struct mdt_thread_info *info, ma->ma_need |= MA_LOV_DEF; } ma->ma_need |= ma_need; - if (ma->ma_need & MA_SOM) - ma->ma_som = &info->mti_u.som.data; rc = mdt_attr_get_complex(info, o, ma); if (unlikely(rc)) { @@ -1641,11 +1599,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, } lock = ldlm_handle2lock(&lhc->mlh_reg_lh); - /* Get MA_SOM attributes if update lock is given. */ - if (lock && - lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_UPDATE && - S_ISREG(lu_object_attr(&mdt_object_child(child)->mo_lu))) - ma_need |= MA_SOM; /* finally, we can get attr for child. */ mdt_set_capainfo(info, 1, child_fid, BYPASS_CAPA); @@ -1660,8 +1613,6 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, "Lock res_id: "DLDLMRES", fid: "DFID"\n", PLDLMRES(lock->l_resource), PFID(mdt_object_fid(child))); - if (mdt_object_exists(child) && !mdt_object_remote(child)) - mdt_pack_size2body(info, child); } if (lock) LDLM_LOCK_PUT(lock); @@ -4323,8 +4274,6 @@ TGT_MDT_HDL(HABEO_CORPUS, MDS_GETXATTR, mdt_tgt_getxattr), TGT_MDT_HDL(0 | HABEO_REFERO, MDS_STATFS, mdt_statfs), TGT_MDT_HDL(0 | MUTABOR, MDS_REINT, mdt_reint), TGT_MDT_HDL(HABEO_CORPUS, MDS_CLOSE, mdt_close), -TGT_MDT_HDL(HABEO_CORPUS, MDS_DONE_WRITING, - mdt_done_writing), TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO, MDS_READPAGE, mdt_readpage), TGT_MDT_HDL(HABEO_CORPUS| HABEO_REFERO, MDS_SYNC, mdt_sync), TGT_MDT_HDL(0, MDS_QUOTACTL, mdt_quotactl), @@ -4516,8 +4465,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, m->mdt_max_mdsize = MAX_MD_SIZE; /* 4 stripes */ - m->mdt_som_conf = 0; - m->mdt_opts.mo_cos = MDT_COS_DEFAULT; /* default is coordinator off, it is started through conf_param @@ -4536,7 +4483,6 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m, obd->u.obt.obt_magic = OBT_MAGIC; } - spin_lock_init(&m->mdt_ioepoch_lock); m->mdt_capa_timeout = CAPA_TIMEOUT; m->mdt_capa_alg = CAPA_HMAC_ALG_SHA1; m->mdt_ck_timeout = CAPA_KEY_TIMEOUT; @@ -4831,7 +4777,7 @@ static struct lu_object *mdt_object_alloc(const struct lu_env *env, lu_object_init(o, h, d); lu_object_add_top(h, o); o->lo_ops = &mdt_obj_ops; - mutex_init(&mo->mot_ioepoch_mutex); + spin_lock_init(&mo->mot_write_lock); mutex_init(&mo->mot_lov_mutex); init_rwsem(&mo->mot_open_sem); RETURN(o); @@ -4882,13 +4828,13 @@ static void mdt_object_free(const struct lu_env *env, struct lu_object *o) } static int mdt_object_print(const struct lu_env *env, void *cookie, - lu_printer_t p, const struct lu_object *o) + lu_printer_t p, const struct lu_object *o) { - struct mdt_object *mdto = mdt_obj((struct lu_object *)o); - return (*p)(env, cookie, LUSTRE_MDT_NAME"-object@%p(ioepoch="LPU64" " - "flags="LPX64", epochcount=%d, writecount=%d)", - mdto, mdto->mot_ioepoch, mdto->mot_flags, - mdto->mot_ioepoch_count, mdto->mot_writecount); + struct mdt_object *mdto = mdt_obj((struct lu_object *)o); + + return (*p)(env, cookie, + LUSTRE_MDT_NAME"-object@%p(flags=%d, writecount=%d)", + mdto, mdto->mot_flags, mdto->mot_write_count); } static int mdt_prepare(const struct lu_env *env, @@ -5017,9 +4963,6 @@ static int mdt_connect_internal(struct obd_export *exp, if (!mdt->mdt_opts.mo_user_xattr) data->ocd_connect_flags &= ~OBD_CONNECT_XATTR; - if (!mdt->mdt_som_conf) - data->ocd_connect_flags &= ~OBD_CONNECT_SOM; - if (data->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) { data->ocd_brw_size = min(data->ocd_brw_size, (__u32)MD_MAX_BRW_SIZE); @@ -5057,15 +5000,6 @@ static int mdt_connect_internal(struct obd_export *exp, return -EBADE; } - if (mdt->mdt_som_conf && - !(data->ocd_connect_flags & (OBD_CONNECT_LIGHTWEIGHT | - OBD_CONNECT_MDS_MDS | - OBD_CONNECT_SOM))) { - CWARN("%s: MDS has SOM enabled, but client does not support " - "it\n", mdt_obd_name(mdt)); - return -EBADE; - } - if (OCD_HAS_FLAG(data, PINGLESS)) { if (ptlrpc_pinger_suppress_pings()) { spin_lock(&exp->exp_obd->obd_dev_lock); @@ -5167,7 +5101,7 @@ static int mdt_export_cleanup(struct obd_export *exp) * archive request into a noop if it's not actually * dirty. */ - if (mfd->mfd_mode & (FMODE_WRITE|MDS_FMODE_TRUNC)) + if (mfd->mfd_mode & FMODE_WRITE) rc = mdt_ctxt_add_dirty_flag(&env, info, mfd); /* Don't unlink orphan on failover umount, LU-184 */ diff --git a/lustre/mdt/mdt_hsm.c b/lustre/mdt/mdt_hsm.c index 34d9fda..a5220a1 100644 --- a/lustre/mdt/mdt_hsm.c +++ b/lustre/mdt/mdt_hsm.c @@ -70,7 +70,7 @@ int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj, /* pack HSM attributes */ lustre_hsm2buf(info->mti_xattr_buf, mh); - /* update SOM attributes */ + /* update HSM attributes */ buf->lb_buf = attrs; buf->lb_len = sizeof(*attrs); rc = mo_xattr_set(info->mti_env, next, buf, XATTR_NAME_HSM, 0); diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 688b3d1..4bc720a 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -188,9 +188,6 @@ struct mdt_device { } mdt_opts; /* mdt state flags */ unsigned long mdt_state; - /* lock to protect IOepoch */ - spinlock_t mdt_ioepoch_lock; - __u64 mdt_ioepoch; /* transaction callbacks */ struct dt_txn_callback mdt_txn_cb; @@ -213,7 +210,6 @@ struct mdt_device { struct ptlrpc_thread mdt_ck_thread; struct lustre_capa_key mdt_capa_keys[2]; unsigned int mdt_capa_conf:1, - mdt_som_conf:1, /* Enable remote dir on non-MDT0 */ mdt_enable_remote_dir:1; @@ -240,15 +236,17 @@ struct mdt_device { #define MDT_SERVICE_WATCHDOG_FACTOR (2) #define MDT_COS_DEFAULT (0) +enum mdt_object_flags { + /** lov object has been created. */ + MOF_LOV_CREATED = 1 << 0, +}; + struct mdt_object { struct lu_object_header mot_header; struct lu_object mot_obj; - __u64 mot_ioepoch; - __u64 mot_flags; - int mot_ioepoch_count; - int mot_writecount; - /* Lock to protect object's IO epoch. */ - struct mutex mot_ioepoch_mutex; + enum mdt_object_flags mot_flags; + int mot_write_count; + spinlock_t mot_write_lock; /* Lock to protect create_data */ struct mutex mot_lov_mutex; /* Lock to protect lease open. @@ -258,26 +256,6 @@ struct mdt_object { atomic_t mot_open_count; }; -enum mdt_object_flags { - /** SOM attributes are changed. */ - MOF_SOM_CHANGE = (1 << 0), - /** - * The SOM recovery state for mdt object. - * This state is an in-memory equivalent of an absent SOM EA, used - * instead of invalidating SOM EA while IOEpoch is still opened when - * a client eviction occurs or a client fails to obtain SOM attributes. - * It indicates that the last IOEpoch holder will need to obtain SOM - * attributes under [0;EOF] extent lock to flush all the client's - * cached of evicted from MDS clients (but not necessary evicted from - * OST) before taking ost attributes. - */ - MOF_SOM_RECOV = (1 << 1), - /** File has been just created. */ - MOF_SOM_CREATED = (1 << 2), - /** lov object has been created. */ - MOF_LOV_CREATED = (1 << 3), -}; - struct mdt_lock_handle { /* Lock type, reg for cross-ref use or pdo lock. */ mdl_type_t mlh_type; @@ -442,16 +420,12 @@ struct mdt_thread_info { /* for mdt_sendpage() */ struct l_wait_info mti_wait_info; } rdpg; - struct { - struct md_attr attr; - struct md_som_data data; - } som; + struct { + struct md_attr attr; + } hsm; } mti_u; - /* IO epoch related stuff. */ - struct mdt_ioepoch *mti_ioepoch; - __u64 mti_replayepoch; - + struct lustre_handle mti_close_handle; loff_t mti_off; struct lu_buf mti_buf; struct lu_buf mti_big_buf; @@ -723,17 +697,6 @@ struct mdt_file_data *mdt_handle2mfd(struct mdt_export_data *med, const struct lustre_handle *handle, bool is_replay); -enum { - MDT_IOEPOCH_CLOSED = 0, - MDT_IOEPOCH_OPENED = 1, - MDT_IOEPOCH_GETATTR = 2, -}; - -enum { - MDT_SOM_DISABLE = 0, - MDT_SOM_ENABLE = 1, -}; - int mdt_get_info(struct tgt_session_info *tsi); int mdt_attr_get_complex(struct mdt_thread_info *info, struct mdt_object *o, struct md_attr *ma); @@ -741,9 +704,6 @@ int mdt_big_xattr_get(struct mdt_thread_info *info, struct mdt_object *o, const char *name); int mdt_stripe_get(struct mdt_thread_info *info, struct mdt_object *o, struct md_attr *ma, const char *name); -int mdt_ioepoch_open(struct mdt_thread_info *info, struct mdt_object *o, - int created); -int mdt_object_is_som_enabled(struct mdt_object *mo); int mdt_write_get(struct mdt_object *o); void mdt_write_put(struct mdt_object *o); int mdt_write_read(struct mdt_object *o); @@ -753,7 +713,6 @@ void mdt_mfd_free(struct mdt_file_data *mfd); int mdt_close(struct tgt_session_info *tsi); int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo, struct md_attr *ma); -int mdt_done_writing(struct tgt_session_info *tsi); int mdt_fix_reply(struct mdt_thread_info *info); int mdt_handle_last_unlink(struct mdt_thread_info *, struct mdt_object *, const struct md_attr *); diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index ce695db..c724cc9 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -1023,17 +1023,23 @@ static int mdt_setattr_unpack_rec(struct mdt_thread_info *info) RETURN(0); } -static int mdt_ioepoch_unpack(struct mdt_thread_info *info) +static int mdt_close_handle_unpack(struct mdt_thread_info *info) { - struct req_capsule *pill = info->mti_pill; - ENTRY; + struct req_capsule *pill = info->mti_pill; + struct mdt_ioepoch *ioepoch; + ENTRY; - if (req_capsule_get_size(pill, &RMF_MDT_EPOCH, RCL_CLIENT)) - info->mti_ioepoch = - req_capsule_client_get(pill, &RMF_MDT_EPOCH); - else - info->mti_ioepoch = NULL; - RETURN(info->mti_ioepoch == NULL ? -EFAULT : 0); + if (req_capsule_get_size(pill, &RMF_MDT_EPOCH, RCL_CLIENT)) + ioepoch = req_capsule_client_get(pill, &RMF_MDT_EPOCH); + else + ioepoch = NULL; + + if (ioepoch == NULL) + RETURN(-EPROTO); + + info->mti_close_handle = ioepoch->handle; + + RETURN(0); } static inline int mdt_dlmreq_unpack(struct mdt_thread_info *info) { @@ -1060,9 +1066,6 @@ static int mdt_setattr_unpack(struct mdt_thread_info *info) if (rc) RETURN(rc); - /* Epoch may be absent */ - mdt_ioepoch_unpack(info); - if (req_capsule_field_present(pill, &RMF_EADATA, RCL_CLIENT)) { rr->rr_eadata = req_capsule_client_get(pill, &RMF_EADATA); rr->rr_eadatalen = req_capsule_get_size(pill, &RMF_EADATA, @@ -1109,10 +1112,10 @@ static int mdt_hsm_release_unpack(struct mdt_thread_info *info) int mdt_close_unpack(struct mdt_thread_info *info) { - int rc; - ENTRY; + int rc; + ENTRY; - rc = mdt_ioepoch_unpack(info); + rc = mdt_close_handle_unpack(info); if (rc) RETURN(rc); @@ -1430,7 +1433,6 @@ static int mdt_open_unpack(struct mdt_thread_info *info) /* Do not trigger ASSERTION if client miss to set such flags. */ if (unlikely(info->mti_spec.sp_cr_flags == 0)) RETURN(-EPROTO); - info->mti_replayepoch = rec->cr_ioepoch; info->mti_cross_ref = !!(rec->cr_bias & MDS_CROSS_REF); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 4844c7f..8cdae12 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -693,68 +693,6 @@ mdt_nosquash_nids_seq_write(struct file *file, const char __user *buffer, } LPROC_SEQ_FOPS(mdt_nosquash_nids); -static int mdt_som_seq_show(struct seq_file *m, void *data) -{ - struct obd_device *obd = m->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - - return seq_printf(m, "%sabled\n", - mdt->mdt_som_conf ? "en" : "dis"); -} - -static ssize_t -mdt_som_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) -{ - struct seq_file *m = file->private_data; - struct obd_device *obd = m->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - struct obd_export *exp; - char kernbuf[16]; - unsigned long val = 0; - - if (count > (sizeof(kernbuf) - 1)) - return -EINVAL; - - if (copy_from_user(kernbuf, buffer, count)) - return -EFAULT; - - kernbuf[count] = '\0'; - - if (!strcmp(kernbuf, "enabled")) - val = 1; - else if (strcmp(kernbuf, "disabled")) - return -EINVAL; - - if (mdt->mdt_som_conf == val) - return count; - - if (!obd->obd_process_conf) { - CERROR("Temporary SOM change is not supported, use lctl " - "conf_param for permanent setting\n"); - return count; - } - - /* 1 stands for self export. */ - list_for_each_entry(exp, &obd->obd_exports, exp_obd_chain) { - if (exp == obd->obd_self_export) - continue; - if (exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) - continue; - /* Some clients are already connected, skip the change */ - LCONSOLE_INFO("%s is already connected, SOM will be %s on " - "the next mount\n", exp->exp_client_uuid.uuid, - val ? "enabled" : "disabled"); - return count; - } - - mdt->mdt_som_conf = val; - LCONSOLE_INFO("Enabling SOM\n"); - - return count; -} -LPROC_SEQ_FOPS(mdt_som); - static int mdt_enable_remote_dir_seq_show(struct seq_file *m, void *data) { struct obd_device *obd = m->private; @@ -864,8 +802,6 @@ static struct lprocfs_vars lprocfs_mdt_obd_vars[] = { .fops = &mdt_root_squash_fops }, { .name = "nosquash_nids", .fops = &mdt_nosquash_nids_fops }, - { .name = "som", - .fops = &mdt_som_fops }, { .name = "instance", .fops = &mdt_target_instance_fops }, { .name = "ir_factor", diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 97918c4..b092b5a 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -138,430 +138,59 @@ static int mdt_create_data(struct mdt_thread_info *info, RETURN(rc); } -static int mdt_ioepoch_opened(struct mdt_object *mo) -{ - return mo->mot_ioepoch_count; -} - -int mdt_object_is_som_enabled(struct mdt_object *mo) -{ - return !mo->mot_ioepoch; -} - -/** - * Re-enable Size-on-MDS. - * Call under ->mot_ioepoch_mutex. - */ -static void mdt_object_som_enable(struct mdt_object *mo, __u64 ioepoch) -{ - if (ioepoch == mo->mot_ioepoch) { - LASSERT(!mdt_ioepoch_opened(mo)); - mo->mot_ioepoch = 0; - mo->mot_flags = 0; - } -} - -/** - * Open the IOEpoch. It is allowed if @writecount is not negative. - * The epoch and writecount handling is performed under the mot_ioepoch_mutex. - */ -int mdt_ioepoch_open(struct mdt_thread_info *info, struct mdt_object *o, - int created) -{ - struct mdt_device *mdt = info->mti_mdt; - int cancel = 0; - int rc = 0; - ENTRY; - - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM) || - !S_ISREG(lu_object_attr(&o->mot_obj))) - RETURN(0); - - mutex_lock(&o->mot_ioepoch_mutex); - if (mdt_ioepoch_opened(o)) { - /* Epoch continues even if there is no writers yet. */ - CDEBUG(D_INODE, "continue epoch "LPU64" for "DFID"\n", - o->mot_ioepoch, PFID(mdt_object_fid(o))); - } else { - /* XXX: ->mdt_ioepoch is not initialized at the mount */ - spin_lock(&mdt->mdt_ioepoch_lock); - if (mdt->mdt_ioepoch < info->mti_replayepoch) - mdt->mdt_ioepoch = info->mti_replayepoch; - - if (info->mti_replayepoch) - o->mot_ioepoch = info->mti_replayepoch; - else if (++mdt->mdt_ioepoch == IOEPOCH_INVAL) - o->mot_ioepoch = ++mdt->mdt_ioepoch; - else - o->mot_ioepoch = mdt->mdt_ioepoch; - - spin_unlock(&mdt->mdt_ioepoch_lock); - - CDEBUG(D_INODE, "starting epoch "LPU64" for "DFID"\n", - o->mot_ioepoch, PFID(mdt_object_fid(o))); - if (created) - o->mot_flags |= MOF_SOM_CREATED; - cancel = 1; - } - o->mot_ioepoch_count++; - mutex_unlock(&o->mot_ioepoch_mutex); - - /* Cancel Size-on-MDS attributes cached on clients for the open case. - * In the truncate case, see mdt_reint_setattr(). */ - if (cancel && (info->mti_rr.rr_fid1 != NULL)) { - struct mdt_lock_handle *lh = &info->mti_lh[MDT_LH_CHILD]; - mdt_lock_reg_init(lh, LCK_EX); - rc = mdt_object_lock(info, o, lh, MDS_INODELOCK_UPDATE, - MDT_LOCAL_LOCK); - if (rc == 0) - mdt_object_unlock(info, o, lh, 1); - } - RETURN(rc); -} - -/** - * Update SOM on-disk attributes. - * If enabling, write update inodes and lustre-ea with the proper IOEpoch, - * mountid and attributes. If disabling, clean SOM xattr. - * Call under ->mot_ioepoch_mutex. - */ -static int mdt_som_attr_set(struct mdt_thread_info *info, - struct mdt_object *obj, __u64 ioepoch, bool enable) -{ - struct md_object *next = mdt_object_child(obj); - int rc; - ENTRY; - - CDEBUG(D_INODE, "Size-on-MDS attribute %s for epoch "LPU64 - " on "DFID".\n", enable ? "update" : "disabling", - ioepoch, PFID(mdt_object_fid(obj))); - - if (enable) { - struct lu_buf *buf = &info->mti_buf; - struct som_attrs *attrs; - struct md_attr *ma = &info->mti_attr; - struct lu_attr *la = &ma->ma_attr; - struct obd_device *obd = info->mti_mdt->mdt_lut.lut_obd; - - attrs = (struct som_attrs *)info->mti_xattr_buf; - CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*attrs)); - - /* pack SOM attributes */ - memset(attrs, 0, sizeof(*attrs)); - attrs->som_ioepoch = ioepoch; - attrs->som_mountid = obd->u.obt.obt_mount_count; - if ((la->la_valid & LA_SIZE) != 0) - attrs->som_size = la->la_size; - if ((la->la_valid & LA_BLOCKS) != 0) - attrs->som_blocks = la->la_blocks; - lustre_som_swab(attrs); - - /* update SOM attributes */ - buf->lb_buf = attrs; - buf->lb_len = sizeof(*attrs); - rc = mo_xattr_set(info->mti_env, next, buf, XATTR_NAME_SOM, 0); - } else { - /* delete SOM attributes */ - rc = mo_xattr_del(info->mti_env, next, XATTR_NAME_SOM); - } - - RETURN(rc); -} - -/** Perform the eviction specific actions on ioepoch close. */ -static inline int mdt_ioepoch_close_on_eviction(struct mdt_thread_info *info, - struct mdt_object *o) -{ - int rc = 0; - - mutex_lock(&o->mot_ioepoch_mutex); - CDEBUG(D_INODE, "Eviction. Closing IOepoch "LPU64" on "DFID". " - "Count %d\n", o->mot_ioepoch, PFID(mdt_object_fid(o)), - o->mot_ioepoch_count); - o->mot_ioepoch_count--; - - /* If eviction occured set MOF_SOM_RECOV, - * if no other epoch holders, disable SOM on disk. */ - o->mot_flags |= MOF_SOM_CHANGE | MOF_SOM_RECOV; - if (!mdt_ioepoch_opened(o)) { - rc = mdt_som_attr_set(info, o, o->mot_ioepoch, MDT_SOM_DISABLE); - mdt_object_som_enable(o, o->mot_ioepoch); - } - mutex_unlock(&o->mot_ioepoch_mutex); - RETURN(rc); -} - -/** - * Perform the replay specific actions on ioepoch close. - * Skip SOM attribute update if obtained and just forget about the inode state - * for the last ioepoch holder. The SOM cache is invalidated on MDS failure. - */ -static inline int mdt_ioepoch_close_on_replay(struct mdt_thread_info *info, - struct mdt_object *o) -{ - int rc = MDT_IOEPOCH_CLOSED; - ENTRY; - - mutex_lock(&o->mot_ioepoch_mutex); - CDEBUG(D_INODE, "Replay. Closing epoch "LPU64" on "DFID". Count %d\n", - o->mot_ioepoch, PFID(mdt_object_fid(o)), o->mot_ioepoch_count); - o->mot_ioepoch_count--; - - /* Get an info from the replayed request if client is supposed - * to send an Attibute Update, reconstruct @rc if so */ - if (info->mti_ioepoch->flags & MF_SOM_AU) - rc = MDT_IOEPOCH_GETATTR; - - if (!mdt_ioepoch_opened(o)) - mdt_object_som_enable(o, info->mti_ioepoch->ioepoch); - mutex_unlock(&o->mot_ioepoch_mutex); - - RETURN(rc); -} - -/** - * Regular file IOepoch close. - * Closes the ioepoch, checks the object state, apply obtained attributes and - * re-enable SOM on the object, if possible. Also checks if the recovery is - * needed and packs OBD_MD_FLGETATTRLOCK flag into the reply to force the client - * to obtain SOM attributes under the server-side OST locks. - * - * Return value: - * MDT_IOEPOCH_CLOSED if ioepoch is closed. - * MDT_IOEPOCH_GETATTR if ioepoch is closed but another SOM update is needed. - */ -static inline int mdt_ioepoch_close_reg(struct mdt_thread_info *info, - struct mdt_object *o) -{ - struct md_attr *tmp_ma; - struct lu_attr *la; - int achange, opened; - int recovery = 0; - int rc = 0, ret = MDT_IOEPOCH_CLOSED; - ENTRY; - - la = &info->mti_attr.ma_attr; - achange = (info->mti_ioepoch->flags & MF_SOM_CHANGE); - - mutex_lock(&o->mot_ioepoch_mutex); - o->mot_ioepoch_count--; - - tmp_ma = &info->mti_u.som.attr; - tmp_ma->ma_lmm = info->mti_attr.ma_lmm; - tmp_ma->ma_lmm_size = info->mti_attr.ma_lmm_size; - tmp_ma->ma_som = &info->mti_u.som.data; - tmp_ma->ma_need = MA_INODE | MA_LOV | MA_SOM; - tmp_ma->ma_valid = 0; - rc = mdt_attr_get_complex(info, o, tmp_ma); - if (rc) - GOTO(error_up, rc); - - /* Check the on-disk SOM state. */ - if (o->mot_flags & MOF_SOM_RECOV) - recovery = 1; - else if (!(o->mot_flags & MOF_SOM_CREATED) && - !(tmp_ma->ma_valid & MA_SOM)) - recovery = 1; - - CDEBUG(D_INODE, "Closing epoch "LPU64" on "DFID". Count %d\n", - o->mot_ioepoch, PFID(mdt_object_fid(o)), o->mot_ioepoch_count); - - opened = mdt_ioepoch_opened(o); - /** - * If IOEpoch is not opened, check if a Size-on-MDS update is needed. - * Skip the check for file with no LOV or for unlink files. - */ - if (!opened && tmp_ma->ma_valid & MA_LOV && - !(tmp_ma->ma_valid & MA_INODE && tmp_ma->ma_attr.la_nlink == 0)) { - if (recovery) - /* If some previous writer was evicted, re-ask the - * client for attributes. Even if attributes are - * provided, we cannot believe in them. - * Another use case is that there is no SOM cache on - * disk -- first access with SOM or there was an MDS - * failure. */ - ret = MDT_IOEPOCH_GETATTR; - else if (o->mot_flags & MOF_SOM_CHANGE) - /* Some previous writer changed the attribute. - * Do not believe to the current Size-on-MDS - * update, re-ask client. */ - ret = MDT_IOEPOCH_GETATTR; - else if (!(la->la_valid & LA_SIZE) && achange) - /* Attributes were changed by the last writer - * only but no Size-on-MDS update is received.*/ - ret = MDT_IOEPOCH_GETATTR; - } - - if (achange || ret == MDT_IOEPOCH_GETATTR) - o->mot_flags |= MOF_SOM_CHANGE; - - /* If epoch ends and relable SOM attributes are obtained, update them. - * Create SOM ea for new files even if there is no attributes obtained - * (0-length file). */ - if (ret == MDT_IOEPOCH_CLOSED && !opened) { - if (achange || o->mot_flags & MOF_SOM_CREATED) { - LASSERT(achange || !(la->la_valid & LA_SIZE)); - rc = mdt_som_attr_set(info, o, o->mot_ioepoch, - MDT_SOM_ENABLE); - /* Avoid the following setattrs of these attributes, - * e.g. for atime update. */ - info->mti_attr.ma_valid = 0; - } - mdt_object_som_enable(o, o->mot_ioepoch); - } - - mutex_unlock(&o->mot_ioepoch_mutex); - /* If recovery is needed, tell the client to perform GETATTR under - * the lock. */ - if (ret == MDT_IOEPOCH_GETATTR && recovery) { - struct mdt_body *rep; - rep = req_capsule_server_get(info->mti_pill, &RMF_MDT_BODY); - rep->mbo_valid |= OBD_MD_FLGETATTRLOCK; - } - - RETURN(rc ? : ret); - -error_up: - mutex_unlock(&o->mot_ioepoch_mutex); - return rc; -} - -/** - * Close IOEpoch (opened file or MDS_FMODE_EPOCH state). It happens if: - * - a client closes the IOEpoch; - * - a client eviction occured. - * Return values: - * MDT_IOEPOCH_OPENED if the client does not close IOEpoch. - * MDT_IOEPOCH_CLOSED if the client closes IOEpoch. - * MDT_IOEPOCH_GETATTR if the client closes IOEpoch but another SOM attribute - * update is needed. - */ -static int mdt_ioepoch_close(struct mdt_thread_info *info, struct mdt_object *o) +int mdt_write_read(struct mdt_object *o) { - struct ptlrpc_request *req = mdt_info_req(info); + int rc = 0; ENTRY; - - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM) || - !S_ISREG(lu_object_attr(&o->mot_obj))) - RETURN(0); - - LASSERT(o->mot_ioepoch_count); - LASSERT(info->mti_ioepoch == NULL || - info->mti_ioepoch->ioepoch == o->mot_ioepoch); - - /* IOEpoch is closed only if client tells about it or eviction occures. - * In the replay case, always close the epoch. */ - if (req == NULL) - RETURN(mdt_ioepoch_close_on_eviction(info, o)); - if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) - RETURN(mdt_ioepoch_close_on_replay(info, o)); - if (info->mti_ioepoch && (info->mti_ioepoch->flags & MF_EPOCH_CLOSE)) - RETURN(mdt_ioepoch_close_reg(info, o)); - /* IO epoch is not closed. */ - RETURN(MDT_IOEPOCH_OPENED); + spin_lock(&o->mot_write_lock); + rc = o->mot_write_count; + spin_unlock(&o->mot_write_lock); + RETURN(rc); } -/** - * Close MDS_FMODE_SOM state, when IOEpoch is already closed and we are waiting - * for attribute update. It happens if: - * - SOM Attribute Update is obtained; - * - the client failed to obtain it and informs MDS about it; - * - a client eviction occured. - * Apply obtained attributes for the 1st case, wipe out the on-disk SOM - * cache otherwise. - */ -static int mdt_som_au_close(struct mdt_thread_info *info, struct mdt_object *o) +int mdt_write_get(struct mdt_object *o) { - struct ptlrpc_request *req = mdt_info_req(info); - __u64 ioepoch = 0; - int act = MDT_SOM_ENABLE; - int rc = 0; + int rc = 0; ENTRY; + spin_lock(&o->mot_write_lock); + if (o->mot_write_count < 0) + rc = -ETXTBSY; + else + o->mot_write_count++; + spin_unlock(&o->mot_write_lock); - LASSERT(!req || info->mti_ioepoch); - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM) || - !S_ISREG(lu_object_attr(&o->mot_obj))) - RETURN(0); - - /* No size whereas MF_SOM_CHANGE is set means client failed to - * obtain ost attributes, drop the SOM cache on disk if so. */ - if (!req || - (info->mti_ioepoch && - info->mti_ioepoch->flags & MF_SOM_CHANGE && - !(info->mti_attr.ma_attr.la_valid & LA_SIZE))) - act = MDT_SOM_DISABLE; - - mutex_lock(&o->mot_ioepoch_mutex); - /* Mark the object it is the recovery state if we failed to obtain - * SOM attributes. */ - if (act == MDT_SOM_DISABLE) - o->mot_flags |= MOF_SOM_RECOV; - - if (!mdt_ioepoch_opened(o)) { - ioepoch = info->mti_ioepoch ? - info->mti_ioepoch->ioepoch : o->mot_ioepoch; - - if (req != NULL - && !(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)) - rc = mdt_som_attr_set(info, o, ioepoch, act); - mdt_object_som_enable(o, ioepoch); - } - mutex_unlock(&o->mot_ioepoch_mutex); - RETURN(rc); -} - -int mdt_write_read(struct mdt_object *o) -{ - int rc = 0; - ENTRY; - mutex_lock(&o->mot_ioepoch_mutex); - rc = o->mot_writecount; - mutex_unlock(&o->mot_ioepoch_mutex); - RETURN(rc); -} - -int mdt_write_get(struct mdt_object *o) -{ - int rc = 0; - ENTRY; - mutex_lock(&o->mot_ioepoch_mutex); - if (o->mot_writecount < 0) - rc = -ETXTBSY; - else - o->mot_writecount++; - mutex_unlock(&o->mot_ioepoch_mutex); - RETURN(rc); + RETURN(rc); } void mdt_write_put(struct mdt_object *o) { - ENTRY; - mutex_lock(&o->mot_ioepoch_mutex); - o->mot_writecount--; - mutex_unlock(&o->mot_ioepoch_mutex); - EXIT; + ENTRY; + spin_lock(&o->mot_write_lock); + o->mot_write_count--; + spin_unlock(&o->mot_write_lock); + EXIT; } static int mdt_write_deny(struct mdt_object *o) { - int rc = 0; - ENTRY; - mutex_lock(&o->mot_ioepoch_mutex); - if (o->mot_writecount > 0) - rc = -ETXTBSY; - else - o->mot_writecount--; - mutex_unlock(&o->mot_ioepoch_mutex); - RETURN(rc); + int rc = 0; + ENTRY; + spin_lock(&o->mot_write_lock); + if (o->mot_write_count > 0) + rc = -ETXTBSY; + else + o->mot_write_count--; + spin_unlock(&o->mot_write_lock); + RETURN(rc); } static void mdt_write_allow(struct mdt_object *o) { - ENTRY; - mutex_lock(&o->mot_ioepoch_mutex); - o->mot_writecount++; - mutex_unlock(&o->mot_ioepoch_mutex); - EXIT; + ENTRY; + spin_lock(&o->mot_write_lock); + o->mot_write_count++; + spin_unlock(&o->mot_write_lock); + EXIT; } /* there can be no real transaction so prepare the fake one */ @@ -623,8 +252,7 @@ static void mdt_empty_transno(struct mdt_thread_info *info, int rc) RETURN_EXIT; } - if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE || - lustre_msg_get_opc(req->rq_reqmsg) == MDS_DONE_WRITING) { + if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE) { if (info->mti_transno != 0) lcd->lcd_last_close_transno = info->mti_transno; lcd->lcd_last_close_xid = req->rq_xid; @@ -741,15 +369,11 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p, repbody->mbo_valid |= OBD_MD_FLDIREA | OBD_MD_MEA; } - if (flags & FMODE_WRITE) { + if (flags & FMODE_WRITE) rc = mdt_write_get(o); - if (rc == 0) { - mdt_ioepoch_open(info, o, created); - repbody->mbo_ioepoch = o->mot_ioepoch; - } - } else if (flags & MDS_FMODE_EXEC) { + else if (flags & MDS_FMODE_EXEC) rc = mdt_write_deny(o); - } + if (rc) RETURN(rc); @@ -853,8 +477,6 @@ static int mdt_mfd_open(struct mdt_thread_info *info, struct mdt_object *p, err_out: if (flags & FMODE_WRITE) - /* XXX We also need to close io epoch here. - * See LU-1220 - green */ mdt_write_put(o); else if (flags & MDS_FMODE_EXEC) mdt_write_allow(o); @@ -2071,8 +1693,7 @@ static int mdt_hsm_release(struct mdt_thread_info *info, struct mdt_object *o, /* Set file as released */ ma->ma_lmm->lmm_pattern |= cpu_to_le32(LOV_PATTERN_F_RELEASED); - /* Hopefully it's not used in this call path */ - orp_ma = &info->mti_u.som.attr; + orp_ma = &info->mti_u.hsm.attr; orp_ma->ma_attr.la_mode = S_IFREG | S_IWUSR; orp_ma->ma_attr.la_uid = ma->ma_attr.la_uid; orp_ma->ma_attr.la_gid = ma->ma_attr.la_gid; @@ -2149,8 +1770,7 @@ out_reprocess: return rc; } -#define MFD_CLOSED(mode) (((mode) & ~(MDS_FMODE_EPOCH | MDS_FMODE_SOM | \ - MDS_FMODE_TRUNC)) == MDS_FMODE_CLOSED) +#define MFD_CLOSED(mode) ((mode) == MDS_FMODE_CLOSED) static int mdt_mfd_closed(struct mdt_file_data *mfd) { @@ -2162,7 +1782,6 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd) struct mdt_object *o = mfd->mfd_object; struct md_object *next = mdt_object_child(o); struct md_attr *ma = &info->mti_attr; - int ret = MDT_IOEPOCH_CLOSED; int rc = 0; __u64 mode; ENTRY; @@ -2179,16 +1798,10 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd) } } - if ((mode & FMODE_WRITE) || (mode & MDS_FMODE_TRUNC)) { - mdt_write_put(o); - ret = mdt_ioepoch_close(info, o); - } else if (mode & MDS_FMODE_EXEC) { - mdt_write_allow(o); - } else if (mode & MDS_FMODE_EPOCH) { - ret = mdt_ioepoch_close(info, o); - } else if (mode & MDS_FMODE_SOM) { - ret = mdt_som_au_close(info, o); - } + if (mode & FMODE_WRITE) + mdt_write_put(o); + else if (mode & MDS_FMODE_EXEC) + mdt_write_allow(o); /* Update atime on close only. */ if ((mode & MDS_FMODE_EXEC || mode & FMODE_READ || mode & FMODE_WRITE) @@ -2209,43 +1822,18 @@ int mdt_mfd_close(struct mdt_thread_info *info, struct mdt_file_data *mfd) if (!MFD_CLOSED(mode)) rc = mo_close(info->mti_env, next, ma, mode); - if (ret == MDT_IOEPOCH_GETATTR || ret == MDT_IOEPOCH_OPENED) { - struct mdt_export_data *med; - - /* The IOepoch is still opened or SOM update is needed. - * Put mfd back into the list. */ - LASSERT(mdt_conn_flags(info) & OBD_CONNECT_SOM); - mdt_mfd_set_mode(mfd, ret == MDT_IOEPOCH_OPENED ? - MDS_FMODE_EPOCH : MDS_FMODE_SOM); - - LASSERT(mdt_info_req(info)); - med = &mdt_info_req(info)->rq_export->exp_mdt_data; - spin_lock(&med->med_open_lock); - list_add(&mfd->mfd_list, &med->med_open_head); - class_handle_hash_back(&mfd->mfd_handle); - spin_unlock(&med->med_open_lock); - - if (ret == MDT_IOEPOCH_OPENED) { - ret = 0; - } else { - ret = -EAGAIN; - CDEBUG(D_INODE, "Size-on-MDS attribute update is " - "needed on "DFID"\n", PFID(mdt_object_fid(o))); - } - } else { - /* adjust open and lease count */ - if (mode & MDS_OPEN_LEASE) { - LASSERT(atomic_read(&o->mot_lease_count) > 0); - atomic_dec(&o->mot_lease_count); - } - LASSERT(atomic_read(&o->mot_open_count) > 0); - atomic_dec(&o->mot_open_count); - - mdt_mfd_free(mfd); - mdt_object_put(info->mti_env, o); + /* adjust open and lease count */ + if (mode & MDS_OPEN_LEASE) { + LASSERT(atomic_read(&o->mot_lease_count) > 0); + atomic_dec(&o->mot_lease_count); } - RETURN(rc ? rc : ret); + LASSERT(atomic_read(&o->mot_open_count) > 0); + atomic_dec(&o->mot_open_count); + mdt_mfd_free(mfd); + mdt_object_put(info->mti_env, o); + + RETURN(rc); } int mdt_close(struct tgt_session_info *tsi) @@ -2266,8 +1854,6 @@ int mdt_close(struct tgt_session_info *tsi) if (rc) GOTO(out, rc = err_serious(rc)); - LASSERT(info->mti_ioepoch); - /* These fields are no longer used and are left for compatibility. * size is always zero */ req_capsule_set_size(info->mti_pill, &RMF_MDT_MD, RCL_SERVER, @@ -2301,13 +1887,12 @@ int mdt_close(struct tgt_session_info *tsi) med = &req->rq_export->exp_mdt_data; spin_lock(&med->med_open_lock); - mfd = mdt_handle2mfd(med, &info->mti_ioepoch->handle, - req_is_replay(req)); + mfd = mdt_handle2mfd(med, &info->mti_close_handle, req_is_replay(req)); if (mdt_mfd_closed(mfd)) { spin_unlock(&med->med_open_lock); CDEBUG(D_INODE, "no handle for file close: fid = "DFID ": cookie = "LPX64"\n", PFID(info->mti_rr.rr_fid1), - info->mti_ioepoch->handle.cookie); + info->mti_close_handle.cookie); /** not serious error since bug 3633 */ rc = -ESTALE; } else { @@ -2340,86 +1925,3 @@ out: mdt_thread_info_fini(info); RETURN(rc ? rc : ret); } - -/** - * DONE_WRITING rpc handler. - * - * As mfd is not kept after replayed CLOSE (see mdt_ioepoch_close_on_replay()), - * only those DONE_WRITING rpc will be replayed which really wrote smth on disk, - * and got a trasid. Waiting for such DONE_WRITING is not reliable, so just - * skip attributes and reconstruct the reply here. - */ -int mdt_done_writing(struct tgt_session_info *tsi) -{ - struct ptlrpc_request *req = tgt_ses_req(tsi); - struct mdt_thread_info *info = tsi2mdt_info(tsi); - struct mdt_body *repbody = NULL; - struct mdt_export_data *med; - struct mdt_file_data *mfd; - int rc; - ENTRY; - - rc = req_capsule_server_pack(tsi->tsi_pill); - if (rc) - GOTO(out, rc = err_serious(rc)); - - repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_MDT_BODY); - repbody->mbo_eadatasize = 0; - repbody->mbo_aclsize = 0; - - /* Done Writing may come with the Size-on-MDS update. Unpack it. */ - rc = mdt_close_unpack(info); - if (rc) - GOTO(out, rc = err_serious(rc)); - - if (mdt_check_resent(info, mdt_reconstruct_generic, NULL)) { - mdt_exit_ucred(info); - GOTO(out, rc = lustre_msg_get_status(req->rq_repmsg)); - } - - med = &info->mti_exp->exp_mdt_data; - spin_lock(&med->med_open_lock); - mfd = mdt_handle2mfd(med, &info->mti_ioepoch->handle, - req_is_replay(req)); - if (mfd == NULL) { - spin_unlock(&med->med_open_lock); - CDEBUG(D_INODE, "no handle for done write: fid = "DFID - ": cookie = "LPX64" ioepoch = "LPU64"\n", - PFID(info->mti_rr.rr_fid1), - info->mti_ioepoch->handle.cookie, - info->mti_ioepoch->ioepoch); - /* If this is a replay, reconstruct the transno. */ - if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - rc = info->mti_ioepoch->flags & MF_SOM_AU ? - -EAGAIN : 0; - mdt_empty_transno(info, rc); - } else - rc = -ESTALE; - GOTO(error_ucred, rc); - } - - LASSERT(mfd->mfd_mode == MDS_FMODE_EPOCH || - mfd->mfd_mode == MDS_FMODE_TRUNC); - class_handle_unhash(&mfd->mfd_handle); - list_del_init(&mfd->mfd_list); - spin_unlock(&med->med_open_lock); - - /* Set EPOCH CLOSE flag if not set by client. */ - info->mti_ioepoch->flags |= MF_EPOCH_CLOSE; - info->mti_attr.ma_valid = 0; - - info->mti_attr.ma_lmm_size = info->mti_mdt->mdt_max_mdsize; - OBD_ALLOC_LARGE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize); - if (info->mti_attr.ma_lmm == NULL) - GOTO(error_ucred, rc = -ENOMEM); - - rc = mdt_mfd_close(info, mfd); - - OBD_FREE_LARGE(info->mti_attr.ma_lmm, info->mti_mdt->mdt_max_mdsize); - mdt_empty_transno(info, rc); -error_ucred: - mdt_exit_ucred(info); -out: - mdt_thread_info_fini(info); - RETURN(rc); -} diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 5358bfe..f9260a3 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -199,8 +199,7 @@ void mdt_req_from_lcd(struct ptlrpc_request *req, struct lsd_client_data *lcd) DEBUG_REQ(D_HA, req, "restoring transno "LPD64"/status %d", lcd->lcd_last_transno, lcd->lcd_last_result); - if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE || - lustre_msg_get_opc(req->rq_repmsg) == MDS_DONE_WRITING) { + if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_CLOSE) { req->rq_transno = lcd->lcd_last_close_transno; req->rq_status = lcd->lcd_last_close_result; } else { @@ -331,21 +330,6 @@ static void mdt_reconstruct_setattr(struct mdt_thread_info *mti, mdt_fake_ma(&mti->mti_attr); mdt_pack_attr2body(mti, body, &mti->mti_attr.ma_attr, mdt_object_fid(obj)); - if (mti->mti_ioepoch && (mti->mti_ioepoch->flags & MF_EPOCH_OPEN)) { - struct mdt_file_data *mfd; - struct mdt_body *repbody; - - repbody = req_capsule_server_get(mti->mti_pill, &RMF_MDT_BODY); - repbody->mbo_ioepoch = obj->mot_ioepoch; - spin_lock(&med->med_open_lock); - list_for_each_entry(mfd, &med->med_open_head, mfd_list) { - if (mfd->mfd_xid == req->rq_xid) - break; - } - LASSERT(&mfd->mfd_list != &med->med_open_head); - spin_unlock(&med->med_open_lock); - repbody->mbo_handle.cookie = mfd->mfd_handle.h_cookie; - } mdt_object_put(mti->mti_env, obj); } diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 9d3f468..bbb20c3 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -661,11 +661,9 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, struct md_attr *ma = &info->mti_attr; struct mdt_reint_record *rr = &info->mti_rr; struct ptlrpc_request *req = mdt_info_req(info); - struct mdt_export_data *med = &req->rq_export->exp_mdt_data; - struct mdt_file_data *mfd; struct mdt_object *mo; struct mdt_body *repbody; - int som_au, rc, rc2; + int rc, rc2; ENTRY; DEBUG_REQ(D_INODE, req, "setattr "DFID" %x", PFID(rr->rr_fid1), @@ -685,70 +683,14 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, if (mdt_object_remote(mo)) GOTO(out_put, rc = -EREMOTE); - /* start a log jounal handle if needed */ - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM)) { - if ((ma->ma_attr.la_valid & LA_SIZE) || - (rr->rr_flags & MRF_OPEN_TRUNC)) { - /* Check write access for the O_TRUNC case */ - if (mdt_write_read(mo) < 0) - GOTO(out_put, rc = -ETXTBSY); - } - } else if (info->mti_ioepoch && - (info->mti_ioepoch->flags & MF_EPOCH_OPEN)) { - /* Truncate case. IOEpoch is opened. */ - rc = mdt_write_get(mo); - if (rc) - GOTO(out_put, rc); - - mfd = mdt_mfd_new(med); - if (mfd == NULL) { - mdt_write_put(mo); - GOTO(out_put, rc = -ENOMEM); - } - - mdt_ioepoch_open(info, mo, 0); - repbody->mbo_ioepoch = mo->mot_ioepoch; - - mdt_object_get(info->mti_env, mo); - mdt_mfd_set_mode(mfd, MDS_FMODE_TRUNC); - mfd->mfd_object = mo; - mfd->mfd_xid = req->rq_xid; - - spin_lock(&med->med_open_lock); - list_add(&mfd->mfd_list, &med->med_open_head); - spin_unlock(&med->med_open_lock); - repbody->mbo_handle.cookie = mfd->mfd_handle.h_cookie; - } - - som_au = info->mti_ioepoch && info->mti_ioepoch->flags & MF_SOM_CHANGE; - if (som_au) { - /* SOM Attribute update case. Find the proper mfd and update - * SOM attributes on the proper object. */ - if (!(mdt_conn_flags(info) & OBD_CONNECT_SOM)) - GOTO(out_put, rc = -EPROTO); - - spin_lock(&med->med_open_lock); - mfd = mdt_handle2mfd(med, &info->mti_ioepoch->handle, - req_is_replay(req)); - if (mfd == NULL) { - spin_unlock(&med->med_open_lock); - CDEBUG(D_INODE, "no handle for file close: " - "fid = "DFID": cookie = "LPX64"\n", - PFID(info->mti_rr.rr_fid1), - info->mti_ioepoch->handle.cookie); - GOTO(out_put, rc = -ESTALE); - } - - if (mfd->mfd_mode != MDS_FMODE_SOM || - (info->mti_ioepoch->flags & MF_EPOCH_CLOSE)) - GOTO(out_put, rc = -EPROTO); - - class_handle_unhash(&mfd->mfd_handle); - list_del_init(&mfd->mfd_list); - spin_unlock(&med->med_open_lock); + if ((ma->ma_attr.la_valid & LA_SIZE) || + (rr->rr_flags & MRF_OPEN_TRUNC)) { + /* Check write access for the O_TRUNC case */ + if (mdt_write_read(mo) < 0) + GOTO(out_put, rc = -ETXTBSY); + } - mdt_mfd_close(info, mfd); - } else if ((ma->ma_valid & MA_INODE) && ma->ma_attr.la_valid) { + if ((ma->ma_valid & MA_INODE) && ma->ma_attr.la_valid) { if (ma->ma_valid & MA_LOV) GOTO(out_put, rc = -EPROTO); @@ -810,7 +752,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, if (info->mti_mdt->mdt_lut.lut_oss_capa && exp_connect_flags(info->mti_exp) & OBD_CONNECT_OSS_CAPA && S_ISREG(lu_object_attr(&mo->mot_obj)) && - (ma->ma_attr.la_valid & LA_SIZE) && !som_au) { + (ma->ma_attr.la_valid & LA_SIZE)) { struct lustre_capa *capa; capa = req_capsule_server_get(info->mti_pill, &RMF_CAPA2); -- 1.8.3.1