X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-ldiskfs%2Fosd_handler.c;h=ef29623de4daaad254d7e13171115690158f675a;hb=aff14dbc522e140945f9207d4e9bbd27d0326819;hp=24ca88c07815cb5561133c3a299bdc5fda9ee3ba;hpb=cae8d0e7120a356e0218783e0678d405306b5da4;p=fs%2Flustre-release.git diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 24ca88c..ef29623 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -209,14 +209,14 @@ osd_idc_add(const struct lu_env *env, struct osd_device *osd, i = oti->oti_ins_cache_size * 2; if (i == 0) i = OSD_INS_CACHE_SIZE; - OBD_ALLOC(idc, sizeof(*idc) * i); + OBD_ALLOC_PTR_ARRAY(idc, i); if (idc == NULL) return ERR_PTR(-ENOMEM); if (oti->oti_ins_cache != NULL) { memcpy(idc, oti->oti_ins_cache, oti->oti_ins_cache_used * sizeof(*idc)); - OBD_FREE(oti->oti_ins_cache, - oti->oti_ins_cache_used * sizeof(*idc)); + OBD_FREE_PTR_ARRAY(oti->oti_ins_cache, + oti->oti_ins_cache_used); } oti->oti_ins_cache = idc; oti->oti_ins_cache_size = i; @@ -477,6 +477,7 @@ int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd, struct lustre_ost_attrs *loa = &info->oti_ost_attrs; struct inode *parent = child->d_parent->d_inode; struct lu_fid *fid = NULL; + char fidstr[FID_LEN + 1] = "unknown"; rc2 = osd_get_lma(info, parent, child->d_parent, loa); if (!rc2) { @@ -493,19 +494,18 @@ int osd_ldiskfs_add_entry(struct osd_thread_info *info, struct osd_device *osd, } if (fid != NULL) - /* below message is checked in sanity.sh test_129 */ - CWARN("%s: directory (inode: %lu, FID: "DFID") %s maximum entry limit\n", - osd_name(osd), parent->i_ino, PFID(fid), - rc == -ENOSPC ? "has reached" : "is approaching"); - else - /* below message is checked in sanity.sh test_129 */ - CWARN("%s: directory (inode: %lu, FID: unknown) %s maximum entry limit\n", - osd_name(osd), parent->i_ino, - rc == -ENOSPC ? "has reached" : "is approaching"); + snprintf(fidstr, sizeof(fidstr), DFID, PFID(fid)); + + /* below message is checked in sanity.sh test_129 */ + if (rc == -ENOSPC) { + CWARN("%s: directory (inode: %lu, FID: %s) has reached max size limit\n", + osd_name(osd), parent->i_ino, fidstr); + } else { + rc = 0; /* ignore such error now */ + CWARN("%s: directory (inode: %lu, FID: %s) is approaching max size limit\n", + osd_name(osd), parent->i_ino, fidstr); + } - /* ignore such error now */ - if (rc == -ENOBUFS) - rc = 0; } return rc; @@ -1400,6 +1400,13 @@ static int osd_object_init(const struct lu_env *env, struct lu_object *l, LINVRNT(osd_invariant(obj)); + if (OBD_FAIL_PRECHECK(OBD_FAIL_MDS_LLOG_UMOUNT_RACE) && + cfs_fail_val == 2) { + struct osd_thread_info *info = osd_oti_get(env); + struct osd_idmap_cache *oic = &info->oti_cache; + /* invalidate thread cache */ + memset(&oic->oic_fid, 0, sizeof(oic->oic_fid)); + } if (fid_is_otable_it(&l->lo_header->loh_fid)) { obj->oo_dt.do_ops = &osd_obj_otable_it_ops; l->lo_header->loh_attr |= LOHA_EXISTS; @@ -1429,6 +1436,7 @@ static int osd_object_init(const struct lu_env *env, struct lu_object *l, result = 0; } } + obj->oo_dirent_count = LU_DIRENT_COUNT_UNSET; LINVRNT(osd_invariant(obj)); return result; @@ -1455,8 +1463,6 @@ static int osd_oxc_get(struct osd_object *obj, const char *name, size_t namelen = strlen(name); int rc; - ENTRY; - rcu_read_lock(); list_for_each_entry_rcu(tmp, &obj->oo_xattr_list, oxe_list) { if (namelen == tmp->oxe_namelen && @@ -1483,7 +1489,6 @@ static int osd_oxc_get(struct osd_object *obj, const char *name, GOTO(out, rc = -ERANGE); memcpy(buf->lb_buf, &oxe->oxe_buf[namelen + 1], rc); - EXIT; out: rcu_read_unlock(); @@ -1583,10 +1588,12 @@ static void osd_object_free(const struct lu_env *env, struct lu_object *l) dt_object_fini(&obj->oo_dt); if (obj->oo_hl_head != NULL) 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_PTR(h); + OBD_FREE_PRE(h, sizeof(*h), "kfreed"); + kfree_rcu(h, loh_rcu); } } @@ -1705,7 +1712,7 @@ static int osd_param_is_not_sane(const struct osd_device *dev, static void osd_trans_commit_cb(struct super_block *sb, struct ldiskfs_journal_cb_entry *jcb, int error) { - struct osd_thandle *oh = container_of0(jcb, struct osd_thandle, ot_jcb); + 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 dt_txn_commit_cb *dcb, *tmp; @@ -1790,7 +1797,7 @@ void osd_trans_dump_creds(const struct lu_env *env, struct thandle *th) struct osd_thread_info *oti = osd_oti_get(env); struct osd_thandle *oh; - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh != NULL); CWARN(" create: %u/%u/%u, destroy: %u/%u/%u\n", @@ -1849,7 +1856,7 @@ static int osd_trans_start(const struct lu_env *env, struct dt_device *d, LASSERT(current->journal_info == NULL); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh != NULL); LASSERT(oh->ot_handle == NULL); @@ -1978,7 +1985,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt, ENTRY; - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); remove_agents = oh->ot_remove_agents; @@ -2027,7 +2034,7 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt, OBD_FREE_PTR(oh); } - osd_trunc_unlock_all(&truncates); + osd_trunc_unlock_all(env, &truncates); /* inform the quota slave device that the transaction is stopping */ qsd_op_end(env, qsd, qtrans); @@ -2063,8 +2070,8 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt, static int osd_trans_cb_add(struct thandle *th, struct dt_txn_commit_cb *dcb) { - struct osd_thandle *oh = container_of0(th, struct osd_thandle, - ot_super); + struct osd_thandle *oh = container_of(th, struct osd_thandle, + ot_super); LASSERT(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC); LASSERT(&dcb->dcb_func != NULL); @@ -2103,6 +2110,9 @@ static void osd_object_delete(const struct lu_env *env, struct lu_object *l) if (!inode) return; + if (osd_has_index(obj) && obj->oo_dt.do_index_ops == &osd_index_iam_ops) + ldiskfs_set_inode_flag(inode, LDISKFS_INODE_JOURNAL_DATA); + uid = i_uid_read(inode); gid = i_gid_read(inode); projid = i_projid_read(inode); @@ -2200,9 +2210,9 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d, statfs_pack(sfs, ksfs); if (unlikely(sb->s_flags & SB_RDONLY)) - sfs->os_state |= OS_STATE_READONLY; + sfs->os_state |= OS_STATFS_READONLY; - sfs->os_state |= osd->od_nonrotational ? OS_STATE_NONROT : 0; + sfs->os_state |= osd->od_nonrotational ? OS_STATFS_NONROT : 0; if (ldiskfs_has_feature_extents(sb)) sfs->os_maxbytes = sb->s_maxbytes; @@ -2418,10 +2428,6 @@ static int osd_commit_async(const struct lu_env *env, RETURN(rc); } -/* Our own copy of the set readonly functions if present, or NU if not. */ -static int (*priv_dev_set_rdonly)(struct block_device *bdev); -static int (*priv_dev_check_rdonly)(struct block_device *bdev); -/* static int (*priv_dev_clear_rdonly)(struct block_device *bdev); */ static int (*priv_security_file_alloc)(struct file *file); int osd_security_file_alloc(struct file *file) @@ -2442,35 +2448,8 @@ static int osd_ro(const struct lu_env *env, struct dt_device *d) ENTRY; - if (priv_dev_set_rdonly) { - struct block_device *jdev = LDISKFS_SB(sb)->journal_bdev; - - rc = 0; - CERROR("*** setting %s read-only ***\n", - osd_dt_dev(d)->od_svname); - - if (sb->s_op->freeze_fs) { - rc = sb->s_op->freeze_fs(sb); - if (rc) - goto out; - } - - if (jdev && (jdev != dev)) { - CDEBUG(D_IOCTL | D_HA, "set journal dev %lx rdonly\n", - (long)jdev); - priv_dev_set_rdonly(jdev); - } - CDEBUG(D_IOCTL | D_HA, "set dev %lx rdonly\n", (long)dev); - priv_dev_set_rdonly(dev); - - if (sb->s_op->unfreeze_fs) - sb->s_op->unfreeze_fs(sb); - } - -out: - if (rc) - CERROR("%s: %lx CANNOT BE SET READONLY: rc = %d\n", - osd_dt_dev(d)->od_svname, (long)dev, rc); + CERROR("%s: %lx CANNOT BE SET READONLY: rc = %d\n", + osd_dt_dev(d)->od_svname, (long)dev, rc); RETURN(rc); } @@ -2619,11 +2598,12 @@ static void osd_inode_getattr(const struct lu_env *env, attr->la_valid |= LA_ATIME | LA_MTIME | LA_CTIME | LA_MODE | LA_SIZE | LA_BLOCKS | LA_UID | LA_GID | LA_PROJID | LA_FLAGS | LA_NLINK | LA_RDEV | - LA_BLKSIZE | LA_TYPE; + LA_BLKSIZE | LA_TYPE | LA_BTIME; attr->la_atime = inode->i_atime.tv_sec; attr->la_mtime = inode->i_mtime.tv_sec; attr->la_ctime = inode->i_ctime.tv_sec; + attr->la_btime = LDISKFS_I(inode)->i_crtime.tv_sec; attr->la_mode = inode->i_mode; attr->la_size = i_size_read(inode); attr->la_blocks = inode->i_blocks; @@ -2644,10 +2624,71 @@ static void osd_inode_getattr(const struct lu_env *env, attr->la_flags |= LUSTRE_PROJINHERIT_FL; } +static int osd_dirent_count(const struct lu_env *env, struct dt_object *dt, + u64 *count) +{ + struct osd_object *obj = osd_dt_obj(dt); + const struct dt_it_ops *iops; + struct dt_it *it; + int rc; + + ENTRY; + + LASSERT(S_ISDIR(obj->oo_inode->i_mode)); + LASSERT(fid_is_namespace_visible(lu_object_fid(&obj->oo_dt.do_lu))); + + if (obj->oo_dirent_count != LU_DIRENT_COUNT_UNSET) { + *count = obj->oo_dirent_count; + RETURN(0); + } + + /* directory not initialized yet */ + if (!dt->do_index_ops) { + *count = 0; + RETURN(0); + } + + iops = &dt->do_index_ops->dio_it; + it = iops->init(env, dt, LUDA_64BITHASH); + if (IS_ERR(it)) + RETURN(PTR_ERR(it)); + + rc = iops->load(env, it, 0); + if (rc < 0) { + if (rc == -ENODATA) { + rc = 0; + *count = 0; + } + GOTO(out, rc); + } + if (rc > 0) + rc = iops->next(env, it); + + for (*count = 0; rc == 0 || rc == -ESTALE; rc = iops->next(env, it)) { + if (rc == -ESTALE) + continue; + + if (iops->key_size(env, it) == 0) + continue; + + (*count)++; + } + if (rc == 1) { + obj->oo_dirent_count = *count; + rc = 0; + } +out: + iops->put(env, it); + iops->fini(env, it); + + RETURN(rc); +} + static int osd_attr_get(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr) { struct osd_object *obj = osd_dt_obj(dt); + int rc = 0; if (unlikely(!dt_object_exists(dt))) return -ENOENT; @@ -2663,9 +2704,17 @@ static int osd_attr_get(const struct lu_env *env, struct dt_object *dt, attr->la_valid |= LA_FLAGS; attr->la_flags |= LUSTRE_ORPHAN_FL; } + if (obj->oo_lma_flags & LUSTRE_ENCRYPT_FL) { + attr->la_valid |= LA_FLAGS; + attr->la_flags |= LUSTRE_ENCRYPT_FL; + } spin_unlock(&obj->oo_guard); - return 0; + if (S_ISDIR(obj->oo_inode->i_mode) && + fid_is_namespace_visible(lu_object_fid(&dt->do_lu))) + rc = osd_dirent_count(env, dt, &attr->la_dirent_count); + + return rc; } static int osd_declare_attr_qid(const struct lu_env *env, @@ -2748,7 +2797,7 @@ static int osd_declare_attr_set(const struct lu_env *env, obj = osd_dt_obj(dt); LASSERT(osd_invariant(obj)); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_ATTR_SET, @@ -3014,7 +3063,7 @@ static int osd_attr_set(const struct lu_env *env, if (unlikely(ipd == NULL)) RETURN(-ENOMEM); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); rc = iam_update(oh->ot_handle, bag, (const struct iam_key *)fid1, (const struct iam_rec *)id, ipd); @@ -3164,6 +3213,8 @@ static int osd_mkdir(struct osd_thread_info *info, struct osd_object *obj, oth = container_of(th, struct osd_thandle, ot_super); LASSERT(oth->ot_handle->h_transaction != NULL); + if (fid_is_namespace_visible(lu_object_fid(&obj->oo_dt.do_lu))) + obj->oo_dirent_count = 0; result = osd_mkfile(info, obj, mode, hint, th, attr); return result; @@ -3406,7 +3457,7 @@ static int __osd_oi_insert(const struct lu_env *env, struct osd_object *obj, LASSERT(obj->oo_inode != NULL); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle); osd_trans_exec_op(env, th, OSD_OT_INSERT); @@ -3472,7 +3523,7 @@ static int osd_declare_create(const struct lu_env *env, struct dt_object *dt, LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); /* @@ -3530,7 +3581,7 @@ static int osd_declare_destroy(const struct lu_env *env, struct dt_object *dt, if (inode == NULL) RETURN(-ENOENT); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_DESTROY, @@ -3581,7 +3632,7 @@ static int osd_destroy(const struct lu_env *env, struct dt_object *dt, ENTRY; - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle); LASSERT(inode); LASSERT(!lu_object_is_dying(dt->do_lu.lo_header)); @@ -4040,7 +4091,7 @@ static int osd_declare_ref_add(const struct lu_env *env, struct dt_object *dt, /* it's possible that object doesn't exist yet */ LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_REF_ADD, @@ -4070,7 +4121,7 @@ static int osd_ref_add(const struct lu_env *env, struct dt_object *dt, LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); osd_trans_exec_op(env, th, OSD_OT_REF_ADD); @@ -4118,7 +4169,7 @@ static int osd_declare_ref_del(const struct lu_env *env, struct dt_object *dt, LASSERT(!dt_object_remote(dt)); LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_REF_DEL, @@ -4146,7 +4197,7 @@ static int osd_ref_del(const struct lu_env *env, struct dt_object *dt, LASSERT(osd_is_write_locked(env, obj)); LASSERT(th != NULL); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); osd_trans_exec_op(env, th, OSD_OT_REF_DEL); @@ -4297,7 +4348,7 @@ static int osd_declare_xattr_set(const struct lu_env *env, LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); if (strcmp(name, XATTR_NAME_LMA) == 0) { @@ -4436,7 +4487,7 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj, /* Remove old PFID EA entry firstly. */ dquot_initialize(inode); - rc = osd_removexattr(dentry, inode, XATTR_NAME_FID); + rc = ll_vfs_removexattr(dentry, inode, XATTR_NAME_FID); if (rc == -ENODATA) { if ((fl & LU_XATTR_REPLACE) && !(fl & LU_XATTR_CREATE)) RETURN(rc); @@ -4516,7 +4567,7 @@ static int osd_xattr_handle_linkea(const struct lu_env *env, ENTRY; - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); rc = linkea_init_with_rec(&ldata); @@ -4685,7 +4736,7 @@ static int osd_declare_xattr_del(const struct lu_env *env, LASSERT(!dt_object_remote(dt)); LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_XATTR_SET, @@ -4742,7 +4793,7 @@ static int osd_xattr_del(const struct lu_env *env, struct dt_object *dt, dquot_initialize(inode); dentry->d_inode = inode; dentry->d_sb = inode->i_sb; - rc = osd_removexattr(dentry, inode, name); + rc = ll_vfs_removexattr(dentry, inode, name); } osd_trans_exec_check(env, handle, OSD_OT_XATTR_SET); @@ -4986,7 +5037,7 @@ static int osd_index_declare_iam_delete(const struct lu_env *env, { struct osd_thandle *oh; - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); /* Recycle may cause additional three blocks to be changed. */ @@ -5034,7 +5085,7 @@ static int osd_index_iam_delete(const struct lu_env *env, struct dt_object *dt, if (unlikely(ipd == NULL)) RETURN(-ENOMEM); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); LASSERT(oh->ot_handle->h_transaction != NULL); @@ -5065,7 +5116,7 @@ static int osd_index_declare_ea_delete(const struct lu_env *env, LASSERT(!dt_object_remote(dt)); LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); credits = osd_dto_credits_noquota[DTO_INDEX_DELETE]; @@ -5227,11 +5278,21 @@ static int osd_index_ea_delete(const struct lu_env *env, struct dt_object *dt, } else { rc = PTR_ERR(bh); } + + if (!rc && fid_is_namespace_visible(lu_object_fid(&dt->do_lu)) && + obj->oo_dirent_count != LU_DIRENT_COUNT_UNSET) { + /* NB, dirent count may not be accurate, because it's counted + * without lock. + */ + if (obj->oo_dirent_count) + obj->oo_dirent_count--; + else + obj->oo_dirent_count = LU_DIRENT_COUNT_UNSET; + } if (hlock != NULL) ldiskfs_htree_unlock(hlock); else up_write(&obj->oo_ext_idx_sem); - GOTO(out, rc); out: LASSERT(osd_invariant(obj)); @@ -5318,7 +5379,7 @@ static int osd_index_declare_iam_insert(const struct lu_env *env, LASSERT(handle != NULL); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); osd_trans_declare_op(env, oh, OSD_OT_INSERT, @@ -5368,7 +5429,7 @@ static int osd_index_iam_insert(const struct lu_env *env, struct dt_object *dt, if (unlikely(ipd == NULL)) RETURN(-ENOMEM); - oh = container_of0(th, struct osd_thandle, ot_super); + oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle != NULL); LASSERT(oh->ot_handle->h_transaction != NULL); if (S_ISDIR(obj->oo_inode->i_mode)) { @@ -5566,6 +5627,10 @@ static int osd_ea_add_rec(const struct lu_env *env, struct osd_object *pobj, hlock, th); } } + if (!rc && fid_is_namespace_visible(lu_object_fid(&pobj->oo_dt.do_lu)) + && pobj->oo_dirent_count != LU_DIRENT_COUNT_UNSET) + pobj->oo_dirent_count++; + if (hlock != NULL) ldiskfs_htree_unlock(hlock); else @@ -5959,7 +6024,7 @@ static int osd_index_declare_ea_insert(const struct lu_env *env, LASSERT(fid != NULL); LASSERT(rec1->rec_type != 0); - oh = container_of0(handle, struct osd_thandle, ot_super); + oh = container_of(handle, struct osd_thandle, ot_super); LASSERT(oh->ot_handle == NULL); credits = osd_dto_credits_noquota[DTO_INDEX_INSERT]; @@ -6119,6 +6184,7 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt, iput(child_inode); LASSERT(osd_invariant(obj)); osd_trans_exec_check(env, th, OSD_OT_INSERT); + RETURN(rc); } @@ -7390,11 +7456,16 @@ static void osd_key_fini(const struct lu_context *ctx, if (info->oti_dio_pages) { int i; for (i = 0; i < PTLRPC_MAX_BRW_PAGES; i++) { - if (info->oti_dio_pages[i]) - __free_page(info->oti_dio_pages[i]); + struct page *page = info->oti_dio_pages[i]; + if (page) { + LASSERT(PagePrivate2(page)); + LASSERT(PageLocked(page)); + ClearPagePrivate2(page); + unlock_page(page); + __free_page(page); + } } - OBD_FREE(info->oti_dio_pages, - sizeof(struct page *) * PTLRPC_MAX_BRW_PAGES); + OBD_FREE_PTR_ARRAY(info->oti_dio_pages, PTLRPC_MAX_BRW_PAGES); } if (info->oti_inode != NULL) @@ -7408,7 +7479,7 @@ static void osd_key_fini(const struct lu_context *ctx, lu_buf_free(&info->oti_big_buf); if (idc != NULL) { LASSERT(info->oti_ins_cache_size > 0); - OBD_FREE(idc, sizeof(*idc) * info->oti_ins_cache_size); + OBD_FREE_PTR_ARRAY(idc, info->oti_ins_cache_size); info->oti_ins_cache = NULL; info->oti_ins_cache_size = 0; } @@ -7450,7 +7521,7 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d, static int osd_fid_init(const struct lu_env *env, struct osd_device *osd) { struct seq_server_site *ss = osd_seq_site(osd); - int rc; + int rc = 0; ENTRY; @@ -7464,13 +7535,8 @@ static int osd_fid_init(const struct lu_env *env, struct osd_device *osd) if (osd->od_cl_seq == NULL) RETURN(-ENOMEM); - rc = seq_client_init(osd->od_cl_seq, NULL, LUSTRE_SEQ_METADATA, - osd->od_svname, ss->ss_server_seq); - if (rc != 0) { - OBD_FREE_PTR(osd->od_cl_seq); - osd->od_cl_seq = NULL; - RETURN(rc); - } + seq_client_init(osd->od_cl_seq, NULL, LUSTRE_SEQ_METADATA, + osd->od_svname, ss->ss_server_seq); if (ss->ss_node_id == 0) { /* @@ -7601,7 +7667,7 @@ static int osd_mount(const struct lu_env *env, *options = '\0'; if (opts != NULL) { /* strip out the options for back compatiblity */ - static char *sout[] = { + static const char * const sout[] = { "mballoc", "iopen", "noiopen", @@ -7669,23 +7735,10 @@ static int osd_mount(const struct lu_env *env, } if (lmd_flags & LMD_FLG_DEV_RDONLY) { - if (priv_dev_set_rdonly) { - priv_dev_set_rdonly(osd_sb(o)->s_bdev); - o->od_dt_dev.dd_rdonly = 1; - LCONSOLE_WARN("%s: set dev_rdonly on this device\n", - name); - } else { - LCONSOLE_WARN("%s: not support dev_rdonly on this device", - name); - - GOTO(out_mnt, rc = -EOPNOTSUPP); - } - } else if (priv_dev_check_rdonly && - priv_dev_check_rdonly(osd_sb(o)->s_bdev)) { - CERROR("%s: underlying device %s is marked as " - "read-only. Setup failed\n", name, dev); + LCONSOLE_WARN("%s: not support dev_rdonly on this device", + name); - GOTO(out_mnt, rc = -EROFS); + GOTO(out_mnt, rc = -EOPNOTSUPP); } if (!ldiskfs_has_feature_journal(o->od_mnt->mnt_sb)) { @@ -7742,6 +7795,8 @@ static struct lu_device *osd_device_fini(const struct lu_env *env, osd_index_backup(env, o, false); osd_shutdown(env, o); osd_procfs_fini(o); + if (o->od_oi_table != NULL) + osd_oi_fini(osd_oti_get(env), o); osd_obj_map_fini(o); osd_umount(env, o); @@ -7919,10 +7974,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); @@ -8094,10 +8147,18 @@ static int osd_prepare(const struct lu_env *env, struct lu_device *pdev, RETURN(result); } -static int osd_fid_alloc(const struct lu_env *env, struct obd_export *exp, - struct lu_fid *fid, struct md_op_data *op_data) +/** + * Implementation of lu_device_operations::ldo_fid_alloc() for OSD + * + * Allocate FID. + * + * see include/lu_object.h for the details. + */ +static int osd_fid_alloc(const struct lu_env *env, struct lu_device *d, + struct lu_fid *fid, struct lu_object *parent, + const struct lu_name *name) { - struct osd_device *osd = osd_dev(exp->exp_obd->obd_lu_dev); + struct osd_device *osd = osd_dev(d); return seq_client_alloc_fid(env, osd->od_cl_seq, fid); } @@ -8116,6 +8177,7 @@ const struct lu_device_operations osd_lu_ops = { .ldo_process_config = osd_process_config, .ldo_recovery_complete = osd_recovery_complete, .ldo_prepare = osd_prepare, + .ldo_fid_alloc = osd_fid_alloc, }; static const struct lu_device_type_operations osd_device_type_ops = { @@ -8154,7 +8216,6 @@ static const struct obd_ops osd_obd_device_ops = { .o_owner = THIS_MODULE, .o_connect = osd_obd_connect, .o_disconnect = osd_obd_disconnect, - .o_fid_alloc = osd_fid_alloc, .o_health_check = osd_health_check, }; @@ -8203,9 +8264,6 @@ static int __init osd_init(void) #ifdef CONFIG_KALLSYMS priv_security_file_alloc = (void *)kallsyms_lookup_name("security_file_alloc"); - priv_dev_set_rdonly = (void *)kallsyms_lookup_name("dev_set_rdonly"); - priv_dev_check_rdonly = - (void *)kallsyms_lookup_name("dev_check_rdonly"); #endif rc = class_register_type(&osd_obd_device_ops, NULL, true, NULL,