X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fliblustre%2Fsuper.c;h=3f3788a7461e75b03e7a5d990f2cbe32e9a0c840;hp=b89c5e900951a2ed79009b56c3de03d6cc07afe5;hb=218322d65b7d33ea185c7186b432f684e440eada;hpb=9f3469f1d00099b9301ba2b90c846c924ce7796b diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index b89c5e9..3f3788a 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -27,7 +27,7 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Whamcloud, Inc. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -69,10 +69,10 @@ static int ll_permission(struct inode *inode, int mask) struct intnl_stat *st = llu_i2stat(inode); mode_t mode = st->st_mode; - if (current->fsuid == st->st_uid) - mode >>= 6; - else if (cfs_curproc_is_in_groups(st->st_gid)) - mode >>= 3; + if (current->fsuid == st->st_uid) + mode >>= 6; + else if (in_group_p(st->st_gid)) + mode >>= 3; if ((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask) return 0; @@ -120,7 +120,7 @@ static ldlm_mode_t llu_take_md_lock(struct inode *inode, __u64 bits, ldlm_policy_data_t policy = { .l_inodebits = {bits}}; struct lu_fid *fid; ldlm_mode_t rc; - int flags; + __u64 flags; ENTRY; fid = &llu_i2info(inode)->lli_fid; @@ -220,10 +220,9 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) valid &= src->o_valid; - LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID | - OBD_MD_FLID | OBD_MD_FLGROUP)), - "object "LPU64"/"LPU64", valid %x\n", - src->o_id, src->o_seq, valid); + LASSERTF(!(valid & (OBD_MD_FLTYPE | OBD_MD_FLGENER | OBD_MD_FLFID | + OBD_MD_FLID | OBD_MD_FLGROUP)), + "object "DOSTID", valid %x\n", POSTID(&src->o_oi), valid); if (valid & (OBD_MD_FLCTIME | OBD_MD_FLMTIME)) CDEBUG(D_INODE,"valid "LPX64", cur time "CFS_TIME_T"/"CFS_TIME_T @@ -274,8 +273,7 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo, oinfo.oi_md = lsm; oinfo.oi_oa = obdo; - oinfo.oi_oa->o_id = lsm->lsm_object_id; - oinfo.oi_oa->o_seq = lsm->lsm_object_seq; + oinfo.oi_oa->o_oi = lsm->lsm_oi; oinfo.oi_oa->o_mode = S_IFREG; oinfo.oi_oa->o_ioepoch = ioepoch; oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | @@ -307,9 +305,9 @@ int llu_inode_getattr(struct inode *inode, struct obdo *obdo, OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE; - obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid); - CDEBUG(D_INODE, "objid "LPX64" size %llu, blocks %llu, " - "blksize %llu\n", oinfo.oi_oa->o_id, + obdo_refresh_inode(inode, oinfo.oi_oa, oinfo.oi_oa->o_valid); + CDEBUG(D_INODE, "objid "DOSTID" size %llu, blocks %llu, " + "blksize %llu\n", POSTID(&oinfo.oi_oa->o_oi), (long long unsigned)llu_i2stat(inode)->st_size, (long long unsigned)llu_i2stat(inode)->st_blocks, (long long unsigned)llu_i2stat(inode)->st_blksize); @@ -368,7 +366,7 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart) struct lustre_handle lockh; ldlm_policy_data_t policy = { .l_inodebits = { lockpart } }; struct lu_fid *fid; - int flags; + __u64 flags; ENTRY; LASSERT(inode); @@ -516,8 +514,7 @@ void llu_clear_inode(struct inode *inode) inode); lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; - md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), - null_if_equal, inode); + md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode)); lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) @@ -572,12 +569,12 @@ static int inode_setattr(struct inode * inode, struct iattr * attr) st->st_mtime = attr->ia_mtime; if (ia_valid & ATTR_CTIME) st->st_ctime = attr->ia_ctime; - if (ia_valid & ATTR_MODE) { - st->st_mode = attr->ia_mode; - if (!cfs_curproc_is_in_groups(st->st_gid) && - !cfs_capable(CFS_CAP_FSETID)) - st->st_mode &= ~S_ISGID; - } + if (ia_valid & ATTR_MODE) { + st->st_mode = attr->ia_mode; + if (!in_group_p(st->st_gid) && + !cfs_capable(CFS_CAP_FSETID)) + st->st_mode &= ~S_ISGID; + } /* mark_inode_dirty(inode); */ return error; } @@ -1263,20 +1260,23 @@ static int llu_file_flock(struct inode *ino, int cmd, struct file_lock *file_lock) { - struct llu_inode_info *lli = llu_i2info(ino); - struct intnl_stat *st = llu_i2stat(ino); - struct ldlm_res_id res_id = - { .name = {fid_seq(&lli->lli_fid), - fid_oid(&lli->lli_fid), - fid_ver(&lli->lli_fid), - LDLM_FLOCK} }; - struct ldlm_enqueue_info einfo = { LDLM_FLOCK, 0, NULL, - ldlm_flock_completion_ast, NULL, NULL, file_lock }; - - struct lustre_handle lockh = {0}; - ldlm_policy_data_t flock; - int flags = 0; - int rc; + struct llu_inode_info *lli = llu_i2info(ino); + struct ldlm_res_id res_id = + { .name = {fid_seq(&lli->lli_fid), + fid_oid(&lli->lli_fid), + fid_ver(&lli->lli_fid), + LDLM_FLOCK} }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_FLOCK, + .ei_mode = 0, + .ei_cb_cp = ldlm_flock_completion_ast, + .ei_cbdata = file_lock, + }; + struct intnl_stat *st = llu_i2stat(ino); + struct lustre_handle lockh = {0}; + ldlm_policy_data_t flock; + __u64 flags = 0; + int rc; CDEBUG(D_VFSTRACE, "VFS Op:inode=%llu file_lock=%p\n", (unsigned long long)st->st_ino, file_lock); @@ -1331,7 +1331,7 @@ static int llu_file_flock(struct inode *ino, LBUG(); } - CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags=%#x, mode=%u, " + CDEBUG(D_DLMTRACE, "inode=%llu, pid=%u, cmd=%d, flags=%#llx, mode=%u, " "start="LPX64", end="LPX64"\n", (unsigned long long)st->st_ino, flock.l_flock.pid, cmd, flags, einfo.ei_mode, flock.l_flock.start, flock.l_flock.end); @@ -1345,11 +1345,12 @@ static int llu_file_flock(struct inode *ino, if (lmv->desc.ld_tgt_count < 1) RETURN(rc = -ENODEV); - if (lmv->tgts[0].ltd_exp != NULL) - rc = ldlm_cli_enqueue(lmv->tgts[0].ltd_exp, NULL, &einfo, &res_id, - &flock, &flags, NULL, 0, &lockh, 0); - else - rc = -ENODEV; + if (lmv->tgts[0] != NULL && lmv->tgts[0]->ltd_exp != NULL) + rc = ldlm_cli_enqueue(lmv->tgts[0]->ltd_exp, NULL, + &einfo, &res_id, &flock, &flags, + NULL, 0, LVB_T_NONE, &lockh, 0); + else + rc = -ENODEV; } RETURN(rc); } @@ -1599,7 +1600,7 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg) LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0])); - if (cfs_copy_from_user(&lum, lump, sizeof(lum))) + if (copy_from_user(&lum, lump, sizeof(lum))) return(-EFAULT); switch (lum.lmm_magic) { @@ -1637,25 +1638,29 @@ static int llu_lov_dir_setstripe(struct inode *ino, unsigned long arg) } static int llu_lov_setstripe_ea_info(struct inode *ino, int flags, - struct lov_user_md *lum, int lum_size) + struct lov_user_md *lum, int lum_size) { - struct llu_sb_info *sbi = llu_i2sbi(ino); - struct llu_inode_info *lli = llu_i2info(ino); - struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; - struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CR, - llu_md_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL }; - struct ptlrpc_request *req = NULL; - struct lustre_md md; - struct md_op_data data = {{ 0 }}; - struct lustre_handle lockh; - int rc = 0; - ENTRY; + struct llu_sb_info *sbi = llu_i2sbi(ino); + struct llu_inode_info *lli = llu_i2info(ino); + struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = LCK_CR, + .ei_cb_bl = llu_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; + struct ptlrpc_request *req = NULL; + struct lustre_md md; + struct md_op_data data = {{ 0 }}; + struct lustre_handle lockh; + int rc = 0; + ENTRY; if (lli->lli_has_smd) { - CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n", - PFID(&lli->lli_fid)); - return -EEXIST; - } + CDEBUG(D_IOCTL, "stripe already exists for ino "DFID"\n", + PFID(&lli->lli_fid)); + return -EEXIST; + } llu_prep_md_op_data(&data, NULL, ino, NULL, 0, O_RDWR, LUSTRE_OPC_ANY); @@ -1707,7 +1712,7 @@ static int llu_lov_file_setstripe(struct inode *ino, unsigned long arg) LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum.lmm_objects[0]) == sizeof(lump->lmm_objects[0])); - if (cfs_copy_from_user(&lum, lump, sizeof(lum))) + if (copy_from_user(&lum, lump, sizeof(lum))) RETURN(-EFAULT); rc = llu_lov_setstripe_ea_info(ino, flags, &lum, sizeof(lum)); @@ -1924,7 +1929,8 @@ llu_fsswop_mount(const char *source, ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION | OBD_CONNECT_FID | OBD_CONNECT_AT | - OBD_CONNECT_VBR | OBD_CONNECT_FULL20; + OBD_CONNECT_VBR | OBD_CONNECT_FULL20 | + OBD_CONNECT_LVB_TYPE; #ifdef LIBLUSTRE_POSIX_ACL ocd.ocd_connect_flags |= OBD_CONNECT_ACL; @@ -1962,7 +1968,8 @@ llu_fsswop_mount(const char *source, ocd.ocd_connect_flags = OBD_CONNECT_SRVLOCK | OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_FID | OBD_CONNECT_AT | - OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS; + OBD_CONNECT_FULL20 | OBD_CONNECT_EINPROGRESS | + OBD_CONNECT_LVB_TYPE; ocd.ocd_version = LUSTRE_VERSION_CODE; err = obd_connect(NULL, &sbi->ll_dt_exp, obd, &sbi->ll_sb_uuid, &ocd, NULL); @@ -2046,7 +2053,8 @@ out_free: OBD_FREE(osc, strlen(lprof->lp_dt) + instlen + 2); if (mdc) OBD_FREE(mdc, strlen(lprof->lp_md) + instlen + 2); - OBD_FREE(sbi, sizeof(*sbi)); + if (err != 0) + OBD_FREE(sbi, sizeof(*sbi)); liblustre_wait_idle(); return err; }