From: Cyril Hrubis <chrubis@suse.cz>
To: Sheng Yong <shengyong1@huawei.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [RESEND PATCH v3 2/4] lib/tst_fs_link_count.c: check fs type and do not fill subdir if no limit
Date: Tue, 27 Jan 2015 16:00:06 +0100 [thread overview]
Message-ID: <20150127150006.GE16759@rei.suse.de> (raw)
In-Reply-To: <1422323457-184525-3-git-send-email-shengyong1@huawei.com>
> Signed-off-by: Sheng Yong <shengyong1@huawei.com>
> ---
> doc/test-writing-guidelines.txt | 5 ++++-
> lib/tst_fs_link_count.c | 35 +++++++++++++++++++++++++++++++++--
> 2 files changed, 37 insertions(+), 3 deletions(-)
>
> diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
> index a59fdd9..8f690f7 100644
> --- a/doc/test-writing-guidelines.txt
> +++ b/doc/test-writing-guidelines.txt
> @@ -892,7 +892,10 @@ int tst_fs_fill_subdirs(void (*cleanup)(void), const char *dir);
>
> Try to get maximum number of subdirectories in directory.
>
> -NOTE: This number depends on the filesystem 'dir' is on.
> +NOTE: This number depends on the filesystem 'dir' is on. For current kernel,
> +subdir limit is not availiable for all filesystems (availiable for ext2, ext3,
> +minix, sysv and more). If the test runs on some other filesystems, like ramfs,
> +tmpfs, it will always fail.
This sounds a bit confusing. Maybe it will be better to say:
it will not even try to reach the limit and return 0 (or -1 if that ends
up the case).
> This function uses 'mkdir(2)' to create directories in 'dir' until it gets
> 'EMLINK' or creates 65535 directories. If the limit is hit, the maximum number
> diff --git a/lib/tst_fs_link_count.c b/lib/tst_fs_link_count.c
> index 1b45f79..4a691bb 100644
> --- a/lib/tst_fs_link_count.c
> +++ b/lib/tst_fs_link_count.c
> @@ -24,9 +24,24 @@
> #include "test.h"
> #include "usctest.h"
> #include "safe_macros.h"
> +#include "tst_fs_type.h"
>
> #define MAX_SANE_HARD_LINKS 65535
>
> +/*
> + * filesystems whose subdir limit is less than MAX_SANE_HARD_LINKS
> + * XXX: we cannot filter ext4 out, because ext2/ext3/ext4 have the
> + * same magic number
> + */
> +const long subdir_limit_whitelist[] = {
> + TST_EXT2_OLD_MAGIC, TST_EXT2_MAGIC, TST_EXT3_MAGIC,
> + TST_MINIX_MAGIC, TST_MINIX_MAGIC2, TST_MINIX2_MAGIC,
> + TST_MINIX2_MAGIC2, TST_MINIX3_MAGIC, TST_UDF_MAGIC,
> + TST_SYSV2_MAGIC, TST_SYSV4_MAGIC, TST_UFS_MAGIC,
> + TST_UFS2_MAGIC, TST_F2FS_MAGIC, TST_NILFS_MAGIC,
> + TST_EXOFS_MAGIC
> +};
> +
> int tst_fs_fill_hardlinks(void (*cleanup) (void), const char *dir)
> {
> unsigned int i, j;
> @@ -88,9 +103,10 @@ max_hardlinks_cleanup:
>
> int tst_fs_fill_subdirs(void (*cleanup) (void), const char *dir)
> {
> - unsigned int i, j;
> + unsigned int i, j, whitelist_size;
> char dirname[PATH_MAX];
> struct stat s;
> + long fs_type;
>
> if (stat(dir, &s) == -1 && errno == ENOENT)
> SAFE_MKDIR(cleanup, dir, 0744);
> @@ -99,6 +115,20 @@ 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, subdir limit is not availiable for all fs */
> + fs_type = tst_fs_type(cleanup, dir);
> +
> + whitelist_size = ARRAY_SIZE(subdir_limit_whitelist);
So you still use whitelist, I would have liked blacklist more because
if, by any change, new filesystem with this limit will be added to
kernel the test will be working as well, but either one needs to be
update under certain conditions, so in the end either one is fine.
> + for (i = 0; i < whitelist_size; i++) {
> + if (fs_type == subdir_limit_whitelist[i])
> + break;
> + }
> + if (i == whitelist_size) {
> + tst_resm(TINFO, "subdir limit is not availiable for "
> + "filesystem %s", tst_fs_type_name(fs_type));
^
%s filesystem.
> + return -1;
> + }
> +
> for (i = 0; i < MAX_SANE_HARD_LINKS; i++) {
> sprintf(dirname, "%s/testdir%d", dir, i);
>
> @@ -134,7 +164,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 %s",
^
on %s filesystem.
> + tst_fs_type_name(fs_type));
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2015-01-27 15:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1422323457-184525-1-git-send-email-shengyong1@huawei.com>
[not found] ` <1422323457-184525-2-git-send-email-shengyong1@huawei.com>
2015-01-27 14:40 ` [LTP] [RESEND PATCH v3 1/4] lib: tst_fs_type: add new filesystem types Cyril Hrubis
[not found] ` <1422323457-184525-5-git-send-email-shengyong1@huawei.com>
2015-01-27 14:46 ` [LTP] [RESEND PATCH v3 4/4] syscall/{rename11, renameat01}: do not test EMLINK if subdir limit not availiable Cyril Hrubis
[not found] ` <54C83795.20809@huawei.com>
2015-01-28 10:12 ` Cyril Hrubis
[not found] ` <1422323457-184525-4-git-send-email-shengyong1@huawei.com>
2015-01-27 14:48 ` [LTP] [RESEND PATCH v3 3/4] lib/tests: do not print max dir number " Cyril Hrubis
[not found] ` <1422323457-184525-3-git-send-email-shengyong1@huawei.com>
2015-01-27 15:00 ` Cyril Hrubis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150127150006.GE16759@rei.suse.de \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=shengyong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox