linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	xfs@oss.sgi.com, david@fromorbit.com,
	Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 05/11] xfstets: fsstress add replace file operation
Date: Tue, 19 Feb 2013 15:37:17 +0400	[thread overview]
Message-ID: <1361273843-16094-5-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1361273843-16094-1-git-send-email-dmonakhov@openvz.org>

The most common usecase for rename(2) syscall is an atomic replacement
of existing file with newer version. But rename_f() rename some existing
filename to newly generated (non existing) filename. As result the most
important usecase is not covered.
Since rename_f() is already exist in fsstress and it has known behavior,
some tests already depends on that behaviour, let's add another operation
(replace_f) which invoke rename(2) for two existing entries.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 ltp/fsstress.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index b4cfb25..85ff72a 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -80,6 +80,7 @@ typedef enum {
 	OP_READ,
 	OP_READLINK,
 	OP_RENAME,
+	OP_REPLACE,
 	OP_RESVSP,
 	OP_RMDIR,
 	OP_SETATTR,
@@ -165,6 +166,7 @@ void	punch_f(int, long);
 void	read_f(int, long);
 void	readlink_f(int, long);
 void	rename_f(int, long);
+void	replace_f(int, long);
 void	resvsp_f(int, long);
 void	rmdir_f(int, long);
 void	setattr_f(int, long);
@@ -202,6 +204,7 @@ opdesc_t	ops[] = {
 	{ OP_READ, "read", read_f, 1, 0 },
 	{ OP_READLINK, "readlink", readlink_f, 1, 0 },
 	{ OP_RENAME, "rename", rename_f, 2, 1 },
+	{ OP_REPLACE, "replace", replace_f, 2, 1 },
 	{ OP_RESVSP, "resvsp", resvsp_f, 1, 1 },
 	{ OP_RMDIR, "rmdir", rmdir_f, 1, 1 },
 	{ OP_SETATTR, "setattr", setattr_f, 0, 1 },
@@ -2680,6 +2683,50 @@ rename_f(int opno, long r)
 }
 
 void
+replace_f(int opno, long r)
+{
+	int		e;
+	pathname_t	src_f, dst_f;
+	fent_t		*src_fep, *dst_fep;
+	flist_t		*src_flp, *dst_flp;
+	int		v;
+	int		v1;
+
+	/* get an existing path for the source of the rename */
+	init_pathname(&src_f);
+	if (!get_fname(FT_ANYm, r, &src_f, &src_flp, &src_fep, &v)) {
+		if (v)
+			printf("%d/%d: replace - no filename\n", procid, opno);
+		free_pathname(&src_f);
+		return;
+	}
+	/* get an existing path for the destination of the rename */
+	init_pathname(&dst_f);
+	if (!get_fname(1 << (src_flp - flist), rand(), &dst_f, &dst_flp, &dst_fep, &v1)) {
+		if (v1)
+			printf("%d/%d: replace - no filename\n", procid, opno);
+		free_pathname(&dst_f);
+		return;
+	}
+	
+	v |= v1;
+	e = rename_path(&src_f, &dst_f) < 0 ? errno : 0;
+	check_cwd();
+	if (e == 0 && src_fep->id != dst_fep->id ) {
+		del_from_flist(src_flp - flist, src_fep - src_flp->fents);
+	}
+	if (v) {
+		printf("%d/%d: replace %s with %s %d\n", procid, opno, dst_f.path,
+			src_f.path, e);
+		if (e == 0 && src_fep->id != dst_fep->id)
+			printf("%d/%d: replace del entry: id=%d,parent=%d\n",
+				procid, opno, src_fep->id, src_fep->parent);
+	}
+	free_pathname(&src_f);
+	free_pathname(&dst_f);
+}
+
+void
 resvsp_f(int opno, long r)
 {
 	int		e;
-- 
1.7.1


  parent reply	other threads:[~2013-02-19 11:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19 11:37 [PATCH 01/11] xfstests: add fio requirement V2 Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 02/11] xfstests: get rid of hardcoded /sbin/mkfs Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 03/11] xfstest: add configurable load factors Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 04/11] xfstests: hardcode fops for determinable fsstests runs Dmitry Monakhov
2013-02-19 11:37 ` Dmitry Monakhov [this message]
2013-02-19 11:37 ` [PATCH 06/11] xfstest: allow fsstress to use load factor where appropriate Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 07/11] xfstest: move run_check to common.rc Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 08/11] xfstest: add fallocate/truncate vs AIO/DIO stress test Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 09/11] xfstest: add fallocate/punch_hole " Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 10/11] xfstest: add defragmentation stress tests for ext4 Dmitry Monakhov
2013-02-19 11:37 ` [PATCH 11/11] xfstests: add disk failure simulation test Dmitry Monakhov
2013-02-20  1:19 ` [PATCH 01/11] xfstests: add fio requirement V2 Dave Chinner
2013-02-20  8:14   ` 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=1361273843-16094-5-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=david@fromorbit.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).