diff --git a/public/assets/data-management-on-zns-ssd/group-state-dark.png b/public/assets/data-management-on-zns-ssd/group-state-dark.png new file mode 100644 index 0000000..cb31d5a Binary files /dev/null and b/public/assets/data-management-on-zns-ssd/group-state-dark.png differ diff --git a/public/assets/data-management-on-zns-ssd/group-state.excalidraw b/public/assets/data-management-on-zns-ssd/group-state.excalidraw new file mode 100644 index 0000000..b552fe0 --- /dev/null +++ b/public/assets/data-management-on-zns-ssd/group-state.excalidraw @@ -0,0 +1,860 @@ +{ + "type": "excalidraw", + "version": 2, + "source": "https://excalidraw.com", + "elements": [ + { + "type": "rectangle", + "version": 533, + "versionNonce": 53924848, + "index": "Zx", + "isDeleted": false, + "id": "3JN32kgbsapsgpkjicxG6", + "fillStyle": "cross-hatch", + "strokeWidth": 1, + "strokeStyle": "dashed", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 671.0379072203485, + "y": 205.50359290803777, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 399.20325568795243, + "height": 152.63110106210587, + "seed": 337179408, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [ + { + "id": "jG2689arKNTWb83LwFdYB", + "type": "text" + } + ], + "updated": 1717326199225, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 320, + "versionNonce": 2028974067, + "index": "Zy", + "isDeleted": false, + "id": "jG2689arKNTWb83LwFdYB", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "dashed", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 676.0379072203485, + "y": 210.50359290803777, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 138.39988708496094, + "height": 25, + "seed": 241331984, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 1, + "text": " Active Zones", + "textAlign": "left", + "verticalAlign": "top", + "containerId": "3JN32kgbsapsgpkjicxG6", + "originalText": " Active Zones", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 1225, + "versionNonce": 158047222, + "index": "a0", + "isDeleted": false, + "id": "epulSIoCC1vPtYjPlCe1q", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 696.2119140625, + "y": 399.998046875, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 142.31640624999997, + "height": 69.65234374999999, + "seed": 276615952, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "type": "text", + "id": "uvSnYq_Ppue4Y-xR9EYmy" + }, + { + "id": "6SYQPXZRUBwo-cEPVyWVJ", + "type": "arrow" + }, + { + "id": "DDA6cFu6wkdGgMNZSV276", + "type": "arrow" + } + ], + "updated": 1717327118836, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 1082, + "versionNonce": 1015532458, + "index": "a08", + "isDeleted": false, + "id": "uvSnYq_Ppue4Y-xR9EYmy", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 746.39013671875, + "y": 422.32421875, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 41.9599609375, + "height": 25, + "seed": 1742660080, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717327118836, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 1, + "text": "Free", + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "epulSIoCC1vPtYjPlCe1q", + "originalText": "Free", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 595, + "versionNonce": 832278070, + "index": "a5", + "isDeleted": false, + "id": "NKZ0uIMagigklnEtjc3s3", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 696.2119140625, + "y": 252.259765625, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 142.31640624999997, + "height": 69.65234374999999, + "seed": 1859887376, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "b6v4NVE97suEtD9HhDi2T", + "type": "text" + }, + { + "id": "6SYQPXZRUBwo-cEPVyWVJ", + "type": "arrow" + }, + { + "id": "nPLTj6RnORhjgxXjSTxW0", + "type": "arrow" + }, + { + "id": "QOXEh2vb0eZXXuBAcHgwg", + "type": "arrow" + } + ], + "updated": 1717327111323, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 452, + "versionNonce": 1596872042, + "index": "a6", + "isDeleted": false, + "id": "b6v4NVE97suEtD9HhDi2T", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 733.530143737793, + "y": 274.5859375, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 67.67994689941406, + "height": 25, + "seed": 1659174672, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717327111323, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 1, + "text": "Waiting", + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "NKZ0uIMagigklnEtjc3s3", + "originalText": "Waiting", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 581, + "versionNonce": 179091728, + "index": "a7", + "isDeleted": false, + "id": "xqfYPqRcnDp05UOVTlMxf", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 908.478515625, + "y": 252.259765625, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 142.31640624999997, + "height": 69.65234374999999, + "seed": 1591232272, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "id": "2f4t12J8LQH0xwUYS77FC", + "type": "text" + }, + { + "id": "nPLTj6RnORhjgxXjSTxW0", + "type": "arrow" + }, + { + "id": "QOXEh2vb0eZXXuBAcHgwg", + "type": "arrow" + }, + { + "id": "k5LG12jvqXgndFgpUoS2b", + "type": "arrow" + } + ], + "updated": 1717326199226, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 439, + "versionNonce": 161291549, + "index": "a8", + "isDeleted": false, + "id": "2f4t12J8LQH0xwUYS77FC", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 948.166748046875, + "y": 274.5859375, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 62.93994140625, + "height": 25, + "seed": 945612048, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 1, + "text": "Writing", + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "xqfYPqRcnDp05UOVTlMxf", + "originalText": "Writing", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "rectangle", + "version": 1133, + "versionNonce": 1315119088, + "index": "a9", + "isDeleted": false, + "id": "m7QmFGTveWzi9VIZvFVcs", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 909.306640625, + "y": 399.998046875, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 142.31640624999997, + "height": 69.65234374999999, + "seed": 807172368, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 3 + }, + "boundElements": [ + { + "type": "text", + "id": "uaffz6bTtyx0z-tBEMxY0" + }, + { + "id": "DDA6cFu6wkdGgMNZSV276", + "type": "arrow" + }, + { + "id": "k5LG12jvqXgndFgpUoS2b", + "type": "arrow" + } + ], + "updated": 1717326199226, + "link": null, + "locked": false + }, + { + "type": "text", + "version": 1004, + "versionNonce": 1076137779, + "index": "aA", + "isDeleted": false, + "id": "uaffz6bTtyx0z-tBEMxY0", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 944.1448822021484, + "y": 422.32421875, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 72.63992309570312, + "height": 25, + "seed": 1984616208, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 20, + "fontFamily": 1, + "text": "Finished", + "textAlign": "center", + "verticalAlign": "middle", + "containerId": "m7QmFGTveWzi9VIZvFVcs", + "originalText": "Finished", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "arrow", + "version": 2347, + "versionNonce": 1481797802, + "index": "aB", + "isDeleted": false, + "id": "6SYQPXZRUBwo-cEPVyWVJ", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 771.4487321643501, + "y": 391.64843750000006, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 1.6184641715994985, + "height": 62.86328125000006, + "seed": 425489680, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1717327116522, + "link": null, + "locked": false, + "startBinding": { + "elementId": "epulSIoCC1vPtYjPlCe1q", + "focus": 0.04216953314195054, + "gap": 8.816406249999943 + }, + "endBinding": { + "elementId": "NKZ0uIMagigklnEtjc3s3", + "focus": -0.0939653598473043, + "gap": 6.873046875 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 1.6184641715994985, + -62.86328125000006 + ] + ] + }, + { + "type": "arrow", + "version": 2030, + "versionNonce": 411661046, + "index": "aC", + "isDeleted": false, + "id": "nPLTj6RnORhjgxXjSTxW0", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 848.0882304370406, + "y": 299.7429779047519, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 52.691406249999886, + "height": 0.6135564653106371, + "seed": 1205954032, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1717327090563, + "link": null, + "locked": false, + "startBinding": { + "elementId": "NKZ0uIMagigklnEtjc3s3", + "focus": 0.313917619027378, + "gap": 9.871433562040579 + }, + "endBinding": { + "elementId": "xqfYPqRcnDp05UOVTlMxf", + "focus": -0.39795063824516524, + "gap": 7.698878937959535 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 52.691406249999886, + 0.6135564653106371 + ] + ] + }, + { + "type": "arrow", + "version": 116, + "versionNonce": 1924509046, + "index": "aH", + "isDeleted": false, + "id": "QOXEh2vb0eZXXuBAcHgwg", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 901.31640625, + "y": 278.28319529493, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 56.92578125, + "height": 0.4251022169158887, + "seed": 275456272, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1717327090563, + "link": null, + "locked": false, + "startBinding": { + "elementId": "xqfYPqRcnDp05UOVTlMxf", + "focus": 0.23960015222859515, + "gap": 7.162109375 + }, + "endBinding": { + "elementId": "NKZ0uIMagigklnEtjc3s3", + "focus": -0.2892509947778386, + "gap": 6.173828125 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + -56.92578125, + -0.4251022169158887 + ] + ] + }, + { + "type": "arrow", + "version": 388, + "versionNonce": 301583914, + "index": "aK", + "isDeleted": false, + "id": "DDA6cFu6wkdGgMNZSV276", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 900.29296875, + "y": 437.01953125, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 57.2685546875, + "height": 2.2480878217788813, + "seed": 1725362448, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1717327116523, + "link": null, + "locked": false, + "startBinding": { + "elementId": "m7QmFGTveWzi9VIZvFVcs", + "focus": 0.02951780935424522, + "gap": 9.013671875 + }, + "endBinding": { + "elementId": "epulSIoCC1vPtYjPlCe1q", + "focus": 0.18464963473437795, + "gap": 4.49609375 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + -57.2685546875, + 2.2480878217788813 + ] + ] + }, + { + "type": "arrow", + "version": 372, + "versionNonce": 152630256, + "index": "aL", + "isDeleted": false, + "id": "k5LG12jvqXgndFgpUoS2b", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0, + "x": 979.846047681619, + "y": 329.9375, + "strokeColor": "#1e1e1e", + "backgroundColor": "transparent", + "width": 0.8029423709931507, + "height": 62.30468750000006, + "seed": 696608528, + "groupIds": [], + "frameId": null, + "roundness": { + "type": 2 + }, + "boundElements": [], + "updated": 1717326199227, + "link": null, + "locked": false, + "startBinding": { + "elementId": "xqfYPqRcnDp05UOVTlMxf", + "focus": 0.004785446061897425, + "gap": 8.025390625 + }, + "endBinding": { + "elementId": "m7QmFGTveWzi9VIZvFVcs", + "focus": 0.010235251786823427, + "gap": 7.755859375 + }, + "lastCommittedPoint": null, + "startArrowhead": null, + "endArrowhead": "arrow", + "points": [ + [ + 0, + 0 + ], + [ + 0.8029423709931507, + 62.30468750000006 + ] + ] + }, + { + "type": "text", + "version": 1573, + "versionNonce": 764768637, + "index": "aM", + "isDeleted": false, + "id": "-8q-dYD0wP5DxAjCAcbCS", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 706.7638201194676, + "y": 365.66400348069556, + "strokeColor": "#2f9e44", + "backgroundColor": "transparent", + "width": 54.010345458984375, + "height": 22.631854058661062, + "seed": 858468112, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 18.10548324692885, + "fontFamily": 1, + "text": "Step 1", + "textAlign": "left", + "verticalAlign": "middle", + "containerId": null, + "originalText": "Step 1", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "text", + "version": 1835, + "versionNonce": 902967507, + "index": "aN", + "isDeleted": false, + "id": "-vIATp9izjRm8BjrWm0zk", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 841.8970707554577, + "y": 312.876425323048, + "strokeColor": "#1971c2", + "backgroundColor": "transparent", + "width": 61.99244689941406, + "height": 22.631854058661062, + "seed": 181919728, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 18.10548324692885, + "fontFamily": 1, + "text": "Step 2", + "textAlign": "left", + "verticalAlign": "middle", + "containerId": null, + "originalText": "Step 2", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "text", + "version": 1905, + "versionNonce": 1816410589, + "index": "aO", + "isDeleted": false, + "id": "EckU6k65gQkk9pqa9d-6r", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 842.894408598354, + "y": 242.37739685544787, + "strokeColor": "#1971c2", + "backgroundColor": "transparent", + "width": 61.43135070800781, + "height": 22.631854058661062, + "seed": 1777150960, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 18.10548324692885, + "fontFamily": 1, + "text": "Step 3", + "textAlign": "left", + "verticalAlign": "middle", + "containerId": null, + "originalText": "Step 3", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "text", + "version": 1922, + "versionNonce": 345677427, + "index": "aP", + "isDeleted": false, + "id": "o4dN4OmTFDyWOtKKhxZ-G", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 995.2694179199954, + "y": 367.2224229979561, + "strokeColor": "#2f9e44", + "backgroundColor": "transparent", + "width": 60.68925476074219, + "height": 22.631854058661062, + "seed": 948653328, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 18.10548324692885, + "fontFamily": 1, + "text": "Step 4", + "textAlign": "left", + "verticalAlign": "middle", + "containerId": null, + "originalText": "Step 4", + "autoResize": true, + "lineHeight": 1.25 + }, + { + "type": "text", + "version": 2057, + "versionNonce": 247133757, + "index": "aQ", + "isDeleted": false, + "id": "5XjgKdRkSAq7e4kxTKU6H", + "fillStyle": "cross-hatch", + "strokeWidth": 2, + "strokeStyle": "solid", + "roughness": 1, + "opacity": 100, + "angle": 0.0070883812980024885, + "x": 844.4959854219873, + "y": 401.5256991825139, + "strokeColor": "#e03131", + "backgroundColor": "transparent", + "width": 60.291046142578125, + "height": 22.631854058661062, + "seed": 1460783088, + "groupIds": [], + "frameId": null, + "roundness": null, + "boundElements": [], + "updated": 1717326266102, + "link": null, + "locked": false, + "fontSize": 18.10548324692885, + "fontFamily": 1, + "text": "Step 5", + "textAlign": "left", + "verticalAlign": "middle", + "containerId": null, + "originalText": "Step 5", + "autoResize": true, + "lineHeight": 1.25 + } + ], + "appState": { + "gridSize": null, + "viewBackgroundColor": "#ffffff" + }, + "files": {} +} \ No newline at end of file diff --git a/public/assets/data-management-on-zns-ssd/group-state.png b/public/assets/data-management-on-zns-ssd/group-state.png new file mode 100644 index 0000000..b770059 Binary files /dev/null and b/public/assets/data-management-on-zns-ssd/group-state.png differ diff --git a/src/content/blog/storage/data-management-on-zns-ssd.md b/src/content/blog/storage/data-management-on-zns-ssd.md new file mode 100644 index 0000000..c7364fd --- /dev/null +++ b/src/content/blog/storage/data-management-on-zns-ssd.md @@ -0,0 +1,97 @@ +--- +author: Chongzhuo Yang +title: Designing a High-Performance Management Layer for ZNS SSDs +pubDatetime: 2024-05-31 15:25:07 +tags: + - storage +slug: "data-management-on-zns-ssd" +description: A guide to designing a high-performance management layer for data I/O, data mapping, and garbage collection on ZNS SSDs. +--- + +## Zone Interface + +There are requirements of writing data to zones of ZNS SSDs. + +1. Data can only be written at the write pointer. +2. Write pointer can be increased and reset by `append` and `reset`. +3. There is the limitation of maxinum number of open and active zones. + +> A closed zone is not a open zone but it is still an active zone. The `finish` can used to make zones inactive. + +## I/O Control + +For data writes, we should ensure that: 1. One zone should be written only by one thread at the same time; 2. The number of active zones should be limited. + +### Zone Group + +We can use the status management to control the writing behavior and align with the limitation of max active zones. The zone status can be divided into four different groups: **free group**, **waiting group**, **writing group**, **finished group**. + +group-state + +group-state + +Initially, all zones are assigned to the free group. If the storage engine cannot find a zone in writing group, it will transfer one zone from the free group to the waiting group (step 1). If a suitable zone is available, it will be moved to the writing group (step 2). Following the write operation, the zone can either remain in the waiting group (step 3) for additional writes or be transferred to the finished group (step 4) to reduce the number of active zones. When the storage nears capacity, the garbage collection (GC) can selectively reclaim zones from the finished group to provide more free zones (step 5). + +### Data Mapping + +Unlike regular SSDs, the data mapping between logical addresses and zone addresses should be maintained by the client. Therefore, applications can access data using logical addresses. The mapping can be designed in various ways to cater to different data layout requirements. + +In this guide, we use the simplest data layout, where all data units have the same size. + +### Parallel Control + +One thread can allocate a zone in the waiting group for exclusive writing. After that, the zone will be transfered into the writing group and further writes of the zone do not need locks. The states of the zone group are controlled using a mutex lock (called `#group-lock`). The number of active/open zones can be controlled in steps 1 and 4 using an simple counter. + +The mapping will be updated after writing data and accessed before reading data. Therefore, a mutex lock is also needed for mapping (called `#mapping-lock`). + +To avoid deadlock, we should pay attention to the lock order of `#group-lock` and `#mapping-lock`. + +## Garbage Collection + +The zones in the finished group can be selected to reclaim invalid space resulting from data updates and deletions. The victim selection policy is an important design in ZNS SSDs. After selecting the victim zone, we will move valid data from the victim zone to the special GC zone reserved for the GC process. + +The victim zone's mapping may also be updated when moving its data. We ignore these updates during data copying, which may move more data but results in a simpler and more efficient GC design. After moving the data, we will check and update the mapping correctly. If the data moved is marked as invalid (by updates or deletes) during moving, we just abort the mapping upades. Otherwise, we will update the mapping with the new data offset. + +After moving all valid data, the victim zone should be reset and moved to the free group. However, since applications may still be reading from the victim zone, we need to introduce a new shared lock, `#read-lock`, to delay the reset operation. + +For delete, after we moved the data and want to update the mapping. we check the mapping whether the data is updated. If the data is updated, we abort the updating. If not, we update the moved offset. + +## Control Flow + +### Read + +1. lock `#mapping-lock`. +2. get zone offset from mapping. +3. lock `#read-lock`. +4. unlock `#mapping-lock`. +5. read data from zone. +6. unlock `#read-lock`. + +### Write + +1. lock `#group-lock`. +2. allocate zone for writing. +3. unlock `#group-lock`. +4. write data to zone. +5. lock `#group-lock` and `#mapping-lock`. +6. update mapping and group states. +7. unlock `#group-lock` and `#mapping-lock`. + +### Garbage Collection + +1. lock `#group-lock`. +2. find a victim zone for reclaiming. +3. lock `#mapping-lock`. +4. read offsets of valid data. +5. unlock `#group-lock` and `#mapping-lock`. +6. move data in victim zone. +7. lock `#mapping-lock`. +8. update mapping. +9. unlock `#mapping-lock`. +10. repeat 6-9 until all data is moved. +11. lock `#group-lock` and `#mapping-lock`. +12. lock `#read-lock`. +13. reset victim zone. +14. unlock `#read-lock`. +15. update group states. +16. unlock `#group-lock` and `#mapping-lock`. diff --git a/src/styles/base.css b/src/styles/base.css index 6efa219..935580b 100644 --- a/src/styles/base.css +++ b/src/styles/base.css @@ -28,6 +28,13 @@ html[data-theme="dark"] #sun-svg { display: block; } + [data-theme='light'] .d-block-light, + [data-theme='dark'] .d-block-dark { + display: block !important; + } + .d-block-hidden { + display: none; + } body { @apply flex min-h-[100svh] flex-col bg-skin-fill font-mono text-skin-base selection:bg-skin-accent selection:bg-opacity-70 selection:text-skin-inverted;