* [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs
@ 2017-11-16 7:48 Xiao Yang
2017-11-22 14:58 ` Cyril Hrubis
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Yang @ 2017-11-16 7:48 UTC (permalink / raw)
To: ltp
We always got the following error when using mkfs.btrfs(v0.20-rc1)
on RHEL6.9GA.
---------------------------------------------------------------------------
...
tst_mkfs.c:83: INFO: Formatting /dev/loop0 with btrfs opts='' extra opts=''
error checking /dev/loop0 mount status
tst_mkfs.c:94: BROK: mkfs.btrfs:1: tst_test.c failed with 693
---------------------------------------------------------------------------
After just calling LOOP_SET_FD to set up loopdev, newer mkfs.btrfs can
get associated filename by backing_file successfully. However older
one cannot get associated filename by LOOP_GET_STATUS which is replaced
by backing_file since btrfs-progs v3.12. So we call LOOP_SET_FD and
LOOP_SET_STATUS to set up loopdev when using all kinds of mkfs.btrfs.
The backing_file was produced in kernel(since v2.6.37):
'ee86273062cb("loop: add some basic read-only sysfs attributes")'
The backing_file began to be used by mkfs.btrfs on btrfs_progs(v3.12):
'abdb0ced0123("Btrfs-progs: fix resolving of loop devices")'
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
lib/tst_device.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 6ad6c47..4a72925 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -134,6 +134,7 @@ static int find_free_loopdev(void)
static int attach_device(const char *dev, const char *file)
{
int dev_fd, file_fd;
+ struct loop_info loopinfo;
dev_fd = open(dev, O_RDWR);
if (dev_fd < 0) {
@@ -156,6 +157,21 @@ static int attach_device(const char *dev, const char *file)
return 1;
}
+ /* Old mkfs.btrfs use LOOP_GET_STATUS instead of backing_file to get
+ * associated filename, so we need to set up the device by calling
+ * LOOP_SET_FD and LOOP_SET_STATUS.
+ */
+ memset(&loopinfo, 0, sizeof(loopinfo));
+ strcpy((char *)loopinfo.lo_name, file);
+
+ if (ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo)) {
+ close(dev_fd);
+ close(file_fd);
+ tst_resm(TWARN | TERRNO,
+ "ioctl(%s, LOOP_SET_STATUS, %s) failed", dev, file);
+ return 1;
+ }
+
close(dev_fd);
close(file_fd);
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs
2017-11-16 7:48 [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs Xiao Yang
@ 2017-11-22 14:58 ` Cyril Hrubis
2017-11-23 1:36 ` [LTP] [PATCH v2] lib/tst_device.c: " Xiao Yang
0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2017-11-22 14:58 UTC (permalink / raw)
To: ltp
Hi!
> static int attach_device(const char *dev, const char *file)
> {
> int dev_fd, file_fd;
> + struct loop_info loopinfo;
>
> dev_fd = open(dev, O_RDWR);
> if (dev_fd < 0) {
> @@ -156,6 +157,21 @@ static int attach_device(const char *dev, const char *file)
> return 1;
> }
>
> + /* Old mkfs.btrfs use LOOP_GET_STATUS instead of backing_file to get
> + * associated filename, so we need to set up the device by calling
> + * LOOP_SET_FD and LOOP_SET_STATUS.
> + */
> + memset(&loopinfo, 0, sizeof(loopinfo));
> + strcpy((char *)loopinfo.lo_name, file);
^
Why the cast here, as far as I can tell the lo_name is
just array of chars which should be char * pointer
compatible.
> + if (ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo)) {
> + close(dev_fd);
> + close(file_fd);
> + tst_resm(TWARN | TERRNO,
> + "ioctl(%s, LOOP_SET_STATUS, %s) failed", dev, file);
> + return 1;
> + }
> +
> close(dev_fd);
> close(file_fd);
> return 0;
Otherwise it looks good.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2] lib/tst_device.c: Fix failure when using old mkfs.btrfs
2017-11-22 14:58 ` Cyril Hrubis
@ 2017-11-23 1:36 ` Xiao Yang
2017-11-23 11:50 ` Cyril Hrubis
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Yang @ 2017-11-23 1:36 UTC (permalink / raw)
To: ltp
We always got the following error when using mkfs.btrfs(v0.20-rc1)
on RHEL6.9GA. For example:
---------------------------------------------------------------------------
./fallocate04
...
tst_mkfs.c:83: INFO: Formatting /dev/loop0 with btrfs opts='' extra opts=''
error checking /dev/loop0 mount status
tst_mkfs.c:94: BROK: mkfs.btrfs:1: tst_test.c failed with 693
---------------------------------------------------------------------------
After just calling LOOP_SET_FD to set up loopdev, newer mkfs.btrfs can
get associated filename by backing_file successfully. However older
one cannot get associated filename by LOOP_GET_STATUS which is replaced
by backing_file since btrfs-progs v3.12. So we call LOOP_SET_FD and
LOOP_SET_STATUS to set up loopdev when using all kinds of mkfs.btrfs.
The backing_file was produced in kernel(since v2.6.37):
'ee86273062cb("loop: add some basic read-only sysfs attributes")'
The backing_file began to be used by mkfs.btrfs on btrfs_progs(v3.12):
'abdb0ced0123("Btrfs-progs: fix resolving of loop devices")'
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
lib/tst_device.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 6ad6c47..4b73f0b 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -134,6 +134,7 @@ static int find_free_loopdev(void)
static int attach_device(const char *dev, const char *file)
{
int dev_fd, file_fd;
+ struct loop_info loopinfo;
dev_fd = open(dev, O_RDWR);
if (dev_fd < 0) {
@@ -156,6 +157,21 @@ static int attach_device(const char *dev, const char *file)
return 1;
}
+ /* Old mkfs.btrfs use LOOP_GET_STATUS instead of backing_file to get
+ * associated filename, so we need to set up the device by calling
+ * LOOP_SET_FD and LOOP_SET_STATUS.
+ */
+ memset(&loopinfo, 0, sizeof(loopinfo));
+ strcpy(loopinfo.lo_name, file);
+
+ if (ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo)) {
+ close(dev_fd);
+ close(file_fd);
+ tst_resm(TWARN | TERRNO,
+ "ioctl(%s, LOOP_SET_STATUS, %s) failed", dev, file);
+ return 1;
+ }
+
close(dev_fd);
close(file_fd);
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH v2] lib/tst_device.c: Fix failure when using old mkfs.btrfs
2017-11-23 1:36 ` [LTP] [PATCH v2] lib/tst_device.c: " Xiao Yang
@ 2017-11-23 11:50 ` Cyril Hrubis
0 siblings, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2017-11-23 11:50 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-23 11:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-16 7:48 [LTP] [PATCH] syscalls/fallocate[4, 5]: Fix failure when using old mkfs.btrfs Xiao Yang
2017-11-22 14:58 ` Cyril Hrubis
2017-11-23 1:36 ` [LTP] [PATCH v2] lib/tst_device.c: " Xiao Yang
2017-11-23 11:50 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox