본문 바로가기

Programming/Linux_Platform

wrtie 비교 O_DIRECT and no-delay-alloc mount option

- O_DIRCET option

open 함수에 주는 flag


- no-delay-alloc option

file system mount option : file write 를 보통 지연시켜서 하는데 이기능을 사용하지 않음.


umount /cache


일반적인 mount 명령어

mount -t ext4 /dev/block/mmcblk0p27 /cache


no delay alloc mount 명령어

mount -t ext4 -o nodelalloc /dev/block/mmcblk0p27 /cache


test source code


하기 파일에서 O_DIRECT 주석을 풀어주면 O_DIRECT 로 동작함.

간단히 input file 을 open 하여 내용을 읽고 output 파일에 write 하는 예제임.

dio_file_test.c


결과를 most 로 출력


O_DIRECT(x), nodelalloc(x) - 실제 출력이 일어 나지 않음

    0.000000000 Q WBS       0   0 139         flush-179:0 M

    0.000096927 G WBS       0   0 139         flush-179:0 M

    0.000144218 I WBS       0   0 139         flush-179:0 M

    0.000340937 C WS       0   0 139         flush-179:0 M

    0.007122031 Q WBS       0   0 139         flush-179:0 M

    0.007205052 G WBS       0   0 139         flush-179:0 M

    0.007347968 I WBS       0   0 139         flush-179:0 M

    0.007555052 C WS       0   0 139         flush-179:0 M

    0.010357864 Q WBS       0   0 139         flush-179:0 M

    0.010797187 G WBS       0   0 139         flush-179:0 M

    0.011235572 I WBS       0   0 139         flush-179:0 M

    0.011494427 C WS       0   0 139         flush-179:0 M

    0.012855104 Q WBS       0   0 139         flush-179:0 M

    0.012934844 G WBS       0   0 139         flush-179:0 M

    0.013074114 I WBS       0   0 139         flush-179:0 M

    0.013282656 C WS       0   0 139         flush-179:0 M


O_DIRECT(o), nodelalloc(0, x) - 실제 출력이 일어나면 ext4 journal 에 write 하지 않고 바로 file 에 write 함.

    0.000000000 A WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.000203021 Q WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.000413802 G WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.000787031 I WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.001071406 D WAS 3072000   8 4458     dio_file_write_ M

    0.002274635 C WAS 3072000   8 4458     dio_file_write_ M

    0.002815781 A WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.003015208 Q WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.003229375 G WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.003601510 I WS 3072000   8 4458     dio_file_write_ D /dio_test/output

    0.003876198 D WAS 3072000   8 4458     dio_file_write_ M

    0.005053229 C WAS 3072000   8 4458     dio_file_write_ M



O_DIRECT(x), nodelalloc(o) - 실제 출력이 일어나면 ext4 journal 과 output file 에 write 함.

    0.000000000 A WS 3067904   8 4267     jbd2/mmcblk0p27 D /dio_test/output

    0.000101250 Q WS 3067904   8 4267     jbd2/mmcblk0p27 D /dio_test/output

    0.000194323 G WS 3067904   8 4267     jbd2/mmcblk0p27 D /dio_test/output

    0.000371614 I WS 3067904   8 4267     jbd2/mmcblk0p27 D /dio_test/output

    0.000493750 A WS 3850568   8 4267     jbd2/mmcblk0p27 J

    0.000501302 Q WS 3850568   8 4267     jbd2/mmcblk0p27 J

    0.000774271 D WAS 3067904   8 4267     jbd2/mmcblk0p27 M

    0.000860573 G WS 3850568   8 4267     jbd2/mmcblk0p27 J

    0.000946562 A WS 3850576   8 4267     jbd2/mmcblk0p27 J

    0.001087135 Q WS 3850576   8 4267     jbd2/mmcblk0p27 J

    0.001168437 M WS 3850576   8 4267     jbd2/mmcblk0p27 J

    0.001254010 A WS 3850584   8 4267     jbd2/mmcblk0p27 J

    0.001393229 Q WS 3850584   8 4267     jbd2/mmcblk0p27 J

    0.001472812 M WS 3850584   8 4267     jbd2/mmcblk0p27 J

    0.001557135 A WS 3850592   8 4267     jbd2/mmcblk0p27 J

    0.001695052 Q WS 3850592   8 4267     jbd2/mmcblk0p27 J

    0.001774427 M WS 3850592   8 4267     jbd2/mmcblk0p27 J

    0.001856354 A WS 3850600   8 4267     jbd2/mmcblk0p27 J

    0.001996458 Q WS 3850600   8 4267     jbd2/mmcblk0p27 J

    0.002075156 M WS 3850600   8 4267     jbd2/mmcblk0p27 J

    0.002156094 A WS 3850608   8 4267     jbd2/mmcblk0p27 J

    0.002293385 Q WS 3850608   8 4267     jbd2/mmcblk0p27 J

    0.002372760 M WS 3850608   8 4267     jbd2/mmcblk0p27 J

    0.002456146 A WS 3850616   8 4267     jbd2/mmcblk0p27 J

    0.002594843 Q WS 3850616   8 4267     jbd2/mmcblk0p27 J

    0.002673073 M WS 3850616   8 4267     jbd2/mmcblk0p27 J

    0.002758958 I WS 3850568  56 4267     jbd2/mmcblk0p27 J

    0.070908968 D WAS 3850568  56 4267     jbd2/mmcblk0p27 M

    0.071568395 C WAS 3067904   8 4267     jbd2/mmcblk0p27 M

    0.080915530 C WAS 3850568  56 4267     jbd2/mmcblk0p27 M

    0.081033290 A WBS 3850624   8 4267     jbd2/mmcblk0p27 M

    0.081073186 Q WBS 3850624   8 4267     jbd2/mmcblk0p27 M

    0.081115269 G WBS 3850624   8 4267     jbd2/mmcblk0p27 M

    0.081189175 I WBS 3850624   8 4267     jbd2/mmcblk0p27 M

    0.081356207 D WS 3850624   8 4267     jbd2/mmcblk0p27 J

    0.082205477 C WS 3850624   8 4267     jbd2/mmcblk0p27 J

    0.082279852 C WS 3850624   0 4267     jbd2/mmcblk0p27 J