From 54183b0637493c995ed2cd5d4cb3cce80192e6cb Mon Sep 17 00:00:00 2001 From: Gregoire Pichon Date: Wed, 20 Jun 2012 13:14:53 +0200 Subject: [PATCH] LU-1544 llog: remove lfs catinfo command This patch removes the llog catinfo code, both client and server side, since it has not been maintained and may crash the client system in some cases. Signed-off-by: Gregoire Pichon Change-Id: Ifa627e61d73a2a416bb548fcc510fb9ca3f36e79 Reviewed-on: http://review.whamcloud.com/3151 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Liu Xuezhao Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- lustre/include/lustre/liblustreapi.h | 1 - lustre/include/lustre/lustre_idl.h | 2 +- lustre/include/lustre_lib.h | 1 + lustre/include/lustre_net.h | 1 - lustre/include/lustre_req_layout.h | 1 - lustre/llite/dir.c | 56 +------- lustre/mgs/mgs_handler.c | 7 +- lustre/ptlrpc/layout.c | 17 --- lustre/ptlrpc/llog_server.c | 247 ----------------------------------- lustre/ptlrpc/ptlrpc_module.c | 1 - lustre/utils/lfs.c | 31 ----- lustre/utils/liblustreapi.c | 45 ------- 12 files changed, 6 insertions(+), 404 deletions(-) diff --git a/lustre/include/lustre/liblustreapi.h b/lustre/include/lustre/liblustreapi.h index 9a0b8f8..8a87398 100644 --- a/lustre/include/lustre/liblustreapi.h +++ b/lustre/include/lustre/liblustreapi.h @@ -192,7 +192,6 @@ extern int llapi_obd_statfs(char *path, __u32 type, __u32 index, struct obd_uuid *uuid_buf); extern int llapi_ping(char *obd_type, char *obd_name); extern int llapi_target_check(int num_types, char **obd_types, char *dir); -extern int llapi_catinfo(char *dir, char *keyword, char *node_name); extern int llapi_file_get_lov_uuid(const char *path, struct obd_uuid *lov_uuid); extern int llapi_file_fget_lov_uuid(int fd, struct obd_uuid *lov_uuid); extern int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count); diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 6a390d8..8b59564 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2763,7 +2763,7 @@ enum llogd_rpc_ops { LLOG_ORIGIN_HANDLE_WRITE_REC = 504, LLOG_ORIGIN_HANDLE_CLOSE = 505, LLOG_ORIGIN_CONNECT = 506, - LLOG_CATINFO = 507, /* for lfs catinfo */ + LLOG_CATINFO = 507, /* deprecated */ LLOG_ORIGIN_HANDLE_PREV_BLOCK = 508, LLOG_ORIGIN_HANDLE_DESTROY = 509, /* for destroy llog object*/ LLOG_LAST_OPC, diff --git a/lustre/include/lustre_lib.h b/lustre/include/lustre_lib.h index 83c9bf3..f9b88b6 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -550,6 +550,7 @@ static inline void obd_ioctl_freedata(char *buf, int len) #define OBD_IOC_LLOG_CANCEL _IOWR('f', 193, OBD_IOC_DATA_TYPE) #define OBD_IOC_LLOG_REMOVE _IOWR('f', 194, OBD_IOC_DATA_TYPE) #define OBD_IOC_LLOG_CHECK _IOWR('f', 195, OBD_IOC_DATA_TYPE) +/* OBD_IOC_LLOG_CATINFO is deprecated */ #define OBD_IOC_LLOG_CATINFO _IOWR('f', 196, OBD_IOC_DATA_TYPE) #define ECHO_IOC_GET_STRIPE _IOWR('f', 200, OBD_IOC_DATA_TYPE) diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 8fc0530..e09b50e 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -2281,7 +2281,6 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req); int llog_origin_handle_read_header(struct ptlrpc_request *req); int llog_origin_handle_close(struct ptlrpc_request *req); int llog_origin_handle_cancel(struct ptlrpc_request *req); -int llog_catinfo(struct ptlrpc_request *req); /* ptlrpc/llog_client.c */ extern struct llog_operations llog_client_ops; diff --git a/lustre/include/lustre_req_layout.h b/lustre/include/lustre_req_layout.h index f103407..ef94738 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -218,7 +218,6 @@ extern struct req_format RQF_LDLM_BL_CALLBACK; extern struct req_format RQF_LDLM_GL_CALLBACK; /* LOG req_format */ extern struct req_format RQF_LOG_CANCEL; -extern struct req_format RQF_LLOG_CATINFO; extern struct req_format RQF_LLOG_ORIGIN_HANDLE_CREATE; extern struct req_format RQF_LLOG_ORIGIN_HANDLE_DESTROY; extern struct req_format RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK; diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index bd8bda6..360b6e3 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1286,61 +1286,7 @@ out_free: return rc; } case OBD_IOC_LLOG_CATINFO: { - struct ptlrpc_request *req = NULL; - char *buf = NULL; - char *str; - int len = 0; - - rc = obd_ioctl_getdata(&buf, &len, (void *)arg); - if (rc) - RETURN(rc); - data = (void *)buf; - - if (!data->ioc_inlbuf1) { - obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); - } - - req = ptlrpc_request_alloc(sbi2mdc(sbi)->cl_import, - &RQF_LLOG_CATINFO); - if (req == NULL) - GOTO(out_catinfo, rc = -ENOMEM); - - req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, - data->ioc_inllen1); - req_capsule_set_size(&req->rq_pill, &RMF_STRING, RCL_CLIENT, - data->ioc_inllen2); - - rc = ptlrpc_request_pack(req, LUSTRE_LOG_VERSION, LLOG_CATINFO); - if (rc) { - ptlrpc_request_free(req); - GOTO(out_catinfo, rc); - } - - str = req_capsule_client_get(&req->rq_pill, &RMF_NAME); - memcpy(str, data->ioc_inlbuf1, data->ioc_inllen1); - if (data->ioc_inllen2) { - str = req_capsule_client_get(&req->rq_pill, - &RMF_STRING); - memcpy(str, data->ioc_inlbuf2, data->ioc_inllen2); - } - - req_capsule_set_size(&req->rq_pill, &RMF_STRING, RCL_SERVER, - data->ioc_plen1); - ptlrpc_request_set_replen(req); - - rc = ptlrpc_queue_wait(req); - if (!rc) { - str = req_capsule_server_get(&req->rq_pill, - &RMF_STRING); - if (cfs_copy_to_user(data->ioc_pbuf1, str, - data->ioc_plen1)) - rc = -EFAULT; - } - ptlrpc_req_finished(req); - out_catinfo: - obd_ioctl_freedata(buf, len); - RETURN(rc); + RETURN(-EOPNOTSUPP); } case OBD_IOC_QUOTACHECK: { struct obd_quotactl *oqctl; diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 22a0b6f..06a60b5 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -930,10 +930,9 @@ int mgs_handle(struct ptlrpc_request *req) rc = llog_origin_handle_close(req); break; case LLOG_CATINFO: - DEBUG_REQ(D_MGS, req, "llog catinfo"); - req_capsule_set(&req->rq_pill, &RQF_LLOG_CATINFO); - rc = llog_catinfo(req); - break; + DEBUG_REQ(D_MGS, req, "llog catinfo"); + rc = -EOPNOTSUPP; + break; default: req->rq_status = -ENOTSUPP; rc = ptlrpc_error(req); diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index ed17822..fe0637c 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -451,17 +451,6 @@ static const struct req_msg_field *mds_setattr_server[] = { &RMF_CAPA2 }; -static const struct req_msg_field *llog_catinfo_client[] = { - &RMF_PTLRPC_BODY, - &RMF_NAME, - &RMF_STRING -}; - -static const struct req_msg_field *llog_catinfo_server[] = { - &RMF_PTLRPC_BODY, - &RMF_STRING -}; - static const struct req_msg_field *llog_origin_handle_create_client[] = { &RMF_PTLRPC_BODY, &RMF_LLOGD_BODY, @@ -625,7 +614,6 @@ static struct req_format *req_formats[] = { &RQF_LDLM_INTENT_CREATE, &RQF_LDLM_INTENT_UNLINK, &RQF_LOG_CANCEL, - &RQF_LLOG_CATINFO, &RQF_LLOG_ORIGIN_HANDLE_CREATE, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, @@ -1240,11 +1228,6 @@ struct req_format RQF_MDS_IS_SUBDIR = mdt_body_only, mdt_body_only); EXPORT_SYMBOL(RQF_MDS_IS_SUBDIR); -struct req_format RQF_LLOG_CATINFO = - DEFINE_REQ_FMT0("LLOG_CATINFO", - llog_catinfo_client, llog_catinfo_server); -EXPORT_SYMBOL(RQF_LLOG_CATINFO); - struct req_format RQF_LLOG_ORIGIN_HANDLE_CREATE = DEFINE_REQ_FMT0("LLOG_ORIGIN_HANDLE_CREATE", llog_origin_handle_create_client, llogd_body_only); diff --git a/lustre/ptlrpc/llog_server.c b/lustre/ptlrpc/llog_server.c index c72d2e1..242b830 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -451,253 +451,6 @@ pop_ctxt: } EXPORT_SYMBOL(llog_origin_handle_cancel); -static int llog_catinfo_config(struct obd_device *obd, char *buf, int buf_len, - char *client) -{ - struct mds_obd *mds = &obd->u.mds; - struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - struct lvfs_run_ctxt saved; - struct llog_handle *handle = NULL; - char name[4][64]; - int rc, i, l, remains = buf_len; - char *out = buf; - ENTRY; - - if (ctxt == NULL || mds == NULL) - GOTO(release_ctxt, rc = -ENODEV); - - push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - - sprintf(name[0], "%s", mds->mds_profile); - sprintf(name[1], "%s-clean", mds->mds_profile); - sprintf(name[2], "%s", client); - sprintf(name[3], "%s-clean", client); - - for (i = 0; i < 4; i++) { - int index, uncanceled = 0; - rc = llog_create(ctxt, &handle, NULL, name[i]); - if (rc) - GOTO(out_pop, rc); - rc = llog_init_handle(handle, 0, NULL); - if (rc) { - llog_close(handle); - GOTO(out_pop, rc = -ENOENT); - } - - for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index ++) { - if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap)) - uncanceled++; - } - - l = snprintf(out, remains, "[Log Name]: %s\nLog Size: %llu\n" - "Last Index: %d\nUncanceled Records: %d\n\n", - name[i], - i_size_read(handle->lgh_file->f_dentry->d_inode), - handle->lgh_last_idx, uncanceled); - out += l; - remains -= l; - - llog_close(handle); - if (remains <= 0) - break; - } - GOTO(out_pop, rc); -out_pop: - pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); -release_ctxt: - llog_ctxt_put(ctxt); - return rc; -} - -struct cb_data { - struct llog_ctxt *ctxt; - char *out; - int remains; - int init; -}; - -static int llog_catinfo_cb(struct llog_handle *cat, - struct llog_rec_hdr *rec, void *data) -{ - static char *out = NULL; - static int remains = 0; - struct llog_ctxt *ctxt = NULL; - struct llog_handle *handle = NULL; - struct llog_logid *logid; - struct llog_logid_rec *lir; - int l, rc, index, count = 0; - struct cb_data *cbd = (struct cb_data*)data; - ENTRY; - - if (cbd->init) { - out = cbd->out; - remains = cbd->remains; - cbd->init = 0; - } - - if (!(cat->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) - RETURN(-EINVAL); - - if (!cbd->ctxt) - RETURN(-ENODEV); - - lir = (struct llog_logid_rec *)rec; - logid = &lir->lid_id; - rc = llog_create(ctxt, &handle, logid, NULL); - if (rc) - RETURN(-EINVAL); - rc = llog_init_handle(handle, 0, NULL); - if (rc) - GOTO(out_close, rc); - - for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index++) { - if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap)) - count++; - } - - l = snprintf(out, remains, "\t[Log ID]: #"LPX64"#"LPX64"#%08x\n" - "\tLog Size: %llu\n\tLast Index: %d\n" - "\tUncanceled Records: %d\n", - logid->lgl_oid, logid->lgl_oseq, logid->lgl_ogen, - i_size_read(handle->lgh_file->f_dentry->d_inode), - handle->lgh_last_idx, count); - out += l; - remains -= l; - cbd->out = out; - cbd->remains = remains; - if (remains <= 0) { - CWARN("Not enough memory\n"); - rc = -ENOMEM; - } - EXIT; -out_close: - llog_close(handle); - return rc; -} - -static int llog_catinfo_deletions(struct obd_device *obd, char *buf, - int buf_len) -{ - struct mds_obd *mds = &obd->u.mds; - struct llog_handle *handle; - struct lvfs_run_ctxt saved; - int size, i, count; - struct llog_catid *idarray; - char name[32] = CATLIST; - struct cb_data data; - struct llog_ctxt *ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); - int rc; - ENTRY; - - if (ctxt == NULL || mds == NULL) - GOTO(release_ctxt, rc = -ENODEV); - - count = mds->mds_lov_desc.ld_tgt_count; - size = sizeof(*idarray) * count; - - OBD_ALLOC_LARGE(idarray, size); - if (!idarray) - GOTO(release_ctxt, rc = -ENOMEM); - - cfs_mutex_lock(&obd->obd_olg.olg_cat_processing); - rc = llog_get_cat_list(obd, name, 0, count, idarray); - if (rc) - GOTO(out_free, rc); - - push_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); - - data.ctxt = ctxt; - data.out = buf; - data.remains = buf_len; - for (i = 0; i < count; i++) { - int l, index, uncanceled = 0; - - rc = llog_create(ctxt, &handle, &idarray[i].lci_logid, NULL); - if (rc) - GOTO(out_pop, rc); - rc = llog_init_handle(handle, 0, NULL); - if (rc) { - llog_close(handle); - GOTO(out_pop, rc = -ENOENT); - } - for (index = 1; index < (LLOG_BITMAP_BYTES * 8); index++) { - if (ext2_test_bit(index, handle->lgh_hdr->llh_bitmap)) - uncanceled++; - } - l = snprintf(data.out, data.remains, - "\n[Catlog ID]: #"LPX64"#"LPX64"#%08x " - "[Log Count]: %d\n", - idarray[i].lci_logid.lgl_oid, - idarray[i].lci_logid.lgl_oseq, - idarray[i].lci_logid.lgl_ogen, uncanceled); - - data.out += l; - data.remains -= l; - data.init = 1; - - llog_process(handle, llog_catinfo_cb, &data, NULL); - llog_close(handle); - - if (data.remains <= 0) - break; - } - EXIT; -out_pop: - pop_ctxt(&saved, &ctxt->loc_exp->exp_obd->obd_lvfs_ctxt, NULL); -out_free: - cfs_mutex_unlock(&obd->obd_olg.olg_cat_processing); - OBD_FREE_LARGE(idarray, size); -release_ctxt: - llog_ctxt_put(ctxt); - return rc; -} - -int llog_catinfo(struct ptlrpc_request *req) -{ - struct obd_export *exp = req->rq_export; - struct obd_device *obd = exp->exp_obd; - char *keyword; - char *buf, *reply; - int rc; - ENTRY; - - OBD_ALLOC(buf, LLOG_CHUNK_SIZE); - if (buf == NULL) - RETURN(-ENOMEM); - - memset(buf, 0, LLOG_CHUNK_SIZE); - - keyword = req_capsule_client_get(&req->rq_pill, &RMF_NAME); - LASSERT(keyword); - - if (strcmp(keyword, "config") == 0) { - char *client = req_capsule_client_get(&req->rq_pill, - &RMF_STRING); - - LASSERT(client); - rc = llog_catinfo_config(obd, buf, LLOG_CHUNK_SIZE, client); - } else if (strcmp(keyword, "deletions") == 0) { - rc = llog_catinfo_deletions(obd, buf, LLOG_CHUNK_SIZE); - } else { - rc = -EOPNOTSUPP; - } - - req_capsule_set_size(&req->rq_pill, &RMF_STRING, RCL_SERVER, - LLOG_CHUNK_SIZE); - rc = req_capsule_server_pack(&req->rq_pill); - if (rc) - GOTO(out_free, rc = -ENOMEM); - - reply = req_capsule_server_get(&req->rq_pill, &RMF_STRING); - if (strlen(buf) == 0) - sprintf(buf, "%s", "No log informations\n"); - memcpy(reply, buf, LLOG_CHUNK_SIZE); - EXIT; -out_free: - OBD_FREE(buf, LLOG_CHUNK_SIZE); - return rc; -} - #else /* !__KERNEL__ */ int llog_origin_handle_create(struct ptlrpc_request *req) { diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index f9487b2..0eed7d7 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -353,7 +353,6 @@ EXPORT_SYMBOL(llog_origin_handle_prev_block); EXPORT_SYMBOL(llog_origin_handle_read_header); EXPORT_SYMBOL(llog_origin_handle_close); EXPORT_SYMBOL(llog_client_ops); -EXPORT_SYMBOL(llog_catinfo); MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Request Processor and Lock Management"); diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 738b446..bcfab94 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -89,7 +89,6 @@ static int lfs_mdts(int argc, char **argv); static int lfs_df(int argc, char **argv); static int lfs_getname(int argc, char **argv); static int lfs_check(int argc, char **argv); -static int lfs_catinfo(int argc, char **argv); #ifdef HAVE_SYS_QUOTA_H static int lfs_quotachown(int argc, char **argv); static int lfs_quotacheck(int argc, char **argv); @@ -163,11 +162,6 @@ command_t cmdlist[] = { "Display the status of MDS or OSTs (as specified in the command)\n" "or all the servers (MDS and OSTs).\n" "usage: check "}, - {"catinfo", lfs_catinfo, 0, - "Show information of specified type logs.\n" - "usage: catinfo {keyword} [node name]\n" - "\tkeywords are one of followings: config, deletions.\n" - "\tnode name must be provided when use keyword config."}, {"join", lfs_join, 0, "join two lustre files into one.\n" "obsolete, HEAD does not support it anymore.\n"}, @@ -1446,31 +1440,6 @@ static int lfs_check(int argc, char **argv) } -static int lfs_catinfo(int argc, char **argv) -{ - char mntdir[PATH_MAX] = {'\0'}; - int rc; - - if (argc < 2 || (!strcmp(argv[1],"config") && argc < 3)) - return CMD_HELP; - - if (strcmp(argv[1], "config") && strcmp(argv[1], "deletions")) - return CMD_HELP; - - rc = llapi_search_mounts(NULL, 0, mntdir, NULL); - if (rc == 0 && mntdir[0] != '\0') { - if (argc == 3) - rc = llapi_catinfo(mntdir, argv[1], argv[2]); - else - rc = llapi_catinfo(mntdir, argv[1], NULL); - } else { - fprintf(stderr, "no lustre_lite mounted.\n"); - rc = -1; - } - - return rc; -} - static int lfs_join(int argc, char **argv) { fprintf(stderr, "join two lustre files into one.\n" diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index ffe0e80..aea7389 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2924,51 +2924,6 @@ int llapi_target_check(int type_num, char **obd_type, char *dir) #undef MAX_STRING_SIZE -int llapi_catinfo(char *dir, char *keyword, char *node_name) -{ - char raw[OBD_MAX_IOCTL_BUFFER]; - char out[LLOG_CHUNK_SIZE]; - char *buf = raw; - struct obd_ioctl_data data = { 0 }; - char key[30]; - DIR *root; - int rc; - - sprintf(key, "%s", keyword); - memset(raw, 0, sizeof(raw)); - memset(out, 0, sizeof(out)); - data.ioc_inlbuf1 = key; - data.ioc_inllen1 = strlen(key) + 1; - if (node_name) { - data.ioc_inlbuf2 = node_name; - data.ioc_inllen2 = strlen(node_name) + 1; - } - data.ioc_pbuf1 = out; - data.ioc_plen1 = sizeof(out); - rc = obd_ioctl_pack(&data, &buf, sizeof(raw)); - if (rc) - return rc; - - root = opendir(dir); - if (root == NULL) { - rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "open %s failed", dir); - return rc; - } - - rc = ioctl(dirfd(root), OBD_IOC_LLOG_CATINFO, buf); - if (rc) { - rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, - "ioctl OBD_IOC_CATINFO failed"); - } else { - llapi_printf(LLAPI_MSG_NORMAL, "%s", data.ioc_pbuf1); - } - - closedir(root); - return rc; -} - /* Is this a lustre fs? */ int llapi_is_lustre_mnttype(const char *type) { -- 1.8.3.1