X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdt%2Fmdt_reint.c;h=bbb20c3cdbd66d615015cc7a61946336c984a4d8;hb=8daba6a7381a2fb8cc933f7e9486f60e659465d4;hp=f751f98a56f307fa68f62f72d11c7508fc6d1925;hpb=b5e911f4a98e60a852fd3c3cd99e5cfeabdc8edc;p=fs%2Flustre-release.git diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index f751f98..bbb20c3 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2013, Intel Corporation. + * Copyright (c) 2011, 2014, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -220,9 +220,10 @@ int mdt_version_get_check_save(struct mdt_thread_info *info, * This checks version of 'name'. Many reint functions uses 'name' for child not * FID, therefore we need to get object by name and check its version. */ -int mdt_lookup_version_check(struct mdt_thread_info *info, - struct mdt_object *p, const struct lu_name *lname, - struct lu_fid *fid, int idx) +static int mdt_lookup_version_check(struct mdt_thread_info *info, + struct mdt_object *p, + const struct lu_name *lname, + struct lu_fid *fid, int idx) { int rc, vbrc; @@ -313,8 +314,13 @@ static int mdt_remote_permission(struct mdt_thread_info *info, return -ENOTSUPP; if (S_ISDIR(attr->la_mode) && spec->u.sp_ea.eadata != NULL && - spec->u.sp_ea.eadatalen != 0 && !mdt_is_striped_client(exp)) - return -ENOTSUPP; + spec->u.sp_ea.eadatalen != 0) { + const struct lmv_user_md *lum = spec->u.sp_ea.eadata; + + if (le32_to_cpu(lum->lum_stripe_count) > 1 && + !mdt_is_striped_client(exp)) + return -ENOTSUPP; + } return 0; } @@ -655,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), @@ -679,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); @@ -763,14 +711,26 @@ static int mdt_reint_setattr(struct mdt_thread_info *info, GOTO(out_put, rc); } else if ((ma->ma_valid & MA_LMV) && (ma->ma_valid & MA_INODE)) { struct lu_buf *buf = &info->mti_buf; + struct mdt_lock_handle *lh; if (ma->ma_attr.la_valid != 0) GOTO(out_put, rc = -EPROTO); + lh = &info->mti_lh[MDT_LH_PARENT]; + mdt_lock_reg_init(lh, LCK_PW); + + rc = mdt_object_lock(info, mo, lh, + MDS_INODELOCK_XATTR, + MDT_LOCAL_LOCK); + if (rc != 0) + GOTO(out_put, rc); + buf->lb_buf = ma->ma_lmv; buf->lb_len = ma->ma_lmv_size; rc = mo_xattr_set(info->mti_env, mdt_object_child(mo), buf, XATTR_NAME_DEFAULT_LMV, 0); + + mdt_object_unlock(info, mo, lh, rc); if (rc) GOTO(out_put, rc); } else { @@ -792,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); @@ -1363,7 +1323,7 @@ static int mdt_lock_objects_in_linkea(struct mdt_thread_info *info, struct list_head *lock_list) { struct lu_buf *buf = &info->mti_big_buf; - struct linkea_data ldata = { 0 }; + struct linkea_data ldata = { NULL }; int count; int rc; ENTRY;