* [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase
@ 2022-11-25 11:31 Yang Xu
2022-11-25 11:31 ` [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase Yang Xu
2022-11-29 14:09 ` [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Richard Palethorpe
0 siblings, 2 replies; 6+ messages in thread
From: Yang Xu @ 2022-11-25 11:31 UTC (permalink / raw)
To: ltp
From mount(2) man-page, it means don't update access times for directories
on this filesystem. Also, test file and directory' atime for
noatime and nodiratime mount option.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
testcases/kernel/syscalls/mount/mount03.c | 59 +++++++++++++++++++++--
1 file changed, 55 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 397c1bf81..31a858c35 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -18,6 +18,7 @@
* - MS_REMOUNT - alter flags of a mounted FS
* - MS_NOSUID - ignore suid and sgid bits
* - MS_NOATIME - do not update access times
+ * - MS_NODIRATIME - only update access_time for directory instead of all types
*/
#include <stdio.h>
@@ -40,6 +41,7 @@
static int otfd;
static char file[PATH_MAX];
+static char dir[PATH_MAX];
static uid_t nobody_uid;
static gid_t nobody_gid;
@@ -95,23 +97,71 @@ static void test_nosuid(void)
tst_reap_children();
}
-static void test_noatime(void)
+static void test_file_dir_noatime(int update_fatime, int update_datime)
{
- time_t atime;
- struct stat st;
+ time_t atime, dir_atime;
+ struct stat st, dir_st;
char readbuf[20];
+ DIR *test_dir;
snprintf(file, PATH_MAX, "%s/noatime", MNTPOINT);
TST_EXP_FD_SILENT(otfd = open(file, O_CREAT | O_RDWR, 0700));
+ snprintf(dir, PATH_MAX, "%s/nodiratime", MNTPOINT);
+ if (access(dir, F_OK) == -1 && errno == ENOENT)
+ SAFE_MKDIR(dir, 0700);
+
SAFE_WRITE(1, otfd, TEST_STR, strlen(TEST_STR));
SAFE_FSTAT(otfd, &st);
atime = st.st_atime;
+
+ test_dir = SAFE_OPENDIR(dir);
+ SAFE_STAT(dir, &dir_st);
+ SAFE_READDIR(test_dir);
+ SAFE_CLOSEDIR(test_dir);
+ dir_atime = dir_st.st_atime;
+
sleep(1);
SAFE_READ(0, otfd, readbuf, sizeof(readbuf));
SAFE_FSTAT(otfd, &st);
- TST_EXP_EQ_LI(st.st_atime, atime);
+
+ test_dir = SAFE_OPENDIR(dir);
+ SAFE_READDIR(test_dir);
+ SAFE_CLOSEDIR(test_dir);
+ SAFE_STAT(dir, &dir_st);
+
+ if (update_fatime) {
+ if (st.st_atime > atime)
+ tst_res(TPASS, "st.st_atime(%ld) > atime(%ld)",
+ st.st_atime, atime);
+ else
+ tst_res(TFAIL, "st.st_atime(%ld) < atime(%ld)",
+ st.st_atime, atime);
+ } else {
+ TST_EXP_EQ_LI(st.st_atime, atime);
+ }
+
+ if (update_datime) {
+ if (dir_st.st_atime > dir_atime)
+ tst_res(TPASS, "dir_st.st_atime(%ld) > dir_atime(%ld)",
+ dir_st.st_atime, dir_atime);
+ else
+ tst_res(TFAIL, "dir_st.st_atime(%ld) < dir_atime(%ld)",
+ dir_st.st_atime, dir_atime);
+ } else {
+ TST_EXP_EQ_LI(dir_st.st_atime, dir_atime);
+ }
+}
+
+static void test_noatime(void)
+{
+ test_file_dir_noatime(0, 0);
+}
+
+static void test_nodiratime(void)
+{
+ test_file_dir_noatime(1, 0);
}
#define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
@@ -128,6 +178,7 @@ static struct tcase {
{MS_RDONLY, FLAG_DESC2(MS_REMOUNT), test_remount},
{FLAG_DESC(MS_NOSUID), test_nosuid},
{FLAG_DESC(MS_NOATIME), test_noatime},
+ {FLAG_DESC(MS_NODIRATIME), test_nodiratime},
};
static void setup(void)
--
2.23.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase
2022-11-25 11:31 [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Yang Xu
@ 2022-11-25 11:31 ` Yang Xu
2022-11-29 13:54 ` Richard Palethorpe
2022-11-29 14:09 ` [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Richard Palethorpe
1 sibling, 1 reply; 6+ messages in thread
From: Yang Xu @ 2022-11-25 11:31 UTC (permalink / raw)
To: ltp
This case should check MS_NOATIME and MS_RELATIME are
not inside stat f_flags[1] .
[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0adde57
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
testcases/kernel/syscalls/mount/mount03.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 31a858c35..60f9963da 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -19,6 +19,7 @@
* - MS_NOSUID - ignore suid and sgid bits
* - MS_NOATIME - do not update access times
* - MS_NODIRATIME - only update access_time for directory instead of all types
+ * - MS_STRICTATIME - always update access times
*/
#include <stdio.h>
@@ -164,6 +165,11 @@ static void test_nodiratime(void)
test_file_dir_noatime(1, 0);
}
+static void test_strictatime(void)
+{
+ test_file_dir_noatime(1, 1);
+}
+
#define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
#define FLAG_DESC2(x) .flag2 = x, .desc = #x
static struct tcase {
@@ -179,6 +185,7 @@ static struct tcase {
{FLAG_DESC(MS_NOSUID), test_nosuid},
{FLAG_DESC(MS_NOATIME), test_noatime},
{FLAG_DESC(MS_NODIRATIME), test_nodiratime},
+ {FLAG_DESC(MS_STRICTATIME), test_strictatime}
};
static void setup(void)
@@ -215,6 +222,15 @@ static void run(unsigned int n)
tc->test();
SAFE_STATFS(MNTPOINT, &stfs);
+ if (tc->flag == MS_STRICTATIME) {
+ if (stfs.f_flags & (MS_NOATIME | MS_RELATIME))
+ tst_res(TFAIL, "statfs() gets the incorrect mount flag");
+ else
+ tst_res(TPASS, "statfs() gets the correct mount flag");
+ cleanup();
+ return;
+ }
+
if (stfs.f_flags & tc->flag2)
tst_res(TPASS, "statfs() gets the correct mount flag");
else
--
2.23.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase
2022-11-25 11:31 ` [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase Yang Xu
@ 2022-11-29 13:54 ` Richard Palethorpe
2022-11-30 2:02 ` xuyang2018.jy
0 siblings, 1 reply; 6+ messages in thread
From: Richard Palethorpe @ 2022-11-29 13:54 UTC (permalink / raw)
To: Yang Xu; +Cc: ltp
Hello,
Yang Xu <xuyang2018.jy@fujitsu.com> writes:
> This case should check MS_NOATIME and MS_RELATIME are
> not inside stat f_flags[1] .
>
> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0adde57
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
> testcases/kernel/syscalls/mount/mount03.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
> index 31a858c35..60f9963da 100644
> --- a/testcases/kernel/syscalls/mount/mount03.c
> +++ b/testcases/kernel/syscalls/mount/mount03.c
> @@ -19,6 +19,7 @@
> * - MS_NOSUID - ignore suid and sgid bits
> * - MS_NOATIME - do not update access times
> * - MS_NODIRATIME - only update access_time for directory instead of all types
> + * - MS_STRICTATIME - always update access times
> */
>
> #include <stdio.h>
> @@ -164,6 +165,11 @@ static void test_nodiratime(void)
> test_file_dir_noatime(1, 0);
> }
>
> +static void test_strictatime(void)
> +{
> + test_file_dir_noatime(1, 1);
> +}
> +
> #define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
> #define FLAG_DESC2(x) .flag2 = x, .desc = #x
> static struct tcase {
> @@ -179,6 +185,7 @@ static struct tcase {
> {FLAG_DESC(MS_NOSUID), test_nosuid},
> {FLAG_DESC(MS_NOATIME), test_noatime},
> {FLAG_DESC(MS_NODIRATIME), test_nodiratime},
> + {FLAG_DESC(MS_STRICTATIME), test_strictatime}
> };
>
> static void setup(void)
> @@ -215,6 +222,15 @@ static void run(unsigned int n)
> tc->test();
>
> SAFE_STATFS(MNTPOINT, &stfs);
> + if (tc->flag == MS_STRICTATIME) {
> + if (stfs.f_flags & (MS_NOATIME | MS_RELATIME))
> + tst_res(TFAIL, "statfs() gets the incorrect mount flag");
> + else
> + tst_res(TPASS, "statfs() gets the correct mount flag");
> + cleanup();
> + return;
> + }
We don't need this branch.
> +
> if (stfs.f_flags & tc->flag2)
Could change this to something like
if (stfs.f_flags & tc->flag2
&& !(stfs.f_flags & MS_STRICTATIME && stfs.f_flags & (MS_NOATIME | MS_RELATIME))
Or however you would like to format that.
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase
2022-11-25 11:31 [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Yang Xu
2022-11-25 11:31 ` [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase Yang Xu
@ 2022-11-29 14:09 ` Richard Palethorpe
1 sibling, 0 replies; 6+ messages in thread
From: Richard Palethorpe @ 2022-11-29 14:09 UTC (permalink / raw)
To: Yang Xu; +Cc: ltp
Hello,
Yang Xu <xuyang2018.jy@fujitsu.com> writes:
> From mount(2) man-page, it means don't update access times for directories
> on this filesystem. Also, test file and directory' atime for
> noatime and nodiratime mount option.
Merged this assumming the next patch will also get merged at some
point. Thanks!
(because update_datime is not used in this patch)
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase
2022-11-29 13:54 ` Richard Palethorpe
@ 2022-11-30 2:02 ` xuyang2018.jy
2022-12-01 9:48 ` Richard Palethorpe
0 siblings, 1 reply; 6+ messages in thread
From: xuyang2018.jy @ 2022-11-30 2:02 UTC (permalink / raw)
To: rpalethorpe; +Cc: ltp
Hi Richard
> Hello,
>
> Yang Xu <xuyang2018.jy@fujitsu.com> writes:
>
>> This case should check MS_NOATIME and MS_RELATIME are
>> not inside stat f_flags[1] .
>>
>> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0adde57
>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>> ---
>> testcases/kernel/syscalls/mount/mount03.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
>> index 31a858c35..60f9963da 100644
>> --- a/testcases/kernel/syscalls/mount/mount03.c
>> +++ b/testcases/kernel/syscalls/mount/mount03.c
>> @@ -19,6 +19,7 @@
>> * - MS_NOSUID - ignore suid and sgid bits
>> * - MS_NOATIME - do not update access times
>> * - MS_NODIRATIME - only update access_time for directory instead of all types
>> + * - MS_STRICTATIME - always update access times
>> */
>>
>> #include <stdio.h>
>> @@ -164,6 +165,11 @@ static void test_nodiratime(void)
>> test_file_dir_noatime(1, 0);
>> }
>>
>> +static void test_strictatime(void)
>> +{
>> + test_file_dir_noatime(1, 1);
>> +}
>> +
>> #define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
>> #define FLAG_DESC2(x) .flag2 = x, .desc = #x
>> static struct tcase {
>> @@ -179,6 +185,7 @@ static struct tcase {
>> {FLAG_DESC(MS_NOSUID), test_nosuid},
>> {FLAG_DESC(MS_NOATIME), test_noatime},
>> {FLAG_DESC(MS_NODIRATIME), test_nodiratime},
>> + {FLAG_DESC(MS_STRICTATIME), test_strictatime}
>> };
>>
>> static void setup(void)
>> @@ -215,6 +222,15 @@ static void run(unsigned int n)
>> tc->test();
>>
>> SAFE_STATFS(MNTPOINT, &stfs);
>> + if (tc->flag == MS_STRICTATIME) {
>> + if (stfs.f_flags & (MS_NOATIME | MS_RELATIME))
>> + tst_res(TFAIL, "statfs() gets the incorrect mount flag");
>> + else
>> + tst_res(TPASS, "statfs() gets the correct mount flag");
>> + cleanup();
>> + return;
>> + }
>
> We don't need this branch.
>
>> +
>> if (stfs.f_flags & tc->flag2)
>
> Could change this to something like
>
> if (stfs.f_flags & tc->flag2
> && !(stfs.f_flags & MS_STRICTATIME && stfs.f_flags & (MS_NOATIME | MS_RELATIME))
I try it, but case reports fail because stfs.f_flags doesn't contain
MS_STRICTATIME flag. Sorry, I guess my commit message only mentioned
that MS_NOATIME and MS_RELATIME are not inside stat f_flags but missed
that the MS_STRICTATIME flag is ignored by kernel.
Best Regards
Yang Xu
>
> Or however you would like to format that.
>
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase
2022-11-30 2:02 ` xuyang2018.jy
@ 2022-12-01 9:48 ` Richard Palethorpe
0 siblings, 0 replies; 6+ messages in thread
From: Richard Palethorpe @ 2022-12-01 9:48 UTC (permalink / raw)
To: xuyang2018.jy; +Cc: ltp
"xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com> writes:
> Hi Richard
>
>> Hello,
>>
>> Yang Xu <xuyang2018.jy@fujitsu.com> writes:
>>
>>> This case should check MS_NOATIME and MS_RELATIME are
>>> not inside stat f_flags[1] .
>>>
>>> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0adde57
>>> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
>>> ---
>>> testcases/kernel/syscalls/mount/mount03.c | 16 ++++++++++++++++
>>> 1 file changed, 16 insertions(+)
>>>
>>> diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
>>> index 31a858c35..60f9963da 100644
>>> --- a/testcases/kernel/syscalls/mount/mount03.c
>>> +++ b/testcases/kernel/syscalls/mount/mount03.c
>>> @@ -19,6 +19,7 @@
>>> * - MS_NOSUID - ignore suid and sgid bits
>>> * - MS_NOATIME - do not update access times
>>> * - MS_NODIRATIME - only update access_time for directory instead of all types
>>> + * - MS_STRICTATIME - always update access times
>>> */
>>>
>>> #include <stdio.h>
>>> @@ -164,6 +165,11 @@ static void test_nodiratime(void)
>>> test_file_dir_noatime(1, 0);
>>> }
>>>
>>> +static void test_strictatime(void)
>>> +{
>>> + test_file_dir_noatime(1, 1);
>>> +}
>>> +
>>> #define FLAG_DESC(x) .flag = x, .flag2 = x, .desc = #x
>>> #define FLAG_DESC2(x) .flag2 = x, .desc = #x
>>> static struct tcase {
>>> @@ -179,6 +185,7 @@ static struct tcase {
>>> {FLAG_DESC(MS_NOSUID), test_nosuid},
>>> {FLAG_DESC(MS_NOATIME), test_noatime},
>>> {FLAG_DESC(MS_NODIRATIME), test_nodiratime},
>>> + {FLAG_DESC(MS_STRICTATIME), test_strictatime}
>>> };
>>>
>>> static void setup(void)
>>> @@ -215,6 +222,15 @@ static void run(unsigned int n)
>>> tc->test();
>>>
>>> SAFE_STATFS(MNTPOINT, &stfs);
>>> + if (tc->flag == MS_STRICTATIME) {
>>> + if (stfs.f_flags & (MS_NOATIME | MS_RELATIME))
>>> + tst_res(TFAIL, "statfs() gets the incorrect mount flag");
>>> + else
>>> + tst_res(TPASS, "statfs() gets the correct mount flag");
>>> + cleanup();
>>> + return;
>>> + }
>>
>> We don't need this branch.
>>
>>> +
>>> if (stfs.f_flags & tc->flag2)
>>
>> Could change this to something like
>>
>> if (stfs.f_flags & tc->flag2
>> && !(stfs.f_flags & MS_STRICTATIME && stfs.f_flags & (MS_NOATIME | MS_RELATIME))
>
> I try it, but case reports fail because stfs.f_flags doesn't contain
> MS_STRICTATIME flag. Sorry, I guess my commit message only mentioned
Ah, sorry, it should be something like:
if (stfs.f_flags & tc->flag2
&& (tc->flag2 != MS_STRICTATIME || !(stfs.f_flags & MS_STRICTATIME
&& stfs.f_flags & (MS_NOATIME | MS_RELATIME)))
but actually this is getting kind of messy now. So I'll merge it as you
sent it. Thanks!
--
Thank you,
Richard.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-01 9:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 11:31 [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Yang Xu
2022-11-25 11:31 ` [LTP] [PATCH v1 2/2] syscalls/mount03: Add MS_STRICTATIME subcase Yang Xu
2022-11-29 13:54 ` Richard Palethorpe
2022-11-30 2:02 ` xuyang2018.jy
2022-12-01 9:48 ` Richard Palethorpe
2022-11-29 14:09 ` [LTP] [PATCH v1 1/2] syscalls/mount03: Add MS_NODIRATIME subcase Richard Palethorpe
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.