From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: xfs@oss.sgi.com, hch@lst.de, aelder@sgi.com, tytso@mit.edu,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 08/12] xfstests: add fiemap operation to fsstress
Date: Thu, 3 Nov 2011 18:24:57 +0400 [thread overview]
Message-ID: <1320330301-2682-9-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1320330301-2682-1-git-send-email-dmonakhov@openvz.org>
Related bug: http://patchwork.ozlabs.org/patch/118863
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
ltp/fsstress.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 997f068..cddfe74 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -24,6 +24,9 @@
#ifdef HAVE_ATTR_ATTRIBUTES_H
#include <attr/attributes.h>
#endif
+#ifdef HAVE_LINUX_FIEMAP_H
+#include <linux/fiemap.h>
+#endif
#ifdef FALLOCATE
#include <linux/falloc.h>
#ifndef FALLOC_FL_PUNCH_HOLE
@@ -65,6 +68,7 @@ typedef enum {
OP_DWRITE,
OP_FALLOCATE,
OP_FDATASYNC,
+ OP_FIEMAP,
OP_FREESP,
OP_FSYNC,
OP_GETATTR,
@@ -149,6 +153,7 @@ void dread_f(int, long);
void dwrite_f(int, long);
void fallocate_f(int, long);
void fdatasync_f(int, long);
+void fiemap_f(int, long);
void freesp_f(int, long);
void fsync_f(int, long);
void getattr_f(int, long);
@@ -184,6 +189,7 @@ opdesc_t ops[] = {
{ OP_DWRITE, "dwrite", dwrite_f, 4, 1 },
{ OP_FALLOCATE, "fallocate", fallocate_f, 1, 1 },
{ OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1 },
+ { OP_FIEMAP, "fiemap", fiemap_f, 1, 1 },
{ OP_FREESP, "freesp", freesp_f, 1, 1 },
{ OP_FSYNC, "fsync", fsync_f, 1, 1 },
{ OP_GETATTR, "getattr", getattr_f, 1, 0 },
@@ -2131,6 +2137,76 @@ fdatasync_f(int opno, long r)
free_pathname(&f);
close(fd);
}
+void
+fiemap_f(int opno, long r)
+{
+#ifdef HAVE_LINUX_FIEMAP_H
+ int e;
+ pathname_t f;
+ int fd;
+ __int64_t lr;
+ off64_t off;
+ struct stat64 stb;
+ int v;
+ char st[1024];
+ int blocks_to_map;
+ struct fiemap *fiemap;
+
+ init_pathname(&f);
+ if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
+ if (v)
+ printf("%d/%d: fiemap - no filename\n", procid, opno);
+ free_pathname(&f);
+ return;
+ }
+ fd = open_path(&f, O_RDWR);
+ e = fd < 0 ? errno : 0;
+ check_cwd();
+ if (fd < 0) {
+ if (v)
+ printf("%d/%d: fiemap - open %s failed %d\n",
+ procid, opno, f.path, e);
+ free_pathname(&f);
+ return;
+ }
+ if (fstat64(fd, &stb) < 0) {
+ if (v)
+ printf("%d/%d: fiemap - fstat64 %s failed %d\n",
+ procid, opno, f.path, errno);
+ free_pathname(&f);
+ close(fd);
+ return;
+ }
+ inode_info(st, sizeof(st), &stb, v);
+ blocks_to_map = random() & 0xffff;
+ fiemap = (struct fiemap *)malloc(sizeof(struct fiemap) +
+ (blocks_to_map * sizeof(struct fiemap_extent)));
+ if (!fiemap) {
+ if (v)
+ printf("%d/%d: malloc failed \n", procid, opno);
+ free_pathname(&f);
+ close(fd);
+ return;
+ }
+ lr = ((__int64_t)random() << 32) + random();
+ off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
+ off %= maxfsize;
+ fiemap->fm_flags = random() & (FIEMAP_FLAGS_COMPAT | 0x10000);
+ fiemap->fm_extent_count = blocks_to_map;
+ fiemap->fm_mapped_extents = random() & 0xffff;
+ fiemap->fm_start = off;
+ fiemap->fm_length = ((__int64_t)random() << 32) + random();
+
+ e = ioctl(fd, FS_IOC_FIEMAP, (unsigned long)fiemap);
+ if (v)
+ printf("%d/%d: ioctl(FIEMAP) %s%s %lld %lld %x %d\n",
+ procid, opno, f.path, st, (long long)fiemap->fm_start,
+ (long long) fiemap->fm_length, fiemap->fm_flags, e);
+ free(fiemap);
+ free_pathname(&f);
+ close(fd);
+#endif
+}
void
freesp_f(int opno, long r)
--
1.7.1
next prev parent reply other threads:[~2011-11-03 14:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-03 14:24 [PATCH 00/12] Bunch of new stress tests -v4 Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 01/12] xfstests: fsstress dump inode info when possible Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 02/12] xfstests: add different logging option to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 03/12] xfstests: fsstress should kill children tasks before exit Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 04/12] xfstests: fsstress add command line style output for show_opts Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 05/12] xfstests: freeze fsstress options for 117'th Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 06/12] xfstests: add fallocate support to fsstress Dmitry Monakhov
2011-11-03 14:24 ` [PATCH 07/12] xfstests: fsstress add FS_IOC_{SET,GET}FLAGS operations v2 Dmitry Monakhov
2011-11-03 14:24 ` Dmitry Monakhov [this message]
2011-11-03 14:24 ` [PATCH 09/12] xfstests: add a new test that runs fsstress under ENOSPC conditions Dmitry Monakhov
2011-11-07 21:22 ` Dave Chinner
2011-11-08 8:32 ` Dmitry Monakhov
2011-11-07 21:25 ` Dave Chinner
2011-11-03 14:24 ` [PATCH 10/12] xfstests: add a new quota " Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 11/12] xfstress: add regression testcase for d583fb87a3ff0 Dmitry Monakhov
2011-11-03 14:25 ` [PATCH 12/12] xfstress: Test data journaling flag switch for a single file Dmitry Monakhov
2011-11-03 14:55 ` [PATCH 00/12] Bunch of new stress tests -v4 Christoph Hellwig
2011-11-03 15:21 ` Dmitry Monakhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1320330301-2682-9-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=aelder@sgi.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).