From: Lukas Czerner <lczerner@redhat.com>
To: xfs@oss.sgi.com
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Lukas Czerner <lczerner@redhat.com>
Subject: [PATCH 2/2] fsstress: Add fallocate collapse range operation
Date: Wed, 2 Apr 2014 17:33:20 +0200 [thread overview]
Message-ID: <1396452800-25775-2-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1396452800-25775-1-git-send-email-lczerner@redhat.com>
This commit adds collapse operation support for fsstress, which is
meant to exercise fallocate FALLOC_FL_COLLAPSE_RANGE support.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
ltp/fsstress.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index fd258bf..1eec11a 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -71,6 +71,7 @@ typedef enum {
OP_MKNOD,
OP_PUNCH,
OP_ZERO,
+ OP_COLLAPSE,
OP_READ,
OP_READLINK,
OP_RENAME,
@@ -168,6 +169,7 @@ void mkdir_f(int, long);
void mknod_f(int, long);
void punch_f(int, long);
void zero_f(int, long);
+void collapse_f(int, long);
void read_f(int, long);
void readlink_f(int, long);
void rename_f(int, long);
@@ -206,6 +208,7 @@ opdesc_t ops[] = {
{ OP_MKNOD, "mknod", mknod_f, 2, 1 },
{ OP_PUNCH, "punch", punch_f, 1, 1 },
{ OP_ZERO, "zero", zero_f, 1, 1 },
+ { OP_COLLAPSE, "collapse", collapse_f, 1, 1 },
{ OP_READ, "read", read_f, 1, 0 },
{ OP_READLINK, "readlink", readlink_f, 1, 0 },
{ OP_RENAME, "rename", rename_f, 2, 1 },
@@ -2173,6 +2176,7 @@ struct print_flags falloc_flags [] = {
{ FALLOC_FL_NO_HIDE_STALE, "NO_HIDE_STALE"},
{ FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"},
{ FALLOC_FL_ZERO_RANGE, "ZERO_RANGE"},
+ { FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"},
{ -1, NULL}
};
@@ -2223,6 +2227,14 @@ do_fallocate(int opno, long r, int mode)
off = (off64_t)(lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
off %= maxfsize;
len = (off64_t)(random() % (1024 * 1024));
+ /*
+ * Collapse range requires off and len to be block aligned, make it
+ * more likely to be the case.
+ */
+ if (FALLOC_FL_COLLAPSE_RANGE && (opno % 2)) {
+ off = ((off + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
+ len = ((len + stb.st_blksize - 1) & ~(stb.st_blksize - 1));
+ }
mode |= FALLOC_FL_KEEP_SIZE & random();
e = fallocate(fd, mode, (loff_t)off, (loff_t)len) < 0 ? errno : 0;
if (v)
@@ -2637,6 +2649,14 @@ zero_f(int opno, long r)
}
void
+collapse_f(int opno, long r)
+{
+#ifdef HAVE_LINUX_FALLOC_H
+ do_fallocate(opno, r, FALLOC_FL_COLLAPSE_RANGE);
+#endif
+}
+
+void
read_f(int opno, long r)
{
char *buf;
--
1.8.3.1
next prev parent reply other threads:[~2014-04-02 15:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-02 15:33 [PATCH 1/2] fsx: Add fallocate collapse range operation Lukas Czerner
2014-04-02 15:33 ` Lukas Czerner [this message]
2014-04-02 15:55 ` Lukáš Czerner
2014-04-03 21:26 ` Dave Chinner
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=1396452800-25775-2-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--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).