From: Gregoire Pichon Date: Wed, 20 Jun 2012 11:14:53 +0000 (+0200) Subject: LU-1544 llog: remove lfs catinfo command X-Git-Tag: 2.1.4-RC1~25 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=96b812cc496f6e3c037625389916c4e691473588;p=fs%2Flustre-release.git 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 Signed-off-by: Bob Glossman Change-Id: Ia55e161ca118dad66a3136850de2f0e8f7aa5206 Reviewed-on: http://review.whamcloud.com/3450 Tested-by: Hudson Reviewed-by: Mike Pershin Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre/liblustreapi.h b/lustre/include/lustre/liblustreapi.h index 87c058a..d85704d 100644 --- a/lustre/include/lustre/liblustreapi.h +++ b/lustre/include/lustre/liblustreapi.h @@ -181,7 +181,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 cf25f7c..00b4a69 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2713,7 +2713,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 6283648..305e69a 100644 --- a/lustre/include/lustre_lib.h +++ b/lustre/include/lustre_lib.h @@ -528,6 +528,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 6ca398b..447714f 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1879,7 +1879,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 88a2ecf..53da7a3 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -215,7 +215,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 e2979f5..06dc266 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1267,61 +1267,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 e34029b..258fefd 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -766,10 +766,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 2d7eeea..b9a9733 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -447,17 +447,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, @@ -620,7 +609,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, @@ -1213,11 +1201,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 c81d860..f1e2551 100644 --- a/lustre/ptlrpc/llog_server.c +++ b/lustre/ptlrpc/llog_server.c @@ -457,253 +457,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_down(&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_up(&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 f1be6c9..72fbd1c 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -347,7 +347,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 683556d..7d25c6a 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -88,7 +88,6 @@ static int lfs_osts(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); @@ -156,11 +155,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"}, @@ -1253,31 +1247,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 9fcb219..1d55551 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2590,51 +2590,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) {