Hi,

On 05/20/2014 12:29 AM, chru...@suse.cz wrote:
> Hi!
>> Note: int rename(const char *old, const char *new);
>> For EMLINK error value test: the file named by old is a directory and the
>> link count of the parent directory of new would exceed {LINK_MAX}.
>>
>> This test will work on ext2 and ext3 filesystem. But there is some 
>> difference in some
>> linux distributions.
>>
>> For example, in fedora19 and RHEL7.0Beta, the kernel configs for 
>> ext2/ext3/ext4 filesystems
>> list below:
>> # CONFIG_EXT2_FS is not set
>> # CONFIG_EXT3_FS is not set
>> CONFIG_EXT4_FS=m
>> CONFIG_EXT4_USE_FOR_EXT23=y
>> CONFIG_EXT4_FS_POSIX_ACL=y
>> CONFIG_EXT4_FS_SECURITY=y
>>
>> If kernel has the above config, ext2 or ext3 is disabled. Then when we mount 
>> ext2 or
>> ext3 filesystem, the ext4 filesystem driver code will be used for ext2 or 
>> ext3 file
>> system mounts. This allows users to reduce their compiled kernel size by 
>> using one
>> file system driver for ext2, ext3, and ext4 file systems. That means though 
>> we mount
>> a block device with ext2 filesystem in it, the kernel will possibely use 
>> ext4 driver
>> code instead.
>>
>> So for this EMLINK error value test, we have test in ext4 directly. But the 
>> max
>> subdirectories(per directory) in ext4 is unlimited default(When the link 
>> count exceeds
>> 65,000, it is reset to 1 and no longer increases.).
> Is this expected behavior? Because if the ref counting resets to 1 the
> fs will break when somebody tries to delete the file. Or is just the
> number reported to userspace wrong?

Yeah, it's expected behavior for ext4.
Please this this url: 
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/installconfig-fs.html

Note: here the discussion is for directory.

I checked the ext4 kernel source code in RHEL7.0RC:

static void ext4_inc_count(handle_t *handle, struct inode *inode)
{
         inc_nlink(inode);
         if (is_dx(inode) && inode->i_nlink > 1) {
                 if (inode->i_nlink >= EXT4_LINK_MAX || inode->i_nlink == 2) {
                         set_nlink(inode, 1);
                         EXT4_SET_RO_COMPAT_FEATURE(inode->i_sb,
                                               
EXT4_FEATURE_RO_COMPAT_DIR_NLINK);
                 }
         }
}

Here EXT4_LINK_MAX is 65000. From the above code, we can
see that if "is_dx(inode)" returns true and i_nlink count is greater than 65000.
i_nlink will be reset to 1. Then if you stat parent directory, you will see its 
link_count is 1.

When we try to rmdir a directory, I also checked the ext4 kernel source code.
If a directory had nlink == 1, then the ext4 will still let it be 1.

You can observe this by following steps:
[root@localhost ~]# mkdir ext4_test/
[root@localhost ~]# cd ext4_test/; for((i=0; i <=65000;i++)) do mkdir $i; done;
[root@localhost ext4_test]# stat .
  File: '.'
  Size: 1392640         Blocks: 2728       IO Block: 4096   directory
Device: 801h/2049d      Inode: 3678747     Links: 1
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-05-20 19:36:24.541944536 +0800
Modify: 2014-05-20 19:35:59.724942953 +0800
Change: 2014-05-20 19:35:59.724942953 +0800
 Birth: -

Now the links is 1.
If you delete some directory, the links will still be 1.

So if we want to have a 65000 limit, we should  "mkfs.ext4 -O ^dir_index 
device", thanks.

>> But EMLINK error value test need the directory have a valid LINK_MAX,
>> so for ext4, we use mkfs to clear "dir_index" filesystem feature, then
>> ext4 has a LINK_MAX:65000: mkfs.ext4 -O ^dir_index device
> So this is the same problem as with XFS.
>
> I still think that correct solution to this problem is to write a
> function that detects if there is a limit on number of links given a
> filesystem path. Then we can simply skip the EMLINK test if the number
> of links is unlimited.

Agree, thanks.
For xfs, the number of links is unlimited.
For ext2/3, the number of links is 32000.
For ext4, it depends some options.

So for xfs, I will skip EMLINK test for it.
For other files ystems, I will try to create as many as files, until the EMLINK 
Is hit.
if EMLINK is not hit, there must be some other errors, such as ENOSPC, for this
case,  the EMLINK test should also be skipped.

I will make a new version for your review, thanks.

Regards,
Xiaoguang Wang
>

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to