X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Flr_reader.c;h=6eb2cbab186c26b6b5c48cb01488b4c1c8e8a689;hb=a213c3341903ff553df2e1cc42dd14a7b3d98845;hp=996f4d9b01610db2441d7d92b029b1a58be4839c;hpb=6869932b552ac705f411de3362f01bd50c1f6f7d;p=fs%2Flustre-release.git diff --git a/lustre/utils/lr_reader.c b/lustre/utils/lr_reader.c index 996f4d9..6eb2cba 100644 --- a/lustre/utils/lr_reader.c +++ b/lustre/utils/lr_reader.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -39,6 +39,10 @@ */ /* Safely read the last_rcvd file from a device */ +#if HAVE_CONFIG_H +# include "config.h" +#endif /* HAVE_CONFIG_H */ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -121,9 +125,9 @@ int main(int argc, char *const argv[]) } memset(cmd, 0, sizeof(cmd)); - sprintf(cmd, - "debugfs -c -R 'dump /%s %s/%s' %s", - LAST_RCVD, tmpdir, LAST_RCVD, dev); + snprintf(cmd, sizeof(cmd), + "%s -c -R 'dump /%s %s/%s' %s", + DEBUGFS, LAST_RCVD, tmpdir, LAST_RCVD, dev); ret = run_command(cmd); if (ret) { @@ -151,75 +155,72 @@ int main(int argc, char *const argv[]) goto out_close; } - #if 0 - __u8 lsd_uuid[40]; /* server UUID */ - __u64 lsd_last_transno; /* last completed transaction ID */ - __u64 lsd_compat14; /* reserved - compat with old last_rcvd */ - __u64 lsd_mount_count; /* incarnation number */ - __u32 lsd_feature_compat; /* compatible feature flags */ - __u32 lsd_feature_rocompat;/* read-only compatible feature flags */ - __u32 lsd_feature_incompat;/* incompatible feature flags */ - __u32 lsd_server_size; /* size of server data area */ - __u32 lsd_client_start; /* start of per-client data area */ - __u16 lsd_client_size; /* size of per-client data area */ - __u16 lsd_subdir_count; /* number of subdirectories for objects */ - __u64 lsd_catalog_oid; /* recovery catalog object id */ - __u32 lsd_catalog_ogen; /* recovery catalog inode generation */ - __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */ - __u32 lsd_ost_index; /* index number of OST in LOV */ - __u32 lsd_mdt_index; /* index number of MDT in LMV */ - __u8 lsd_padding[LR_SERVER_SIZE - 148]; - #endif - - printf("UUID %s\n", lsd.lsd_uuid); - printf("Feature compat=%#x\n", lsd.lsd_feature_compat); - printf("Feature incompat=%#x\n", lsd.lsd_feature_incompat); - printf("Feature rocompat=%#x\n", lsd.lsd_feature_rocompat); - printf("Last transaction %llu\n", (long long)lsd.lsd_last_transno); - printf("ost index %u\n", lsd.lsd_ost_index); - printf("mdt index %u\n", lsd.lsd_mdt_index); - - if ((lsd.lsd_feature_compat & OBD_COMPAT_OST) || - (lsd.lsd_feature_incompat & OBD_INCOMPAT_OST)) { - printf("OST, index %d\n", lsd.lsd_ost_index); - } else if ((lsd.lsd_feature_compat & OBD_COMPAT_MDT) || - (lsd.lsd_feature_incompat & OBD_INCOMPAT_MDT)) { - /* We must co-locate so mgs can see old logs. - If user doesn't want this, they can copy the old - logs manually and re-tunefs. */ - printf("MDS, index %d\n", lsd.lsd_mdt_index); - } else { - /* If neither is set, we're pre-1.4.6, make a guess. */ - /* Construct debugfs command line. */ - memset(cmd, 0, sizeof(cmd)); - sprintf(cmd, - "debugfs -c -R 'rdump /%s %s' %s", - MDT_LOGS_DIR, tmpdir, dev); - - run_command(cmd); - - sprintf(filepnm, "%s/%s", tmpdir, MDT_LOGS_DIR); - if (lsd.lsd_ost_index > 0) { - printf("non-flagged OST, index %d\n", - lsd.lsd_ost_index); - } else { - /* If there's a LOGS dir, it's an MDT */ - if ((ret = access(filepnm, F_OK)) == 0) { - /* Old MDT's are always index 0 - (pre CMD) */ - printf("non-flagged MDS, index 0\n"); - } else { - printf("non-flagged OST, index unknown\n"); - } - } - } - +#if 0 + __u8 lsd_uuid[40]; /* server UUID */ + __u64 lsd_last_transno; /* last completed transaction ID */ + __u64 lsd_compat14; /* reserved - compat with old last_rcvd */ + __u64 lsd_mount_count; /* incarnation number */ + __u32 lsd_feature_compat; /* compatible feature flags */ + __u32 lsd_feature_rocompat;/* read-only compatible feature flags */ + __u32 lsd_feature_incompat;/* incompatible feature flags */ + __u32 lsd_server_size; /* size of server data area */ + __u32 lsd_client_start; /* start of per-client data area */ + __u16 lsd_client_size; /* size of per-client data area */ + __u16 lsd_subdir_count; /* number of subdirectories for objects */ + __u64 lsd_catalog_oid; /* recovery catalog object id */ + __u32 lsd_catalog_ogen; /* recovery catalog inode generation */ + __u8 lsd_peeruuid[40]; /* UUID of MDS associated with this OST */ + __u32 lsd_osd_index; /* index number of OST/MDT in LOV/LMV */ + __u8 lsd_padding[LR_SERVER_SIZE - 148]; +#endif + + printf("UUID %s\n", lsd.lsd_uuid); + printf("Feature compat=%#x\n", lsd.lsd_feature_compat); + printf("Feature incompat=%#x\n", lsd.lsd_feature_incompat); + printf("Feature rocompat=%#x\n", lsd.lsd_feature_rocompat); + printf("Last transaction %llu\n", (long long)lsd.lsd_last_transno); + printf("target index %u\n", lsd.lsd_osd_index); + + if ((lsd.lsd_feature_compat & OBD_COMPAT_OST) || + (lsd.lsd_feature_incompat & OBD_INCOMPAT_OST)) { + printf("OST, index %d\n", lsd.lsd_osd_index); + } else if ((lsd.lsd_feature_compat & OBD_COMPAT_MDT) || + (lsd.lsd_feature_incompat & OBD_INCOMPAT_MDT)) { + /* We must co-locate so mgs can see old logs. + If user doesn't want this, they can copy the old + logs manually and re-tunefs. */ + printf("MDS, index %d\n", lsd.lsd_osd_index); + } else { + /* If neither is set, we're pre-1.4.6, make a guess. */ + /* Construct debugfs command line. */ + memset(cmd, 0, sizeof(cmd)); + snprintf(cmd, sizeof(cmd), "%s -c -R 'rdump /%s %s' %s", + DEBUGFS, MDT_LOGS_DIR, tmpdir, dev); + + run_command(cmd); + + sprintf(filepnm, "%s/%s", tmpdir, MDT_LOGS_DIR); + if (lsd.lsd_osd_index > 0) { + printf("non-flagged OST, index %d\n", + lsd.lsd_osd_index); + } else { + /* If there's a LOGS dir, it's an MDT */ + if ((ret = access(filepnm, F_OK)) == 0) { + /* Old MDT's are always index 0 + (pre CMD) */ + printf("non-flagged MDS, index 0\n"); + } else { + printf("non-flagged OST, index unknown\n"); + } + } + } + out_close: - fclose(filep); + fclose(filep); out_rmdir: - memset(cmd, 0, sizeof(cmd)); - sprintf(cmd, "rm -rf %s", tmpdir); - run_command(cmd); - return ret; + memset(cmd, 0, sizeof(cmd)); + sprintf(cmd, "rm -rf %s", tmpdir); + run_command(cmd); + return ret; }