fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH] src/fssum: skip subvolumes when building a sum
Date: Tue, 17 Dec 2019 10:25:05 -0500	[thread overview]
Message-ID: <20191217152505.44650-1-josef@toxicpanda.com> (raw)

With the snapshot/subvolume support added to fsstress I've been seeing
random failures with our send/receive related tests.  This is because
fssum is summing the path with the subvolumes for our test fs'es that
are generated by fsstress.  But with send/receive it skips subvolumes,
which makes the sums mismatch.  Fix this by skipping directories that do
not match our st_dev, which is how we differentiate subvolumes in btrfs.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 src/fssum.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/fssum.c b/src/fssum.c
index 6ba0a95c..a243839a 100644
--- a/src/fssum.c
+++ b/src/fssum.c
@@ -517,6 +517,12 @@ sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
 	int excl;
 	sum_file_data_t sum_file_data = flags[FLAG_STRUCTURE] ?
 			sum_file_data_strict : sum_file_data_permissive;
+	struct stat64 dir_st;
+
+	if (fstat64(dirfd, &dir_st)) {
+		perror("fstat");
+		exit(-1);
+	}
 
 	d = fdopendir(dirfd);
 	if (!d) {
@@ -570,6 +576,11 @@ sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
 				path_prefix, path, strerror(errno));
 			exit(-1);
 		}
+
+		/* We are crossing into a different subvol, skip this subtree. */
+		if (st.st_dev != dir_st.st_dev)
+			goto next;
+
 		sum_add_u64(&meta, level);
 		sum_add(&meta, namelist[i], strlen(namelist[i]));
 		if (!S_ISDIR(st.st_mode))
-- 
2.23.0


             reply	other threads:[~2019-12-17 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-17 15:25 Josef Bacik [this message]
2019-12-17 16:19 ` [PATCH] src/fssum: skip subvolumes when building a sum Filipe Manana

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=20191217152505.44650-1-josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=fstests@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).