X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_handler.c;h=cf82eb024ae72f2a40f723bca551eb69bc437b61;hb=8daba6a7381a2fb8cc933f7e9486f60e659465d4;hp=5118c445e1692707838e1dbf7b5d8aa4a3f32081;hpb=ad1810a2dbea1eed5e8b5feb55bdf915a545feb3;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5118c44..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. @@ -454,27 +427,60 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, LASSERT(ma->ma_valid & MA_INODE); - b->mbo_atime = attr->la_atime; - b->mbo_mtime = attr->la_mtime; - b->mbo_ctime = attr->la_ctime; - b->mbo_mode = attr->la_mode; - b->mbo_size = attr->la_size; - b->mbo_blocks = attr->la_blocks; - b->mbo_uid = nodemap_map_id(nodemap, NODEMAP_UID, - NODEMAP_FS_TO_CLIENT, - attr->la_uid); - b->mbo_gid = nodemap_map_id(nodemap, NODEMAP_GID, - NODEMAP_FS_TO_CLIENT, - attr->la_gid); - b->mbo_flags = attr->la_flags; - b->mbo_nlink = attr->la_nlink; - b->mbo_rdev = attr->la_rdev; - - /* XXX should pack the reply body according to lu_valid */ - b->mbo_valid |= OBD_MD_FLCTIME | OBD_MD_FLUID | - OBD_MD_FLGID | OBD_MD_FLTYPE | - OBD_MD_FLMODE | OBD_MD_FLNLINK | OBD_MD_FLFLAGS | - OBD_MD_FLATIME | OBD_MD_FLMTIME ; + if (attr->la_valid & LA_ATIME) { + b->mbo_atime = attr->la_atime; + b->mbo_valid |= OBD_MD_FLATIME; + } + if (attr->la_valid & LA_MTIME) { + b->mbo_mtime = attr->la_mtime; + b->mbo_valid |= OBD_MD_FLMTIME; + } + if (attr->la_valid & LA_CTIME) { + b->mbo_ctime = attr->la_ctime; + b->mbo_valid |= OBD_MD_FLCTIME; + } + if (attr->la_valid & LA_FLAGS) { + b->mbo_flags = attr->la_flags; + b->mbo_valid |= OBD_MD_FLFLAGS; + } + if (attr->la_valid & LA_NLINK) { + b->mbo_nlink = attr->la_nlink; + b->mbo_valid |= OBD_MD_FLNLINK; + } + if (attr->la_valid & LA_UID) { + b->mbo_uid = nodemap_map_id(nodemap, NODEMAP_UID, + NODEMAP_FS_TO_CLIENT, + attr->la_uid); + b->mbo_valid |= OBD_MD_FLUID; + } + if (attr->la_valid & LA_GID) { + b->mbo_gid = nodemap_map_id(nodemap, NODEMAP_GID, + NODEMAP_FS_TO_CLIENT, + attr->la_gid); + b->mbo_valid |= OBD_MD_FLGID; + } + b->mbo_mode = attr->la_mode; + if (attr->la_valid & LA_MODE) + b->mbo_valid |= OBD_MD_FLMODE; + if (attr->la_valid & LA_TYPE) + b->mbo_valid |= OBD_MD_FLTYPE; + + if (fid != NULL) { + b->mbo_fid1 = *fid; + b->mbo_valid |= OBD_MD_FLID; + CDEBUG(D_INODE, DFID": nlink=%d, mode=%o, valid="LPX64"\n", + PFID(fid), b->mbo_nlink, b->mbo_mode, b->mbo_valid); + } + + if (info != NULL) + mdt_body_reverse_idmap(info, b); + + if (!(attr->la_valid & LA_TYPE)) + return; + + b->mbo_rdev = attr->la_rdev; + b->mbo_size = attr->la_size; + b->mbo_blocks = attr->la_blocks; if (!S_ISREG(attr->la_mode)) { b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLRDEV; @@ -499,17 +505,6 @@ void mdt_pack_attr2body(struct mdt_thread_info *info, struct mdt_body *b, b->mbo_valid |= OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; } - if (fid) { - b->mbo_fid1 = *fid; - b->mbo_valid |= OBD_MD_FLID; - CDEBUG(D_INODE, DFID": nlink=%d, mode=%o, size="LPU64"\n", - PFID(fid), b->mbo_nlink, - b->mbo_mode, b->mbo_size); - } - - if (info) - mdt_body_reverse_idmap(info, b); - if (fid != NULL && (b->mbo_valid & OBD_MD_FLSIZE)) CDEBUG(D_VFSTRACE, DFID": returning size %llu\n", PFID(fid), (unsigned long long)b->mbo_size); @@ -792,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); @@ -919,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)) { @@ -1212,6 +1192,32 @@ out: return rc; } +/** + * Exchange MOF_LOV_CREATED flags between two objects after a + * layout swap. No assumption is made on whether o1 or o2 have + * created objects or not. + * + * \param[in,out] o1 First swap layout object + * \param[in,out] o2 Second swap layout object + */ +static void mdt_swap_lov_flag(struct mdt_object *o1, struct mdt_object *o2) +{ + __u64 o1_flags; + + mutex_lock(&o1->mot_lov_mutex); + mutex_lock(&o2->mot_lov_mutex); + + o1_flags = o1->mot_flags; + o1->mot_flags = (o1->mot_flags & ~MOF_LOV_CREATED) | + (o2->mot_flags & MOF_LOV_CREATED); + + o2->mot_flags = (o2->mot_flags & ~MOF_LOV_CREATED) | + (o1_flags & MOF_LOV_CREATED); + + mutex_unlock(&o2->mot_lov_mutex); + mutex_unlock(&o1->mot_lov_mutex); +} + static int mdt_swap_layouts(struct tgt_session_info *tsi) { struct mdt_thread_info *info; @@ -1297,7 +1303,11 @@ static int mdt_swap_layouts(struct tgt_session_info *tsi) rc = mo_swap_layouts(info->mti_env, mdt_object_child(o1), mdt_object_child(o2), msl->msl_flags); - GOTO(unlock2, rc); + if (rc < 0) + GOTO(unlock2, rc); + + mdt_swap_lov_flag(o1, o2); + unlock2: mdt_object_unlock(info, o2, lh2, rc); unlock1: @@ -1589,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); @@ -1608,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); @@ -4271,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), @@ -4464,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 @@ -4484,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; @@ -4779,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); @@ -4830,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, @@ -4965,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); @@ -5005,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); @@ -5115,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 */ @@ -5367,7 +5353,7 @@ static int mdt_path_current(struct mdt_thread_info *info, struct lu_buf *buf = &info->mti_big_buf; char *ptr; int reclen; - struct linkea_data ldata = { 0 }; + struct linkea_data ldata = { NULL }; int rc = 0; bool first = true; ENTRY; @@ -5546,10 +5532,11 @@ static int mdt_fid2path(struct mdt_thread_info *info, } obj = mdt_object_find(info->mti_env, mdt, &fp->gf_fid); - if (obj == NULL || IS_ERR(obj)) { - CDEBUG(D_IOCTL, "no object "DFID": %ld\n", PFID(&fp->gf_fid), - PTR_ERR(obj)); - RETURN(-EINVAL); + if (IS_ERR(obj)) { + rc = PTR_ERR(obj); + CDEBUG(D_IOCTL, "cannot find "DFID": rc = %d\n", + PFID(&fp->gf_fid), rc); + RETURN(rc); } if (mdt_object_remote(obj))