Whamcloud - gitweb
b=21244 utility to decode filter fid xattr
authorVladimir Saveliev <Vladimir.Saveliev@sun.com>
Thu, 10 Jun 2010 03:07:56 +0000 (07:07 +0400)
committerRobert Read <robert.read@oracle.com>
Thu, 10 Jun 2010 23:32:17 +0000 (16:32 -0700)
program and sanity test

i=andreas.dilger

lustre/tests/sanity.sh
lustre/tests/test-framework.sh
lustre/utils/Makefile.am
lustre/utils/ll_decode_filter_fid.c [new file with mode: 0644]

index 2832acd..747efc9 100755 (executable)
@@ -1278,6 +1278,72 @@ test_27y() {
 }
 run_test 27y "create files while OST0 is degraded and the rest inactive"
 
+check_seq_oid()
+{
+        echo check file $1
+        local old_ifs="$IFS"
+        IFS=$'\t\n :'
+        lmm=($($GETSTRIPE -v $1))
+
+        IFS=$'[:]'
+        fid=($($LFS path2fid $1))
+        IFS="$old_ifs"
+
+        # compare lmm_seq and lu_fid->f_seq
+        [ ${lmm[4]} = ${fid[1]} ] || { error "SEQ mismatch"; return 1; }
+        # compare lmm_object_id and lu_fid->oid
+        [ ${lmm[6]} = ${fid[2]} ] || { error "OID mismatch"; return 2; }
+
+        echo -e "\tseq ${fid[1]}, oid ${fid[2]} ver ${fid[3]}\n\tstripe count: ${lmm[8]}"
+
+        [ "$FSTYPE" != "ldiskfs" ] && skip "can not check trusted.fid FSTYPE=$FSTYPE" && return 0
+
+        # check the trusted.fid attribute of the OST objects of the file
+        for (( i=0, j=19; i < ${lmm[8]}; i++, j+=4 )); do
+                local obdidx=${lmm[$j]}
+                local devnum=$((obdidx + 1))
+                local objid=${lmm[$((j+1))]}
+                local group=${lmm[$((j+3))]}
+                local dev=$(ostdevname $devnum)
+                local dir=${MOUNT%/*}/ost$devnum
+                do_facet ost$devnum mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS ||
+                        { error "mounting $dev as $FSTYPE failed"; return 3; }
+
+                obj_filename=$(do_facet ost$devnum find $dir/O/$group -name $objid)
+                local ff=$(do_facet ost$devnum $LL_DECODE_FILTER_FID $obj_filename)
+                IFS=$'/= [:]'
+                ff=($(echo $ff))
+                IFS="$old_ifs"
+
+                # compare lmm_seq and filter_fid->ff_parent.f_seq
+                [ ${ff[11]} = ${lmm[4]} ] || { error "parent SEQ mismatch"; return 4; }
+                # compare lmm_object_id and filter_fid->ff_parent.f_oid
+                [ ${ff[12]} = ${lmm[6]} ] || { error "parent OID mismatch"; return 5; }
+                let stripe=${ff[13]}
+                [ $stripe -eq $i ] || { error "stripe mismatch"; return 6; }
+
+                echo -e "\t\tost $obdidx, objid $objid, group $group"
+                do_facet ost$devnum umount -d $dev
+        done
+}
+
+test_27z() {
+        mkdir -p $DIR/$tdir
+        $SETSTRIPE $DIR/$tdir/$tfile-1 -c 1 -o 0 -s 1m ||
+                { error "setstripe -c -1 failed"; return 1; }
+        dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=1M count=1 ||
+                { error "dd 1 mb failed"; return 2; }
+        $SETSTRIPE $DIR/$tdir/$tfile-2 -c -1 -o $(($OSTCOUNT - 1)) -s 1m ||
+                { error "setstripe -c 1 failed"; return 3; }
+        dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=1M count=$OSTCOUNT ||
+                { error "dd $OSTCOUNT mb failed"; return 4; }
+        sync
+
+        check_seq_oid $DIR/$tdir/$tfile-1 || return 5
+        check_seq_oid $DIR/$tdir/$tfile-2 || return 6
+}
+run_test 27z "check SEQ/OID on the MDT and OST filesystems"
+
 # createtest also checks that device nodes are created and
 # then visible correctly (#2091)
 test_28() { # bug 2091
index 50584a2..7744307 100644 (file)
@@ -167,6 +167,8 @@ init_test_env() {
             export L_GETIDENTITY=NONE
         fi
     fi
+    export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
+    [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
     export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
     [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
     export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
index e846e9b..f6c234b 100644 (file)
@@ -22,7 +22,7 @@ rootsbin_PROGRAMS = mount.lustre
 sbin_PROGRAMS = mkfs.lustre tunefs.lustre lctl wiretest \
        l_getidentity llverfs llverdev \
        llog_reader lr_reader lshowmount lustre_rsync \
-       ll_recover_lost_found_objs ltrack_stats
+       ll_recover_lost_found_objs ltrack_stats ll_decode_filter_fid
 if LIBPTHREAD
 sbin_PROGRAMS += loadgen
 endif
diff --git a/lustre/utils/ll_decode_filter_fid.c b/lustre/utils/ll_decode_filter_fid.c
new file mode 100644 (file)
index 0000000..c7e2c63
--- /dev/null
@@ -0,0 +1,86 @@
+/* -*- 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.
+ *
+ * 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  2009 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.
+ *
+ * lustre/utils/ll_decode_filter_fid.c
+ *
+ * Tool for printing the OST filter_fid structure on the objects
+ * in human readable form.
+ *
+ * Author: Andreas Dilger <adilger@sun.com>
+ */
+
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/xattr.h>
+#include <liblustre.h>
+#include <lustre/lustre_user.h>
+
+int main(int argc, char *argv[])
+{
+       char *prog;
+       int rc = 0;
+       int i;
+
+       prog = basename(argv[0]);
+
+       for (i = 1; i < argc; i++) {
+               char buf[1024]; /* allow xattr that may be larger */
+               struct filter_fid *ff = (void *)buf;
+               int size;
+
+               size = getxattr(argv[i], "trusted.fid", buf, sizeof(buf));
+               if (size < 0) {
+                       fprintf(stderr, "%s: error reading fid: %s\n",
+                               argv[i], strerror(errno));
+                       if (rc == 0)
+                               rc = size;
+                        continue;
+                }
+                if (size > sizeof(*ff))
+                       fprintf(stderr, "%s: warning: fid larger than expected "
+                                "(%d bytes), recompile?\n", argv[i], size);
+
+                printf("%s: objid=%llu seq=%llu parent="DFID"\n",
+                       argv[i], le64_to_cpu(ff->ff_objid),
+                       le64_to_cpu(ff->ff_seq),
+                       le64_to_cpu(ff->ff_parent.f_seq),
+                       le32_to_cpu(ff->ff_parent.f_oid),
+                       le32_to_cpu(ff->ff_parent.f_ver));
+       }
+
+       return rc;
+}