X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fllog_ioctl.c;h=bff97f3b9219e37e1d0309390cb8ab8282951bc4;hb=b5ff160e58b070c03290598914554a9ffecbea2e;hp=e210d9544e21dae0049f0166e7b817d4a5c47219;hpb=2f8dcb7b8da13c8621a982be730a335bb189df08;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index e210d95..bff97f3 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -27,7 +27,7 @@ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -37,12 +37,14 @@ #define DEBUG_SUBSYSTEM S_LOG #include +#include #include #include "llog_internal.h" static int str2logid(struct llog_logid *logid, char *str, int len) { char *start, *end, *endp; + __u64 id, seq; ENTRY; start = str; @@ -57,7 +59,7 @@ static int str2logid(struct llog_logid *logid, char *str, int len) RETURN(-EINVAL); *end = '\0'; - logid->lgl_oid = simple_strtoull(start, &endp, 0); + id = simple_strtoull(start, &endp, 0); if (endp != end) RETURN(-EINVAL); @@ -69,11 +71,14 @@ static int str2logid(struct llog_logid *logid, char *str, int len) RETURN(-EINVAL); *end = '\0'; - logid->lgl_oseq = simple_strtoull(start, &endp, 0); + seq = simple_strtoull(start, &endp, 0); if (endp != end) RETURN(-EINVAL); - start = ++end; + ostid_set_seq(&logid->lgl_oi, seq); + ostid_set_id(&logid->lgl_oi, id); + + start = ++end; if (start - str >= len - 1) RETURN(-EINVAL); logid->lgl_ogen = simple_strtoul(start, &endp, 16); @@ -87,7 +92,8 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data) { struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data; - static int l, remains, from, to; + static int l, remains; + static long from, to; static char *out; char *endp; int cur_index, rc = 0; @@ -130,9 +136,8 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, RETURN(-EOPNOTSUPP); rc = llog_cat_id2handle(env, handle, &loghandle, &lir->lid_id); if (rc) { - CDEBUG(D_IOCTL, - "cannot find log #"LPX64"#"LPX64"#%08x\n", - lir->lid_id.lgl_oid, lir->lid_id.lgl_oseq, + CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", + POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen); RETURN(rc); } @@ -174,7 +179,8 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_rec_hdr *rec, void *data) { struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data; - static int l, remains, from, to; + static int l, remains; + static long from, to; static char *out; char *endp; int cur_index; @@ -210,14 +216,14 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, RETURN(-EINVAL); } - l = snprintf(out, remains, - "[index]: %05d [logid]: #"LPX64"#"LPX64"#%08x\n", - cur_index, lir->lid_id.lgl_oid, - lir->lid_id.lgl_oseq, lir->lid_id.lgl_ogen); + l = snprintf(out, remains, + "[index]: %05d [logid]: #"DOSTID"#%08x\n", + cur_index, POSTID(&lir->lid_id.lgl_oi), + lir->lid_id.lgl_ogen); } else if (rec->lrh_type == OBD_CFG_REC) { int rc; - rc = class_config_parse_rec(rec, out, remains); + rc = class_config_yaml_output(rec, out, remains); if (rc < 0) RETURN(rc); l = rc; @@ -245,8 +251,8 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, rc = llog_cat_id2handle(env, cat, &log, logid); if (rc) { - CDEBUG(D_IOCTL, "cannot find log #"LPX64"#"LPX64"#%08x\n", - logid->lgl_oid, logid->lgl_oseq, logid->lgl_ogen); + CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", + POSTID(&logid->lgl_oi), logid->lgl_ogen); RETURN(-ENOENT); } @@ -316,18 +322,18 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, cfs_size_round(data->ioc_inllen1); char *out = data->ioc_bulk; - l = snprintf(out, remains, - "logid: #"LPX64"#"LPX64"#%08x\n" - "flags: %x (%s)\n" - "records count: %d\n" - "last index: %d\n", - handle->lgh_id.lgl_oid, handle->lgh_id.lgl_oseq, - handle->lgh_id.lgl_ogen, - handle->lgh_hdr->llh_flags, - handle->lgh_hdr->llh_flags & - LLOG_F_IS_CAT ? "cat" : "plain", - handle->lgh_hdr->llh_count, - handle->lgh_last_idx); + l = snprintf(out, remains, + "logid: #"DOSTID"#%08x\n" + "flags: %x (%s)\n" + "records count: %d\n" + "last index: %d\n", + POSTID(&handle->lgh_id.lgl_oi), + handle->lgh_id.lgl_ogen, + handle->lgh_hdr->llh_flags, + handle->lgh_hdr->llh_flags & + LLOG_F_IS_CAT ? "cat" : "plain", + handle->lgh_hdr->llh_count, + handle->lgh_last_idx); out += l; remains -= l; if (remains <= 0) { @@ -363,7 +369,7 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, GOTO(out_close, rc = -EINVAL); if (handle->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN) { - rc = llog_cancel_rec(NULL, handle, cookie.lgc_index); + rc = llog_cancel_rec(env, handle, cookie.lgc_index); GOTO(out_close, rc); } else if (!(handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)) { GOTO(out_close, rc = -EINVAL); @@ -422,3 +428,51 @@ out_close: RETURN(rc); } EXPORT_SYMBOL(llog_ioctl); + +int llog_catalog_list(const struct lu_env *env, struct dt_device *d, + int count, struct obd_ioctl_data *data, + const struct lu_fid *fid) +{ + int size, i; + struct llog_catid *idarray; + struct llog_logid *id; + char *out; + int l, remains, rc = 0; + + ENTRY; + + if (count == 0) { /* get total number of logs */ + rc = llog_osd_get_cat_list(env, d, 0, 0, NULL, fid); + if (rc < 0) + RETURN(rc); + count = rc; + } + + size = sizeof(*idarray) * count; + + OBD_ALLOC_LARGE(idarray, size); + if (!idarray) + RETURN(-ENOMEM); + + rc = llog_osd_get_cat_list(env, d, 0, count, idarray, fid); + if (rc) + GOTO(out, rc); + + out = data->ioc_bulk; + remains = data->ioc_inllen1; + for (i = 0; i < count; i++) { + id = &idarray[i].lci_logid; + l = snprintf(out, remains, + "catalog log: #"DOSTID"#%08x\n", + POSTID(&id->lgl_oi), + id->lgl_ogen); + out += l; + remains -= l; + if (remains <= 0) + break; + } +out: + OBD_FREE_LARGE(idarray, size); + RETURN(rc); +} +EXPORT_SYMBOL(llog_catalog_list);