X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_handler.c;h=c561425f3f5d98b540976d504ca8283b4100e497;hb=7805b45f1182ed21198c0cd2000ffe93b7de5340;hp=84df699928a91dcddf2683ec876aecd3557b5e53;hpb=9be2db987767a64fdcc20cbf31c37e59a954913c;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 84df699..c561425 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -39,6 +39,7 @@ #define DEBUG_SUBSYSTEM S_OSD +#include #include #include #include @@ -956,8 +957,7 @@ static int osd_check_lmv(struct osd_thread_info *oti, struct osd_device *dev, { struct lu_buf *buf = &oti->oti_big_buf; struct dentry *dentry = &oti->oti_obj_dentry; - struct file *filp = &oti->oti_file; - const struct file_operations *fops; + struct file *filp; struct lmv_mds_md_v1 *lmv1; struct osd_check_lmv_buf oclb = { .ctx.actor = osd_stripe_dir_filldir, @@ -1002,18 +1002,7 @@ again: if (le32_to_cpu(lmv1->lmv_magic) != LMV_MAGIC_V1) GOTO(out, rc = 0); - fops = inode->i_fop; - dentry->d_inode = inode; - dentry->d_sb = inode->i_sb; - filp->f_pos = 0; - filp->f_path.dentry = dentry; - filp->f_flags |= O_NOATIME; - filp->f_mode = FMODE_64BITHASH | FMODE_NONOTIFY; - filp->f_mapping = inode->i_mapping; - filp->f_op = fops; - filp->private_data = NULL; - filp->f_cred = current_cred(); - filp->f_inode = inode; + filp = osd_quasi_file(oti->oti_env, inode); rc = osd_security_file_alloc(filp); if (rc) goto out; @@ -1023,7 +1012,7 @@ again: rc = iterate_dir(filp, &oclb.ctx); } while (rc >= 0 && oclb.oclb_items > 0 && !oclb.oclb_found && filp->f_pos != LDISKFS_HTREE_EOF_64BIT); - fops->release(inode, filp); + inode->i_fop->release(inode, filp); out: if (rc < 0) @@ -1178,17 +1167,19 @@ trigger: } } - if (thread_is_running(&scrub->os_thread)) { + if (scrub->os_running) { if (scrub->os_partial_scan && !scrub->os_in_join) goto join; - if (IS_ERR_OR_NULL(inode) || result) + osd_add_oi_cache(info, dev, id, fid); + if (IS_ERR_OR_NULL(inode) || result) { + osd_oii_insert(dev, oic, result == -ENOENT); GOTO(out, result = -EINPROGRESS); + } LASSERT(remote); LASSERT(obj->oo_inode == inode); - osd_add_oi_cache(info, dev, id, fid); osd_oii_insert(dev, oic, true); goto found; } @@ -1211,13 +1202,15 @@ join: if (rc1 && rc1 != -EALREADY) GOTO(out, result = -EREMCHG); - if (IS_ERR_OR_NULL(inode) || result) + osd_add_oi_cache(info, dev, id, fid); + if (IS_ERR_OR_NULL(inode) || result) { + osd_oii_insert(dev, oic, result == -ENOENT); GOTO(out, result = -EINPROGRESS); + } LASSERT(remote); LASSERT(obj->oo_inode == inode); - osd_add_oi_cache(info, dev, id, fid); osd_oii_insert(dev, oic, true); goto found; @@ -1590,11 +1583,8 @@ static void osd_object_free(const struct lu_env *env, struct lu_object *l) ldiskfs_htree_lock_head_free(obj->oo_hl_head); /* obj doesn't contain an lu_object_header, so we don't need call_rcu */ OBD_FREE_PTR(obj); - if (unlikely(h)) { - lu_object_header_fini(h); - OBD_FREE_PRE(h, sizeof(*h), "kfreed"); - kfree_rcu(h, loh_rcu); - } + if (unlikely(h)) + lu_object_header_free(h); } /* @@ -1616,16 +1606,6 @@ static void osd_index_fini(struct osd_object *o) } } -/* - * Concurrency: no concurrent access is possible that late in object - * life-cycle (for all existing callers, that is. New callers have to provide - * their own locking.) - */ -static int osd_inode_unlinked(const struct inode *inode) -{ - return inode->i_nlink == 0; -} - enum { OSD_TXN_OI_DELETE_CREDITS = 20, OSD_TXN_INODE_DELETE_CREDITS = 20 @@ -2912,6 +2892,13 @@ static int osd_inode_setattr(const struct lu_env *env, /* always keep S_NOCMTIME */ inode->i_flags = ll_ext_to_inode_flags(attr->la_flags) | S_NOCMTIME; +#if defined(S_ENCRYPTED) + /* Always remove S_ENCRYPTED, because ldiskfs must not be + * aware of encryption status. It is just stored into LMA + * so that it can be forwared to client side. + */ + inode->i_flags &= ~S_ENCRYPTED; +#endif /* * Ext4 did not transfer inherit flags from * @inode->i_flags to raw inode i_flags when writing @@ -2926,7 +2913,8 @@ static int osd_inode_setattr(const struct lu_env *env, } #ifdef HAVE_PROJECT_QUOTA -static int osd_transfer_project(struct inode *inode, __u32 projid) +static int osd_transfer_project(struct inode *inode, __u32 projid, + struct thandle *handle) { struct super_block *sb = inode->i_sb; struct ldiskfs_inode_info *ei = LDISKFS_I(inode); @@ -2958,9 +2946,18 @@ static int osd_transfer_project(struct inode *inode, __u32 projid) raw_inode = ldiskfs_raw_inode(&iloc); if (!LDISKFS_FITS_IN_INODE(raw_inode, ei, i_projid)) { - err = -EOVERFLOW; - brelse(iloc.bh); - return err; + struct osd_thandle *oh = container_of(handle, + struct osd_thandle, + ot_super); + /** + * try to expand inode size automatically. + */ + ldiskfs_mark_inode_dirty(oh->ot_handle, inode); + if (!LDISKFS_FITS_IN_INODE(raw_inode, ei, i_projid)) { + err = -EOVERFLOW; + brelse(iloc.bh); + return err; + } } brelse(iloc.bh); @@ -2977,7 +2974,8 @@ static int osd_transfer_project(struct inode *inode, __u32 projid) } #endif -static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr) +static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr, + struct thandle *handle) { int rc; @@ -3012,7 +3010,7 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr) if (attr->la_valid & LA_PROJID && attr->la_projid != i_projid_read(inode)) { #ifdef HAVE_PROJECT_QUOTA - rc = osd_transfer_project(inode, attr->la_projid); + rc = osd_transfer_project(inode, attr->la_projid, handle); #else rc = -ENOTSUPP; #endif @@ -3073,7 +3071,7 @@ static int osd_attr_set(const struct lu_env *env, inode = obj->oo_inode; - rc = osd_quota_transfer(inode, attr); + rc = osd_quota_transfer(inode, attr, handle); if (rc) return rc; @@ -3361,7 +3359,8 @@ static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah, } static void osd_attr_init(struct osd_thread_info *info, struct osd_object *obj, - struct lu_attr *attr, struct dt_object_format *dof) + struct lu_attr *attr, struct dt_object_format *dof, + struct thandle *handle) { struct inode *inode = obj->oo_inode; __u64 valid = attr->la_valid; @@ -3378,7 +3377,7 @@ static void osd_attr_init(struct osd_thread_info *info, struct osd_object *obj, if ((valid & LA_MTIME) && (attr->la_mtime == inode->i_mtime.tv_sec)) attr->la_valid &= ~LA_MTIME; - result = osd_quota_transfer(inode, attr); + result = osd_quota_transfer(inode, attr, handle); if (result) return; @@ -3429,7 +3428,7 @@ static int __osd_create(struct osd_thread_info *info, struct osd_object *obj, } if (likely(result == 0)) { - osd_attr_init(info, obj, attr, dof); + osd_attr_init(info, obj, attr, dof, th); osd_object_init0(obj); } @@ -3648,8 +3647,10 @@ static int osd_destroy(const struct lu_env *env, struct dt_object *dt, } if (S_ISDIR(inode->i_mode)) { - LASSERT(osd_inode_unlinked(inode) || inode->i_nlink == 1 || - inode->i_nlink == 2); + if (inode->i_nlink > 2) + CERROR("%s: directory "DFID" ino %lu link count is %u at unlink. run e2fsck to repair\n", + osd_name(osd), PFID(fid), inode->i_ino, + inode->i_nlink); spin_lock(&obj->oo_guard); clear_nlink(inode); @@ -3853,6 +3854,7 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, struct osd_thread_info *info = osd_oti_get(env); struct inode *local; struct osd_thandle *oh; + uid_t own[2] = {0, 0}; int rc; ENTRY; @@ -3861,8 +3863,7 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle->h_transaction != NULL); - local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, type, - NULL); + local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, type, own); if (IS_ERR(local)) { CERROR("%s: create local error %d\n", osd_name(osd), (int)PTR_ERR(local)); @@ -3894,7 +3895,7 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, #ifdef HAVE_PROJECT_QUOTA if (LDISKFS_I(pobj->oo_inode)->i_flags & LUSTRE_PROJINHERIT_FL && i_projid_read(pobj->oo_inode) != 0) { - rc = osd_transfer_project(local, 0); + rc = osd_transfer_project(local, 0, th); if (rc) { CERROR("%s: quota transfer failed: rc = %d. Is project " "quota enforcement enabled on the ldiskfs " @@ -4197,6 +4198,9 @@ static int osd_ref_del(const struct lu_env *env, struct dt_object *dt, LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); + if (OBD_FAIL_CHECK(OBD_FAIL_OSD_REF_DEL)) + return -EIO; + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); @@ -4811,20 +4815,11 @@ static int osd_object_sync(const struct lu_env *env, struct dt_object *dt, { struct osd_object *obj = osd_dt_obj(dt); struct inode *inode = obj->oo_inode; - struct osd_thread_info *info = osd_oti_get(env); - struct dentry *dentry = &info->oti_obj_dentry; - struct file *file = &info->oti_file; + struct file *file = osd_quasi_file(env, inode); int rc; ENTRY; - dentry->d_inode = inode; - dentry->d_sb = inode->i_sb; - file->f_path.dentry = dentry; - file->f_mapping = inode->i_mapping; - file->f_op = inode->i_fop; - file->f_inode = inode; - rc = vfs_fsync_range(file, start, end, 0); RETURN(rc); @@ -5656,8 +5651,7 @@ osd_consistency_check(struct osd_thread_info *oti, struct osd_device *dev, if (!fid_is_norm(fid) && !fid_is_igif(fid)) RETURN(0); - if (thread_is_running(&scrub->os_thread) && - scrub->os_pos_current > id->oii_ino) + if (scrub->os_running && scrub->os_pos_current > id->oii_ino) RETURN(0); if (dev->od_auto_scrub_interval == AS_NEVER || @@ -5698,7 +5692,7 @@ again: insert = false; trigger: - if (thread_is_running(&scrub->os_thread)) { + if (scrub->os_running) { if (inode == NULL) { inode = osd_iget(oti, dev, id); /* The inode has been removed (by race maybe). */ @@ -7280,8 +7274,6 @@ static inline int osd_it_ea_rec(const struct lu_env *env, rc = osd_ea_fid_get(env, obj, ino, fid, id); } - } else { - osd_id_gen(id, ino, OSD_OII_NOGEN); } } @@ -7291,15 +7283,6 @@ static inline int osd_it_ea_rec(const struct lu_env *env, it->oie_dirent->oied_namelen, it->oie_dirent->oied_type, attr); - if (rc < 0) - RETURN(rc); - - if (osd_remote_fid(env, dev, fid)) - RETURN(0); - - if (likely(!(attr & (LUDA_IGNORE | LUDA_UNKNOWN)) && rc == 0)) - osd_add_oi_cache(oti, dev, id, fid); - RETURN(rc > 0 ? 0 : rc); } @@ -7465,7 +7448,8 @@ static void osd_key_fini(const struct lu_context *ctx, __free_page(page); } } - OBD_FREE_PTR_ARRAY(info->oti_dio_pages, PTLRPC_MAX_BRW_PAGES); + OBD_FREE_PTR_ARRAY_LARGE(info->oti_dio_pages, + PTLRPC_MAX_BRW_PAGES); } if (info->oti_inode != NULL) @@ -7974,10 +7958,8 @@ static struct lu_device *osd_device_free(const struct lu_env *env, /* XXX: make osd top device in order to release reference */ d->ld_site->ls_top_dev = d; lu_site_purge(env, d->ld_site, -1); - if (!cfs_hash_is_empty(d->ld_site->ls_obj_hash)) { - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL); - lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer); - } + lu_site_print(env, d->ld_site, &d->ld_site->ls_obj_hash.nelems, + D_ERROR, lu_cdebug_printer); lu_site_fini(&o->od_site); dt_device_fini(&o->od_dt_dev); OBD_FREE_PTR(o);