[LTP] [PATCH v4 3/4] syscalls/statx11: Add basic test for STATX_DIOALIGN on block device

Yang Xu (Fujitsu) xuyang2018.jy@fujitsu.com
Thu Apr 27 05:50:25 CEST 2023



on 2023/04/27 11:37, Yang Xu (Fujitsu) wrote:
> 
> 
>    2023/04/27 6:12, Eric Biggers 写道:
>> On Thu, Apr 06, 2023 at 01:40:21PM +0800, Yang Xu wrote:
>>> +static void verify_statx(void)
>>> +{
>>> +	struct statx buf;
>>> +
>>> +	memset(&buf, 0, sizeof(buf));
>>
>> It is not necessary to memset struct statx to 0 before calling statx().
> 
> Will remove.
>>
>>> +#ifdef HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN
>>
>> Again, this looks wrong.  If the system headers are outdated, then LTP should
>> use its in-tree header instead.
> 
> Have mention this in the previous email. We can discussion this in that
> email.
> 
>>
>>> +static void setup(void)
>>> +{
>>> +	char *dev_name;
>>> +
>>> +	dev_name = basename((char *)tst_device->dev);
>>
>> This is modifying a const string, which seems problematic.
> 
> Yes, I plan to  modify code as below:
>           char full_name[256];
> 
>           strcpy(full_name, tst_device->dev);
>           dev_name = SAFE_BASENAME(full_name);
> 
>>
>>> +	sprintf(sys_bdev_logical_path, "/sys/block/%s/queue/logical_block_size", dev_name);
>>> +	while (access(sys_bdev_logical_path, F_OK) != 0) {
>>> +		dev_name[strlen(dev_name)-1] = '\0';
>>> +		sprintf(sys_bdev_logical_path, "/sys/block/%s/queue/logical_block_size", dev_name);
>>> +	}
>>
>> What is this code doing?  Is it trying to strip off the partition number of the
>> block device name?
> 
> Yes.
> 
>> If so, it is incorrect because it assumes the partition
>> number is only 1 digit long, which is not guaranteed.
> 
> I don't assume the partition number is only 1 digit long, this code has
> a while circulate. Also, I try the /dev/vdb11 and it also works.
> 
> 
>>
>> How about just using /sys/class/block/%s/queue, which works for partitions?

  /sys/class/block/%s/queue for partitions does't exist.

[root@localhost sda5]# pwd
/sys/class/block/sda5
[root@localhost sda5]# ls
alignment_offset  dev  discard_alignment  holders  inflight  partition 
power  ro  size  start  stat  subsystem  trace  uevent
[root@localhost sda5]#

Best Regards
Yang Xu

> 
> In fact, /sys/block or /sys/class/block, these files are all link files
> to /sys/device/pci...... see below:
> #cd /sys/class/block
> [root@localhost block]# ls -l
> total 0
> lrwxrwxrwx. 1 root root 0 Apr 20 00:07 loop0 ->
> ../../devices/virtual/block/loop0
> lrwxrwxrwx. 1 root root 0 Apr 20 00:07 loop1 ->
> ../../devices/virtual/block/loop1
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda1 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda2 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda3 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda3
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda4 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda4
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda5 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda5
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 sda6 ->
> ../../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda6
> lrwxrwxrwx. 1 root root 0 Apr 27 08:25 zram0 ->
> ../../devices/virtual/block/zram0
> [root@localhost block]# cd /sys/block/
> [root@localhost block]# ls -l
> total 0
> lrwxrwxrwx. 1 root root 0 Apr 20 00:03 loop0 ->
> ../devices/virtual/block/loop0
> lrwxrwxrwx. 1 root root 0 Apr 20 00:03 loop1 ->
> ../devices/virtual/block/loop1
> lrwxrwxrwx. 1 root root 0 Apr 20 00:03 sda ->
> ../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
> lrwxrwxrwx. 1 root root 0 Apr 20 00:03 zram0 ->
> ../devices/virtual/block/zram0
> [root@localhost block]# pwd
> 
> Best Regards
> Yang Xu
> 
>>
>> - Eric
> 


More information about the ltp mailing list