ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
ใช้พื้นที่เก็บข้อมูล
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android 8 เพิ่มการรองรับ storaged
ซึ่งเป็นเดรัมน์ของ Android ที่จะรวบรวมและเผยแพร่เมตริกพื้นที่เก็บข้อมูลในอุปกรณ์ Android
- สำหรับ 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 (รวมถึง Diskstat ที่ค้าง) และ eMMC ลงในบันทึกเหตุการณ์ของ Android ซึ่งบริการเช็คอินของแพลตฟอร์มจะรวบรวมบันทึก
storaged
การดำเนินการจะเกิดขึ้นโดยอัตโนมัติและจัดการโดยเฟรมเวิร์ก Android ทั้งหมด คุณจึงไม่ต้องดำเนินการติดตั้งใช้งานใดๆ หน้านี้อธิบายการออกแบบ storaged
(รวมถึงอินเทอร์เฟซใหม่) และวิธีใช้เพื่อรับสถานะ I/O จากเคอร์เนล
การออกแบบที่เก็บไว้
ระบบจะใช้ storaged
เป็นโมดูลเคอร์เนลที่แสดงข้อมูล I/O ตาม uid (แทนที่จะใช้ proc/PID/io
มาตรฐาน) เพื่อเพิ่มความยืดหยุ่นในการบันทึกบัญชีและสิทธิ์ ข้อมูล I/O ดิบของคำขอ I/O แต่ละรายการจะยังคงจัดเก็บและอัปเดตในเคอร์เนล task_struct
ต่อไป และเคอร์เนลจะติดตามเมื่อกระบวนการหนึ่งๆ สิ้นสุดการทำงานเพื่อไม่ให้พลาดการใช้งาน I/O ที่เกิดขึ้นจากเหตุการณ์การเรียกข้อมูล storaged
ครั้งล่าสุด
โมดูลจะอ่านข้อมูลดิบและประมวลผลเฉพาะเมื่อเฟรมเวิร์กแจ้งให้ทราบถึงการสลับเบื้องหน้า/เบื้องหลังของ uid หรือเมื่อเดรัมน์ storaged
ขอรายงาน ในขณะนั้น โมดูลจะส่งออกโหนดไฟล์จากเคอร์เนลเพื่อการสื่อสารกับเฟรมเวิร์กและ storaged
daemon
storaged
เปิดตัวอินเทอร์เฟซ /proc/uid_io/stats
ซึ่งจะแสดงรายการสถิติ I/O สําหรับ UID แต่ละรายการในระบบ รูปแบบคือ
<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 จากอุปกรณ์จัดเก็บข้อมูล
- read/write chars (เป็นไบต์เช่นกัน) คือข้อมูลที่ขอโดย read/write
syscalls
รับสถานะ 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
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ 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```"]]