X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fllog_ioctl.c;h=f6b4b17bbb7bd2fabf36b226c73701a5acf07307;hb=e21430272b4187e919a87fef4aa3ed7350e3c2d6;hp=d036c2d6bd5822453567430dd445068c887c39d5;hpb=b5b6224b227ca816fc40739741f0c37364db6677;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index d036c2d..f6b4b17 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -1,9 +1,37 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * You should have received a copy of the GNU General Public License - * along with Lustre; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #define DEBUG_SUBSYSTEM S_LOG @@ -12,15 +40,16 @@ #define EXPORT_SYMTAB #endif -#include -#include -#include -#include +#include +#include +#include +#include "llog_internal.h" static int str2logid(struct llog_logid *logid, char *str, int len) { char *start, *end, *endp; + ENTRY; start = str; if (*start != '#') RETURN(-EINVAL); @@ -68,6 +97,7 @@ static int llog_check_cb(struct llog_handle *handle, struct llog_rec_hdr *rec, char *endp; int cur_index, rc = 0; + ENTRY; cur_index = rec->lrh_index; if (ioc_data && (ioc_data->ioc_inllen1)) { @@ -101,7 +131,14 @@ static int llog_check_cb(struct llog_handle *handle, struct llog_rec_hdr *rec, } if (handle->lgh_ctxt == NULL) RETURN(-EOPNOTSUPP); - llog_cat_id2handle(handle, &log_handle, &lir->lid_id); + rc = llog_cat_id2handle(handle, &log_handle, &lir->lid_id); + if (rc) { + CDEBUG(D_IOCTL, + "cannot find log #"LPX64"#"LPX64"#%08x\n", + lir->lid_id.lgl_oid, lir->lid_id.lgl_ogr, + lir->lid_id.lgl_ogen); + RETURN(rc); + } rc = llog_process(log_handle, llog_check_cb, NULL, NULL); llog_close(log_handle); } else { @@ -109,8 +146,8 @@ static int llog_check_cb(struct llog_handle *handle, struct llog_rec_hdr *rec, case OST_SZ_REC: case OST_RAID1_REC: case MDS_UNLINK_REC: + case MDS_SETATTR_REC: case OBD_CFG_REC: - case PTL_CFG_REC: case LLOG_HDR_MAGIC: { l = snprintf(out, remains, "[index]: %05d [type]: " "%02x [len]: %04d ok\n", @@ -151,6 +188,7 @@ static int llog_print_cb(struct llog_handle *handle, struct llog_rec_hdr *rec, char *endp; int cur_index; + ENTRY; if (ioc_data->ioc_inllen1) { l = 0; remains = ioc_data->ioc_inllen4 + @@ -204,6 +242,7 @@ static int llog_remove_log(struct llog_handle *cat, struct llog_logid *logid) struct llog_handle *log; int rc, index = 0; + ENTRY; down_write(&cat->lgh_lock); rc = llog_cat_id2handle(cat, &log, logid); if (rc) { @@ -234,8 +273,9 @@ static int llog_delete_cb(struct llog_handle *handle, struct llog_rec_hdr *rec, struct llog_logid_rec *lir = (struct llog_logid_rec*)rec; int rc; + ENTRY; if (rec->lrh_type != LLOG_LOGID_MAGIC) - return (-EINVAL); + RETURN (-EINVAL); rc = llog_remove_log(handle, &lir->lid_id); RETURN(rc); @@ -248,16 +288,17 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data) int err = 0; struct llog_handle *handle = NULL; + ENTRY; if (*data->ioc_inlbuf1 == '#') { err = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1); if (err) GOTO(out, err); - err = llog_open(ctxt, &handle, &logid, NULL, 0); + err = llog_create(ctxt, &handle, &logid, NULL); if (err) GOTO(out, err); } else if (*data->ioc_inlbuf1 == '$') { char *name = data->ioc_inlbuf1 + 1; - err = llog_open(ctxt, &handle, NULL, name, 0); + err = llog_create(ctxt, &handle, NULL, name); if (err) GOTO(out, err); } else { @@ -304,9 +345,11 @@ int llog_ioctl(struct llog_ctxt *ctxt, int cmd, struct obd_ioctl_data *data) case OBD_IOC_LLOG_PRINT: { LASSERT(data->ioc_inllen1); - err = llog_process(handle, llog_print_cb, data, NULL); + err = llog_process(handle, class_config_dump_handler,data,NULL); if (err == -LLOG_EEMPTY) err = 0; + else + err = llog_process(handle, llog_print_cb, data, NULL); GOTO(out_close, err); } @@ -386,19 +429,17 @@ int llog_catalog_list(struct obd_device *obd, int count, char *out; int l, remains, rc = 0; + ENTRY; size = sizeof(*idarray) * count; - OBD_ALLOC(idarray, size); + OBD_VMALLOC(idarray, size); if (!idarray) RETURN(-ENOMEM); - memset(idarray, 0, size); - rc = llog_get_cat_list(&obd->obd_lvfs_ctxt, obd->obd_fsops, - name, count, idarray); - if (rc) { - OBD_FREE(idarray, size); - RETURN(rc); - } + mutex_down(&obd->obd_olg.olg_cat_processing); + rc = llog_get_cat_list(obd, obd, name, 0, count, idarray); + if (rc) + GOTO(out, rc); out = data->ioc_bulk; remains = data->ioc_inllen1; @@ -414,8 +455,12 @@ int llog_catalog_list(struct obd_device *obd, int count, break; } } - OBD_FREE(idarray, size); - RETURN(0); +out: + /* release semaphore */ + mutex_up(&obd->obd_olg.olg_cat_processing); + + OBD_VFREE(idarray, size); + RETURN(rc); } EXPORT_SYMBOL(llog_catalog_list);