X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fllite%2Fllite_lib.c;h=01ddfd2512c6fb6d5b84263544590e93a134aeae;hp=9ac70e51d2cbcebf74dd3321b28b92a53cf4467d;hb=ea766bd959cc2347b223d597b3f8a31e010bed72;hpb=59c3911deb8357c4b6aad68d1b1fc81a8ad61b3f diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 9ac70e5..01ddfd2 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.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, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -280,6 +280,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sbi->ll_md_exp->exp_connect_data = *data; + err = obd_fid_init(sbi->ll_md_exp->exp_obd, sbi->ll_md_exp, + LUSTRE_SEQ_METADATA); + if (err) { + CERROR("%s: Can't init metadata layer FID infrastructure, " + "rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); + GOTO(out_md, err); + } + /* For mount, we only need fs info from MDT0, and also in DNE, it * can make sure the client can be mounted as long as MDT0 is * avaible */ @@ -287,7 +295,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), OBD_STATFS_FOR_MDT0); if (err) - GOTO(out_md, err); + GOTO(out_md_fid, err); /* This needs to be after statfs to ensure connect has finished. * Note that "data" does NOT contain the valid connect reply. @@ -310,7 +318,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, "server or downgrade client.\n", sbi->ll_md_exp->exp_obd->obd_name, buf); OBD_FREE(buf, CFS_PAGE_SIZE); - GOTO(out_md, err = -EPROTO); + GOTO(out_md_fid, err = -EPROTO); } size = sizeof(*data); @@ -319,7 +327,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (err) { CERROR("%s: Get connect data failed: rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); - GOTO(out_md, err); + GOTO(out_md_fid, err); } LASSERT(osfs->os_bsize); @@ -389,7 +397,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, obd = class_name2obd(dt); if (!obd) { CERROR("DT %s: not setup or attached\n", dt); - GOTO(out_md, err = -ENODEV); + GOTO(out_md_fid, err = -ENODEV); } data->ocd_connect_flags = OBD_CONNECT_GRANT | OBD_CONNECT_VERSION | @@ -451,6 +459,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, sbi->ll_dt_exp->exp_connect_data = *data; + err = obd_fid_init(sbi->ll_dt_exp->exp_obd, sbi->ll_dt_exp, + LUSTRE_SEQ_METADATA); + if (err) { + CERROR("%s: Can't init data layer FID infrastructure, " + "rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, err); + GOTO(out_dt, err); + } + mutex_lock(&sbi->ll_lco.lco_lock); sbi->ll_lco.lco_flags = data->ocd_connect_flags; sbi->ll_lco.lco_md_exp = sbi->ll_md_exp; @@ -461,13 +477,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, err = md_getstatus(sbi->ll_md_exp, &sbi->ll_root_fid, &oc); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); - GOTO(out_dt, err); + GOTO(out_lock_cn_cb, err); } if (!fid_is_sane(&sbi->ll_root_fid)) { CERROR("%s: Invalid root fid "DFID" during mount\n", sbi->ll_md_exp->exp_obd->obd_name, PFID(&sbi->ll_root_fid)); - GOTO(out_dt, err = -EINVAL); + GOTO(out_lock_cn_cb, err = -EINVAL); } CDEBUG(D_SUPER, "rootfid "DFID"\n", PFID(&sbi->ll_root_fid)); @@ -486,7 +502,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, OBD_ALLOC_PTR(op_data); if (op_data == NULL) - GOTO(out_dt, err = -ENOMEM); + GOTO(out_lock_cn_cb, err = -ENOMEM); op_data->op_fid1 = sbi->ll_root_fid; op_data->op_mode = 0; @@ -500,7 +516,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (err) { CERROR("%s: md_getattr failed for root: rc = %d\n", sbi->ll_md_exp->exp_obd->obd_name, err); - GOTO(out_dt, err); + GOTO(out_lock_cn_cb, err); } err = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp, @@ -508,11 +524,13 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (err) { CERROR("failed to understand root inode md: rc = %d\n", err); ptlrpc_req_finished(request); - GOTO(out_dt, err); + GOTO(out_lock_cn_cb, err); } LASSERT(fid_is_sane(&sbi->ll_root_fid)); - root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid, 0), &lmd); + root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid, + sbi->ll_flags & LL_SBI_32BIT_API), + &lmd); md_free_lustre_md(sbi->ll_md_exp, &lmd); ptlrpc_req_finished(request); @@ -589,11 +607,15 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, out_root: if (root) iput(root); +out_lock_cn_cb: + obd_fid_fini(sbi->ll_dt_exp->exp_obd); out_dt: obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; /* Make sure all OScs are gone, since cl_cache is accessing sbi. */ obd_zombie_barrier(); +out_md_fid: + obd_fid_fini(sbi->ll_md_exp->exp_obd); out_md: obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; @@ -681,6 +703,7 @@ void client_common_put_super(struct super_block *sb) cfs_list_del(&sbi->ll_conn_chain); + obd_fid_fini(sbi->ll_dt_exp->exp_obd); obd_disconnect(sbi->ll_dt_exp); sbi->ll_dt_exp = NULL; /* wait till all OSCs are gone, since cl_cache is accessing sbi. @@ -689,6 +712,7 @@ void client_common_put_super(struct super_block *sb) lprocfs_unregister_mountpoint(sbi); + obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; @@ -709,9 +733,11 @@ void ll_kill_super(struct super_block *sb) /* we need restore s_dev from changed for clustred NFS before put_super * because new kernels have cached s_dev and change sb->s_dev in * put_super not affected real removing devices */ - if (sbi) - sb->s_dev = sbi->ll_sdev_orig; - EXIT; + if (sbi) { + sb->s_dev = sbi->ll_sdev_orig; + sbi->ll_umounting = 1; + } + EXIT; } char *ll_read_opt(const char *opt, char *data) @@ -1117,8 +1143,6 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); - cl_env_cache_purge(~0); - cfs_module_put(THIS_MODULE); EXIT; @@ -1281,16 +1305,12 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, RETURN(rc); } - /* We want to adjust timestamps. - * If there is at least some data in file, we cleared ATTR_SIZE - * to avoid update size, otherwise it is important to do.(SOM case) - * (bug 6196) */ - ia_valid = op_data->op_attr.ia_valid; - /* Since we set ATTR_*_SET flags above, and already done permission - * check, So don't let inode_change_ok() check it again. */ - op_data->op_attr.ia_valid &= ~TIMES_SET_FLAGS; - rc = simple_setattr(dentry, &op_data->op_attr); - op_data->op_attr.ia_valid = ia_valid; + ia_valid = op_data->op_attr.ia_valid; + /* inode size will be in ll_setattr_ost, can't do it now since dirty + * cache is not cleared yet. */ + op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); + rc = simple_setattr(dentry, &op_data->op_attr); + op_data->op_attr.ia_valid = ia_valid; /* Extract epoch data if obtained. */ op_data->op_handle = md.body->handle; @@ -1413,12 +1433,10 @@ out_big: */ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) { - struct lov_stripe_md *lsm; struct inode *inode = dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; - int ia_valid = attr->ia_valid; int rc = 0, rc1 = 0; ENTRY; @@ -1427,7 +1445,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) PFID(&lli->lli_fid), i_size_read(inode), attr->ia_size, attr->ia_valid); - if (ia_valid & ATTR_SIZE) { + if (attr->ia_valid & ATTR_SIZE) { /* Check new size against VFS/VM file size limit and rlimit */ rc = inode_newsize_ok(inode, attr->ia_size); if (rc) @@ -1447,7 +1465,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) } /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ - if (ia_valid & TIMES_SET_FLAGS) { + if (attr->ia_valid & TIMES_SET_FLAGS) { if (cfs_curproc_fsuid() != inode->i_uid && !cfs_capable(CFS_CAP_FOWNER)) RETURN(-EPERM); @@ -1458,11 +1476,13 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) attr->ia_ctime = CFS_CURRENT_TIME; attr->ia_valid |= ATTR_CTIME_SET; } - if (!(ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) { + if (!(attr->ia_valid & ATTR_ATIME_SET) && + (attr->ia_valid & ATTR_ATIME)) { attr->ia_atime = CFS_CURRENT_TIME; attr->ia_valid |= ATTR_ATIME_SET; } - if (!(ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) { + if (!(attr->ia_valid & ATTR_MTIME_SET) && + (attr->ia_valid & ATTR_MTIME)) { attr->ia_mtime = CFS_CURRENT_TIME; attr->ia_valid |= ATTR_MTIME_SET; } @@ -1474,6 +1494,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* If we are changing file size, file content is modified, flag it. */ if (attr->ia_valid & ATTR_SIZE) { + attr->ia_valid |= MDS_OPEN_OWNEROVERRIDE; spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_DATA_MODIFIED; spin_unlock(&lli->lli_lock); @@ -1487,28 +1508,17 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) RETURN(-ENOMEM); if (!S_ISDIR(inode->i_mode)) { - if (ia_valid & ATTR_SIZE) + if (attr->ia_valid & ATTR_SIZE) inode_dio_write_done(inode); mutex_unlock(&inode->i_mutex); down_write(&lli->lli_trunc_sem); } - /* We need a steady stripe configuration for setattr to avoid - * confusion. */ - lsm = ccc_inode_lsm_get(inode); - - /* NB: ATTR_SIZE will only be set after this point if the size - * resides on the MDS, ie, this file has no objects. */ - if (lsm != NULL) - attr->ia_valid &= ~ATTR_SIZE; - /* can't call ll_setattr_ost() while holding a refcount of lsm */ - ccc_inode_lsm_put(inode, lsm); - memcpy(&op_data->op_attr, attr, sizeof(*attr)); /* Open epoch for truncate. */ if (exp_connect_som(ll_i2mdexp(inode)) && - (ia_valid & (ATTR_SIZE | ATTR_MTIME | ATTR_MTIME_SET))) + (attr->ia_valid & (ATTR_SIZE | ATTR_MTIME | ATTR_MTIME_SET))) op_data->op_flags = MF_EPOCH_OPEN; rc = ll_md_setattr(dentry, op_data, &mod); @@ -1526,11 +1536,9 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) if (!S_ISREG(inode->i_mode)) GOTO(out, rc = 0); - if (ia_valid & ATTR_SIZE) - attr->ia_valid |= ATTR_SIZE; - if (ia_valid & (ATTR_SIZE | - ATTR_ATIME | ATTR_ATIME_SET | - ATTR_MTIME | ATTR_MTIME_SET)) + if (attr->ia_valid & (ATTR_SIZE | + ATTR_ATIME | ATTR_ATIME_SET | + ATTR_MTIME | ATTR_MTIME_SET)) /* For truncate and utimes sending attributes to OSTs, setting * mtime/atime to the past will be performed under PW [0:EOF] * extent lock (new_size:EOF for truncate). It may seem @@ -1551,11 +1559,11 @@ out: if (!S_ISDIR(inode->i_mode)) { up_write(&lli->lli_trunc_sem); mutex_lock(&inode->i_mutex); - if (ia_valid & ATTR_SIZE) + if (attr->ia_valid & ATTR_SIZE) inode_dio_wait(inode); } - ll_stats_ops_tally(ll_i2sbi(inode), (ia_valid & ATTR_SIZE) ? + ll_stats_ops_tally(ll_i2sbi(inode), (attr->ia_valid & ATTR_SIZE) ? LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1); return rc; @@ -1731,7 +1739,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) spin_unlock(&lli->lli_lock); } #endif - inode->i_ino = cl_fid_build_ino(&body->fid1, 0); + inode->i_ino = cl_fid_build_ino(&body->fid1, + sbi->ll_flags & LL_SBI_32BIT_API); inode->i_generation = cl_fid_build_gen(&body->fid1); if (body->valid & OBD_MD_FLATIME) { @@ -1790,7 +1799,7 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) if (body->valid & OBD_MD_FLSIZE) { if (exp_connect_som(ll_i2mdexp(inode)) && - S_ISREG(inode->i_mode) && lli->lli_has_smd) { + S_ISREG(inode->i_mode)) { struct lustre_handle lockh; ldlm_mode_t mode; @@ -1897,7 +1906,8 @@ void ll_delete_inode(struct inode *inode) if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) /* discard all dirty pages before truncating them, required by * osc_extent implementation at LU-1030. */ - cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, CL_FSYNC_DISCARD); + cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, + CL_FSYNC_DISCARD, 1); truncate_inode_pages(&inode->i_data, 0); @@ -1990,8 +2000,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, RETURN(-ENOMEM); } oinfo.oi_md = lsm; - 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_flags = flags; oinfo.oi_oa->o_valid = OBD_MD_FLID | OBD_MD_FLFLAGS | OBD_MD_FLGROUP; @@ -2072,16 +2081,15 @@ void ll_umount_begin(struct super_block *sb) obd->obd_force = 1; OBD_ALLOC_PTR(ioc_data); - if (ioc_data) { - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, - sizeof ioc_data, ioc_data, NULL); + if (ioc_data) { + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, + sizeof *ioc_data, ioc_data, NULL); - obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, - sizeof ioc_data, ioc_data, NULL); - - OBD_FREE_PTR(ioc_data); - } + obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp, + sizeof *ioc_data, ioc_data, NULL); + OBD_FREE_PTR(ioc_data); + } /* Really, we'd like to wait until there are no requests outstanding, * and then continue. For now, we just invalidate the requests, @@ -2160,7 +2168,9 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, */ LASSERT(fid_is_sane(&md.body->fid1)); - *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1, 0), &md); + *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1, + sbi->ll_flags & LL_SBI_32BIT_API), + &md); if (*inode == NULL || IS_ERR(*inode)) { #ifdef CONFIG_FS_POSIX_ACL if (md.posix_acl) {