* [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA
@ 2017-04-12 3:34 Xiao Yang
2017-04-12 3:34 ` [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA Xiao Yang
2017-04-12 6:55 ` [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Cyril Hrubis
0 siblings, 2 replies; 7+ messages in thread
From: Xiao Yang @ 2017-04-12 3:34 UTC (permalink / raw)
To: ltp
Compilation failed on RHEL6.9GA because SEEK_DATA is not defined.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
include/lapi/seek.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/lapi/seek.h b/include/lapi/seek.h
index fe1999f..023f1fb 100644
--- a/include/lapi/seek.h
+++ b/include/lapi/seek.h
@@ -20,8 +20,8 @@
#include <unistd.h>
-#ifndef DATA_HOLE
-# define DATA_HOLE 4
+#ifndef SEEK_DATA
+# define SEEK_DATA 3
#endif
#ifndef SEEK_HOLE
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
2017-04-12 3:34 [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Xiao Yang
@ 2017-04-12 3:34 ` Xiao Yang
2017-04-12 11:42 ` Cyril Hrubis
2017-04-12 6:55 ` [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Cyril Hrubis
1 sibling, 1 reply; 7+ messages in thread
From: Xiao Yang @ 2017-04-12 3:34 UTC (permalink / raw)
To: ltp
1) Compilation failed on RHEL6.9GA because syncfs() was not defined.
this function was introduced since linux 2.6.39, so we could use
sync() instead of syncfs().
2) We should Add a check if SEEK_DATA was implemented in get_blocksize().
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
index fe226b5..01b9fa4 100644
--- a/testcases/kernel/syscalls/lseek/lseek11.c
+++ b/testcases/kernel/syscalls/lseek/lseek11.c
@@ -116,8 +116,15 @@ static void get_blocksize(void)
offset <<= 1;
SAFE_FTRUNCATE(fd, 0);
SAFE_PWRITE(1, fd, "a", 1, offset);
- syncfs(fd);
- pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
+ sync();
+ pos = lseek(fd, 0, SEEK_DATA);
+ if (pos == -1) {
+ if (errno == EINVAL) {
+ tst_brk(TCONF | TERRNO,
+ "SEEK_DATA not implemented");
+ }
+ tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
+ }
}
/* bisect for double check */
@@ -125,7 +132,7 @@ static void get_blocksize(void)
while (shift && offset < (st.st_blksize * 2)) {
SAFE_FTRUNCATE(fd, 0);
SAFE_PWRITE(1, fd, "a", 1, offset);
- syncfs(fd);
+ sync();
pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
offset += pos ? -shift : shift;
shift >>= 1;
@@ -178,7 +185,7 @@ static void setup(void)
if (lseek(fd, 0, SEEK_HOLE) < 0) {
if (errno == EINVAL) {
tst_brk(TCONF | TERRNO,
- "SEEK_DATA and SEEK_HOLE not implemented");
+ "SEEK_HOLE not implemented");
}
tst_brk(TBROK | TERRNO, "SEEK_HOLE failed");
}
@@ -192,7 +199,7 @@ static void setup(void)
SAFE_LSEEK(fd, -128, SEEK_END);
write_data(fd, i + 1);
- syncfs(fd);
+ sync();
SAFE_LSEEK(fd, 0, SEEK_SET);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA
2017-04-12 3:34 [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Xiao Yang
2017-04-12 3:34 ` [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA Xiao Yang
@ 2017-04-12 6:55 ` Cyril Hrubis
1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2017-04-12 6:55 UTC (permalink / raw)
To: ltp
Hi!
> Compilation failed on RHEL6.9GA because SEEK_DATA is not defined.
Thanks for fixing this, applied.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
2017-04-12 3:34 ` [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA Xiao Yang
@ 2017-04-12 11:42 ` Cyril Hrubis
2017-04-13 1:29 ` Xiao Yang
2017-04-13 2:31 ` [LTP] [PATCH v2] syscalls/lseek11.c: fix " Xiao Yang
0 siblings, 2 replies; 7+ messages in thread
From: Cyril Hrubis @ 2017-04-12 11:42 UTC (permalink / raw)
To: ltp
Hi!
> 1) Compilation failed on RHEL6.9GA because syncfs() was not defined.
> this function was introduced since linux 2.6.39, so we could use
> sync() instead of syncfs().
Looking at this again, why don't we use fsync(fd) instead?
> 2) We should Add a check if SEEK_DATA was implemented in get_blocksize().
Missed the lseek() in get_blocksize(), sorry.
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
> index fe226b5..01b9fa4 100644
> --- a/testcases/kernel/syscalls/lseek/lseek11.c
> +++ b/testcases/kernel/syscalls/lseek/lseek11.c
> @@ -116,8 +116,15 @@ static void get_blocksize(void)
> offset <<= 1;
> SAFE_FTRUNCATE(fd, 0);
> SAFE_PWRITE(1, fd, "a", 1, offset);
> - syncfs(fd);
> - pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
> + sync();
> + pos = lseek(fd, 0, SEEK_DATA);
> + if (pos == -1) {
> + if (errno == EINVAL) {
> + tst_brk(TCONF | TERRNO,
> + "SEEK_DATA not implemented");
> + }
> + tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
> + }
> }
>
> /* bisect for double check */
> @@ -125,7 +132,7 @@ static void get_blocksize(void)
> while (shift && offset < (st.st_blksize * 2)) {
> SAFE_FTRUNCATE(fd, 0);
> SAFE_PWRITE(1, fd, "a", 1, offset);
> - syncfs(fd);
> + sync();
> pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
> offset += pos ? -shift : shift;
> shift >>= 1;
> @@ -178,7 +185,7 @@ static void setup(void)
> if (lseek(fd, 0, SEEK_HOLE) < 0) {
> if (errno == EINVAL) {
> tst_brk(TCONF | TERRNO,
> - "SEEK_DATA and SEEK_HOLE not implemented");
> + "SEEK_HOLE not implemented");
> }
> tst_brk(TBROK | TERRNO, "SEEK_HOLE failed");
> }
We should get rid of this whole lseek() test in setup() since we call
tst_brk() in the get_blocksize() the lseek() will never fail here.
> @@ -192,7 +199,7 @@ static void setup(void)
> SAFE_LSEEK(fd, -128, SEEK_END);
> write_data(fd, i + 1);
>
> - syncfs(fd);
> + sync();
> SAFE_LSEEK(fd, 0, SEEK_SET);
> }
>
> --
> 1.8.3.1
>
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
2017-04-12 11:42 ` Cyril Hrubis
@ 2017-04-13 1:29 ` Xiao Yang
2017-04-13 2:31 ` [LTP] [PATCH v2] syscalls/lseek11.c: fix " Xiao Yang
1 sibling, 0 replies; 7+ messages in thread
From: Xiao Yang @ 2017-04-13 1:29 UTC (permalink / raw)
To: ltp
Hi Cyril
Thanks for your comment.
I will send v2 patch as you said.
Thanks,
Xiao Yang.
On 2017/04/12 19:42, Cyril Hrubis wrote:
> Hi!
>> 1) Compilation failed on RHEL6.9GA because syncfs() was not defined.
>> this function was introduced since linux 2.6.39, so we could use
>> sync() instead of syncfs().
> Looking at this again, why don't we use fsync(fd) instead?
>
>> 2) We should Add a check if SEEK_DATA was implemented in get_blocksize().
> Missed the lseek() in get_blocksize(), sorry.
>
>> Signed-off-by: Xiao Yang<yangx.jy@cn.fujitsu.com>
>> ---
>> testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++-----
>> 1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
>> index fe226b5..01b9fa4 100644
>> --- a/testcases/kernel/syscalls/lseek/lseek11.c
>> +++ b/testcases/kernel/syscalls/lseek/lseek11.c
>> @@ -116,8 +116,15 @@ static void get_blocksize(void)
>> offset<<= 1;
>> SAFE_FTRUNCATE(fd, 0);
>> SAFE_PWRITE(1, fd, "a", 1, offset);
>> - syncfs(fd);
>> - pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
>> + sync();
>> + pos = lseek(fd, 0, SEEK_DATA);
>> + if (pos == -1) {
>> + if (errno == EINVAL) {
>> + tst_brk(TCONF | TERRNO,
>> + "SEEK_DATA not implemented");
>> + }
>> + tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
>> + }
>> }
>>
>> /* bisect for double check */
>> @@ -125,7 +132,7 @@ static void get_blocksize(void)
>> while (shift&& offset< (st.st_blksize * 2)) {
>> SAFE_FTRUNCATE(fd, 0);
>> SAFE_PWRITE(1, fd, "a", 1, offset);
>> - syncfs(fd);
>> + sync();
>> pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
>> offset += pos ? -shift : shift;
>> shift>>= 1;
>> @@ -178,7 +185,7 @@ static void setup(void)
>> if (lseek(fd, 0, SEEK_HOLE)< 0) {
>> if (errno == EINVAL) {
>> tst_brk(TCONF | TERRNO,
>> - "SEEK_DATA and SEEK_HOLE not implemented");
>> + "SEEK_HOLE not implemented");
>> }
>> tst_brk(TBROK | TERRNO, "SEEK_HOLE failed");
>> }
> We should get rid of this whole lseek() test in setup() since we call
> tst_brk() in the get_blocksize() the lseek() will never fail here.
>
>> @@ -192,7 +199,7 @@ static void setup(void)
>> SAFE_LSEEK(fd, -128, SEEK_END);
>> write_data(fd, i + 1);
>>
>> - syncfs(fd);
>> + sync();
>> SAFE_LSEEK(fd, 0, SEEK_SET);
>> }
>>
>> --
>> 1.8.3.1
>>
>>
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH v2] syscalls/lseek11.c: fix syncfs() && SEEK_DATA
2017-04-12 11:42 ` Cyril Hrubis
2017-04-13 1:29 ` Xiao Yang
@ 2017-04-13 2:31 ` Xiao Yang
2017-04-13 10:04 ` Cyril Hrubis
1 sibling, 1 reply; 7+ messages in thread
From: Xiao Yang @ 2017-04-13 2:31 UTC (permalink / raw)
To: ltp
1) We add SAFE_FSYNC().
2) Compilation failed on RHEL6.9GA because syncfs() was not defined.
this function is introduced since linux 2.6.39, so we could use
SAFE_FSYNC() instead of syncfs().
3) We add a check if SEEK_DATA was implemented in get_blocksize(),
and remove this check in setup().
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
include/tst_safe_macros.h | 3 +++
lib/safe_macros.c | 14 ++++++++++++++
testcases/kernel/syscalls/lseek/lseek11.c | 23 ++++++++++++-----------
3 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 7683109..a25a4f0 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -427,4 +427,7 @@ int safe_removexattr(const char *file, const int lineno, const char *path,
#define SAFE_REMOVEXATTR(path, name) \
safe_removexattr(__FILE__, __LINE__, (path), (name))
+int safe_fsync(const char *file, const int lineno, int fd);
+#define SAFE_FSYNC(fd) safe_fsync(__FILE__, __LINE__, (fd))
+
#endif /* SAFE_MACROS_H__ */
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index df0df7f..bffc5a1 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -874,3 +874,17 @@ int safe_removexattr(const char *file, const int lineno, const char *path,
return rval;
}
+
+int safe_fsync(const char *file, const int lineno, int fd)
+{
+ int rval;
+
+ rval = fsync(fd);
+
+ if (rval) {
+ tst_brkm(TBROK | TERRNO, NULL,
+ "%s:%d: fsync(%i) failed", file, lineno, fd);
+ }
+
+ return rval;
+}
diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
index fe226b5..4c5bb00 100644
--- a/testcases/kernel/syscalls/lseek/lseek11.c
+++ b/testcases/kernel/syscalls/lseek/lseek11.c
@@ -116,8 +116,15 @@ static void get_blocksize(void)
offset <<= 1;
SAFE_FTRUNCATE(fd, 0);
SAFE_PWRITE(1, fd, "a", 1, offset);
- syncfs(fd);
- pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
+ SAFE_FSYNC(fd);
+ pos = lseek(fd, 0, SEEK_DATA);
+ if (pos == -1) {
+ if (errno == EINVAL) {
+ tst_brk(TCONF | TERRNO, "SEEK_DATA "
+ "and SEEK_HOLE not implemented");
+ }
+ tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
+ }
}
/* bisect for double check */
@@ -125,7 +132,7 @@ static void get_blocksize(void)
while (shift && offset < (st.st_blksize * 2)) {
SAFE_FTRUNCATE(fd, 0);
SAFE_PWRITE(1, fd, "a", 1, offset);
- syncfs(fd);
+ SAFE_FSYNC(fd);
pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
offset += pos ? -shift : shift;
shift >>= 1;
@@ -175,13 +182,7 @@ static void setup(void)
*/
SAFE_FTRUNCATE(fd, FILE_BLOCKS * block_size);
- if (lseek(fd, 0, SEEK_HOLE) < 0) {
- if (errno == EINVAL) {
- tst_brk(TCONF | TERRNO,
- "SEEK_DATA and SEEK_HOLE not implemented");
- }
- tst_brk(TBROK | TERRNO, "SEEK_HOLE failed");
- }
+ SAFE_LSEEK(fd, 0, SEEK_HOLE);
for (i = 0; i < UNIT_COUNT; i++) {
offset = UNIT_BLOCKS * block_size * i;
@@ -192,7 +193,7 @@ static void setup(void)
SAFE_LSEEK(fd, -128, SEEK_END);
write_data(fd, i + 1);
- syncfs(fd);
+ SAFE_FSYNC(fd);
SAFE_LSEEK(fd, 0, SEEK_SET);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH v2] syscalls/lseek11.c: fix syncfs() && SEEK_DATA
2017-04-13 2:31 ` [LTP] [PATCH v2] syscalls/lseek11.c: fix " Xiao Yang
@ 2017-04-13 10:04 ` Cyril Hrubis
0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2017-04-13 10:04 UTC (permalink / raw)
To: ltp
Hi!
Pushed, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-13 10:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 3:34 [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Xiao Yang
2017-04-12 3:34 ` [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA Xiao Yang
2017-04-12 11:42 ` Cyril Hrubis
2017-04-13 1:29 ` Xiao Yang
2017-04-13 2:31 ` [LTP] [PATCH v2] syscalls/lseek11.c: fix " Xiao Yang
2017-04-13 10:04 ` Cyril Hrubis
2017-04-12 6:55 ` [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.