dd: iSCSI LUN에 4k 블록 크기 쓰기에 대한 매개변수가 잘못되었습니다.

dd: iSCSI LUN에 4k 블록 크기 쓰기에 대한 매개변수가 잘못되었습니다.

oflag=direct4k 블록 크기 iSCSI 디스크에서 작동 하지 않는 이유는 무엇입니까 ?이 문제가 다른 응용 프로그램에서도 발생합니까?

root@testvm02:~# dd if=/root/speedtest of=/mnt/8k_512/speedtest oflag=direct
51200+0 records in
51200+0 records out
26214400 bytes (26 MB, 25 MiB) copied, 59,4312 s, 441 kB/s

root@testvm02:~# dd if=/root/speedtest of=/mnt/8k_4k/speedtest oflag=direct
dd: writing to '/mnt/8k_4k/speedtest': Invalid argument
1+0 records in
0+0 records out
0 bytes copied, 0,000790648 s, 0,0 kB/s

root@testvm02:~# dd if=/root/speedtest of=/mnt/4k_4k/speedtest oflag=direct
dd: writing to '/mnt/4k_4k/speedtest': Invalid argument
1+0 records in
0+0 records out
0 bytes copied, 0.000139662 s, 0.0 kB/s

내 환경@storageserver:

/usr/sbin/zfs create -s -V 50GiB STORAGE01/4af1a9b7-0592-4707-a875-986d91fceac4 #<-- / & vda on testvm02
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --lun 1 -b /dev/zvol/STORAGE01/4af1a9b7-0592-4707-a875-986d91fceac4
#
/usr/sbin/zfs create -s -V 50GiB STORAGE01/209afd7c-bdd6-4125-a899-b98758fcc6c0 #<-- /mnt/8k-512 & vdb on testvm02
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --lun 2 -b /dev/zvol/STORAGE01/209afd7c-bdd6-4125-a899-b98758fcc6c0
#
/usr/sbin/zfs create -s -V 50GiB STORAGE01/6ae21fa3-df76-4843-ab65-0700af4f04f7 #<-- /mnt/8k-4k & vdc on testvm02
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --blocksize 4096 --lun 3 -b /dev/zvol/STORAGE01/6ae21fa3-df76-4843-ab65-0700af4f04f7
#
/usr/sbin/zfs create -s -o volblocksize=4k -V 50GiB STORAGE01/24d38989-b47b-4e3c-b5ea-5d9a30d611f6 #<-- /mnt/4k-4k & vdd on testvm02
/usr/sbin/tgtadm --lld iscsi --op new --mode logicalunit --tid 19 --blocksize 4096 --lun 4 -b /dev/zvol/STORAGE01/24d38989-b47b-4e3c-b5ea-5d9a30d611f6
#
# default zvol blocksize = 8k, default iSCSI LUN blocksize = 512

가상 기기:

virt-install --name 'testvm02.domain.de' --description 'desc' --os-type 'Linux' --os-variant 'debian9' --ram 2048 --vcpus 2 --cdrom '/var/lib/libvirt/boot/firmware-10.9.0-amd64-netinst.iso' --graphics vnc,password=foobar --network 'bridge:br540,model=virtio,virtualport_type=openvswitch' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:1,logical_block_size=512,physical_block_size=512' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:2,logical_block_size=512,physical_block_size=512' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:3,logical_block_size=4096,physical_block_size=4096' --disk 'vol=c0dcc42e-7805-4ab3-845f-363bdedada5b/unit:0:0:4,logical_block_size=4096,physical_block_size=4096'

ext4로 포맷된 모든 디스크

root@testvm02:~# fdisk -l
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x50172cb2

Device     Boot  Start       End   Sectors  Size Id Type
/dev/vda1  *      2048    999423    997376  487M 83 Linux
/dev/vda2       999424 104855551 103856128 49,5G 83 Linux


Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5e831f4b

Device     Boot Start       End   Sectors Size Id Type
/dev/vdb1        2048 104855551 104853504  50G 83 Linux


Disk /dev/vdc: 50 GiB, 53687091200 bytes, 13107200 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x791f5094

Device     Boot Start      End  Sectors Size Id Type
/dev/vdc1         256 13106943 13106688  50G 83 Linux


Disk /dev/vdd: 50 GiB, 53687091200 bytes, 13107200 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x6de2b945

Device     Boot Start      End  Sectors Size Id Type
/dev/vdd1         256 13106943 13106688  50G 83 Linux

답변1

oflag=direct4k 블록 크기 iSCSI 디스크에서 작동 하지 않는 이유는 무엇입니까 ?

직접 I/O를 사용할 수 있지만 커널 캐시를 우회하면 다음과 같은 제한 사항이 적용됩니다.open(2)맨페이지:

O_DIRECT플래그는 사용자 공간 버퍼의 길이와 주소 및 I/O에 대한 파일 오프셋에 대한 정렬 제약 조건을 부과할 수 있습니다. Linux에서는 정렬 제한이 파일 시스템과 커널 버전에 따라 다르며 전혀 존재하지 않을 수도 있습니다.
(...)
Linux 2.4에서는 전송 크기, 사용자 버퍼 정렬 및 파일 오프셋이 모두 파일 시스템 논리 블록 크기의 배수여야 합니다. Linux 2.6.0부터 기본 스토리지의 논리적 블록 크기(일반적으로 512바이트)에 대한 정렬이면 충분합니다. 논리적 블록 크기는 다음을 사용하여 결정할 수 있습니다.읽기 및 쓰기 제어(2) BLKSSZGET또는 다음 명령을 사용하여 쉘에서:blockdev --getss

요약하자면, 을 사용하는 경우 기본 블록 크기의 배수 oflag=direct도 설정해야 합니다 bs(또는 바로 여기에서). 기본값은 512이므로 블록 크기가 4096인 경우 4k, 8k 등으로 설정해야 합니다.obsbs

dd if=/root/speedtest of=/mnt/8k_4k/speedtest oflag=direct bs=4k

관련 정보