Skip to contentSkip to conversation

xfsteststs: get fsstress DIO working on non-xfs filesystems

PATCH In review Eric Sandeen 3 participants 5 messages Jan 18, 2010 – Oct 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfsteststs: get fsstress DIO working on non-xfs filesystems

Pretty sure all DIO IO fails in fsstress today since XFS_IOC_DIOINFO fails. If so, rather than just bailing out on the op, assign some sane default DIO parameters.

This falls down for 4k sector devices but not really sure how to get the underlying sector size easily from here; I think we can live with this for now.

hch suggested moving XFS_IOC_DIOINFO up higher in the vfs, that's probably a good idea in the long run.

---

ltp/fsstress.c +6 -6
index 6978381..dab6bf7 100644
@@ -1818,9 +1818,9 @@ dread_f(int opno, long r)
 			printf(
 			"%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s failed %d\n",
 				procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
+		diob.d_maxiosz = -1U;
+		diob.d_miniosz = 512;
+		diob.d_mem = 512;
 	}
 	align = (__int64_t)diob.d_miniosz;
 	lr = ((__int64_t)random() << 32) + random();
@@ -1888,9 +1888,9 @@ dwrite_f(int opno, long r)
 			printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
 				" %s failed %d\n",
 				procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
+		diob.d_maxiosz = -1U;
+		diob.d_miniosz = 512;
+		diob.d_mem = 512;
 	}
 	align = (__int64_t)diob.d_miniosz;
 	lr = ((__int64_t)random() << 32) + random();

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw
Quoted 7 lines · Eric Sandeen

Pretty sure all DIO IO fails in fsstress today since XFS_IOC_DIOINFO fails. If so, rather than just bailing out on the op, assign some sane default DIO parameters.

This falls down for 4k sector devices but not really sure how to get the underlying sector size easily from here; I think we can live with this for now.

ioctl(fd, BLKSSZGET, ...) perhaps? And then if that fails, just hard code it?

Quoted 2 lines

hch suggested moving XFS_IOC_DIOINFO up higher in the vfs, that's probably a good idea in the long run.

Yeah, that makes sense to do.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
In reply to Eric Sandeen
Quoted 32 lines · Eric Sandeen

Pretty sure all DIO IO fails in fsstress today since XFS_IOC_DIOINFO fails. If so, rather than just bailing out on the op, assign some sane default DIO parameters.

This falls down for 4k sector devices but not really sure how to get the underlying sector size easily from here; I think we can live with this for now.

hch suggested moving XFS_IOC_DIOINFO up higher in the vfs, that's probably a good idea in the long run.

---

ltp/fsstress.c +3 -3
index 6978381..dab6bf7 100644
@@ -1818,9 +1818,9 @@ dread_f(int opno, long r)
 			printf(
 			"%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s failed %d\n",
 				procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
+		diob.d_maxiosz = -1U;
+		diob.d_miniosz = 512;
+		diob.d_mem = 512;
 	}
 	align = (__int64_t)diob.d_miniosz;
 	lr = ((__int64_t)random() << 32) + random();

ltp/fsstress.c dwrite_f(int opno, long r) · line 1893

Quoted 9 lines
ltp/fsstress.c +3 -3
@@ -1888,9 +1888,9 @@ dwrite_f(int opno, long r)
 			printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
 				" %s failed %d\n",
 				procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
+		diob.d_maxiosz = -1U;
+		diob.d_miniosz = 512;
+		diob.d_mem = 512;

Can you factor out the alignment bits into a small helper and use it in both places?

static void get_alignment(pathname_t *f, int fd, struct dioattr *dio)

