{"id":2190,"date":"2015-12-04T00:43:42","date_gmt":"2015-12-03T15:43:42","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=2190"},"modified":"2015-12-04T00:45:03","modified_gmt":"2015-12-03T15:45:03","slug":"file-storage%e3%81%aepre-allocate%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6fallocate","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=2190","title":{"rendered":"file-storage\u306epre-allocate\u306b\u3064\u3044\u3066(fallocate)"},"content":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u306f<a href=\"http:\/\/qiita.com\/advent-calendar\/2015\/varnish\">Varnish Cache Advent Calendar 2015<\/a>\u306e3\u65e5\u76ee\u306e\u8a18\u4e8b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>Varnish\u306f4.0\u307e\u3067\u306ffile-storage\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u7279\u306bpre-allocate\u3092\u3057\u306a\u3044\u305f\u3081\u3001\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u306b\u3088\u308b\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u4f4e\u4e0b\u3092\u9632\u3050\u305f\u3081\u306b<a href=\"https:\/\/www.varnish-cache.org\/docs\/trunk\/users-guide\/storage-backends.html?highlight=dd(1)#file\">dd(1)<\/a>\u3092\u4f7f\u3063\u3066\u5148\u306b\u78ba\u4fdd\u3057\u3066\u3057\u307e\u3046\u306e\u3092\u63a8\u5968\u3057\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n4.1\u3067\u3082\u4e8b\u524d\u78ba\u4fdd\u3059\u308b\u306e\u3092\u63a8\u5968\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001\u5b9f\u306fbeta\u307e\u3067\u306ffallocate\u3092\u5229\u7528\u3057\u3066pre-allocate\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\u6b63\u5f0f\u7248\u3067\u306f\u3053\u306e\u6a5f\u80fd\u306fext4\u9650\u5b9a\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u4ed6\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3067\u306fdisable\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u4f55\u6545\u304bxfs\u3060\u3068\u65e2\u306b\u9818\u57df\u3092\u78ba\u4fdd\u3057\u3066\u3044\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305afallocate\u3092\u4f7f\u304a\u3046\u3068\u3059\u308b\u3068ENOSPC\u304c\u3067\u308b\u30b1\u30fc\u30b9\u304c\u3042\u3063\u305f\u305f\u3081\u3067\u3059\u3002<br \/>\n\u3053\u306e<a href=\"https:\/\/www.varnish-cache.org\/trac\/ticket\/1792\">\u30d0\u30b0<\/a>\u306e\u5831\u544a\u3092\u3057\u305f\u306e\u306f\u81ea\u5206\u306a\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u969b\u306bfallocate\u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u305f\u3089\u5272\u3068\u8208\u5473\u6df1\u3044\u52d5\u304d\u3060\u3063\u305f\u306e\u3067\u4eca\u56de\u66f8\u304d\u307e\u3059\u3002<\/p>\n<p><strong>fallocate\u3068\u306f<\/strong><br \/>\n\u3059\u3054\u304f\u7c21\u5358\u306b\u3044\u3046\u3068\u3081\u3063\u3061\u3083\u9ad8\u901f\u306b\u30c7\u30a3\u30b9\u30af\u9818\u57df\u306e\u5272\u5f53\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u3069\u308c\u3050\u3089\u3044\u901f\u3044\u304b\u3068\u3044\u3046\u3068<\/p>\n<pre class=\"brush: shell; \">\n\r\n# time fallocate -l 10GB varnish_storage.bin\r\n\r\nreal    0m0.001s\r\nuser    0m0.000s\r\nsys     0m0.001s\r\n\r\n\n<\/pre>\n<p>\u3068\u6c17\u306b\u306a\u3089\u306a\u3044\u30ec\u30d9\u30eb\u3067\u3059\u3002<br \/>\n\u5272\u3068\u4fbf\u5229\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><strong>fallocate\u306e\u4e0d\u601d\u8b70\u306a\u52d5\u304d<\/strong><br \/>\nxfs\u3068ext4\u3067fallocate\u306e\u52d5\u304d\u3092\u78ba\u8a8d\u3057\u305f\u969b\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u52d5\u304d\u3092\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>xfs-fallocate<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/xfs# df -T .\r\nFilesystem     Type 1K-blocks  Used Available Use% Mounted on\r\n\/dev\/xvdh      xfs   15718400 32928  15685472   1% \/mnt\/xfs\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 10GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/xfs# df -T .\r\nFilesystem     Type 1K-blocks    Used Available Use% Mounted on\r\n\/dev\/xvdh      xfs   15718400 9798556   5919844  63% \/mnt\/xfs\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 10GB varnish_storage.bin\r\nfallocate: varnish_storage.bin: fallocate \u304c\u5931\u6557: \u30c7\u30d0\u30a4\u30b9\u306b\u7a7a\u304d\u9818\u57df\u304c\u3042\u308a\u307e\u305b\u3093\r\nroot@varnish-trunk:\/mnt\/xfs# ls -ltah varnish_storage.bin\r\n-rw-r--r-- 1 root root 9.4G 12\u6708  3 23:55 varnish_storage.bin\r\n\n<\/pre>\n<p>ext4-fallocate<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/ext4# df -T .\r\nFilesystem     Type 1K-blocks  Used Available Use% Mounted on\r\n\/dev\/xvdi      ext4  15350768 38384  14509568   1% \/mnt\/ext4\r\nroot@varnish-trunk:\/mnt\/ext4# fallocate -l 10GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/ext4# df -T .\r\nFilesystem     Type 1K-blocks    Used Available Use% Mounted on\r\n\/dev\/xvdi      ext4  15350768 9804016   4743936  68% \/mnt\/ext4\r\nroot@varnish-trunk:\/mnt\/ext4# fallocate -l 10GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/ext4# ls -ltah varnish_storage.bin\r\n-rw-r--r-- 1 root root 9.4G 12\u6708  3 23:56 varnish_storage.bin\r\n\n<\/pre>\n<p>\u306a\u305c\u304bxfs\u306f\u540c\u3058\u5bb9\u91cf\u3092\u78ba\u4fdd\u3057\u3088\u3046\u3068\u3057\u3066\u308b\u306e\u306b\u5931\u6557\u3059\u308b\u3002<\/p>\n<p>xfs-stat<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/xfs# stat varnish_storage.bin\r\n  File: `varnish_storage.bin&#039;\r\n  Size: 1000000000      Blocks: 1953128    IO Block: 4096   \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\r\nDevice: ca70h\/51824d    Inode: 131         Links: 1\r\nAccess: (0644\/-rw-r--r--)  Uid: (    0\/    root)   Gid: (    0\/    root)\r\nAccess: 2015-12-03 23:58:42.851567000 +0900\r\nModify: 2015-12-03 23:58:47.475567000 +0900\r\nChange: 2015-12-03 23:58:47.475567000 +0900\r\n Birth: -\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/xfs# stat varnish_storage.bin\r\n  File: `varnish_storage.bin&#039;\r\n  Size: 1000000000      Blocks: 1953128    IO Block: 4096   \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\r\nDevice: ca70h\/51824d    Inode: 131         Links: 1\r\nAccess: (0644\/-rw-r--r--)  Uid: (    0\/    root)   Gid: (    0\/    root)\r\nAccess: 2015-12-03 23:58:42.851567000 +0900\r\nModify: 2015-12-03 23:59:15.123567000 +0900\u2605\u5909\u308f\u3063\u305f\r\nChange: 2015-12-03 23:59:15.123567000 +0900\u2605\u5909\u308f\u3063\u305f\r\n Birth: -\r\n\n<\/pre>\n<p>ext4-stat<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/ext4# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/ext4# stat varnish_storage.bin\r\n  File: `varnish_storage.bin&#039;\r\n  Size: 1000000000      Blocks: 1953136    IO Block: 4096   \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\r\nDevice: ca80h\/51840d    Inode: 12          Links: 1\r\nAccess: (0644\/-rw-r--r--)  Uid: (    0\/    root)   Gid: (    0\/    root)\r\nAccess: 2015-12-03 23:59:35.871567000 +0900\r\nModify: 2015-12-03 23:59:35.871567000 +0900\r\nChange: 2015-12-03 23:59:35.871567000 +0900\r\n Birth: -\r\nroot@varnish-trunk:\/mnt\/ext4# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/ext4# stat varnish_storage.bin\r\n  File: `varnish_storage.bin&#039;\r\n  Size: 1000000000      Blocks: 1953136    IO Block: 4096   \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\r\nDevice: ca80h\/51840d    Inode: 12          Links: 1\r\nAccess: (0644\/-rw-r--r--)  Uid: (    0\/    root)   Gid: (    0\/    root)\r\nAccess: 2015-12-03 23:59:35.871567000 +0900\r\nModify: 2015-12-03 23:59:35.871567000 +0900\u2605\u5909\u308f\u3063\u3066\u306a\u3044\r\nChange: 2015-12-03 23:59:35.871567000 +0900\r\n Birth: -\r\n\n<\/pre>\n<p>xfs\u306f\u540c\u3058\u30b5\u30a4\u30ba\u3067fallocate\u3092\u53e9\u304f\u3068\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u304c\u5909\u308f\u308b\u3002<\/p>\n<p>xfs-filefrag<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/xfs# filefrag -v varnish_storage.bin |md5sum\r\n8a5e67e82aa00af5af01c6d825bd8142  -\r\nroot@varnish-trunk:\/mnt\/xfs# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/xfs# filefrag -v varnish_storage.bin |md5sum\r\n8a5e67e82aa00af5af01c6d825bd8142  -\r\n\n<\/pre>\n<p>ext4-filefrag<\/p>\n<pre class=\"brush: shell; \">\n\r\nroot@varnish-trunk:\/mnt\/ext4# filefrag -v varnish_storage.bin |md5sum\r\n9785097e3ce0e6eb3dd703fbd54e5d69  -\r\nroot@varnish-trunk:\/mnt\/ext4# fallocate -l 1GB varnish_storage.bin\r\nroot@varnish-trunk:\/mnt\/ext4# filefrag -v varnish_storage.bin |md5sum\r\n9785097e3ce0e6eb3dd703fbd54e5d69  -\r\n\n<\/pre>\n<p>\u4e21\u65b9\u5171\u3001physical_offset\u306b\u5909\u5316\u306a\u3057<br \/>\n\u3061\u306a\u307f\u306bext4\u306e\u5834\u5408\u306f\u5272\u3068\u30d5\u30e9\u30b0\u30e1\u30f3\u30c8\u3057\u307e\u3059\u304cxfs\u306e\u5834\u5408\u306f\u3042\u307e\u308a\u3057\u307e\u305b\u3093\u3067\u3057\u305f\u3002<br \/>\n(10GB\u78ba\u4fdd\u6642\u306bext4=12~50extents xfs=3~5extents)<\/p>\n<p>\u3053\u308c\u3089\u3092\u898b\u3066\u307f\u308b\u3068\u6050\u3089\u304fxfs\u306f\u6bce\u56de\u7a7a\u304d\u5bb9\u91cf\u3068\u78ba\u4fdd\u3057\u305f\u3044\u5bb9\u91cf\u3092\u4ed8\u304d\u3042\u308f\u305b\u3066\u3044\u3066\uff08\u65e2\u306ballocate\u3055\u308c\u3066\u308b\u5bb9\u91cf\u306f\u7121\u8996\uff1f\uff09<br \/>\next4\u306f\u6700\u521d\u306b\u30b3\u30de\u30f3\u30c9\u5b9f\u65bd\u304c\u5fc5\u8981\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066\u308b\u3088\u3046\u306b\u898b\u3048\u307e\u3059\u3002<br \/>\n\u306a\u3093\u3067\u3053\u3046\u306a\u308b\u306e\u304bxfs\u306e\u30b3\u30fc\u30c9\u3092\u5c11\u3057\u8ffd\u3063\u305f\u306e\u3067\u3059\u304c\u6d41\u77f3\u306b\u30ad\u30c4\u304b\u3063\u305f\u306e\u3067\u9014\u4e2d\u3067\u8ae6\u3081\u307e\u3057\u305f\u3002<\/p>\n<p><strong>\u307e\u3068\u3081\u3068\u304b<\/strong><br \/>\nfallocate\u306f\u901f\u304f\u3066\u4fbf\u5229\u306a\u3093\u3067dd\u4f7f\u3063\u3066pre-allocate\u3057\u3066\u308b\u4eba\u306ffallocate\u4f7f\u3046\u3068\u5e78\u305b\u306b\u306a\u308c\u308b\u3068\u601d\u3044\u307e\u3059\uff08\u3068\u306f\u8a00\u3048ext3\u3068\u304b\u306f\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u307e\u305b\u3093\u304c\uff09<br \/>\n\u305d\u3057\u3066varnish4.1\u3092ext4\u3067\u52d5\u304b\u3059\u5834\u5408\u306f\u5185\u90e8\u3067fallocate\u3059\u308b\u306e\u3067\u3001\u4eca\u307e\u3067\u624b\u52d5\u3067\u3084\u3063\u3066\u3044\u305fpre-allocate\u306f\u4e0d\u8981\u3067\u3059\u3002<br \/>\n\u3082\u3057\u3001\u81ea\u5206\u3067fallocate\u3092\u4f7f\u3063\u305f\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u5834\u5408\u306f\u5b9f\u884c\u524d\u306bfstat\u7b49\u3067\u5b9f\u969b\u306b\u4f7f\u7528\u3057\u3066\u3044\u308b\u5bb9\u91cf\u3092\u8abf\u3079\u308b\u306a\u3069\u3057\u3066\u4f7f\u3046\u3068\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D2190&title=file-storage%E3%81%AEpre-allocate%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%28fallocate%29' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_hatena_users\"><a href='\/\/b.hatena.ne.jp\/entry\/https:\/\/blog.xcir.net\/?p=2190' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - file-storage\u306epre-allocate\u306b\u3064\u3044\u3066(fallocate)' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='\/\/b.hatena.ne.jp\/entry\/image\/https:\/\/blog.xcir.net\/?p=2190' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - file-storage\u306epre-allocate\u306b\u3064\u3044\u3066(fallocate)' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - file-storage\u306epre-allocate\u306b\u3064\u3044\u3066(fallocate)'   class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D2190&t=file-storage%E3%81%AEpre-allocate%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%28fallocate%29' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_linkedin\"><a href='\/\/www.linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D2190&title=file-storage%E3%81%AEpre-allocate%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%28fallocate%29' title='LinkedIn \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/linkedin.png' alt='LinkedIn \u306b\u30b7\u30a7\u30a2' title='LinkedIn \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/blog.xcir.net\/?p=2190\" data-text=\"file-storage\u306epre-allocate\u306b\u3064\u3044\u3066(fallocate)\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u306fVarnish Cache Advent Calendar 2015\u306e3\u65e5\u76ee\u306e\u8a18\u4e8b\u306b\u306a\u308a\u307e\u3059\u3002 Varnish\u306f4.0\u307e\u3067\u306ffile-storage\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u306f\u7279\u306bpre-allocate\u3092\u3057\u306a\u3044\u305f\u3081\u3001\u30d5\u30e9 <a href='https:\/\/blog.xcir.net\/?p=2190' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-2190","post","type-post","status-publish","format-standard","hentry","category-3","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/2190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2190"}],"version-history":[{"count":8,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/2190\/revisions"}],"predecessor-version":[{"id":2198,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/2190\/revisions\/2198"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}