2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
storaged 구현
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 8은 Android 기기의 저장소 측정항목을 수집하고 게시하는 Android 네이티브 데몬인 storaged
지원을 추가합니다.
- 일일 diskstats와 관련하여
storaged
는 주기적으로 /sys/block/mmcblk0/stat
(eMMC 저장기기) 또는 /sys/block/sda/stat
(비 eMMC 기기)을 파싱합니다.
- eMMC 전체 기간과 관련하여
storaged
는 /d/mmc0/mmc0:001/ext_csd
(있는 경우)를 파싱합니다.
- 앱 I/O 블레임과 관련하여
storaged
는 주기적으로 /proc/uid_io/stats
를 순회하고 파싱된 데이터를 유지합니다. 여기에는 실행 중인 앱뿐만 아니라 모든 앱의 데이터가 포함됩니다. dumpsys
는 storaged
를 호출하여 버그 신고에 앱 I/O 사용을 로깅할 수 있습니다.
Diskstat(지연된 diskstats 포함) 및 eMMC 정보는 플랫폼 체크인 서비스에서 로그를 수집하는 Android 이벤트 로그에 로그됩니다.
storaged
연산은 자동으로 발생하며 전체가 Android 프레임워크에 의해 처리됩니다. 따라서 구현 작업을 실행할 필요가 없습니다. 이 페이지에서는 storaged
의 설계(새 인터페이스 포함), 그리고 이를 사용하여 커널에서 I/O 상태를 가져오는 방법을 설명합니다.
storaged 설계
기록 및 권한 관리의 유연성을 위해 storaged
는 표준 proc/PID/io
를 사용하는 대신 UID별 I/O 정보를 반환하는 커널 모듈로 구현됩니다. 각 I/O 요청의 원본 I/O 데이터는 계속해서 커널 task_struct
에서 저장 및 업데이트되며, 커널은 마지막 storaged
폴링 이벤트에서 발생하는 I/O 사용을 놓치지 않도록 프로세스 종료 시점을 추적합니다.
모듈은 프레임워크에서 UID 포그라운드/백그라운드의 전환을 알리거나 storaged
데몬이 보고서를 요청하는 경우에만 원본 데이터를 읽고 처리합니다. 이때 모듈은 프레임워크 및 storaged
데몬과의 통신을 위해 커널의 파일 노드를 내보냅니다.
storaged
는 시스템 내 각 UID의 I/O 상태 목록을 반환하는 /proc/uid_io/stats
인터페이스를 불러옵니다. 형식은 다음과 같습니다.
<uid>: <foreground read bytes> <foreground write bytes> <foreground read chars> <foreground write chars> <background read bytes> <background write bytes> <background read chars> <background write chars>
- 읽기/쓰기 바이트가 저장기기의 I/O 이벤트입니다.
- 마찬가지로 바이트인 읽기/쓰기 문자가 읽기/쓰기 syscall에 의해 요청됩니다.
커널에서 I/O 상태 가져오기
커널에서 I/O 사용을 덤프하려면 storaged
명령어를 -u
옵션과 함께 사용합니다.
명령어: storaged -u
명령어 출력 형식: name/uid fg_rchar fg_wchar fg_rbytes fg_wbytes
bg_rchar bg_wchar bg_rbytes bg_wbytes fg_fsync bg_fsync
참고: 이 출력은 proc/uid_io/stats
의 출력과 유사합니다. storaged
가 /proc/uid_io/stats
의 데이터를 처리하고 자체 데이터를 생성하기 때문입니다.
출력 예:
com.google.android.backuptransport 2269 60 0 0 1719845663 143912573 149065728 184180736
com.android.vending 2170 60 0 0 219904796 38693092 174436352 18944000
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Implement storaged\n\nAndroid 8 adds support for `storaged`, an Android native daemon that\ncollects and publishes storage metrics on Android devices.\n\n- For daily diskstats, `storaged` periodically parses `/sys/block/mmcblk0/stat` (eMMC storage devices) or `/sys/block/sda/stat` (non-eMMC devices).\n- For eMMC lifetime, `storaged` parses `/d/mmc0/mmc0:001/ext_csd` (if available).\n- For app I/O blaming, `storaged` periodically traverses `/proc/uid_io/stats` and maintains parsed data, which includes data from all apps (not just running apps). `dumpsys` can call `storaged` to log the app I/O usage in a bug report.\n\nDiskstat (including stalled diskstats) and eMMC information is logged to the\nAndroid event log, where a platform checkin service collects the logs.\n\n`storaged` operations occur automatically and are handled entirely by the Android\nframework, so you don't need to do any implementation work. This page\ndescribes the design of `storaged` (including new interfaces) and how to use it to\nget I/O status from the kernel.\n\nstoraged design\n---------------\n\nFor accounting and permission flexibility, `storaged` is implemented as a kernel\nmodule that returns per-uid I/O information (instead of using standard\n`proc/PID/io`). Raw I/O data for each I/O request continues to be\nstored and updated in kernel `task_struct`, and the kernel keeps\ntrack of when a process exits so it doesn't miss I/O usage that occurs from the\nlast `storaged` polling event.\n\nThe module reads raw data and processes it only when the framework notifies it\nof a uid foreground/background switch or when the `storaged` daemon requests a\nreport. At that time, the module exports a file node from kernel for\ncommunication with framework and `storaged` daemon.\n\n`storaged` introduces the `/proc/uid_io/stats` interface, which returns\na list of I/O stats for each UID in the system. The format is: \n\n```\n\u003cuid\u003e: \u003cforeground read bytes\u003e \u003cforeground write bytes\u003e \u003cforeground read chars\u003e \u003cforeground write chars\u003e \u003cbackground read bytes\u003e \u003cbackground write bytes\u003e \u003cbackground read chars\u003e \u003cbackground write chars\u003e\n```\n\n- read/write bytes are I/O events from a storage device.\n- read/write chars (also in bytes) are data requested by read/write syscalls.\n\nGet I/O status from the kernel\n------------------------------\n\nTo dump I/O usage from the kernel, use the `storaged` command with\nthe **`-u`** option.\n\nCommand: `storaged -u`\n\nCommand output format: `name/uid fg_rchar fg_wchar fg_rbytes fg_wbytes\nbg_rchar bg_wchar bg_rbytes bg_wbytes fg_fsync bg_fsync`\n\n**Note:** This output is similar to the output for\n`proc/uid_io/stats`. This is because `storaged` processes data from\n`/proc/uid_io/stats` and generates its own data.\n\nExample output: \n\n```\ncom.google.android.backuptransport 2269 60 0 0 1719845663 143912573 149065728 184180736\ncom.android.vending 2170 60 0 0 219904796 38693092 174436352 18944000\n```"]]