{
	if (xfsctl(f->path, fd, XFS_IOC_DIOINFO, dio) < 0) {
		if (v)
			printf(...);

		/* use fallback values if the query fails. */
		diob.d_maxiosz = -1U;
		diob.d_miniosz = 512;
		diob.d_mem = 512;
}

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH v2 1/1 xfstests: get fsstress DIO working on non-xfs filesystems

In reply to Eric Sandeen

Pretty sure all DIO IO fails in fsstress today since XFS_IOC_DIOINFO fails. If so, rather than just bailing out on the op, assign some sane default DIO parameters, getting min IO size from sector size if possible.

---

V2: factor out get_alignment, use BLKSSZGET for min DIO size rather than guessing at 512.

ltp/fsstress.c +25 -4
index 5d5611f..af06059 100644
@@ -550,6 +550,27 @@ int main(int argc, char **argv)
 	return 0;
 }
 
+/*
+ * Get alignment via XFS_IOC_DIOINFO, else fall back to
+ * best guess from BLKSSZGET, else return -1.
+ */
+static int
+get_alignment(pathname_t *f, int fd, struct dioattr *dio)
+{
+	if (xfsctl(f->path, fd, XFS_IOC_DIOINFO, dio) < 0) {
+		int sectorsize;
+
+		if (ioctl(fd, BLKSSZGET, &sectorsize) < 0)
+			return -1;
+
+		dio->d_maxiosz = -1U;
+		dio->d_miniosz = sectorsize;
+		dio->d_mem = sectorsize;
+	}
+
+	return 0;
+}
+
 void
 add_to_flist(int ft, int id, int parent)
 {
@@ -1965,10 +1986,10 @@ dread_f(int opno, long r)
 		close(fd);
 		return;
 	}
-	if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
+	if (get_alignment(&f, fd, &diob) < 0) {
 		if (v)
 			printf(
-			"%d/%d: dread - xfsctl(XFS_IOC_DIOINFO) %s%s failed %d\n",
+			"%d/%d: dread - get_alignment %s%s failed %d\n",
 				procid, opno, f.path, st, errno);
 		free_pathname(&f);
 		close(fd);
@@ -2037,9 +2058,9 @@ dwrite_f(int opno, long r)
 		return;
 	}
 	inode_info(st, sizeof(st), &stb, v);
-	if (xfsctl(f.path, fd, XFS_IOC_DIOINFO, &diob) < 0) {
+	if (get_alignment(&f, fd, &diob) < 0) {
 		if (v)
-			printf("%d/%d: dwrite - xfsctl(XFS_IOC_DIOINFO)"
+			printf("%d/%d: dwrite - get_alignment"
 				" %s%s failed %d\n",
 			       procid, opno, f.path, st, errno);
 		free_pathname(&f);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw

Re: [PATCH V2] xfstests: get fsstress DIO working on non-xfs filesystems

Quoted 26 lines · Eric Sandeen

Pretty sure all DIO IO fails in fsstress today since XFS_IOC_DIOINFO fails. If so, rather than just bailing out on the op, assign some sane default DIO parameters, getting min IO size from sector size if possible.

---

V2: factor out get_alignment, use BLKSSZGET for min DIO size rather than guessing at 512.

ltp/fsstress.c +6 -0
index 5d5611f..af06059 100644
@@ -550,6 +550,27 @@ int main(int argc, char **argv)
 	return 0;
 }
 
+/*
+ * Get alignment via XFS_IOC_DIOINFO, else fall back to
+ * best guess from BLKSSZGET, else return -1.
+ */
+static int
+get_alignment(pathname_t *f, int fd, struct dioattr *dio)

ltp/fsstress.c int main(int argc, char **argv) · line 568

Quoted 10 lines
ltp/fsstress.c +10 -0
+{
+	if (xfsctl(f->path, fd, XFS_IOC_DIOINFO, dio) < 0) {
+		int sectorsize;
+
+		if (ioctl(fd, BLKSSZGET, &sectorsize) < 0)
+			return -1;
+
+		dio->d_maxiosz = -1U;
+		dio->d_miniosz = sectorsize;
+		dio->d_mem = sectorsize;

To be safe, shouldn't we align d_mem to page size given it is the alignment of the data within the user page, not the alignment of the offset of the IO?

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs