{"id":169003,"date":"2020-01-11T12:00:02","date_gmt":"2020-01-11T04:00:02","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=169003"},"modified":"2020-01-13T13:16:03","modified_gmt":"2020-01-13T05:16:03","slug":"linux-device-mapper-kernel","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-device-mapper-kernel.html","title":{"rendered":"\u4e86\u89e3Linux\u7cfb\u7edf\u4e2d\u7684Device Mapper\u673a\u5236\uff1a\u5185\u6838\u7a7a\u95f4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nDevice Mapper \u662f Linux2.6 \u5185\u6838\u4e2d\u652f\u6301\u903b\u8f91\u5377\u7ba1\u7406\u7684\u901a\u7528\u8bbe\u5907\u6620\u5c04\u673a\u5236\uff0c\u5b83\u4e3a\u5b9e\u73b0\u7528\u4e8e\u5b58\u50a8\u8d44\u6e90\u7ba1\u7406\u7684\u5757\u8bbe\u5907\u9a71\u52a8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ad8\u5ea6\u6a21\u5757\u5316\u7684\u5185\u6838\u67b6\u6784\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Device Mapper \u662f Linux2.6 \u5185\u6838\u4e2d\u652f\u6301\u903b\u8f91\u5377\u7ba1\u7406\u7684\u901a\u7528\u8bbe\u5907\u6620\u5c04\u673a\u5236\uff0c\u5b83\u4e3a\u5b9e\u73b0\u7528\u4e8e\u5b58\u50a8\u8d44\u6e90\u7ba1\u7406\u7684\u5757\u8bbe\u5907\u9a71\u52a8\u63d0\u4f9b\u4e86\u4e00\u4e2a\u9ad8\u5ea6\u6a21\u5757\u5316\u7684\u5185\u6838\u67b6\u6784\uff0c\u5982\u4e0b\u56fe:<\/p>\n

\"\"<\/p>\n

\u5728\u5185\u6838\u4e2d\u5b83\u901a\u8fc7\u4e00\u4e2a\u4e00\u4e2a\u6a21\u5757\u5316\u7684 target driver \u63d2\u4ef6\u5b9e\u73b0\u5bf9 IO \u8bf7\u6c42\u7684\u8fc7\u6ee4\u6216\u8005\u91cd\u65b0\u5b9a\u5411\u7b49\u5de5\u4f5c\uff0c\u5f53\u524d\u5df2\u7ecf\u5b9e\u73b0\u7684 target driver \u63d2\u4ef6\u5305\u62ec\u8f6f raid\u3001\u8f6f\u52a0\u5bc6\u3001\u903b\u8f91\u5377\u6761\u5e26\u3001\u591a\u8def\u5f84\u3001\u955c\u50cf\u3001\u5feb\u7167\u7b49\uff0c\u56fe\u4e2d linear\u3001mirror\u3001snapshot\u3001multipath \u8868\u793a\u7684\u5c31\u662f\u8fd9\u4e9b target driver\u3002Device mapper \u8fdb\u4e00\u6b65\u4f53\u73b0\u4e86\u5728 Linux \u5185\u6838\u8bbe\u8ba1\u4e2d\u7b56\u7565\u548c\u673a\u5236\u5206\u79bb\u7684\u539f\u5219\uff0c\u5c06\u6240\u6709\u4e0e\u7b56\u7565\u76f8\u5173\u7684\u5de5\u4f5c\u653e\u5230\u7528\u6237\u7a7a\u95f4\u5b8c\u6210\uff0c\u5185\u6838\u4e2d\u4e3b\u8981\u63d0\u4f9b\u5b8c\u6210\u8fd9\u4e9b\u7b56\u7565\u6240\u9700\u8981\u7684\u673a\u5236\u3002Device mapper \u7528\u6237\u7a7a\u95f4\u76f8\u5173\u90e8\u5206\u4e3b\u8981\u8d1f\u8d23\u914d\u7f6e\u5177\u4f53\u7684\u7b56\u7565\u548c\u63a7\u5236\u903b\u8f91\uff0c\u6bd4\u5982\u903b\u8f91\u8bbe\u5907\u548c\u54ea\u4e9b\u7269\u7406\u8bbe\u5907\u5efa\u7acb\u6620\u5c04\uff0c\u600e\u4e48\u5efa\u7acb\u8fd9\u4e9b\u6620\u5c04\u5173\u7cfb\u7b49\u7b49\uff0c\u800c\u5177\u4f53\u8fc7\u6ee4\u548c\u91cd\u5b9a\u5411 IO \u8bf7\u6c42\u7684\u5de5\u4f5c\u7531\u5185\u6838\u4e2d\u76f8\u5173\u4ee3\u7801\u5b8c\u6210\u3002\u56e0\u6b64\u6574\u4e2a device mapper \u673a\u5236\u7531\u4e24\u90e8\u5206\u7ec4\u6210--\u5185\u6838\u7a7a\u95f4\u7684 device mapper \u9a71\u52a8\u3001\u7528\u6237\u7a7a\u95f4\u7684device mapper \u5e93\u4ee5\u53ca\u5b83\u63d0\u4f9b\u7684 dmsetup \u5de5\u5177\u3002\u5728\u4e0b\u6587\u4e2d\uff0c\u6211\u4eec\u5206\u5185\u6838\u548c\u7528\u6237\u7a7a\u95f4\u4e24\u90e8\u5206\u8fdb\u884c\u4ecb\u7ecd\u3002<\/p>\n

\u5185\u6838\u90e8\u5206<\/strong><\/div>\n

Device mapper \u7684\u5185\u6838\u76f8\u5173\u4ee3\u7801\u5df2\u7ecf\u4f5c\u4e3a Linux 2.6 \u5185\u6838\u53d1\u5e03\u7248\u7684\u4e00\u90e8\u5206\u96c6\u6210\u5230\u5185\u6838\u6e90\u7801\u4e2d\u4e86\uff0c\u76f8\u5173\u4ee3\u7801\u5728\u5185\u6838\u6e90\u7801\u7684 driver\/md\/ \u76ee\u5f55\u4e2d\uff0c\u5176\u4ee3\u7801\u6587\u4ef6\u53ef\u4ee5\u5212\u5206\u4e3a\u5b9e\u73b0 device mapper \u5185\u6838\u4e2d\u57fa\u672c\u67b6\u6784\u7684\u6587\u4ef6\u548c\u5b9e\u73b0\u5177\u4f53\u6620\u5c04\u5de5\u4f5c\u7684 target driver \u63d2\u4ef6\u6587\u4ef6\u4e24\u90e8\u5206\u3002\u6587\u7ae0\u4e0b\u9762\u7684\u5206\u6790\u7ed3\u679c\u4e3b\u8981\u662f\u57fa\u4e8e\u4e0a\u8ff0\u6e90\u7801\u6587\u4ef6\u5f97\u5230\u7684\u3002<\/p>\n

\u91cd\u8981\u6982\u5ff5<\/strong><\/span><\/div>\n

Device mapper \u5728\u5185\u6838\u4e2d\u4f5c\u4e3a\u4e00\u4e2a\u5757\u8bbe\u5907\u9a71\u52a8\u88ab\u6ce8\u518c\u7684\uff0c\u5b83\u5305\u542b\u4e09\u4e2a\u91cd\u8981\u7684\u5bf9\u8c61\u6982\u5ff5\uff0cmapped device\u3001\u6620\u5c04\u8868\u3001target device\u3002Mapped device \u662f\u4e00\u4e2a\u903b\u8f91\u62bd\u8c61\uff0c\u53ef\u4ee5\u7406\u89e3\u6210\u4e3a\u5185\u6838\u5411\u5916\u63d0\u4f9b\u7684\u903b\u8f91\u8bbe\u5907\uff0c\u5b83\u901a\u8fc7\u6620\u5c04\u8868\u63cf\u8ff0\u7684\u6620\u5c04\u5173\u7cfb\u548c target device \u5efa\u7acb\u6620\u5c04\u3002\u4ece Mapped device \u5230\u4e00\u4e2a target device \u7684\u6620\u5c04\u8868\u7531\u4e00\u4e2a\u591a\u5143\u7ec4\u8868\u793a\uff0c\u8be5\u591a\u5143\u7ec4\u7531\u8868\u793a mapped device \u903b\u8f91\u7684\u8d77\u59cb\u5730\u5740\u3001\u8303\u56f4\u3001\u548c\u8868\u793a\u5728 target device \u6240\u5728\u7269\u7406\u8bbe\u5907\u7684\u5730\u5740\u504f\u79fb\u91cf\u4ee5\u53catarget \u7c7b\u578b\u7b49\u53d8\u91cf\u7ec4\u6210\uff08\u8fd9\u4e9b\u5730\u5740\u548c\u504f\u79fb\u91cf\u90fd\u662f\u4ee5\u78c1\u76d8\u7684\u6247\u533a\u4e3a\u5355\u4f4d\u7684\uff0c\u5373 512 \u4e2a\u5b57\u8282\u5927\u5c0f\uff09\u3002Target device \u8868\u793a\u7684\u662f mapped device \u6240\u6620\u5c04\u7684\u7269\u7406\u7a7a\u95f4\u6bb5\uff0c\u5bf9 mapped device \u6240\u8868\u793a\u7684\u903b\u8f91\u8bbe\u5907\u6765\u8bf4\uff0c\u5c31\u662f\u8be5\u903b\u8f91\u8bbe\u5907\u6620\u5c04\u5230\u7684\u4e00\u4e2a\u7269\u7406\u8bbe\u5907\u3002Device mapper \u4e2d\u8fd9\u4e09\u4e2a\u5bf9\u8c61\u548c target driver \u63d2\u4ef6\u4e00\u8d77\u6784\u6210\u4e86\u4e00\u4e2a\u53ef\u8fed\u4ee3\u7684\u8bbe\u5907\u6811\u3002\u5728\u8be5\u6811\u578b\u7ed3\u6784\u4e2d\u7684\u9876\u5c42\u6839\u8282\u70b9\u662f\u6700\u7ec8\u4f5c\u4e3a\u903b\u8f91\u8bbe\u5907\u5411\u5916\u63d0\u4f9b\u7684 mapped device\uff0c\u53f6\u5b50\u8282\u70b9\u662f target device \u6240\u8868\u793a\u7684\u5e95\u5c42\u7269\u7406\u8bbe\u5907\u3002\u6700\u5c0f\u7684\u8bbe\u5907\u6811\u7531\u5355\u4e2a mapped device \u548c target device \u7ec4\u6210\u3002\u6bcf\u4e2a target device \u90fd\u662f\u88abmapped device \u72ec\u5360\u7684\uff0c\u53ea\u80fd\u88ab\u4e00\u4e2a mapped device \u4f7f\u7528\u3002\u4e00\u4e2a mapped device \u53ef\u4ee5\u6620\u5c04\u5230\u4e00\u4e2a\u6216\u8005\u591a\u4e2a target device \u4e0a\uff0c\u800c\u4e00\u4e2a mapped device \u53c8\u53ef\u4ee5\u4f5c\u4e3a\u5b83\u4e0a\u5c42 mapped device\u7684 target device \u88ab\u4f7f\u7528\uff0c\u8be5\u5c42\u6b21\u5728\u7406\u8bba\u4e0a\u53ef\u4ee5\u5728 device mapper \u67b6\u6784\u4e0b\u65e0\u9650\u8fed\u4ee3\u4e0b\u53bb\u3002<\/p>\n

\"\"<\/p>\n

\u4ece\u4e0a\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u5230 mapped device1 \u901a\u8fc7\u6620\u5c04\u8868\u548c a\u3001b\u3001c \u4e09\u4e2a target device \u5efa\u7acb\u4e86\u6620\u5c04\u5173\u7cfb\uff0c\u800c target device a \u53c8\u662f\u901a\u8fc7 mapped device 2 \u6f14\u5316\u8fc7\u6765\uff0cmapped device 2 \u901a\u8fc7\u6620\u5c04\u8868\u548c target device d \u5efa\u7acb\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n

\u6211\u4eec\u8fdb\u4e00\u6b65\u770b\u4e00\u4e0b\u4e0a\u56fe\u4e2d\u4e09\u4e2a\u5bf9\u8c61\u5728\u4ee3\u7801\u4e2d\u7684\u5177\u4f53\u5b9e\u73b0\uff0cdm.c \u6587\u4ef6\u5b9a\u4e49\u7684 mapped_device \u7ed3\u6784\u7528\u4e8e\u8868\u793a mapped device\uff0c\u5b83\u4e3b\u8981\u5305\u62ec\u8be5 mapped device \u76f8\u5173\u7684\u9501\uff0c\u6ce8\u518c\u7684\u8bf7\u6c42\u961f\u5217\u548c\u4e00\u4e9b\u5185\u5b58\u6c60\u4ee5\u53ca\u6307\u5411\u5b83\u6240\u5bf9\u5e94\u6620\u5c04\u8868\u7684\u6307\u9488\u7b49\u57df\u3002<\/p>\n

Mapped device \u5bf9\u5e94\u7684\u6620\u5c04\u8868\u662f\u7531 dm_table.c \u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684 dm_table \u7ed3\u6784\u8868\u793a\u7684\uff0c\u8be5\u7ed3\u6784\u4e2d\u5305\u542b\u4e00\u4e2a dm_target\u7ed3\u6784\u6570\u7ec4\uff0cdm_target \u7ed3\u6784\u5177\u4f53\u63cf\u8ff0\u4e86 mapped_device \u5230\u5b83\u67d0\u4e2a target device \u7684\u6620\u5c04\u5173\u7cfb\u3002<\/p>\n

\u800c\u5728 dm_table \u7ed3\u6784\u4e2d\u5c06\u8fd9\u4e9b dm_target \u6309\u7167 B \u6811\u7684\u65b9\u5f0f\u7ec4\u7ec7\u8d77\u6765\u65b9\u4fbf IO \u8bf7\u6c42\u6620\u5c04\u65f6\u7684\u67e5\u627e\u64cd\u4f5c\u3002Dm_target \u7ed3\u6784\u5177\u4f53\u8bb0\u5f55\u8be5\u7ed3\u6784\u5bf9\u5e94 target device \u6240\u6620\u5c04\u7684 mapped device \u903b\u8f91\u533a\u57df\u7684\u5f00\u59cb\u5730\u5740\u548c\u8303\u56f4\uff0c\u540c\u65f6\u8fd8\u5305\u542b\u6307\u5411\u5177\u4f53 target device \u76f8\u5173\u64cd\u4f5c\u7684 target_type \u7ed3\u6784\u7684\u6307\u9488\u3002<\/p>\n

Target_type \u7ed3\u6784\u4e3b\u8981\u5305\u542b\u4e86 target device \u5bf9\u5e94\u7684 target driver \u63d2\u4ef6\u7684\u540d\u5b57\u3001\u5b9a\u4e49\u7684\u6784\u5efa\u548c\u5220\u9664\u8be5\u7c7b\u578btarget device\u7684\u65b9\u6cd5\u3001\u8be5\u7c7btarget device\u5bf9\u5e94\u7684IO\u8bf7\u6c42\u91cd\u6620\u5c04\u548c\u7ed3\u675fIO\u7684\u65b9\u6cd5\u7b49\u3002\u800c\u8868\u793a\u5177\u4f53\u7684target device\u7684\u57df\u662fdm_target\u4e2d\u7684private\u57df\uff0c\u8be5\u6307\u9488\u6307\u5411mapped device\u6240\u6620\u5c04\u7684\u5177\u4f53target device\u5bf9\u5e94\u7684\u7ed3\u6784\u3002\u8868\u793atarget device\u7684\u5177\u4f53\u7ed3\u6784\u7531\u4e8e\u4e0d\u540c\u7684target \u7c7b\u578b\u800c\u4e0d\u540c\uff0c\u6bd4\u5982\u6700\u7b80\u5355\u7684\u7ebf\u6027\u6620\u5c04target\u7c7b\u578b\u5bf9\u5e94target device\u7684\u7ed3\u6784\u662fdm-linear.c\u6587\u4ef6\u4e2d\u5b9a\u4e49\u7684linear_c\u7ed3\u6784\u3002\u5176\u5b9a\u4e49\u5982\u4e0b\uff1a<\/p>\n

struct linear_c { struct dm_dev *dev; sector_t start; };<\/pre>\n

\u8be5target device\u7684\u5b9a\u4e49\u76f8\u5f53\u7b80\u5355\uff0c\u5c31\u53ea\u5305\u62ec\u4e86\u8868\u793a\u5bf9\u5e94\u7269\u7406\u8bbe\u5907\u7684dm_dev\u7ed3\u6784\u6307\u9488\u548c\u5728\u8be5\u7269\u7406\u8bbe\u5907\u4e2d\u4ee5\u6247\u533a\u4e3a\u5355\u4f4d\u7684\u504f\u79fb\u5730\u5740start\u3002\u4e0a\u8ff0\u51e0\u4e2a\u6570\u636e\u7ed3\u6784\u5173\u7cfb\u5982\u56fe\u6240\u793a\uff1a<\/p>\n

\"\"<\/p>\n

\u5185\u6838\u4e2d\u5efa\u7acb\u8fc7\u7a0b<\/strong><\/span><\/div>\n

\u5728\u4e0b\u9762\u6211\u4eec\u7ed3\u5408\u5177\u4f53\u7684\u4ee3\u7801\u7b80\u8981\u4ecb\u7ecd\u4e0b\u5728\u5185\u6838\u4e2d\u521b\u5efa\u4e00\u4e2amapped device\u7684\u8fc7\u7a0b\uff1a<\/p>\n

    \n
  1. \u6839\u636e\u5185\u6838\u5411\u7528\u6237\u7a7a\u95f4\u63d0\u4f9b\u7684ioctl \u63a5\u53e3\u4f20\u6765\u7684\u53c2\u6570\uff0c\u7528dm-ioctl.c\u6587\u4ef6\u4e2d\u7684dev_create\u51fd\u6570\u521b\u5efa\u76f8\u5e94\u7684mapped device\u7ed3\u6784\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u5f88\u7b80\u5355\uff0c\u4e3b\u8981\u662f\u5411\u5185\u6838\u7533\u8bf7\u5fc5\u8981\u7684\u5185\u5b58\u8d44\u6e90\uff0c\u5305\u62ecmapped device\u548c\u4e3a\u8fdb\u884cIO\u64cd\u4f5c\u9884\u7533\u8bf7\u7684\u5185\u5b58\u6c60\uff0c\u901a\u8fc7\u5185\u6838\u63d0\u4f9b\u7684blk_queue_make_request\u51fd\u6570\u6ce8\u518c\u8be5mapped device\u5bf9\u5e94\u7684\u8bf7\u6c42\u961f\u5217dm_request\u3002\u5e76\u5c06\u8be5mapped device\u4f5c\u4e3a\u78c1\u76d8\u5757\u8bbe\u5907\u6ce8\u518c\u5230\u5185\u6838\u4e2d\u3002<\/li>\n
  2. \u8c03\u7528dm_hash_insert\u5c06\u521b\u5efa\u597d\u7684mapped device\u63d2\u5165\u5230device mapper\u4e2d\u7684\u4e00\u4e2a\u5168\u5c40hash\u8868\u4e2d\uff0c\u8be5\u8868\u4e2d\u4fdd\u5b58\u4e86\u5185\u6838\u4e2d\u5f53\u524d\u521b\u5efa\u7684\u6240\u6709mapped device\u3002<\/li>\n
  3. \u7528\u6237\u7a7a\u95f4\u547d\u4ee4\u901a\u8fc7ioctl\u8c03\u7528table_load\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u6839\u636e\u7528\u6237\u7a7a\u95f4\u4f20\u6765\u7684\u53c2\u6570\u6784\u5efa\u6307\u5b9amapped device\u7684\u6620\u5c04\u8868\u548c\u6240\u6620\u5c04\u7684target device\u3002\u8be5\u51fd\u6570\u5148\u6784\u5efa\u76f8\u5e94\u7684dm_table\u3001dm_target\u7ed3\u6784\uff0c\u518d\u8c03\u7528dm-table.c\u4e2d\u7684dm_table_add_target\u51fd\u6570\u6839\u636e\u7528\u6237\u4f20\u5165\u7684\u53c2\u6570\u521d\u59cb\u5316\u8fd9\u4e9b\u7ed3\u6784\uff0c\u5e76\u4e14\u6839\u636e\u53c2\u6570\u6240\u6307\u5b9a\u7684target\u7c7b\u578b\uff0c\u8c03\u7528\u76f8\u5e94\u7684target\u7c7b\u578b\u7684\u6784\u5efa\u51fd\u6570ctr\u5728\u5185\u5b58\u4e2d\u6784\u5efatarget device\u5bf9\u5e94\u7684\u7ed3\u6784\uff0c\u7136\u540e\u518d\u6839\u636e\u6240\u5efa\u7acb\u7684dm_target\u7ed3\u6784\u66f4\u65b0dm_table\u4e2d\u7ef4\u62a4\u7684B\u6811\u3002\u4e0a\u8ff0\u8fc7\u7a0b\u5b8c\u6bd5\u540e\uff0c\u518d\u5c06\u5efa\u7acb\u597d\u7684dm_table\u6dfb\u52a0\u5230mapped device\u7684\u5168\u5c40hash\u8868\u5bf9\u5e94\u7684hash_cell\u7ed3\u6784\u4e2d\u3002<\/li>\n
  4. \u6700\u540e\u901a\u8fc7ioctl\u8c03\u7528do_resume\u51fd\u6570\u5efa\u7acbmapped device\u548c\u6620\u5c04\u8868\u4e4b\u95f4\u7684\u7ed1\u5b9a\u5173\u7cfb\uff0c\u4e8b\u5b9e\u4e0a\u8be5\u8fc7\u7a0b\u5c31\u662f\u901a\u8fc7dm_swap_table\u51fd\u6570\u5c06\u5f53\u524ddm_table\u7ed3\u6784\u6307\u9488\u503c\u8d4b\u4e88mapped_device\u76f8\u5e94\u7684map\u57df\u4e2d\uff0c\u7136\u540e\u518d\u4fee\u6539mapped_device\u8868\u793a\u5f53\u524d\u72b6\u6001\u7684\u57df\u3002<\/li>\n<\/ol>\n

    \u901a\u8fc7\u4e0a\u8ff0\u76844\u4e2a\u4e3b\u8981\u6b65\u9aa4\uff0cdevice mapper\u5728\u5185\u6838\u4e2d\u5c31\u5efa\u7acb\u4e00\u4e2a\u53ef\u4ee5\u63d0\u4f9b\u7ed9\u7528\u6237\u4f7f\u7528\u7684mapped device\u903b\u8f91\u5757\u8bbe\u5907\u3002<\/p>\n

    IO\u6d41<\/strong><\/span><\/div>\n

    Device mapper\u672c\u8d28\u529f\u80fd\u5c31\u662f\u6839\u636e\u6620\u5c04\u5173\u7cfb\u548ctarget driver\u63cf\u8ff0\u7684IO\u5904\u7406\u89c4\u5219\uff0c\u5c06IO\u8bf7\u6c42\u4ece\u903b\u8f91\u8bbe\u5907mapped device\u8f6c\u53d1\u76f8\u5e94\u7684target device\u4e0a\u3002Device mapper\u5904\u7406\u6240\u6709\u4ece\u5185\u6838\u4e2d\u5757\u4e00\u7ea7IO\u5b50\u7cfb\u7edf\u7684generic_make_request\u548csubmit_bio\u63a5\u53e3[\u4e24\u4e2a\u63a5\u53e3\u5177\u4f53\u7684\u63cf\u8ff0\u53ef\u4ee5\u67e5\u770b\u53c2\u8003\u6587\u732e[1]\u548c[2]\uff0c\u8fd9\u4e24\u672c\u4e66\u5bf9\u5185\u6838\u4e2d\u7684\u5757IO\u5c42\u6709\u6bd4\u8f83\u8be6\u5c3d\u7684\u8bb2\u89e3\u3002] \u4e2d\u5b9a\u5411\u5230mapped device\u7684\u6240\u6709\u5757\u8bfb\u5199IO\u8bf7\u6c42\u3002IO\u8bf7\u6c42\u5728device mapper\u7684\u8bbe\u5907\u6811\u4e2d\u901a\u8fc7\u8bf7\u6c42\u8f6c\u53d1\u4ece\u4e0a\u5230\u4e0b\u5730\u8fdb\u884c\u5904\u7406\u3002\u5f53\u4e00\u4e2abio\u8bf7\u6c42\u5728\u8bbe\u5907\u6811\u4e2d\u7684mapped deivce\u5411\u4e0b\u5c42\u8f6c\u53d1\u65f6\uff0c\u4e00\u4e2a\u6216\u8005\u591a\u4e2abio\u7684\u514b\u9686\u88ab\u521b\u5efa\u5e76\u53d1\u9001\u7ed9\u4e0b\u5c42target device\u3002\u7136\u540e\u76f8\u540c\u7684\u8fc7\u7a0b\u5728\u8bbe\u5907\u6811\u7684\u6bcf\u4e00\u4e2a\u5c42\u6b21\u4e0a\u91cd\u590d\uff0c\u53ea\u8981\u8bbe\u5907\u6811\u8db3\u591f\u5927\u7406\u8bba\u4e0a\u8fd9\u79cd\u8f6c\u53d1\u8fc7\u7a0b\u53ef\u4ee5\u65e0\u9650\u8fdb\u884c\u4e0b\u53bb\u3002\u5728\u8bbe\u5907\u6811\u4e0a\u67d0\u4e2a\u5c42\u6b21\u4e2d\uff0ctarget driver\u7ed3\u675f\u67d0\u4e2abio\u8bf7\u6c42\u540e\uff0c\u5c06\u8868\u793a\u7ed3\u675f\u8be5bio\u8bf7\u6c42\u7684\u4e8b\u4ef6\u4e0a\u62a5\u7ed9\u5b83\u4e0a\u5c42\u7684mapped device\uff0c\u8be5\u8fc7\u7a0b\u5728\u5404\u4e2a\u5c42\u6b21\u4e0a\u8fdb\u884c\u76f4\u5230\u8be5\u4e8b\u4ef6\u6700\u7ec8\u4e0a\u4f20\u5230\u6839mapped device\u7684\u4e3a\u6b62\uff0c\u7136\u540edevice mapper\u7ed3\u675f\u6839mapped device\u4e0a\u539f\u59cbbio\u8bf7\u6c42\uff0c\u7ed3\u675f\u6574\u4e2aIO\u8bf7\u6c42\u8fc7\u7a0b\u3002<\/p>\n

    Bio\u5728device mapper\u7684\u8bbe\u5907\u6811\u8fdb\u884c\u9010\u5c42\u7684\u8f6c\u53d1\u65f6\uff0c\u6700\u7ec8\u8f6c\u53d1\u5230\u4e00\u4e2a\u6216\u591a\u4e2a\u53f6\u5b50target\u8282\u70b9\u7ec8\u6b62\u3002\u56e0\u4e3a\u4e00\u4e2abio\u8bf7\u6c42\u4e0d\u53ef\u4ee5\u8de8\u591a\u4e2atarget device(\u4ea6\u5373\u7269\u7406\u7a7a\u95f4\u6bb5)\uff0c \u56e0\u6b64\u5728\u6bcf\u4e00\u4e2a\u5c42\u6b21\u4e0a\uff0cdevice mapper\u6839\u636e\u7528\u6237\u9884\u5148\u544a\u77e5\u7684mapped device \u7684target\u6620\u5c04\u4fe1\u606f\u514b\u9686\u4e00\u4e2a\u6216\u8005\u591a\u4e2abio\uff0c\u5c06bio\u8fdb\u884c\u62c6\u5206\u540e\u8f6c\u53d1\u5230\u5bf9\u5e94\u7684target device\u4e0a\u3002\u8fd9\u4e9b\u514b\u9686\u7684bio\u5148\u4ea4\u7ed9mapped device\u4e0a\u5bf9\u5e94\u7684target driver\u4e0a\u8fdb\u884c\u5904\u7406\uff0c\u6839\u636etarget driver\u4e2d\u5b9a\u4e49\u7684IO\u5904\u7406\u89c4\u5219\u8fdb\u884cIO\u8bf7\u6c42\u7684\u8fc7\u6ee4\u7b49\u5904\u7406\uff0c\u7136\u540e\u518d\u63d0\u4ea4\u7ed9target device\u5b8c\u6210\u3002\u4e0a\u8ff0\u8fc7\u7a0b\u5728dm.c\u6587\u4ef6\u4e2d\u7684dm_request\u51fd\u6570\u4e2d\u5b8c\u6210\u3002Target driver\u53ef\u4ee5\u5bf9\u8fd9\u4e9bbio\u505a\u5982\u4e0b\u5904\u7406\uff1a<\/p>\n

      \n
    1. \u5c06\u8fd9\u4e9bbio\u5728\u672c\u9a71\u52a8\u5185\u90e8\u6392\u961f\u7b49\u5f85\u4ee5\u540e\u8fdb\u884c\u5904\u7406\uff1b<\/li>\n
    2. \u5c06bio\u91cd\u65b0\u5b9a\u5411\u5230\u4e00\u4e2a\u6216\u591a\u4e2atarget device\u4e0a\u6216\u8005\u6bcf\u4e2atarget device\u4e0a\u7684\u4e0d\u540c\u6247\u533a\uff1b<\/li>\n
    3. \u5411device mapper\u8fd4\u56deerror \u72b6\u6001\u3002<\/li>\n<\/ol>\n

      IO\u8bf7\u6c42\u5c31\u6309\u7167\u4e0a\u6587\u4e2d\u63cf\u8ff0\u7684\u8fc7\u7a0b\u5728\u56fe2\u4e2d\u6240\u793a\u7684\u8bbe\u5907\u6811\u4e2d\u9010\u5c42\u8fdb\u884c\u5904\u7406\uff0c\u76f4\u5230IO\u8bf7\u6c42\u7ed3\u675f\u3002<\/p>\n

      \u5c0f\u7ed3<\/strong><\/span><\/div>\n

      Device mapper\u5728\u5185\u6838\u4e2d\u5411\u5916\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ece\u903b\u8f91\u8bbe\u5907\u5230\u7269\u7406\u8bbe\u5907\u7684\u6620\u5c04\u67b6\u6784\uff0c\u53ea\u8981\u7528\u6237\u5728\u7528\u6237\u7a7a\u95f4\u5236\u5b9a\u597d\u6620\u5c04\u7b56\u7565\uff0c\u6309\u7167\u81ea\u5df1\u7684\u9700\u8981\u7f16\u5199\u5904\u7406\u5177\u4f53IO\u8bf7\u6c42\u7684target driver\u63d2\u4ef6\uff0c\u5c31\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5b9e\u73b0\u4e00\u4e2a\u7c7b\u4f3cLVM\u7684\u903b\u8f91\u5377\u7ba1\u7406\u5668\u3002Device mapper\u4ee5ioctl\u7684\u65b9\u5f0f\u5411\u5916\u63d0\u4f9b\u63a5\u53e3\uff0c\u7528\u6237\u901a\u8fc7\u7528\u6237\u7a7a\u95f4\u7684device mapper\u5e93\uff0c\u5411device mapper\u7684\u5b57\u7b26\u8bbe\u5907\u53d1\u9001ioctl\u547d\u4ee4\uff0c\u5b8c\u6210\u5411\u5185\u7684\u901a\u4fe1\u3002\u5b83\u8fd8\u901a\u8fc7ioctl\u63d0\u4f9b\u5411\u5f80\u7684\u4e8b\u4ef6\u901a\u77e5\u673a\u5236\uff0c\u5141\u8bb8target driver\u5c06IO\u76f8\u5173\u7684\u67d0\u4e9b\u4e8b\u4ef6\u4f20\u9001\u5230\u7528\u6237\u7a7a\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

      Device Mapper \u662f Linux2.6 \u5185\u6838\u4e2d\u652f\u6301\u903b\u8f91\u5377\u7ba1\u7406\u7684\u901a\u7528\u8bbe\u5907\u6620\u5c04\u673a\u5236\uff0c\u5b83\u4e3a\u5b9e\u73b0\u7528\u4e8e\u5b58\u50a8\u8d44\u6e90 […]<\/p>\n","protected":false},"author":317,"featured_media":31510,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-169003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=169003"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169003\/revisions"}],"predecessor-version":[{"id":169008,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/169003\/revisions\/169008"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/31510"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=169003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=169003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=169003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}