-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
1093 lines (583 loc) · 35.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
<!--[if lt IE 9]>
<style>body {display: none; background: none !important} </style>
<meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
<![endif]-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="author" content="Arking">
<meta name="baidu-site-verification" content="9d4qW6GBFN">
<meta property="og:type" content="website">
<meta property="og:title" content="Arking">
<meta property="og:url" content="https://arkingc.github.io/index.html">
<meta property="og:site_name" content="Arking">
<meta property="og:locale" content="default">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Arking">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="alternate" href="/atom.xml" title="Arking" type="application/atom+xml">
<link rel="shortcut icon" href="/favicon.png">
<link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">
<link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
<link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">
<link rel="stylesheet" href="/css/style.css">
<style> .article { opacity: 0;} </style>
<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<title>Arking</title>
<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>
<script>
var yiliaConfig = {
fancybox: true,
animate: true,
isHome: true,
isPost: false,
isArchive: false,
isTag: false,
isCategory: false,
fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
search: false
}
</script>
<script> yiliaConfig.jquery_ui = [false]; </script>
<script> yiliaConfig.rootUrl = "\/";</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?95fde47c8eb7fd8f64bddfc637e05427";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head></html>
<body>
<div id="container">
<div class="left-col">
<div class="overlay"></div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="/img/avatar.png" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/">Arking</a></h1>
</hgroup>
<div id="switch-btn" class="switch-btn">
<div class="icon">
<div class="icon-ctn">
<div class="icon-wrap icon-house" data-idx="0">
<div class="birdhouse"></div>
<div class="birdhouse_holes"></div>
</div>
<div class="icon-wrap icon-ribbon hide" data-idx="1">
<div class="ribbon"></div>
</div>
<div class="icon-wrap icon-link hide" data-idx="2">
<div class="loopback_l"></div>
<div class="loopback_r"></div>
</div>
<div class="icon-wrap icon-me hide" data-idx="3">
<div class="user"></div>
<div class="shoulder"></div>
</div>
</div>
</div>
<div class="tips-box hide">
<div class="tips-arrow"></div>
<ul class="tips-inner">
<li>菜单</li>
<li>标签</li>
<li>友情链接</li>
<li>关于我</li>
</ul>
</div>
</div>
<div id="switch-area" class="switch-area">
<div class="switch-wrap">
<section class="switch-part switch-part1">
<nav class="header-menu">
<ul>
<li><a href="/">主页</a></li>
<li><a href="/archives/">归档</a></li>
<li><a href="/tags/">标签</a></li>
<li><a href="/link/">链接</a></li>
<li><a href="/about/">关于我</a></li>
</ul>
</nav>
<nav class="header-nav">
<ul class="social">
<a class="fa Email" href="mailto:[email protected]" title="Email"></a>
<a class="fa GitHub" href="https://github.com/arkingc" title="GitHub"></a>
</ul>
</nav>
</section>
<section class="switch-part switch-part2">
<div class="widget tagcloud" id="js-tagcloud">
<ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/aufs/">aufs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/btrfs/">btrfs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/c/">c</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/device-mapper/">device mapper</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/docker-storage/">docker storage</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/kernel/">kernel</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/lvm/">lvm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/overlay-overlay2/">overlay/overlay2</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/overlayfs/">overlayfs</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vfs/">vfs</a></li></ul>
</div>
</section>
<section class="switch-part switch-part3">
<div id="js-friends">
<a class="main-nav-link switch-friends-link" href="http://xiaohuazheng.github.io/">华仔</a>
<a class="main-nav-link switch-friends-link" href="https://guanjunjian.github.io/">健哥</a>
<a class="main-nav-link switch-friends-link" href="http://blog.xbblfz.site/">波波</a>
<a class="main-nav-link switch-friends-link" href="https://starrymoon.github.io/">扛把子</a>
<a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
<a class="main-nav-link switch-friends-link" href="https://github.com/MOxFIVE/hexo-theme-yelee">yelle</a>
</div>
</section>
<section class="switch-part switch-part4">
<div id="js-aboutme">专注于后台</div>
</section>
</div>
</div>
</header>
</div>
</div>
<div class="mid-col">
<nav id="mobile-nav">
<div class="overlay">
<div class="slider-trigger"></div>
<h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">Arking</a></h1>
</div>
<div class="intrude-less">
<header id="header" class="inner">
<a href="/" class="profilepic">
<img src="/img/avatar.png" class="animated zoomIn">
</a>
<hgroup>
<h1 class="header-author"><a href="/" title="回到主页">Arking</a></h1>
</hgroup>
<nav class="header-menu">
<ul>
<li><a href="/">主页</a></li>
<li><a href="/archives/">归档</a></li>
<li><a href="/tags/">标签</a></li>
<li><a href="/link/">链接</a></li>
<li><a href="/about/">关于我</a></li>
<div class="clearfix"></div>
</ul>
</nav>
<nav class="header-nav">
<ul class="social">
<a class="fa Email" target="_blank" href="mailto:[email protected]" title="Email"></a>
<a class="fa GitHub" target="_blank" href="https://github.com/arkingc" title="GitHub"></a>
</ul>
</nav>
</header>
</div>
<link class="menu-list" tags="标签" friends="友情链接" about="关于我">
</nav>
<div class="body-wrap">
<article id="post-2018-12-13-linux-lvm" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/13/2018-12-13-linux-lvm/" class="article-date">
<time datetime="2018-12-13T12:51:00.000Z" itemprop="datePublished">2018-12-13</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/13/2018-12-13-linux-lvm/">Linux Device Mapper</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>Device Mapper 是 Linux2.6 内核中支持逻辑卷管理的通用设备映射机制,它为实现用于存储资源管理的块设备驱动提供了一个高度模块化的内核架构</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Linux/">Linux</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/device-mapper/">device mapper</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/kernel/">kernel</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/lvm/">lvm</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/12/13/2018-12-13-linux-lvm/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-12-11-docker-storage-persist" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/11/2018-12-11-docker-storage-persist/" class="article-date">
<time datetime="2018-12-11T02:51:00.000Z" itemprop="datePublished">2018-12-11</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/11/2018-12-11-docker-storage-persist/"> Docker容器数据持久化 </a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>容器中的数据可以存储在容器层。但是将数据存放在容器层存在以下问题:</p>
<ul>
<li>数据不是持久化。意思是如果容器删除了,这些数据也就没了</li>
<li>主机上的其它进程不方便访问这些数据</li>
<li>对这些数据的I/O会经过存储驱动,然后到达主机,引入了一层间接层,因此性能会有所下降</li>
</ul>
<p>Docker提供了3种持久化数据的方式:</p>
<ol>
<li><strong><em>volumes</em></strong>:存于主机文件系统中的某个区域,由Docker管理(<code>/var/lib/docker/volumes/</code> on linux)。非Docker进程不应该修改这些数据。<strong>卷是Docker中持久化数据的最好方式</strong></li>
<li><strong><em>bind mount</em></strong>:存于主机文件系统中的任意位置。非Docker进程可以修改这些数据</li>
<li><strong><em>tmpfs mount</em></strong>(Linux中):存于内存中(注意,并不是持久化到磁盘)。在容器的生命周期中,它能被容器用来存放非持久化的状态或敏感信息</li>
</ol>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Docker/">Docker</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker-storage/">docker storage</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/12/11/2018-12-11-docker-storage-persist/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-12-08-linux-benchmark-fxmark" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/12/08/2018-12-08-linux-benchmark-fxmark/" class="article-date">
<time datetime="2018-12-08T08:35:00.000Z" itemprop="datePublished">2018-12-08</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/12/08/2018-12-08-linux-benchmark-fxmark/">使用FXMARK测试文件系统的多核可扩展性</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>并行I/O技术是一项用于提升应用性能的技术。随着NVMe设备的出现与发展,并发I/O能力增强。同时,CPU核数呈现增长的趋势。这使得很多高性能数据库开始利用多核来加速核心操作。但是,由于文件系统中存在诸如锁竞争、引用计数、cache-line竞争等扩展性瓶颈,因此文件系统操作的处理能力并不能随着核数的增加呈现出线性增长的关系。<a href="https://github.com/sslab-gatech/fxmark" target="_blank" rel="noopener">FxMark</a>就是 USENIX Annual Technical Conference(ATC’16) 中文章 “Understanding Manycore Scalability of File Systems” 的作者开源的一套microbench套件,可以测试文件系统创建、删除、读/写等操作的多核扩展性</p>
<p>这篇博文从源码的角度分析FxMark的使用</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/性能调优/">性能调优</a>
</div>
<p class="article-more-link">
<a href="/2018/12/08/2018-12-08-linux-benchmark-fxmark/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-09-05-linux-kernel" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/09/05/2018-09-05-linux-kernel/" class="article-date">
<time datetime="2018-09-05T02:05:00.000Z" itemprop="datePublished">2018-09-05</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/09/05/2018-09-05-linux-kernel/">Ubuntu下内核与内核模块的编译过程</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>内核开发中经常需要编译内核,这里对ubuntu下内核编译的步骤进行总结</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Linux/">Linux</a>
</div>
<p class="article-more-link">
<a href="/2018/09/05/2018-09-05-linux-kernel/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-01-19-docker-imagestore" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/01/19/2018-01-19-docker-imagestore/" class="article-date">
<time datetime="2018-01-18T18:57:00.000Z" itemprop="datePublished">2018-01-19</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/01/19/2018-01-19-docker-imagestore/"> Docker源码分析—镜像存储 </a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p>基于Docker 17.05.x</p>
</blockquote>
<p>Docker使用<a href="https://arkingc.github.io/2018/01/14/docker-layerstore/">层存储</a>来管理容器和镜像的层,那么如何知道哪些层属于某一个镜像?也就说如果现在系统上有很多个镜像,每个镜像又包括很多层,如果使用Overlay2,你可以在存储驱动目录下看到一大堆目录,如何知道哪些层是属于某个镜像?也就是说<strong>一个镜像如何和镜像层之间建立起关系</strong>?</p>
<p>这篇文章主要通过分析Docker源码,介绍镜像存储的创建过程</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Docker/">Docker</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker-storage/">docker storage</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/01/19/2018-01-19-docker-imagestore/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-01-15-docker-storage-overlay2" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/01/15/2018-01-15-docker-storage-overlay2/" class="article-date">
<time datetime="2018-01-14T18:57:00.000Z" itemprop="datePublished">2018-01-15</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/01/15/2018-01-15-docker-storage-overlay2/"> Docker源码分析—存储驱动 </a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p>基于Docker 17.05.x</p>
</blockquote>
<p>Docker使用<a href="https://arkingc.github.io/2018/01/14/docker-layerstore/">层存储</a>来管理镜像层和容器层。使用<strong>存储驱动</strong>来管理层的内容,使用<strong>层的元数据存储</strong>管理层的元数据</p>
<p><strong>这篇文章以overlay2作为存储驱动</strong>,通过分析源码介绍存储驱动如何管理容器层和镜像层的内容</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Docker/">Docker</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker-storage/">docker storage</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/overlay-overlay2/">overlay/overlay2</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/01/15/2018-01-15-docker-storage-overlay2/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-01-14-docker-layerstore" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/01/14/2018-01-14-docker-layerstore/" class="article-date">
<time datetime="2018-01-13T18:57:00.000Z" itemprop="datePublished">2018-01-14</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/01/14/2018-01-14-docker-layerstore/"> Docker源码分析—层存储 </a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p>基于Docker 17.05.x</p>
</blockquote>
<p>Docker镜像由多层只读镜像层组成,Docker容器实际上就是创建了一层读写层,然后将这层读写层与使用的镜像关联起来。所以实际上镜像和容器在Docker中都是通过“层”来进行存储,每一层对应一个目录,<strong>Docker层存储</strong>就是用来管理这些“层”以及这些层的元数据</p>
<p>这篇文章根据Docker源码介绍Docker层存储的创建过程</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Docker/">Docker</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/docker-storage/">docker storage</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/overlay-overlay2/">overlay/overlay2</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/01/14/2018-01-14-docker-layerstore/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2018-01-10-c-stack_frame" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2018/01/12/2018-01-10-c-stack_frame/" class="article-date">
<time datetime="2018-01-11T18:57:00.000Z" itemprop="datePublished">2018-01-12</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2018/01/12/2018-01-10-c-stack_frame/"> C函数栈帧 </a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<p>一个可执行C程序由一系列二进制码组成,程序代码会被翻译成由二进制组成的机器指令。程序执行时,CPU取出程序指令执行,寄存器用于程序中变量数据的交换以及算术运算。由于寄存器数量等因素,程序执行过程中产生的数据(如变量)不会一直保存在寄存器中,变量和寄存器状态等会被保存在为函数分配的一个栈空间中,这个为函数分配的内存空间,就称为栈帧</p>
<p>栈帧可以加深对C中函数调用与返回的理解,了解函数的栈帧也有利于对C中一些问题进行更深入的思考:</p>
<ul>
<li>函数参数的传递过程</li>
<li>局部变量的生命周期</li>
<li>为什么应该将一些经常调用到的简短的函数定义为内敛函数</li>
<li>…</li>
</ul>
<p>这篇文章使用VC++ 6.0对一个错误的swap函数进行调试,分析其栈帧结构,并解释错误的原因</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/编程语言/">编程语言</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/c/">c</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2018/01/12/2018-01-10-c-stack_frame/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2017-12-26-linux-code-overlayfs-read_write" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2017/12/26/2017-12-26-linux-code-overlayfs-read_write/" class="article-date">
<time datetime="2017-12-25T18:51:00.000Z" itemprop="datePublished">2017-12-26</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/12/26/2017-12-26-linux-code-overlayfs-read_write/">内核OverlayFS—文件读写</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p><strong>内核版本4.4.68</strong></p>
</blockquote>
<p>文件(一般文件或目录)的读写和文件的创建删除不同,文件的创建删除作用于inode结构,需要用到inode操作。而文件的读写则是作用于file结构,因此需要用到file操作</p>
<p>通常,<strong>读写文件之前需要先打开这个文件</strong>,通过open系统调用,传入表示文件的路径字符串,随后内核会根据路径字符串进行路径查找,最终得到一个表示文件的file结构,并使之与当前进程相关联,之后的读写便会根据这个file结构来进行,这个结构的f_op字段是一个file操作的指针,file操作包含了文件读写函数的指针。OverlayFS中文件的读写也不例外,但是在OverlayFS中,一般文件的读写和目录的读写又有区别:</p>
<ul>
<li>一般文件的读写:在OverlayFS中,文件来源于upper层或lower层。在打开文件时,OverlayFS实际上打开的是upper层或者lower层的文件,因此随后发生的读写也就是对upper层或lower层的文件。</li>
<li>目录的读写:与一般文件不同的是,目录的读写相对复杂。因为对于一个同时存在upper层和lower层的目录,在对该目录进行搜索时,OverlayFS会对upper层和lower层的目录分别进行搜索,然后做一些合并处理。但是对于同时存在于upper层或lower层的文件来说,由于”上层覆盖下层“,因此只需要读取upper层中文件就行了</li>
</ul>
<p>正因如此,<strong>对于目录的读取,OverlayFS定义了自己的file操作</strong>,而<strong>对于一般文件的读写,OverlayFS不需要定义自己的操作</strong></p>
<p>这篇文章重点在分析文件读写如何获得自己的读写操作,而不会深入的某个具体的读写函数。比如目录搜索是一个目录读写的例子,这部分另一篇博文有介绍,这里主要是分析OverlayFS中文件读写的本质</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Linux/">Linux</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/kernel/">kernel</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/overlayfs/">overlayfs</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2017/12/26/2017-12-26-linux-code-overlayfs-read_write/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>
<article id="post-2017-12-22-linux-code-overlayfs-create_delete" class="article article-type-post" itemscope="" itemprop="blogPost">
<div class="article-meta">
<a href="/2017/12/22/2017-12-22-linux-code-overlayfs-create_delete/" class="article-date">
<time datetime="2017-12-21T18:51:00.000Z" itemprop="datePublished">2017-12-22</time>
</a>
</div>
<div class="article-inner">
<input type="hidden" class="isFancy">
<header class="article-header">
<h1 itemprop="name">
<a class="article-title" href="/2017/12/22/2017-12-22-linux-code-overlayfs-create_delete/">内核OverlayFS—创建与删除文件</a>
</h1>
</header>
<div class="article-entry" itemprop="articleBody">
<blockquote>
<p><strong>内核版本4.4.68</strong></p>
</blockquote>
<p>在OverlayFS中,创建和删除一个文件实际上并不是在OverlayFS的联合挂载目录下进行,而是在upper目录进行</p>
<p>举个例子,如果OverlayFS中存在/dir目录,而且这个目录是一个upper目录,那么执行命令touch /dir/file实际上会在upper目录下的dir目录中创建一个file文件。如果/dir目录下存在file文件,想要删除这个文件,也是到upper目录下的dir目录中删除这个file文件</p>
<p>由于upper目录并不属于OverlayFS,假设upper目录是ext4下的一个目录,因此OverlayFS无法直接在upper目录下创建或删除文件。那么OverlayFS是如何实现upper目录下的文件创建与删除的?实际上,在OverlayFS定义的文件创建与删除的函数中,只是负责找到对应的upper层中的目录,然后将操作的控制权转交给VFS,然后VFS进一步调用upper目录实际文件系统定义的文件创建与删除函数。这篇文章就是通过两个实际例子来分析这些步骤是如何完成的</p>
</div>
<div class="article-info article-info-index">
<div class="article-category tagcloud">
<a class="article-category-link" href="/categories/Linux/">Linux</a>
</div>
<div class="article-tag tagcloud">
<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/filesystem/">filesystem</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/kernel/">kernel</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/overlayfs/">overlayfs</a></li></ul>
</div>
<p class="article-more-link">
<a href="/2017/12/22/2017-12-22-linux-code-overlayfs-create_delete/#more">more >></a>
</p>
<div class="clearfix"></div>
</div>
</div>
</article>