在 2015/1/15 10:11, Xiaoguang Wang 写道:
> Hi,
> 
> On 01/14/2015 08:32 PM, Sheng Yong wrote:
>> This number of max sub-directories depends on the filesystem. For current
>> kernel, subdir limit is not availiable for all filesystems (availiable for
>> ext2, ext3, minix, jfs, xfs, logfs etc). If the test runs on some other
>> filesystems, like ramfs, tmpfs, it will always fail.
>>
>> So we check the fs type in tst_fs_fill_subdirs(), and only try to reach the
>> limit on ext2 and ext3. Otherwise, give an information tells that subdir
>> limit is not avaliable, and returns -1.
> 
> If tst_fs_fill_subdirs() returns a  positive number, we can see that sub 
> directory
> limit has bee hit, so it'll be OK to have a test. If it returns 0, there 
> would be
> two possibility:
>   1) we got a ENOSPC or EDQUOT error, then this function print *message* and
>      return 0.
>   2) If we got some other errors, it also prints *message* and returns 0.
> 
> As you know, '0' means that tst_fs_fill_subdirs() couldn't create appropriate
> testing conditions. Caller should skip corresponding test cases and return 0.
> For example:
>       max_subdirs = tst_fs_fill_subdirs(cleanup, "emlink_dir");
>       if (max_subdirs == 0) {
>               tst_resm(TCONF, "EMLINK test is not appropriate");
>               return;
>       }
Yes, I agree that the return value '0' and message could help for testing 
people, and
the testcase renameat01 does have such judgement. But the caller cannot tell 
whether
the test really fails or the EMLINK test can be safely skipped. If it only 
returns '0',
the test will always fail in the above situation.

So I think another return value is needed, maybe '-1' is not an appropriate 
value.

> I think our original logical is reasonable :) But I agree that the *message*
> should be more informative.
> 
>>
>> Signed-off-by: Sheng Yong <[email protected]>
>> ---
>>  doc/test-writing-guidelines.txt |  5 ++++-
>>  lib/tst_fs_link_count.c         | 22 ++++++++++++++++++++++
>>  2 files changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/doc/test-writing-guidelines.txt 
>> b/doc/test-writing-guidelines.txt
>> index a59fdd9..eafe2fd 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, jfs, xfs, logfs etc). If the test runs on some other filesystems, 
>> like
>> +ramfs, tmpfs, it will always fail.
>>  
>>  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..5583993 100644
>> --- a/lib/tst_fs_link_count.c
>> +++ b/lib/tst_fs_link_count.c
>> @@ -20,6 +20,7 @@
>>  #include <sys/types.h>
>>  #include <sys/stat.h>
>>  #include <unistd.h>
>> +#include <sys/vfs.h>
>>  
>>  #include "test.h"
>>  #include "usctest.h"
>> @@ -91,6 +92,7 @@ int tst_fs_fill_subdirs(void (*cleanup) (void), const char 
>> *dir)
>>      unsigned int i, j;
>>      char dirname[PATH_MAX];
>>      struct stat s;
>> +    struct statfs fs;
>>  
>>      if (stat(dir, &s) == -1 && errno == ENOENT)
>>              SAFE_MKDIR(cleanup, dir, 0744);
>> @@ -99,6 +101,26 @@ 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;
>> +    }
>> +
>> +    switch (fs.f_type) {
>> +    case 0xEF51: /* EXT2_OLD_SUPER_MAGIC */
>> +    case 0xEF53: /* EXT2_SUPER_MAGIC, EXT3_SUPER_MAGIC */
> 
> It seems that ext4 has the same magic... If ext4 file system has dir_nlink 
> feature
> enabled. it will have so such sub directory limit and allow more than 65000 
> sub directories
> per directory.
Yes, ext4 has the same magic number with ext3. We cannot pick ext4 out. Ext4 
also may exceed
the 65000 limit. In this case, we may only depends on the output message.

 And as you said, minix, jfs, xfs, logfs has sub directory limit,
> why should we skip these file system?
We shouldn't. I will add them.

thanks,
Sheng Yong
> 
> Regards,
> Xiaoguang Wang 
>> +            break;
>> +    default:
>> +            tst_resm(TINFO, "subdir limit is not availiable for "
>> +                     "filesystem 0x%lx", (unsigned long) fs.f_type);
>> +            return -1;
>> +    }
>> +
>>      for (i = 0; i < MAX_SANE_HARD_LINKS; i++) {
>>              sprintf(dirname, "%s/testdir%d", dir, i);
>>  
>>
> 
> 
> .
> 


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to