{"id":2067,"date":"2019-01-10T01:13:17","date_gmt":"2019-01-10T01:13:17","guid":{"rendered":""},"modified":"2019-01-10T09:13:49","modified_gmt":"2019-01-10T01:13:49","slug":"%e4%b8%80%e7%a7%8d%e8%a2%ab%e7%a7%b0%e4%b8%babarrier-enabled+io+stack%e7%9a%84%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2067","title":{"rendered":"\u4e00\u79cd\u88ab\u79f0\u4e3aBarrier-enabled IO stack\u7684\u65b9\u6848"},"content":{"rendered":"

\n\t\u672c\u671f\u548c\u5927\u5bb6\u804a\u7684\u662f\u521a\u521a\u57282\u6708\u4efd\u62ff\u5230FAST 2018\u6700\u4f73\u8bba\u6587\u5956\u7684\u4e00\u7bc7\u6587\u7ae0\u3002\u5b83\u8ba8\u8bba\u4e86\u5b9e\u73b0\u4e00\u79cd\u652f\u6301\u4fdd\u5e8fIO\u64cd\u4f5c\u7684\u8bbe\u5907\u4f1a\u5e26\u6765\u54ea\u4e9b\u597d\u5904\uff0c\u76ee\u524d\u7684Linux<\/u>\u5185\u6838\u91cc\u5904\u7406FLUSH\u3001FUA\u7684\u65b9\u5f0f\u53ef\u4ee5\u53c2\u89c1 https:\/\/lwn.net\/Arti<\/u>cles\/400541\/ <\/p>\n

\n\t\u4f5c\u8005<\/p>\n

\n\t <\/div>\n

\n\t\u6731\u5ef6\u6d77\uff0cLinux\u7cfb\u7edf\u5de5\u7a0b\u5e08\uff0c\u6765\u81ea\u963f\u91cc\u4e91\u7cfb\u7edf\u7ec4\u3002<\/p>\n

\n\t\u963f\u91cc\u4e91\u7cfb\u7edf\u56e2\u961f\uff0c\u662f\u7531\u539f\u6dd8\u5b9d\u5185\u6838\u7ec4\u6269\u5efa\u800c\u6210\uff0c2013\u5e74\u6dd8\u5b9d\u5185\u6838\u7ec4\u54cd\u5e94\u963f\u91cc\u5df4\u5df4\u96c6\u56e2\u7684\u53f7\u53ec\uff0c\u6574\u5efa\u5236\u8f6c\u5165\u963f\u91cc\u4e91\uff0c\u5f00\u59cb\u4e3a\u4e91\u8ba1\u7b97\u5e95\u5c42\u7cfb\u7edf\u6784\u5efa\u5b8c\u5584\u7684\u7cfb\u7edf\u652f\u6301\u3002 \u963f\u91cc\u4e91\u7cfb\u7edf\u56e2\u961f\u662f\u7531\u4e00\u7fa4\u5177\u6709\u9ad8\u5ea6\u4f7f\u547d\u611f\u548c\u81ea\u6211\u8ffd\u6c42\u7684\u5185\u6838\u5f00\u53d1\u4eba\u5458\u7ec4\u6210\uff0c\u56e2\u961f\u4e2d\u7684\u5927\u591a\u6570\u4eba\uff0c\u90fd\u662f\u6d3b\u8dc3\u7684\u793e\u533a\u5185\u6838\u5f00\u53d1\u4eba\u5458\u3002\u76ee\u524d\u7684\u5de5\u4f5c\u9886\u57df\u4e3b\u8981\u6d89\u53ca\uff08\u4f46\u4e0d\u9650\u4e8e\uff09 Linux\u5185\u6838\u7684\u5185\u5b58\u7ba1\u7406\u3001\u6587\u4ef6\u7cfb\u7edf\u3001\u7f51\u7edc\u548c\u5185\u6838\u7ef4\u62a4\u6784\u5efa\uff0c\u4ee5\u53ca\u548c\u5185\u6838\u76f8\u5173\u8054\u7684\u7528\u6237\u6001\u5e93\u548c\u5de5\u5177\u3002\u5982\u679c\u4f60\u5bf9\u6211\u4eec\u7684\u5de5\u4f5c\u5f88\u611f\u5174\u8da3\uff0c\u6b22\u8fce\u52a0\u5165\u6211\u4eec\uff0c\u8bf7\u5c06\u7b80\u5386\u53d1\u9001\u81f3 tao.ma at linux.alibaba.com\u6216\u8005 boyu.mt at alibaba-inc.com\u3002<\/p>\n

\n\t\u6982\u8ff0<\/p>\n

\n\t\u73b0\u4ee3\u9ad8\u901fFlash\u8bbe\u5907\u7684\u6027\u80fd\u8bc0\u7a8d\u5728\u4e8e\u5145\u5206\u63d0\u9ad8\u8bf7\u6c42\u5904\u7406\u7684\u5e76\u884c\u5ea6\uff08scale-out\uff09\uff0c\u800c\u5e76\u975e\u65e0\u9650\u5730\u964d\u4f4e\u5176\u5ef6\u8fdf\uff08scale-up\uff09—\u4f8b\u5982\uff0c\u4f7f\u7528\u591a\u901a\u9053\u63a7\u5236\u5668\uff08multi-channel controllers<\/u>\uff09\u3001\u66f4\u5927\u7684\u7f13\u5b58\u4ee5\u53ca\u66f4\u6df1\u7684\u547d\u4ee4\u961f\u5217\uff0c\u8fd9\u4e9b\u90fd\u662f\u7528\u6765\u63d0\u9ad8\u5e76\u884c\u5ea6\u7684\u6709\u6548\u529e\u6cd5\u3002\u540c\u65f6\uff0c\u5199\u4e00\u4e2aflash cell\u6240\u9700\u8981\u7684\u65f6\u95f4\u4e00\u76f4\u6ca1\u6709\u4ec0\u4e48\u53d8\u5316\uff0c\u8fd1\u6765\u751a\u81f3\u6709\u53d8\u5dee\u7684\u8d8b\u52bf\u3002\u5728\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\uff0c\u7528\u6237\u5bf9\u6b64\u5e76\u4e0d\u5728\u610f\uff0c\u4e5f\u611f\u89c9\u4e0d\u5230—\u9664\u975e\u4f60\u7684\u5e94\u7528\u5e0c\u671b\u5b83\u53d1\u51fa\u7684\u4e00\u7cfb\u5217\u8bf7\u6c42\u662f\u4fdd\u5e8f\u7684\uff08guarante<\/u>e ordering\uff09\uff0c\u8fd9\u4e5f\u5c31\u662f\u672c\u6587\u6240\u8981\u91cd\u70b9\u8ba8\u8bba\u7684\u95ee\u9898\uff1a<\/p>\n

\n\t“\u5728\u76ee\u524d\u7684\u8bbe\u5907\u4e0a\uff0c\u4e3a\u8bf7\u6c42\u4fdd\u5e8f\u662f\u901a\u8fc7\u4e00\u79cd\u4ee3\u4ef7\u5f88\u9ad8\u7684\u529e\u6cd5\u6765\u5b9e\u73b0\u7684\uff1a\u628a\u6392\u5728\u8bf7\u6c42X\u524d\u8fb9\u7684\u6240\u6709\u8bf7\u6c42\u90fd\u53d1\u51fa\u53bb\uff0c\u7136\u540e\u7b49\u5f85\u5b83\u4eec\u5168\u90e8\u5b8c\u6210\u3001\u6301\u4e45\u5316\u5e76\u8fd4\u56de\uff0c\u7136\u540e\u624d\u53d1\u5c04\u8bf7\u6c42X\uff0c\u8fd9\u65f6\u6211\u4eec\u5c31\u53ef\u4ee5\u8bf4X\u524d\u8fb9\u7684\u8bf7\u6c42\u548cX\u4e4b\u95f4\u5efa\u7acb\u4e86\u660e\u786e\u7684\u5148\u540e\u987a\u5e8f\u5173\u7cfb\u3002\u6211\u4eec\u628a\u8fd9\u79cd\u673a\u5236\u53eb\u505aTransfer-and-Flush\u3002”<\/p>\n

\n\t\u663e\u800c\u6613\u89c1\uff0c\u5f53\u4f60\u4f7f\u7528Transfer-and-Flush\u673a\u5236\u65f6\uff0c\u8bbe\u5907\u7684\u5e76\u884c\u5ea6\u4f1a\u5927\u5927\u964d\u4f4e\uff0c\u56e0\u6b64\u5e26\u6765\u6700\u7ec8\u6027\u80fd\u7684\u964d\u4f4e\uff0c\u8bbe\u5907\u8d8a\u662f\u4f9d\u8d56\u9ad8\u5e76\u884c\u5ea6\u6765\u652b\u53d6\u6027\u80fd\uff0c\u8fd9\u79cd\u505a\u6cd5\u5c31\u8d8a\u662f\u4ee4\u4eba\u65e0\u6cd5\u63a5\u53d7\u3002\u4f8b\u5982\uff0c\u5728\u4e00\u4e2a\u667a\u80fd\u624b\u673a\u7684\u5355\u901a\u9053SSD\u4e0a\uff0c\u4fdd\u5e8f\u5199\u8bf7\u6c42\u7684IOPS\u662f\u65e0\u5e8f\u5199\u8bf7\u6c42\u768420%\uff0c\u5bf9\u4e8e32\u901a\u9053SSD\uff0c\u8fd9\u4e00\u6bd4\u4f8b\u964d\u4f4e\u81f31%\u3002\u5728\u76ee\u524d\u7684Linux\u5185\u6838\u4e2d\uff0c\u6587\u4ef6\u7cfb\u7edf\u82e5\u771f\u7684\u60f3\u6267\u884c\u4e00\u7cfb\u5217\u4fdd\u5e8f\u8bf7\u6c42\uff0c\u4f7f\u7528\u7684\u673a\u5236\u4e5f\u662fTransfer-and-Flush\u3002\u7136\u800c\uff0c\u901a\u8fc7Transfer-and-Flush\u6765\u4fdd\u5e8f\u663e\u7136\u6740\u4f24\u529b\u8fc7\u5927\u4e86\uff1a\u9996\u5148\uff0c\u4e5f\u8bb8\u6587\u4ef6\u7cfb\u7edf\u539f\u672c\u53ea\u60f3\u8ba9\u4e24\u4e2a\u5355\u4e2a\u8bf7\u6c42\u4e4b\u95f4\u662f\u6709\u5e8f\u7684\uff0c\u4f46\u5374\u4e0d\u5f97\u4e0d\u4f7f\u5f97\u7531flush\u5206\u9694\u7684\u4e24\u7ec4\u64cd\u4f5c\u96c6\u5408\u4e4b\u95f4\u53d8\u5f97\u6709\u5e8f\uff0c\u800c\u8fd9\u6bcf\u4e00\u4e2a\u96c6\u5408\u91cc\u90fd\u53ef\u80fd\u5305\u542b\u4e86\u5927\u91cf\u4e0d\u9700\u8981\u4fdd\u5e8f\u7684\u8bf7\u6c42\uff1b\u5176\u6b21\uff0c\u8fd9\u4e48\u505a\u4e0d\u4ec5\u5b9e\u73b0\u4e86\u4fdd\u5e8f\uff0c\u540c\u65f6\u8fd8\u63d0\u4f9b\u4e86\u540c\u6b65\u7684\u6301\u4e45\u5316\u4fdd\u8bc1\uff0c\u8fd9\u5e76\u4e0d\u662f\u4fdd\u5e8f\u60f3\u8981\u7684—\u5f53\u4e00\u4e2a\u4e0a\u5c42\u5e94\u7528\u53d1\u51fa\u4e24\u4e2a\u4fdd\u5e8f\u7684\u8bf7\u6c42A1\u548cA2\u65f6\uff0c\u5b83\u5bf9\u4e8eA1\u548cA2\u5177\u4f53\u4f55\u65f6\u88ab\u6301\u4e45\u5316\u5e76\u6ca1\u6709\u4ec0\u4e48\u671f\u5f85\uff0c\u53ef\u4ee5\u662f\u5f02\u6b65\u7684\uff0c\u5b83\u552f\u4e00\u7684\u8981\u6c42\u662f\u4e00\u4f46\u6301\u4e45\u5316\u52a8\u4f5c\u5f00\u59cb\uff0cA1\u7684\u6301\u4e45\u5316\u5fc5\u987b\u53d1\u751f\u5728A2\u4e4b\u524d\u3002<\/p>\n

\n\t\u672c\u6587\u7684\u4f5c\u8005\u63d0\u51fa\u4e86\u4e00\u79cd\u88ab\u79f0\u4e3aBarrier-enabled IO stack\u7684\u65b9\u6848\uff0c\u8fd9\u4e00\u65b9\u6848\u4e0d\u4f9d\u8d56Transfer-and-Flush\uff0c\u6587\u4ef6\u7cfb\u7edf\u4e5f\u5c31\u65e0\u9700\u505c\u4e0b\u6765\u7b49\u5f85\u524d\u8fb9\u7684\u8bf7\u6c42\u6210\u529f\u8fd4\u56de\u3002\u8fd9\u4e00\u65b9\u6848\u5f97\u5230\u7684\u6027\u80fd\u63d0\u5347\u76f8\u5f53\u60ca\u4eba\uff1a<\/p>\n

\n\t“SQlite\u670d\u52a1\u5668\u573a\u666f\u6027\u80fd\u63d0\u5347270%\uff0c\u624b\u673a\u573a\u666f\u6027\u80fd\u63d0\u534775%\uff1b\u5b9e\u73b0\u4e86Barrier-enabled IO stack\u7684BarrierFS\u5728MySQL\u573a\u666f\u6027\u80fd\u6307\u6807\u662fEXT4\u768443\u500d\uff0c\u5728SQLite\u573a\u666f\u6027\u80fd\u6307\u6807\u662fEXT4\u768473\u500d”<\/p>\n

\n\t\u4e0b\u8fb9\u6211\u4eec\u6765\u4ecb\u7ecd\u4e0b\u4f5c\u8005\u7684\u65b9\u6848<\/p>\n

\n\t<\/p>\n

\n\t\u6211\u4eec\u77e5\u9053\uff0c\u73b0\u4ee3IO stack\u5929\u751f\u5c31\u662f\u4e71\u5e8f\u7684\u3002\u8bd5\u60f3\u6587\u4ef6\u7cfb\u7edf\u53d1\u5c04\u51fa\u6765\u7684\u4e00\u7c07\u8bf7\u6c42\u5728\u4e0b\u8fb9\u7684\u8def\u5f84\u91cc\u4f1a\u7ecf\u5386\u4e9b\u4ec0\u4e48\uff1a<\/p>\n

\n\tIO\u8c03\u5ea6\u5668\u4f1a\u5bf9\u8bf7\u6c42\u91cd\u6392\u5217\uff0c\u8fd8\u6709\u53ef\u80fd\u5408\u5e76\u8bf7\u6c42<\/p>\n

\n\t\u8bbe\u5907\u4e0a\u7684\u63a7\u5236\u5668\u6536\u5230\u8bf7\u6c42\u540e\u653e\u5230\u81ea\u5df1\u5185\u90e8\u7684\u547d\u4ee4\u961f\u5217\u91cc\uff0c\u8fd9\u65f6\u5b83\u4e5f\u53ef\u4ee5\u968f\u610f\u6539\u53d8\u8bf7\u6c42\u987a\u5e8f\u3002\u8bbe\u5907\u5185\u90e8\u7684\u9519\u8bef\u3001\u8d85\u65f6\u3001\u91cd\u4f20\u7b49\u7b49\u4e5f\u90fd\u6709\u53ef\u80fd\u5bf9\u8bf7\u6c42\u5b9e\u9645\u6267\u884c\u7684\u987a\u5e8f\u4ea7\u751f\u5f71\u54cd<\/p>\n

\n\t\u73b0\u4ee3\u8bbe\u5907\u5185\u90e8\u901a\u5e38\u4e5f\u50cf\u6587\u4ef6\u7cfb\u7edf\u4e00\u6837\uff0c\u6709\u6570\u636e\u5757\u548c\u5143\u6570\u636e\u5757\uff0c\u6709\u81ea\u5df1\u7684journal\u3002\u8bf7\u6c42\u62b5\u8fbe\u5b58\u50a8\u8bbe\u5907\u5185\u90e8\u4e4b\u540e\uff0c\u6700\u7ec8\u5bf9\u7528\u6237\u53ef\u89c1\u3001\u5bf9\u7528\u6237\u6709\u610f\u4e49\u7684\u6301\u4e45\u5316“\u987a\u5e8f”\u4e0d\u5149\u662f\u7531\u6570\u636e\u5757\u7684\u6301\u4e45\u5316\u987a\u5e8f\u51b3\u5b9a\uff0c\u540c\u65f6\u4e5f\u53d7\u90a3\u4e9b\u5143\u6570\u636e\u7684\u6301\u4e45\u5316\u987a\u5e8f\u5f71\u54cd\uff0c\u800c\u8fd9\u4e24\u8005\u5e76\u4e0d\u4e00\u5b9a\u662f\u76f8\u540c\u7684\u3002<\/p>\n

\n\t\u56e0\u6b64\uff0c\u591a\u6570\u64cd\u4f5c\u7cfb\u7edf\u7684IO stack\u90fd\u5305\u542b\u4e86\u4e00\u4e2a\u4ece\u786c\u76d8\u65f6\u4ee3\u6d41\u4f20\u4e0b\u6765\u7684\u8bbe\u8ba1\u5047\u8bbe\uff1a\u4e0a\u4f4d\u673a\u4e0d\u80fd\u63a7\u5236\u6301\u4e45\u5316\u987a\u5e8f<\/p>\n

\n\t“\u73b0\u4ee3IO stack\u8bbe\u8ba1\u4e2d\u7684\u4e00\u4e2a\u57fa\u672c\u5047\u8bbe\u5c31\u662f\u4e0a\u4f4d\u673a\u4e0d\u80fd\u771f\u6b63\u5730\u63a7\u5236\u5230\u6570\u636e\u7684\u6301\u4e45\u5316\u987a\u5e8f”<\/p>\n

\n\t\u56e0\u6b64\uff0c\u4e00\u4f46\u4e0a\u4f4d\u673a\u786e\u5b9e\u9700\u8981\u63a7\u5236\u6301\u4e45\u5316\u987a\u5e8f\u65f6\uff0c\u5c31\u53ea\u80fd\u4f7f\u7528\u6602\u8d35\u7684Transfer-and-Flush\u673a\u5236\u4e86\uff1a\u5982\u679c\u8bf7\u6c42a\u9700\u8981\u6392\u5728\u8bf7\u6c42b\u4e4b\u524d\u5b8c\u6210\uff0c\u90a3\u4e48\u628a\u8bf7\u6c42a\u53d1\u5230\u5b58\u50a8\u8bbe\u5907\u4e4b\u540e\uff0c\u4e0a\u4f4d\u673a\u5c31\u9996\u5148\u9700\u8981\u7b49\u8bbe\u5907\u62a5\u544aa\u5f7b\u5e95\u5b8c\u6210\uff0c\u7136\u540e\u53d1\u4e00\u4e2aflush\u547d\u4ee4\u5e76\u7b49\u5f85flush\u5b8c\u6210\uff08\u4ee5\u9632\u8bbe\u5907\u4e0a\u7684cache\u9020\u6210\u4e71\u5e8f\uff09\uff0c\u7136\u540e\u624d\u53d1\u8bf7\u6c42b\u3002<\/p>\n

\n\t\u4ee5EXT4\u7684\u9ed8\u8ba4\u5de5\u4f5c\u6a21\u5f0fOrdered\u6a21\u5f0f\u4e3a\u4f8b\uff0c\u5f53\u5b83\u63d0\u4ea4\u4e00\u4e2ajournal transaction\u65f6\uff0c\u5b83\u9700\u8981\u6267\u884c\u4e24\u6b21\u5199\uff1a\u7b2c\u4e00\u6b21\u5199journal descriptor\u548clog blocks\uff08JD\uff09\uff0c\u7b2c\u4e8c\u6b21\u5199commit block\uff08JC\uff09\u3002JD\u5fc5\u987b\u5148\u4e8eJC\u5b8c\u6210\u6301\u4e45\u5316\u3002\u5728transaction\u7684\u5c42\u9762\u4e0a\u770b\uff0c\u5404\u4e2atransaction\u4e4b\u95f4\u4e5f\u5fc5\u987b\u662f\u6709\u5e8f\u7684\uff0c\u6392\u5728\u524d\u8fb9\u7684transaction\u4e00\u5b9a\u8981\u6bd4\u6392\u5728\u540e\u8fb9\u7684transaction\u5148\u5b8c\u6210\u6301\u4e45\u5316\uff0c\u5426\u5219\u6587\u4ef6\u7cfb\u7edf\u6267\u884c\u6545\u969c\u6062\u590d\u65f6\u5c31\u6709\u5d29\u6e83\u7684\u53ef\u80fd\u3002 \u4e3a\u4e86\u628a\u4fdd\u5e8f\u8bed\u4e49\u5f15\u5165IO stack\uff0c\u4f5c\u8005\u663e\u7136\u9700\u8981\u81ea\u5e95\u5411\u4e0a\u628a\u8fd9\u4e2a\u8bed\u4e49\u8d2f\u7a7f\u5230\u6574\u4e2aIO stack\u4e2d\u53bb\u3002\u4e0b\u8fb9\u5177\u4f53\u4ecb\u7ecd\u4e00\u4e0b\u4f5c\u8005\u7684\u5de5\u4f5c\u3002<\/p>\n

\n\t\u5e26barrier\u7684\u4fdd\u5e8f\u5757\u8bbe\u5907<\/p>\n

\n\t“\u7ed9\u8bbe\u5907\u52a0\u5165barrier\u6307\u4ee4\u652f\u6301\u540e\uff0c\u4e0a\u4f4d\u673a\u5c31\u4e0d\u518d\u9700\u8981\u901a\u8fc7\u663e\u5f0f\u5730\u5237cache\u6765\u4fdd\u8bc1\u8bf7\u6c42\u987a\u5e8f\u4e86\u3002\u5f53\u8bbe\u5907\u6536\u5230barrier\u6307\u4ee4\u65f6\uff0c\u5b83\u4f1a\u786e\u4fdd\u6392\u5728barrier\u524d\u7684\u6240\u6709\u6307\u4ee4—\u53ef\u80fd\u662f\u5199\u4e5f\u53ef\u80fd\u662f\u8bfb—\u90fd\u6267\u884c\u5b8c\u6bd5\u3001\u5b8c\u6210\u6570\u636e\u4f20\u8f93\u540e\uff0c\u624d\u5f00\u59cb\u6267\u884c\u6392\u5728barrier\u540e\u8fb9\u7684\u6307\u4ee4\u3002”<\/p>\n

\n\t\u8bba\u6587\u7684\u4f5c\u8005\u628a\u4ed6\u63d0\u51fa\u7684\u8fd9\u79cdbarrier\u5b9e\u73b0\u6210\u4e86SCSI<\/u>\u547d\u4ee4\u7684\u4e00\u4e2a\u9644\u52a0\u5c5e\u6027\uff0c\u800c\u4e0d\u662f\u4e00\u6761\u72ec\u7acb\u7684SCSI\u547d\u4ee4\u3002\u8bbe\u5907\u5177\u4f53\u5b9e\u73b0barrier\u652f\u6301\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff0c\u5bf9\u4e8e\u672c\u8eab\u5df2\u7ecf\u5e26\u6709\u4e00\u4e2a\u5927\u7535\u5bb9<\/u>\uff0c\u5199\u64cd\u4f5c\u8fd4\u56de\u65f6\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u6301\u4e45\u5316\u7684\u90a3\u4e9b\u8bbe\u5907\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u5b83\u4eec\u5929\u751f\u5bf9\u4e8e\u6536\u5230\u7684\u5199\u8bf7\u6c42\u5c31\u662f\u4fdd\u5e8f\u7684\uff0c\u56e0\u6b64\u53ea\u8981\u5728\u8bbe\u5907\u4e0a\u8fb9\u7684\u5404\u4e2a\u5c42\u6b21\u80fd\u591f\u4fdd\u8bc1\u63d0\u4ea4\u987a\u5e8f\uff0c\u6574\u6761\u94fe\u8def\u5c31\u76f4\u63a5\u53ef\u4ee5\u505a\u51fa\u4fdd\u5e8f\u7684\u627f\u8bfa\uff0c\u56e0\u6b64\u5bf9\u4e8e\u8fd9\u4e9b\u8bbe\u5907\u6ca1\u4ec0\u4e48\u9700\u8981\u4fee\u6539\u7684\u3002\u5bf9\u4e8e\u5176\u4ed6\u8bbe\u5907\uff0c\u5728\u8bbe\u5907\u5185\u90e8\u5b9e\u73b0\u4fdd\u5e8f\u5176\u5b9e\u548c\u4e4b\u524d\u5728\u6574\u4e2aIO stack\u4e0a\u5b9e\u73b0\u4fdd\u5e8f\u7684\u903b\u8f91\u57fa\u672c\u662f\u4e00\u6837\u7684\uff0c\u8981\u4e48\u786e\u4fddwriteback cache\u6309\u987a\u5e8f\u56de\u5199\u3001\u8981\u4e48\u5728\u56de\u5199\u65f6\u5f15\u5165\u4e8b\u52a1\u673a\u5236\u3001\u8981\u4e48\u5b9e\u73b0\u6309\u987a\u5e8frecovery\u3002\u8bba\u6587\u5bf9\u4e8e\u5177\u4f53\u5982\u4f55\u5b9e\u73b0\u8fd9\u79cd\u5e26barrier\u652f\u6301\u7684\u5b58\u50a8\u8bbe\u5907\u4e00\u7b14\u5e26\u8fc7\uff0c\u5e76\u8868\u793a\u8fd9\u4e0d\u662f\u91cd\u70b9\uff0c\u4f5c\u8005\u8ba4\u4e3a\u8bba\u6587\u7684\u91cd\u70b9\u5728\u4e8e\u8bf4\u660e\u4e00\u4f46\u62e5\u6709\u6b64\u79cd\u8bbe\u5907\u4f1a\u5e26\u6765\u591a\u5927\u597d\u5904\uff0c\u81f3\u4e8e\u5982\u4f55\u5b9e\u73b0\u8fd9\u79cd\u8bbe\u5907\u90a3\u662f\u7eaf\u7cb9\u7684engineering efforts\uff0c\u4e0d\u518d\u8fc7\u591a\u8003\u8651\u3002<\/p>\n

\n\t\u603b\u4e4b\uff0c\u4e00\u4f46\u62e5\u6709\u8fd9\u79cd\u8bbe\u5907\uff0c\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8bf7\u6c42\u7684\u4fdd\u5e8f\u53d1\u9001\uff1a<\/p>\n

\n\t“\u4fdd\u5e8f\u53d1\u9001\u662f\u672c\u6587\u7684\u91cd\u8981\u521b\u65b0\u4e4b\u5904\uff0c\u4e0a\u5c42\u7684\u6587\u4ef6\u7cfb\u7edf\u5bf9\u4e8e\u9700\u8981\u4fdd\u5e8f\u7684\u8bf7\u6c42\u53ef\u4ee5\u5e26\u4e0abarrier\u6807\u5fd7\uff0c\u53ea\u8981\u6ce8\u610f\u5728\u53d1\u9001\u65f6\u4e0d\u628a\u5b83\u4eec\u91cd\u6392\u5e8f\u5c31\u884c\uff0c\u4e0d\u518d\u9700\u8981\u7b49\u5f85flush\u3002\u7531\u4e0b\u8fb9\u7684\u5b58\u50a8\u8bbe\u5907\u6765\u4fdd\u8bc1\u5e26barrier\u6807\u5fd7\u8bf7\u6c42\u7684\u6301\u4e45\u5316\u987a\u5e8f\u4e0e\u5b83\u4eec\u7684\u53d1\u9001\u987a\u5e8f\u76f8\u540c\u3002\u6211\u4eec\u628a\u8fd9\u79cd\u673a\u5236\u53eb\u505awai<\/u>t-on-dispatch”<\/p>\n

\n\t\u663e\u7136\uff0cwait-on-dispatch\u6bd4wait-on-transfer\u7684\u6210\u672c\u8981\u5c0f\u5f88\u591a\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

\n\t<\/p>\n

\n\tscsi layer<\/p>\n

\n\t\u6211\u4eec\u6cbf\u7740\u4ece\u4e0b\u5f80\u4e0a\u7684\u65b9\u5411\u7ee7\u7eed\u5411\u4e0a\u5c42\u8d70\uff0c\u5f53\u8bbe\u5907\u5b9e\u73b0\u4e86barrier\u652f\u6301\u4e4b\u540e\uff0c\u7d27\u63a5\u7740\u9700\u8981\u4fee\u6539\u7684\u662fscsi\u5c42\u3002\u5728\u8fd9\u91cc\u4f5c\u8005\u5229\u7528\u4e86scsi\u5c42\u5df2\u6709\u7684command priority level\u673a\u5236\uff0c\u6309\u7167scsi\u89c4\u8303\uff0c\u547d\u4ee4\u53ef\u4ee5\u5206\u6210\u4e09\u79cd\uff1ahead of the queue\uff08\u6536\u5230\u547d\u4ee4\u65f6\u8981\u628a\u5b83\u63d2\u5165\u5230\u961f\u5217\u5934\u4e0a\uff09\u3001ordered\uff08\u6536\u5230\u547d\u4ee4\u65f6\u8981\u628a\u5b83\u63d2\u5165\u5230\u961f\u5217\u5c3e\u90e8\uff09\u3001simple\uff08\u547d\u4ee4\u53ef\u4ee5\u63d2\u5165\u5230\u961f\u5217\u4e2d\u4efb\u610f\u4f4d\u7f6e\uff0c\u4f46\u4e0d\u80fd\u653e\u5728head of the queue\u547d\u4ee4\u6216ordered\u547d\u4ee4\u7684\u524d\u8fb9\uff09\u3002\u56e0\u6b64\uff0c\u53ea\u9700\u8981\u628abarrier\u547d\u4ee4\u6253\u4e0aordered\u5c5e\u6027\u53d1\u9001\uff0c\u628a\u5176\u4ed6\u5199\u8bf7\u6c42\u6253\u4e0asimple\u5c5e\u6027\u53d1\u9001\uff0c\u5c31\u5929\u7136\u5730\u53ef\u4ee5\u5728scsi\u5c42\u4e0a\u4fdd\u8bc1barrier\u8bed\u4e49\u4e86\u3002<\/p>\n

\n\t“\u5728\u76ee\u524d\u7684\u5757\u8bbe\u5907\u5c42\u5b9e\u73b0\u4e2d\uff0cordered\u547d\u4ee4\u5f88\u5c11\u4f7f\u7528\uff0c\u8fd9\u662f\u56e0\u4e3a\u5f53\u6574\u4e2aIO stack\u5c1a\u4e14\u4e0d\u80fd\u505a\u5230\u4fdd\u5e8f\u53d1\u9001\u65f6\uff0c\u5355\u72ec\u5728scsi\u5c42\u63a7\u5236\u547d\u4ee4\u7684\u53d1\u9001\u987a\u5e8f\u6ca1\u6709\u4ec0\u4e48\u610f\u4e49\u3002\u7136\u800c\uff0c\u5f53\u6211\u4eec\u5728\u5168\u8def\u5f84\u4e0a\u5f15\u5165barrier\u8bed\u4e49\u540e\uff0cscsi\u5c42\u7684ordered\u547d\u4ee4\u5c31\u5f00\u59cb\u626e\u6f14\u91cd\u8981\u7684\u89d2\u8272\u4e86”<\/p>\n

\n\tepoch-based IO scheduler<\/p>\n

\n\t\u5728\u89e3\u51b3\u4e86scsi\u5c42\u7684\u95ee\u9898\u540e\uff0c\u4f5c\u8005\u6cbf\u7740IO\u8def\u5f84\u7ee7\u7eed\u5f80\u4e0a\u8d70\uff0c\u5bf9IO\u8c03\u5ea6\u5668\u52a0\u4ee5\u4fee\u6539\uff0c\u5f15\u5165\u4e86\u6240\u8c13\u7684epoch-based scheduling\uff1a<\/p>\n

\n\t\u9700\u8981\u4fdd\u5e8f\u7684\u5199\u64cd\u4f5c\uff0c\u5e26\u6709REQ_ORDERED\u6807\u5fd7<\/p>\n

\n\t\u4e00\u5bf9REQ_BARRIER\u4e4b\u95f4\u7684\u6240\u6709RED_ORDERED\u5199\u6784\u6210\u4e00\u4e2aepoch<\/p>\n

\n\t\u4e24\u4e2aepoch\u4e4b\u95f4\u6574\u4f53\u4e0a\u7684\u63d0\u4ea4\u662f\u4fdd\u5e8f\u7684\uff0c\u5373\u7b2c\u4e00\u4e2aepoch\u7684\u6240\u6709\u5199\u8bf7\u6c42\u63d0\u4ea4\u7ed3\u675f\u540e\uff0c\u624d\u63d0\u4ea4\u7b2c\u4e8c\u4e2aepoch\u91cc\u7684\u5199\u8bf7\u6c42<\/p>\n

\n\t\u4e00\u4e2aepoch\u5185\u90e8\u7684REQ_ORDERED\u5199\u4e4b\u95f4\u53ef\u4ee5\u81ea\u7531\u91cd\u6392\u5e8f<\/p>\n

\n\t\u4e0d\u5e26REQ_ORDERED\u7684\u5199\u8bf7\u6c42\u53ef\u4ee5\u4efb\u610f\u81ea\u7531\u8de8epoch\u91cd\u6392\u5e8f<\/p>\n

\n\t\u8fd9\u6837\u4f5c\u8005\u5c31\u8fdb\u4e00\u6b65\u89e3\u51b3\u4e86barrier\u6740\u4f24\u529b\u8fc7\u5927\u7684\u95ee\u9898—\u53ea\u6709\u660e\u786e\u8868\u793a\u9700\u8981\u4fdd\u5e8f\u7684\u5199\u8bf7\u6c42\uff0c\u5176\u63d0\u4ea4\u987a\u5e8f\u624d\u53d7barrier\u7ea6\u675f\u3002<\/p>\n

\n\tBarrier-enabled filesystem<\/p>\n

\n\tIO\u8c03\u5ea6\u5668\u7406\u987a\u4e4b\u540e\uff0c\u4f5c\u8005\u7ee7\u7eed\u5411\u4e0a\u8d70\uff0c\u5f00\u59cb\u4fee\u6539\u6587\u4ef6\u7cfb\u7edf\uff0c\u63d0\u51fa\u4e86barrier-enabled filesystem\uff08BFS\uff09\u7684\u6982\u5ff5\uff0cBFS\u5f15\u5165\u4e86\u4e24\u4e2a\u65b0\u7684\u539f\u8bed\uff1afbarrier()\u548cfdatabarrier()\uff0c\u5b83\u4eec\u5206\u522b\u662ffsync()\u548cfdatasyn()\u5728\u4fdd\u5e8f\u8fd9\u4e2a\u610f\u4e49\u4e0a\u7684\u5bf9\u5e94\u4ea7\u7269\uff0c\u5373\u662f\u8bf4\uff0c\u5f53\u4f60\u8c03\u7528\u5b83\u4eec\u65f6\uff0c\u5b83\u4eec\u4f1a\u786e\u4fdd\u6392\u5728\u8c03\u7528\u70b9\u4e4b\u524d\u7684\u6240\u6709\u5199\u64cd\u4f5c\uff08\u6216\u8005\u6240\u6709\u6570\u636e\u5199\u64cd\u4f5c\uff09\u4e00\u5b9a\u6bd4\u6392\u5728\u5b83\u4eec\u4e4b\u540e\u7684\u6240\u6709\u5199\u64cd\u4f5c\u5148\u5b8c\u6210\u6301\u4e45\u5316\uff0c\u7136\u800c\u5bf9\u4e8e\u5177\u4f53\u4f55\u65f6\u4f1a\u5b8c\u6210\u6301\u4e45\u5316\u4e0d\u505a\u4fdd\u8bc1\u3002\u53e6\u5916\uff0c\u4f5c\u8005\u4e5f\u4fee\u6539\u4e86ext4\u7684journal\u4ee5\u4f7f\u5b83\u5229\u7528\u4e0a\u65b0\u7684barrier\u673a\u5236\uff1a<\/p>\n

\n\t“\u5229\u7528\u5e95\u5c42\u8bbe\u5907\u63d0\u4f9b\u7684\u4fdd\u5e8f\u8bed\u4e49\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u628a\u4e00\u6b21journal\u63d0\u4ea4\u8fc7\u7a0b\u4e2d\u7684\u63a7\u5236\u5e73\u9762\u6d3b\u52a8\uff08\u5199\u8bf7\u6c42\u7684\u63d0\u4ea4\uff09\u548c\u6570\u636e\u5e73\u9762\u6d3b\u52a8\uff08\u6570\u636e\u53cajournal\u7684\u6301\u4e45\u5316\uff09\u5206\u5f00\u5904\u7406\uff0c\u6211\u4eec\u5efa\u7acb\u4e24\u4e2a\u7ebf\u7a0b\uff0c\u4e00\u4e2a\u8d1f\u8d23\u4fdd\u5e8f\u63d0\u4ea4\u8bf7\u6c42\uff0c\u53e6\u4e00\u4e2a\u8d1f\u8d23\u7b49\u5f85\u5b83\u4eec\u5b8c\u6210\u3002\u6211\u4eec\u628a\u8fd9\u79cd\u673a\u5236\u53eb\u505aDual Mode Journaling”<\/p>\n

\n\t\u6548\u679c\u8bc4\u4f30<\/p>\n

\n\t\u539f\u6587\u4e2d\u7684\u7b2c6\u5c0f\u8282\u4e5f\u5305\u62ec\u4e86\u5757\u8bbe\u5907\u5c42\u548c\u6587\u4ef6\u7cfb\u7edf\u5c42\u7684\u6027\u80fd\u6d4b\u8bd5\uff0c\u4e0d\u8fc7\u6211\u4eec\u8fd9\u91cc\u76f4\u63a5\u5173\u6ce8\u6700\u7ec8\u7684\u5e94\u7528\u6027\u80fd\u63d0\u5347\u3002<\/p>\n

\n\t\u5bf9\u4e8e\u670d\u52a1\u5668\u8d1f\u8f7d\uff0c\u4f5c\u8005\u8dd1\u4e86varm<\/u>ail\uff08varmail\u53d1\u7684fsync\u975e\u5e38\u591a\uff09\uff0c\u8fd8\u6709MySQL\u4e0a\u7684OLTP-insert\u6d4b\u8bd5\u3002\u4f5c\u8005\u628a\u8fd9\u91cc\u7684\u5bf9\u6bd4\u6d4b\u8bd5\u7ec6\u5206\u6210\u4e86\u4e24\u79cd\u60c5\u51b5\uff0c\u7b2c\u4e00\u79cd\u662f\u6240\u8c13\u7684durability guarantee\u6d4b\u8bd5\uff0c\u5728\u8fd9\u4e2a\u6d4b\u8bd5\u91cc\u5e94\u7528\u4ee3\u7801\u5b8c\u5168\u4e0d\u6539\uff0c\u7528BarrierFS\u548c\u6807\u51c6\u7684EXT4\u505a\u5bf9\u6bd4\uff0c\u8fd9\u662f\u4e3a\u4e86\u8bf4\u660e\u5229\u7528\u4e86barrier\u8bed\u4e49\u540efsync()\u672c\u8eab\u7684\u6027\u80fd\u63d0\u5347\uff1b\u7b2c\u4e8c\u79cd\u662f\u6240\u8c13\u7684ordering guarantee\u6d4b\u8bd5\uff0c\u5728\u8fd9\u4e2a\u6d4b\u8bd5\u91cc\u4f5c\u8005\u8dd1\u4e86BarrierFS\u3001OptFS\u548cEXT4\u4e09\u79cd\u6587\u4ef6\u7cfb\u7edf\uff08\u524d\u4e24\u79cd\u652f\u6301barrier\u8bed\u4e49\uff09\uff0c\u5e76\u5728\u524d\u4e24\u79cd\u6587\u4ef6\u7cfb\u7edf\u4e0a\u628a\u5e94\u7528\u7684fsync()\u6362\u6210fdatabarrier()\u548cosync()\uff08osync\u662fOptFS\u91cc\u7684barrier\u64cd\u4f5c\uff09\uff0c\u5bf9\u4e8eEXT4\u5219\u52a0\u4e0anobarrier\u53c2\u6570\u3002\u8fd9\u4e00\u6d4b\u8bd5\u662f\u4e3a\u4e86\u8bf4\u660ewait-on-dispatch\u6bd4wait-on-transfer\u7684\u4f18\u8d8a\u4e4b\u5904\uff0c\u6ce8\u610f\u8fd9\u91cc\u4f5c\u8005\u5b9e\u9645\u4e0a\u505a\u4e86\u4e00\u4e2a\u4e0d\u5207\u5b9e\u9645\u7684\u5047\u5b9a\uff0c\u987b\u77e5\u6709\u65f6\u5e94\u7528\u8c03\u7528fsync()\u65f6\u786e\u5b9e\u662f\u60f3\u4fdd\u8bc1\u5176\u6301\u4e45\u6027\u7684\uff0c\u5e76\u975e\u6bcf\u4e00\u5904fsync()\u90fd\u53ef\u4ee5\u6362\u6210fdatabarrier()\uff0c\u5177\u4f53\u8981\u5982\u4f55\u4fee\u6539\u5e94\u7528\u5fc5\u987b\u7ed3\u5408\u5e94\u7528\u7684\u5177\u4f53\u4e0a\u4e0b\u6587\u3002\u7b2c\u4e8c\u4e2a\u6d4b\u8bd5\u7684\u7ed3\u679c\u53ea\u80fd\u8bf4\u660e\u7ed3\u5408\u5e94\u7528\u5177\u4f53\u573a\u666f\uff0c\u53bb\u6389overkill\u7684\u6301\u4e45\u5316\u7ea6\u675f\u540e\u6027\u80fd\u63d0\u5347\u7684\u4e0a\u9650\u4f1a\u662f\u591a\u5c11\u3002<\/p>\n

\n\t\u5728durability guarantee\u6d4b\u8bd5\u4e2d\uff0cBarrierFS\u4e3avarmail\u5e26\u6765\u4e8610%-60%\u7684\u6027\u80fd\u63d0\u5347\uff0c\u4e3aMySQL\u5e26\u6765\u4e8612%\u7684\u6027\u80fd\u63d0\u5347\uff1b\u5728ordering guarantee\u6d4b\u8bd5\u4e2d\uff0cBarrierFS\u5e26\u6765\u4e8636\u500d\u6027\u80fd\u63d0\u5347\uff0c\u4e3aMySQL\u5e26\u6765\u4e8643\u500d\u6027\u80fd\u63d0\u5347\u3002<\/p>\n

\n\t\u5bf9\u4e8e\u79fb\u52a8\u8bbe\u5907\u8d1f\u8f7d\uff0c\u4f5c\u8005\u6d4b\u8bd5\u4e86Sqlite\uff0cdurability guarantee\u5e26\u6765\u4e8675%\u6027\u80fd\u63d0\u5347\uff0cordering guarantee\u5e26\u6765\u4e862.8\u500d\u6027\u80fd\u63d0\u5347\u3002<\/p>\n

\n\t\u7ed3\u8bed<\/p>\n

\n\t“\u4e3a\u9ad8\u5e76\u53d1Flash\u8bbe\u5907\u8bbe\u8ba1\u4e00\u4e2a\u652f\u6301barrier\u8bed\u4e49\u7684IO stack\u4f1a\u5e26\u6765\u6781\u5927\u7684\u6027\u80fd\u4f18\u52bf …… \u8fd9\u79cdbarrier\u8bed\u4e49\u5df2\u7ecf\u65e5\u6e10\u6210\u4e3a\u4e00\u79cd\u5fc5\u987b\u54c1\uff0c\u6211\u4eec\u5efa\u8bae\u4ece\u79fb\u52a8\u7aef\u5230\u670d\u52a1\u7aef\u7684\u5404\u79cdFlash\u8bbe\u5907\u5382\u5546\u8003\u8651\u652f\u6301barrier\u8bed\u4e49”<\/p>\n","protected":false},"excerpt":{"rendered":"

\u672c\u671f\u548c\u5927\u5bb6\u804a\u7684\u662f\u521a\u521a\u57282\u6708\u4efd\u62ff\u5230FAST 2018\u6700\u4f73\u8bba\u6587\u5956\u7684\u4e00\u7bc7\u6587\u7ae0\u3002\u5b83\u8ba8\u8bba\u4e86\u5b9e\u73b0\u4e00\u79cd\u652f\u6301\u4fdd\u5e8fIO\u64cd\u4f5c\u7684\u8bbe\u5907\u4f1a\u5e26\u6765\u54ea\u4e9b\u597d\u5904\uff0c\u76ee\u524d\u7684 Linux \u5185\u6838\u91cc\u5904\u7406FLUSH\u3001FUA\u7684\u65b9\u5f0f\u53ef\u4ee5\u53c2\u89c1https:\/\/lwn.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2067"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2067"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2067\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2067"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2067"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2067"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}