X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_handler.c;h=98b36a6b748d3b0e1f28286d4a64e5df1617a5e7;hp=c561425f3f5d98b540976d504ca8283b4100e497;hb=82c6e42d6137f39a1f2394b7bc6e8d600eb36181;hpb=7805b45f1182ed21198c0cd2000ffe93b7de5340;ds=sidebyside diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index c561425..98b36a6 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -285,6 +285,76 @@ osd_idc_find_or_init(const struct lu_env *env, struct osd_device *osd, return idc; } +static void osd_idc_dump_lma(const struct lu_env *env, + struct osd_device *osd, + unsigned long ino, + bool check_in_oi) +{ + struct osd_thread_info *info = osd_oti_get(env); + struct lustre_ost_attrs *loa = &info->oti_ost_attrs; + const struct lu_fid *fid; + struct osd_inode_id lid; + struct inode *inode; + int rc; + + inode = osd_ldiskfs_iget(osd_sb(osd), ino); + if (IS_ERR(inode)) { + CERROR("%s: can't get inode %lu: rc = %d\n", + osd->od_svname, ino, (int)PTR_ERR(inode)); + return; + } + if (is_bad_inode(inode)) { + CERROR("%s: bad inode %lu\n", osd->od_svname, ino); + goto put; + } + rc = osd_get_lma(info, inode, &info->oti_obj_dentry, loa); + if (rc) { + CERROR("%s: can't get LMA for %lu: rc = %d\n", + osd->od_svname, ino, rc); + goto put; + } + fid = &loa->loa_lma.lma_self_fid; + LCONSOLE(D_INFO, "%s: "DFID" in inode %lu/%u\n", osd->od_svname, + PFID(fid), ino, (unsigned)inode->i_generation); + if (!check_in_oi) + goto put; + rc = osd_oi_lookup(osd_oti_get(env), osd, fid, &lid, 0); + if (rc) { + CERROR("%s: can't lookup "DFID": rc = %d\n", + osd->od_svname, PFID(fid), rc); + goto put; + } + LCONSOLE(D_INFO, "%s: "DFID" maps to %u/%u\n", osd->od_svname, + PFID(fid), lid.oii_ino, lid.oii_gen); +put: + iput(inode); +} + +static void osd_idc_dump_debug(const struct lu_env *env, + struct osd_device *osd, + const struct lu_fid *fid, + unsigned long ino1, + unsigned long ino2) +{ + struct osd_inode_id lid; + + int rc; + + rc = osd_oi_lookup(osd_oti_get(env), osd, fid, &lid, 0); + if (!rc) { + LCONSOLE(D_INFO, "%s: "DFID" maps to %u/%u\n", + osd->od_svname, PFID(fid), lid.oii_ino, lid.oii_gen); + osd_idc_dump_lma(env, osd, lid.oii_ino, false); + } else { + CERROR("%s: can't lookup "DFID": rc = %d\n", + osd->od_svname, PFID(fid), rc); + } + if (ino1) + osd_idc_dump_lma(env, osd, ino1, true); + if (ino2) + osd_idc_dump_lma(env, osd, ino2, true); +} + /* * lookup mapping for given FID and fill it from the given object. * the object is lolcal by definition. @@ -302,7 +372,12 @@ static int osd_idc_find_and_init(const struct lu_env *env, if (obj->oo_inode == NULL) return 0; if (idc->oic_lid.oii_ino != obj->oo_inode->i_ino) { - LASSERT(idc->oic_lid.oii_ino == 0); + if (idc->oic_lid.oii_ino) { + osd_idc_dump_debug(env, osd, fid, + idc->oic_lid.oii_ino, + obj->oo_inode->i_ino); + return -EINVAL; + } idc->oic_lid.oii_ino = obj->oo_inode->i_ino; idc->oic_lid.oii_gen = obj->oo_inode->i_generation; } @@ -392,12 +467,11 @@ int osd_get_lma(struct osd_thread_info *info, struct inode *inode, lustre_loa_swab(loa, true); /* Check LMA compatibility */ if (lma->lma_incompat & ~LMA_INCOMPAT_SUPP) { - CWARN("%s: unsupported incompat LMA feature(s) %#x " - "for fid = "DFID", ino = %lu\n", + rc = -EOPNOTSUPP; + CWARN("%s: unsupported incompat LMA feature(s) %#x for fid = "DFID", ino = %lu: rc = %d\n", osd_ino2name(inode), lma->lma_incompat & ~LMA_INCOMPAT_SUPP, - PFID(&lma->lma_self_fid), inode->i_ino); - rc = -EOPNOTSUPP; + PFID(&lma->lma_self_fid), inode->i_ino, rc); } } else if (rc == 0) { rc = -ENODATA; @@ -442,10 +516,11 @@ struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev, iput(inode); inode = ERR_PTR(-ESTALE); } else if (is_bad_inode(inode)) { - CWARN("%s: bad inode: ino = %u\n", - osd_dev2name(dev), id->oii_ino); + rc = -ENOENT; + CWARN("%s: bad inode: ino = %u: rc = %d\n", + osd_dev2name(dev), id->oii_ino, rc); iput(inode); - inode = ERR_PTR(-ENOENT); + inode = ERR_PTR(rc); } else if ((rc = osd_attach_jinode(inode))) { iput(inode); inode = ERR_PTR(rc); @@ -1016,9 +1091,9 @@ again: out: if (rc < 0) - CDEBUG(D_LFSCK, "%s: fail to check LMV EA, inode = %lu/%u," - DFID": rc = %d\n", osd_ino2name(inode), - inode->i_ino, inode->i_generation, + CDEBUG(D_LFSCK, + "%s: cannot check LMV, ino = %lu/%u "DFID": rc = %d\n", + osd_ino2name(inode), inode->i_ino, inode->i_generation, PFID(&oic->oic_fid), rc); else rc = 0; @@ -1052,7 +1127,13 @@ static int osd_fid_lookup(const struct lu_env *env, struct osd_object *obj, LINVRNT(osd_invariant(obj)); LASSERT(obj->oo_inode == NULL); - LASSERTF(fid_is_sane(fid) || fid_is_idif(fid), DFID"\n", PFID(fid)); + + if (fid_is_sane(fid) == 0) { + CERROR("%s: invalid FID "DFID"\n", ldev->ld_obd->obd_name, + PFID(fid)); + dump_stack(); + RETURN(-EINVAL); + } dev = osd_dev(ldev); scrub = &dev->od_scrub.os_scrub; @@ -1695,6 +1776,7 @@ static void osd_trans_commit_cb(struct super_block *sb, struct osd_thandle *oh = container_of(jcb, struct osd_thandle, ot_jcb); struct thandle *th = &oh->ot_super; struct lu_device *lud = &th->th_dev->dd_lu_dev; + struct osd_device *osd = osd_dev(lud); struct dt_txn_commit_cb *dcb, *tmp; LASSERT(oh->ot_handle == NULL); @@ -1714,7 +1796,8 @@ static void osd_trans_commit_cb(struct super_block *sb, } lu_ref_del_at(&lud->ld_reference, &oh->ot_dev_link, "osd-tx", th); - lu_device_put(lud); + if (atomic_dec_and_test(&osd->od_commit_cb_in_flight)) + wake_up(&osd->od_commit_cb_done); th->th_dev = NULL; OBD_FREE_PTR(oh); @@ -1755,6 +1838,7 @@ static struct thandle *osd_trans_create(const struct lu_env *env, th->th_dev = d; th->th_result = 0; oh->ot_credits = 0; + oh->oh_declared_ext = 0; INIT_LIST_HEAD(&oh->ot_commit_dcb_list); INIT_LIST_HEAD(&oh->ot_stop_dcb_list); INIT_LIST_HEAD(&oh->ot_trunc_locks); @@ -1897,7 +1981,7 @@ static int osd_trans_start(const struct lu_env *env, struct dt_device *d, oh->ot_handle = jh; LASSERT(oti->oti_txns == 0); - lu_device_get(&d->dd_lu_dev); + atomic_inc(&dev->od_commit_cb_in_flight); lu_ref_add_at(&d->dd_lu_dev.ld_reference, &oh->ot_dev_link, "osd-tx", th); oti->oti_txns++; @@ -2038,6 +2122,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt, if (unlikely(remove_agents != 0)) osd_process_scheduled_agent_removals(env, osd); + LASSERT(oti->oti_ins_cache_depth > 0); oti->oti_ins_cache_depth--; /* reset OI cache for safety */ if (oti->oti_ins_cache_depth == 0) @@ -2354,6 +2439,8 @@ static void osd_conf_get(const struct lu_env *env, d->od_svname, name); } } + + param->ddp_has_lseek_data_hole = true; } static struct super_block *osd_mnt_sb_get(const struct dt_device *d) @@ -2804,9 +2891,9 @@ static int osd_declare_attr_set(const struct lu_env *env, bool ignore_edquot = !(attr->la_flags & LUSTRE_SET_SYNC_FL); if (!ignore_edquot) - CDEBUG(D_QUOTA, "%s: enforce quota on UID %u, GID %u" - "(the quota space is %lld)\n", - obj->oo_inode->i_sb->s_id, attr->la_uid, + CDEBUG(D_QUOTA, + "%s: enforce quota on UID %u, GID %u (quota space is %lld)\n", + osd_ino2name(obj->oo_inode), attr->la_uid, attr->la_gid, bspace); /* USERQUOTA */ @@ -2999,9 +3086,8 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr, rc = dquot_transfer(inode, &iattr); if (rc) { - CERROR("%s: quota transfer failed: rc = %d. Is quota " - "enforcement enabled on the ldiskfs " - "filesystem?\n", inode->i_sb->s_id, rc); + CERROR("%s: quota transfer failed. Is quota enforcement enabled on the ldiskfs filesystem? rc = %d\n", + osd_ino2name(inode), rc); return rc; } } @@ -3015,9 +3101,8 @@ static int osd_quota_transfer(struct inode *inode, const struct lu_attr *attr, rc = -ENOTSUPP; #endif if (rc) { - CERROR("%s: quota transfer failed: rc = %d. Is project " - "enforcement enabled on the ldiskfs " - "filesystem?\n", inode->i_sb->s_id, rc); + CERROR("%s: quota transfer failed. Is project enforcement enabled on the ldiskfs filesystem? rc = %d\n", + osd_ino2name(inode), rc); return rc; } } @@ -3456,6 +3541,9 @@ static int __osd_oi_insert(const struct lu_env *env, struct osd_object *obj, LASSERT(obj->oo_inode != NULL); + if (CFS_FAIL_CHECK(OBD_FAIL_OSD_OI_ENOSPC)) + return -ENOSPC; + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle); osd_trans_exec_op(env, th, OSD_OT_INSERT); @@ -3814,6 +3902,9 @@ static int osd_add_dot_dotdot_internal(struct osd_thread_info *info, __u32 saved_nlink = dir->i_nlink; int rc; + if (OBD_FAIL_CHECK(OBD_FAIL_OSD_DOTDOT_ENOSPC)) + return -ENOSPC; + dot_dot_ldp = (struct ldiskfs_dentry_param *)info->oti_ldp2; osd_get_ldiskfs_dirent_param(dot_dot_ldp, dot_dot_fid); @@ -3897,9 +3988,8 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, i_projid_read(pobj->oo_inode) != 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 " - "filesystem?\n", local->i_sb->s_id, rc); + CERROR("%s: quota transfer failed:. Is project quota enforcement enabled on the ldiskfs filesystem? rc = %d\n", + osd_ino2name(local), rc); RETURN(ERR_PTR(rc)); } } @@ -4063,8 +4153,21 @@ static int osd_create(const struct lu_env *env, struct dt_object *dt, obj->oo_dt.do_body_ops = &osd_body_ops; } - if (!result && !CFS_FAIL_CHECK(OBD_FAIL_OSD_NO_OI_ENTRY)) + if (!result && !CFS_FAIL_CHECK(OBD_FAIL_OSD_NO_OI_ENTRY)) { + struct inode *inode = obj->oo_inode; + result = __osd_oi_insert(env, obj, fid, th); + if (result && inode) { + spin_lock(&obj->oo_guard); + clear_nlink(inode); + spin_unlock(&obj->oo_guard); + osd_dirty_inode(inode, I_DIRTY_DATASYNC); + ldiskfs_set_inode_state(inode, + LDISKFS_STATE_LUSTRE_DESTROY); + iput(inode); + obj->oo_inode = NULL; + } + } /* * a small optimization - dt_insert() isn't usually applied @@ -4088,6 +4191,7 @@ static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *handle) { struct osd_thandle *oh; + int rc; /* it's possible that object doesn't exist yet */ LASSERT(handle != NULL); @@ -4098,9 +4202,10 @@ static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt, osd_trans_declare_op(env, oh, OSD_OT_REF_ADD, osd_dto_credits_noquota[DTO_ATTR_SET_BASE]); - osd_idc_find_and_init(env, osd_dev(dt->do_lu.lo_dev), osd_dt_obj(dt)); + rc = osd_idc_find_and_init(env, osd_dev(dt->do_lu.lo_dev), + osd_dt_obj(dt)); - return 0; + return rc; } /* @@ -4830,6 +4935,10 @@ static int osd_invalidate(const struct lu_env *env, struct dt_object *dt) return 0; } +static bool osd_check_stale(struct dt_object *dt) +{ + return false; +} /* * Index operations. */ @@ -5018,6 +5127,7 @@ static const struct dt_object_operations osd_obj_ops = { .do_xattr_list = osd_xattr_list, .do_object_sync = osd_object_sync, .do_invalidate = osd_invalidate, + .do_check_stale = osd_check_stale, }; static const struct dt_object_operations osd_obj_otable_it_ops = { @@ -5725,8 +5835,7 @@ trigger: rc = osd_scrub_start(oti->oti_env, dev, SS_AUTO_PARTIAL | SS_CLEAR_DRYRUN | SS_CLEAR_FAILOUT); CDEBUG(D_LFSCK | D_CONSOLE | D_WARNING, - "%s: trigger partial OI scrub for RPC inconsistency " - "checking FID "DFID": rc = %d\n", + "%s: trigger partial OI scrub for RPC inconsistency checking FID "DFID": rc = %d\n", osd_dev2name(dev), PFID(fid), rc); if (rc == 0 || rc == -EALREADY) goto again; @@ -6686,18 +6795,13 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, filp->f_cred = current_cred(); rc = osd_security_file_alloc(filp); if (rc) - RETURN(rc); + GOTO(unlock, rc); filp->f_flags |= O_NOATIME; filp->f_mode |= FMODE_NONOTIFY; rc = iterate_dir(filp, &buf.ctx); if (rc) - RETURN(rc); - - if (hlock != NULL) - ldiskfs_htree_unlock(hlock); - else - up_read(&obj->oo_ext_idx_sem); + GOTO(unlock, rc); if (it->oie_rd_dirent == 0) { /* @@ -6711,6 +6815,11 @@ static int osd_ldiskfs_it_fill(const struct lu_env *env, it->oie_dirent = it->oie_buf; it->oie_it_dirent = 1; } +unlock: + if (hlock != NULL) + ldiskfs_htree_unlock(hlock); + else + up_read(&obj->oo_ext_idx_sem); RETURN(rc); } @@ -6859,11 +6968,10 @@ osd_dirent_reinsert(const struct lu_env *env, struct osd_device *dev, * That means we lose it! */ if (rc != 0) - CDEBUG(D_LFSCK, "%s: fail to reinsert the dirent, " - "dir = %lu/%u, name = %.*s, "DFID": rc = %d\n", - osd_ino2name(inode), - dir->i_ino, dir->i_generation, namelen, - dentry->d_name.name, PFID(fid), rc); + CDEBUG(D_LFSCK, + "%s: fail to reinsert the dirent, dir = %lu/%u, name = %.*s, "DFID": rc = %d\n", + osd_ino2name(inode), dir->i_ino, dir->i_generation, + namelen, dentry->d_name.name, PFID(fid), rc); RETURN(rc); } @@ -7577,6 +7685,8 @@ static void osd_umount(const struct lu_env *env, struct osd_device *o) if (o->od_mnt != NULL) { shrink_dcache_sb(osd_sb(o)); osd_sync(env, &o->od_dt_dev); + wait_event(o->od_commit_cb_done, + !atomic_read(&o->od_commit_cb_in_flight)); mntput(o->od_mnt); o->od_mnt = NULL; @@ -7781,6 +7891,8 @@ static struct lu_device *osd_device_fini(const struct lu_env *env, osd_procfs_fini(o); if (o->od_oi_table != NULL) osd_oi_fini(osd_oti_get(env), o); + if (o->od_extent_bytes_percpu) + free_percpu(o->od_extent_bytes_percpu); osd_obj_map_fini(o); osd_umount(env, o); @@ -7814,6 +7926,7 @@ static int osd_device_init0(const struct lu_env *env, spin_lock_init(&o->od_lock); o->od_index_backup_policy = LIBP_NONE; o->od_t10_type = 0; + init_waitqueue_head(&o->od_commit_cb_done); o->od_read_cache = 1; o->od_writethrough_cache = 1; @@ -7821,6 +7934,8 @@ static int osd_device_init0(const struct lu_env *env, o->od_readcache_max_iosize = OSD_READCACHE_MAX_IO_MB << 20; o->od_writethrough_max_iosize = OSD_WRITECACHE_MAX_IO_MB << 20; o->od_auto_scrub_interval = AS_DEFAULT; + /* default fallocate to unwritten extents: LU-14326/LU-14333 */ + o->od_fallocate_zero_blocks = 0; cplen = strlcpy(o->od_svname, lustre_cfg_string(cfg, 4), sizeof(o->od_svname)); @@ -7903,6 +8018,12 @@ static int osd_device_init0(const struct lu_env *env, GOTO(out_procfs, rc); } + o->od_extent_bytes_percpu = alloc_percpu(unsigned int); + if (!o->od_extent_bytes_percpu) { + rc = -ENOMEM; + GOTO(out_procfs, rc); + } + RETURN(0); out_procfs: