xfs
[Top] [All Lists]

[PATCH 5/8] xfstests: Dump inode info when possible

To: linux-fsdevel@xxxxxxxxxxxxxxx, xfs@xxxxxxxxxxx, linux-ext4@xxxxxxxxxxxxxxx, jack@xxxxxxx, hch@xxxxxxxxxxxxx, aelder@xxxxxxx
Subject: [PATCH 5/8] xfstests: Dump inode info when possible
From: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
Date: Wed, 19 Oct 2011 14:29:46 +0400
Cc: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=BOZ5BJdh12MnCo9JzGHG3b4zoKgt5eyu7mclFEmeJu0=; b=E/wkzUDbzoiiKs8/4jKvfvAHfK/xLnyGK3Va7Fin41KItb0MrZH08FuTpa/x63i7rc mQYzBsv3T4Lfmb3kO/C8K5YsRIWWZ73XNdZdJ6wbKZdpELQpDpWyzHlvvfoU/ZjHK8Ya cxOLr8sy+b6AQptwh0MR5nrEGyF0JEnGKnzoA=
In-reply-to: <1319020189-13584-1-git-send-email-dmonakhov@xxxxxxxxxx>
References: <1319020189-13584-1-git-send-email-dmonakhov@xxxxxxxxxx>
Sender: Dmitry Monakhov <dmonlist@xxxxxxxxx>
Fsstress exec behaviour is not completely determinated in case of
low resources mode due to ENOMEM, ENOSPC, etc. In some places we
call stat(2). This information may be halpfull for future
investigations purposes. Let's dump stat info where possible.

Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
 ltp/fsstress.c |   92 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 62 insertions(+), 30 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 756bdd6..baccbbd 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -1482,6 +1482,14 @@ zero_freq(void)
                p->freq = 0;
 }
 
+void inode_info(char *str, size_t sz, struct stat64 *s, int verbose)
+{
+       if (verbose)
+               snprintf(str, sz, "[%ld %ld %d %d %lld %lld]", (long)s->st_ino,
+                        (long)s->st_nlink,  s->st_uid, s->st_gid,
+                        (long long) s->st_blocks, (long long) s->st_size);
+}
+
 void
 allocsp_f(int opno, long r)
 {
@@ -1493,6 +1501,7 @@ allocsp_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1519,6 +1528,8 @@ allocsp_f(int opno, long r)
                close(fd);
                return;
        }
+
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -1526,9 +1537,10 @@ allocsp_f(int opno, long r)
        fl.l_start = off;
        fl.l_len = 0;
        e = xfsctl(f.path, fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
-       if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n",
-                       procid, opno, f.path, (long long)off, e);
+       if (v) {
+               printf("%d/%d: xfsctl(XFS_IOC_ALLOCSP64) %s%s %lld 0 %d\n",
+                      procid, opno, f.path, st, (long long)off, e);
+       }
        free_pathname(&f);
        close(fd);
 }
@@ -1918,6 +1930,7 @@ dread_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -1939,15 +1952,17 @@ dread_f(int opno, long r)
        if (fstat64(fd, &stb) < 0) {
                if (v)
                        printf("%d/%d: dread - fstat64 %s failed %d\n",
-                               procid, opno, f.path, errno);
+                              procid, opno, f.path, errno);
                free_pathname(&f);
                close(fd);
                return;
        }
+
+       inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: dread - %s zero size\n", procid, opno,
-                               f.path);
+                       printf("%d/%d: dread - %s%s zero size\n", procid, opno,
+                              f.path, st);
                free_pathname(&f);
                close(fd);
                return;
@@ -1955,8 +1970,8 @@ dread_f(int opno, long r)
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf(
-                       "%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s failed %d\n",
-                               procid, opno, f.path, errno);
+                       "%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s failed 
%d\n",
+                               procid, opno, f.path, st, errno);
                free_pathname(&f);
                close(fd);
                return;
@@ -1976,8 +1991,8 @@ dread_f(int opno, long r)
        e = read(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: dread %s [%lld,%d] %d\n",
-                       procid, opno, f.path, (long long)off, (int)len, e);
+               printf("%d/%d: dread %s%s [%lld,%d] %d\n",
+                      procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
@@ -1996,6 +2011,7 @@ dwrite_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2022,11 +2038,12 @@ dwrite_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
                if (v)
                        printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
-                               " %s failed %d\n",
-                               procid, opno, f.path, errno);
+                               " %s%s failed %d\n",
+                              procid, opno, f.path, st, errno);
                free_pathname(&f);
                close(fd);
                return;
@@ -2049,8 +2066,8 @@ dwrite_f(int opno, long r)
        e = write(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: dwrite %s [%lld,%d] %d\n",
-                       procid, opno, f.path, (long long)off, (int)len, e);
+               printf("%d/%d: dwrite %s%s [%lld,%d] %d\n",
+                      procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
@@ -2067,6 +2084,7 @@ fallocate_f(int opno, long r)
        off64_t         len;
        struct stat64   stb;
        int             v;
+       char            st[1024];
        int mode = 0;
 
        init_pathname(&f);
@@ -2094,6 +2112,8 @@ fallocate_f(int opno, long r)
                close(fd);
                return;
        }
+
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2101,9 +2121,9 @@ fallocate_f(int opno, long r)
        mode |= FALLOC_FL_KEEP_SIZE & random();
        e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: fallocate(%d) %s %lld %lld %d\n",
+               printf("%d/%d: fallocate(%d) %s %st %lld %lld %d\n",
                       procid, opno, mode,
-                      f.path, (long long)off, (long long)len, e);
+                      f.path, st, (long long)off, (long long)len, e);
        free_pathname(&f);
        close(fd);
 #endif
@@ -2154,6 +2174,7 @@ freesp_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2180,6 +2201,7 @@ freesp_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2188,8 +2210,8 @@ freesp_f(int opno, long r)
        fl.l_len = 0;
        e = xfsctl(f.path, fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_FREESP64) %s %lld 0 %d\n",
-                       procid, opno, f.path, (long long)off, e);
+               printf("%d/%d: xfsctl(XFS_IOC_FREESP64) %s%s %lld 0 %d\n",
+                      procid, opno, f.path, st, (long long)off, e);
        free_pathname(&f);
        close(fd);
 }
@@ -2392,6 +2414,7 @@ punch_f(int opno, long r)
        off64_t         len;
        struct stat64   stb;
        int             v;
+       char            st[1024];
        int mode = FALLOC_FL_PUNCH_HOLE;
 
        init_pathname(&f);
@@ -2419,6 +2442,7 @@ punch_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2426,9 +2450,9 @@ punch_f(int opno, long r)
        mode |= FALLOC_FL_KEEP_SIZE & random();
        e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: punch hole(%d) %s %lld %lld %d\n",
+               printf("%d/%d: punch hole(%d) %s %s %lld %lld %d\n",
                       procid, opno, mode,
-                      f.path, (long long)off, (long long)len, e);
+                      f.path, st, (long long)off, (long long)len, e);
        free_pathname(&f);
        close(fd);
 #endif
@@ -2446,6 +2470,7 @@ read_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2472,10 +2497,11 @@ read_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        if (stb.st_size == 0) {
                if (v)
-                       printf("%d/%d: read - %s zero size\n", procid, opno,
-                               f.path);
+                       printf("%d/%d: read - %s%s zero size\n", procid, opno,
+                              f.path, st);
                free_pathname(&f);
                close(fd);
                return;
@@ -2488,8 +2514,8 @@ read_f(int opno, long r)
        e = read(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: read %s [%lld,%d] %d\n",
-                       procid, opno, f.path, (long long)off, (int)len, e);
+               printf("%d/%d: read %s%s [%lld,%d] %d\n",
+                      procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
@@ -2596,6 +2622,7 @@ resvsp_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2622,6 +2649,7 @@ resvsp_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2630,8 +2658,8 @@ resvsp_f(int opno, long r)
        fl.l_len = (off64_t)(random() % (1024 * 1024));
        e = xfsctl(f.path, fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n",
-                       procid, opno, f.path,
+               printf("%d/%d: xfsctl(XFS_IOC_RESVSP64) %s%s %lld %lld %d\n",
+                      procid, opno, f.path, st,
                        (long long)off, (long long)fl.l_len, e);
        free_pathname(&f);
        close(fd);
@@ -2822,6 +2850,7 @@ unresvsp_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
@@ -2848,6 +2877,7 @@ unresvsp_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2856,8 +2886,8 @@ unresvsp_f(int opno, long r)
        fl.l_len = (off64_t)(random() % (1 << 20));
        e = xfsctl(f.path, fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
        if (v)
-               printf("%d/%d: xfsctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n",
-                       procid, opno, f.path,
+               printf("%d/%d: xfsctl(XFS_IOC_UNRESVSP64) %s%s %lld %lld %d\n",
+                      procid, opno, f.path, st,
                        (long long)off, (long long)fl.l_len, e);
        free_pathname(&f);
        close(fd);
@@ -2875,6 +2905,7 @@ write_f(int opno, long r)
        off64_t         off;
        struct stat64   stb;
        int             v;
+       char            st[1024];
 
        init_pathname(&f);
        if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
@@ -2901,6 +2932,7 @@ write_f(int opno, long r)
                close(fd);
                return;
        }
+       inode_info(st, sizeof(st), &stb, v);
        lr = ((__int64_t)random() << 32) + random();
        off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
        off %= maxfsize;
@@ -2911,8 +2943,8 @@ write_f(int opno, long r)
        e = write(fd, buf, len) < 0 ? errno : 0;
        free(buf);
        if (v)
-               printf("%d/%d: write %s [%lld,%d] %d\n",
-                       procid, opno, f.path, (long long)off, (int)len, e);
+               printf("%d/%d: write %s%s [%lld,%d] %d\n",
+                      procid, opno, f.path, st, (long long)off, (int)len, e);
        free_pathname(&f);
        close(fd);
 }
-- 
1.7.1

<Prev in Thread] Current Thread [Next in Thread>