* Re: [LTP] [PATCH V2 1/3] lib/tst_fs_link_count.c: check fs type and do not fill subdir if no limit
[not found] ` <1421331671-231350-2-git-send-email-shengyong1@huawei.com>
@ 2015-01-15 14:41 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2015-01-15 14:41 UTC (permalink / raw)
To: Sheng Yong; +Cc: yanegomi, ltp-list
Hi!
> +/* filesystems whose subdir limit is less than MAX_SANE_HARD_LINKS */
> +const long fs_type_filter[] = {
> + 0xEF51, /* EXT2_OLD_SUPER_MAGIC */
> + 0xEF53, /* EXT2/3/4_SUPER_MAGIC, cannot filter ext4 out */
> + 0x137F, 0x138F, /* MINIX_SUPER_MAGIC, MINIX_SUPER_MAGIC2 */
> + 0x2468, 0x2478, /* MINIX2_SUPER_MAGIC, MINIX2_SUPER_MAGIC2 */
> + 0x4d5a, /* MINIX3_SUPER_MAGIC */
> + 0x15013346, /* UDF_SUPER_MAGIC */
> + 0x012FF7B6, 0x012FF7B5, /* SYSV2_SUPER_MAGIC, SYSV4_SUPER_MAGIC */
> + 0x00011954, 0x19540119, /* UFS_MAGIC, UFS2_MAGIC */
> + 0xF2F52010, /* F2FS_SUPER_MAGIC */
> + 0x3434, /* NILFS_SUPER_MAGIC */
> + 0x5DF5 /* EXOFS_SUPER_MAGIC */
> +};
We have most of these defined in include/tst_fs_type.h, make use of
them. And if there are any missing, add them (in a separate patch).
Also it may be better to add a blacklist rather than whitelist. I.e.
skip tmpfs, ramfs, etc.
> int tst_fs_fill_hardlinks(void (*cleanup) (void), const char *dir)
> {
> unsigned int i, j;
> @@ -88,9 +104,10 @@ max_hardlinks_cleanup:
>
> int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir)
> {
> - unsigned int i, j;
> + unsigned int i, j, filter_size;
> char dirname[PATH_MAX];
> struct stat s;
> + struct statfs fs;
>
> if (stat(dir, &s) == -1 && errno == ENOENT)
> SAFE_MKDIR(cleanup, dir, 0744);
> @@ -99,6 +116,27 @@ int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir)
> if (!S_ISDIR(s.st_mode))
> tst_brkm(TBROK, cleanup, "%s is not directory", dir);
>
> + /*
> + * for current kernel, hardlink limit is not availiable for all
> + * filesystem. Only test if on ext2 and ext3.
> + */
> + if (statfs(dir, &fs) < 0) {
> + tst_resm(TINFO | TERRNO, "cannot detect filesystem type "
> + "for %s", dir);
> + return 0;
> + }
> +
> + filter_size = (int) (sizeof(fs_type_filter) / sizeof(long));
Use ARRAY_SIZE();
> + for (i = 0; i < filter_size; i++) {
> + if (fs.f_type == fs_type_filter[i])
> + break;
> + }
> + if (i == filter_size) {
> + tst_resm(TINFO, "subdir limit is not availiable for "
> + "filesystem 0x%lx", (unsigned long) fs.f_type);
> + return -1;
> + }
Why overcomplicate the code, just return -1 from the if () inside the
loop. Also we have tst_fs_type_name().
> for (i = 0; i < MAX_SANE_HARD_LINKS; i++) {
> sprintf(dirname, "%s/testdir%d", dir, i);
>
> @@ -134,7 +172,8 @@ int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir)
>
> }
>
> - tst_resm(TINFO, "Failed reach the subdirs limit");
> + tst_resm(TINFO, "Failed reach the subdirs limit on filesystem 0x%lx",
> + fs.f_type);
Again tst_fs_type_name();
> max_subdirs_cleanup:
> for (j = 0; j < i; j++) {
> --
> 1.8.3.4
>
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH V2 2/3] syscall/renameat01: do not test EMLINK if subdir limit not availiable
[not found] ` <1421331671-231350-3-git-send-email-shengyong1@huawei.com>
@ 2015-01-15 14:41 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2015-01-15 14:41 UTC (permalink / raw)
To: Sheng Yong; +Cc: yanegomi, ltp-list
Hi!
> Do not test EMLINK, if the filesystem has no subdir limit.
>
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
> testcases/kernel/syscalls/renameat/renameat01.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/renameat/renameat01.c b/testcases/kernel/syscalls/renameat/renameat01.c
> index bb5e6df..b92f96d 100644
> --- a/testcases/kernel/syscalls/renameat/renameat01.c
> +++ b/testcases/kernel/syscalls/renameat/renameat01.c
> @@ -211,6 +211,11 @@ static void setup(void)
>
> static void renameat_verify(const struct test_case_t *tc)
> {
> + if (tc->exp_errno == EMLINK && max_subdirs == -1) {
> + tst_resm(TPASS, "EMLINK test is not tested");
This is TCONF not PASS.
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-15 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1421331671-231350-1-git-send-email-shengyong1@huawei.com>
[not found] ` <1421331671-231350-2-git-send-email-shengyong1@huawei.com>
2015-01-15 14:41 ` [LTP] [PATCH V2 1/3] lib/tst_fs_link_count.c: check fs type and do not fill subdir if no limit Cyril Hrubis
[not found] ` <1421331671-231350-3-git-send-email-shengyong1@huawei.com>
2015-01-15 14:41 ` [LTP] [PATCH V2 2/3] syscall/renameat01: do not test EMLINK if subdir limit not availiable Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox