1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 2006 Andrew Morton <akpm@osdl.org>
4 .\" and Copyright 2006 Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" 2006-07-05 Initial creation, Michael Kerrisk based on
27 .\" Andrew Morton's comments in fs/sync.c
29 .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
30 .\" all rights reserved.
31 .\" Translated 2007-01-09, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.43
32 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
33 .\" Updated 2010-04-23, Akihiro MOTOKI, LDP v3.24
35 .TH SYNC_FILE_RANGE 2 2010-01-17 "Linux" "Linux Programmer's Manual"
37 sync_file_range \- ¥Õ¥¡¥¤¥ë¥»¥°¥á¥ó¥È¤ò¥Ç¥£¥¹¥¯¤ÈƱ´ü¤¹¤ë
40 .BR "#define _GNU_SOURCE" " /* feature_test_macros(7) »²¾È */"
43 .BI "int sync_file_range(int " fd ", off64_t " offset ", off64_t " nbytes ,
44 .BI " unsigned int " flags );
47 .BR sync_file_range ()
48 ¤ò»È¤¦¤È¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
50 ¤Ç»²¾È¤µ¤ì¤ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Î¥Ç¥£¥¹¥¯¤È¤ÎƱ´ü¤Ë´Ø¤·¤Æ¡¢
51 ¤¤áºÙ¤«¤ÊÀ©¸æ¤¬²Äǽ¤È¤Ê¤ë¡£
54 ¤Ï¡¢Æ±´ü¤ò¹Ô¤¦¥Õ¥¡¥¤¥ë¤ÎÎΰè¤Î³«»Ï¥Ð¥¤¥È¤Ç¤¢¤ë¡£
56 ¤Ë¤ÏƱ´ü¤ò¹Ô¤¦Îΰè¤ÎŤµ¤ò¥Ð¥¤¥Èñ°Ì¤Ç»ØÄꤹ¤ë¡£
60 ¤«¤é¥Õ¥¡¥¤¥ëËöÈø¤Þ¤Ç¤ÎÁ´¥Ð¥¤¥È¤òƱ´ü¤¹¤ë¡£
61 Ʊ´ü¤Ï¥·¥¹¥Æ¥à¤Î¥Ú¡¼¥¸¥µ¥¤¥º¤Îñ°Ì¤Ç¹Ô¤ï¤ì¤ë¡£
63 ¤Ï¥Ú¡¼¥¸¶³¦¤Ë¤¢¤ï¤»¤ÆÀڤ겼¤²¤é¤ì¡¢
65 ¤Ï¥Ú¡¼¥¸¶³¦¤Ë¤¢¤ï¤»¤ÆÀÚ¤ê¾å¤²¤é¤ì¤ë¡£
69 ¤Ë¤Ï°Ê²¼¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤¤ë:
71 .B SYNC_FILE_RANGE_WAIT_BEFORE
72 ²¿¤é¤«¤Î½ñ¤¹þ¤ß¤ò¹Ô¤¦Á°¤Ë¡¢»ØÄꤵ¤ì¤¿Îΰè¤Î¥Ú¡¼¥¸¤Ç
73 ½ñ¤½Ð¤·¤ò¹Ô¤¦¤è¤¦¤Ë¥Ç¥Ð¥¤¥¹¥É¥é¥¤¥Ð¤Ë¤¹¤Ç¤ËÍ׵᤬ȯ¹Ô¤µ¤ì¤Æ¤¤¤ë
74 ¥Ú¡¼¥¸¤Î½ñ¤½Ð¤·¤¬Á´¤Æ´°Î»¤¹¤ë¤Î¤òÂԤġ£
76 .B SYNC_FILE_RANGE_WRITE
77 »ØÄꤵ¤ì¤¿Îΰè¤Î¥Ú¡¼¥¸¤Ç¡¢½ñ¤½Ð¤·Í׵᤬ȯ¹Ô¤µ¤ì¤Æ¤¤¤Ê¤¤
78 Á´¤Æ¤Î dirty (¥¥ã¥Ã¥·¥å¤À¤±¤¬Êѹ¹¤µ¤ì¤Æ¤¤¤ë) ¥Ú¡¼¥¸¤Î
80 ¥ê¥¯¥¨¥¹¥È¥¥å¡¼¤ÎÂ礤µ¤è¤ê¿¤¯½ñ¤¹þ¤â¤¦¤È¤·¤¿¾ì¹ç¤Ë¤Ï¡¢
81 ¤³¤Î½èÍý¤ÏÄä»ß (block) ¤¹¤ë²ÄǽÀ¤¬¤¢¤ëÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
83 .B SYNC_FILE_RANGE_WAIT_AFTER
84 ²¿¤é¤«¤Î½ñ¤¹þ¤ß¸å¤Ë¡¢»ØÄꤵ¤ì¤¿Îΰè¤ÎÁ´¤Æ¤Î¥Ú¡¼¥¸¤Î
85 ½ñ¤½Ð¤·¤¬¹Ô¤ï¤ì¤ë¤Î¤òÂԤġ£
88 ¤Ë 0 ¤ò»ØÄꤷ¤¿¾ì¹ç¡¢²¿¤â¤·¤Ê¤¤¤³¤È¤òɽ¤¹¡£
90 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÈó¾ï¤Ë´í¸±¤Ç¤¢¤ê¡¢
91 °Ü¿¢À¤¬É¬Í×¤Ê¥×¥í¥°¥é¥à¤Ç»ÈÍѤ¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£
92 ¤³¤ì¤é¤ÎÁàºî¤Ç¤Ï¤É¤ì¤â¥Õ¥¡¥¤¥ë¤Î¥á¥¿¥Ç¡¼¥¿¤Î½ñ¤½Ð¤·¤ò¹Ô¤ï¤Ê¤¤¡£
93 ¤·¤¿¤¬¤Ã¤Æ¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤êºîÀ®ºÑ¤ß¤Î¥Ç¥£¥¹¥¯¥Ö¥í¥Ã¥¯¤Î
94 ¾å½ñ¤¤Î¼Â¹Ô¤¬³Î¼Â¤Ë¹Ô¤ï¤ì¤Ê¤¤¸Â¤ê¡¢¥¯¥é¥Ã¥·¥å¤Î¸å¤Ç¤â¥Ç¡¼¥¿¤¬
95 ÍøÍѤǤ¤ëÊݾڤϤʤ¤¡£
96 ½ñ¤¹þ¤ß¤¬¾å½ñ¤¤À¤±¤Ç¤¢¤ë¤«¤òÃΤ뤿¤á¤Î¥æ¡¼¥¶¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï¸ºß¤·¤Ê¤¤¡£
98 ¤Ê¤É¤Î) copy-on-write Æ°ºî¤ò»È¤Ã¤¿¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï¡¢
99 ´û¸¤Î³ä¤êÅö¤ÆºÑ¤ß¤Î¥Ö¥í¥Ã¥¯¤ËÂФ¹¤ë¾å½ñ¤¼«ÂΤ¬¤Ç¤¤Ê¤¤¡£
100 Á°¤â¤Ã¤Æ³ä¤êÅö¤Æ¤é¤ì¤¿Îΰè¤Ë½ñ¤¹þ¤ß¤ò¹Ô¤¦¾ì¹ç¡¢
101 ¿¤¯¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¤Ï block allocator ¤Ø¤Î½ñ¤¹þ¤ß¤âɬÍפȤʤ뤬¡¢
102 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï block allocator ¤Î¥Ç¥£¥¹¥¯¤Ø¤ÎƱ´ü¤ò¹Ô¤ï¤Ê¤¤¡£
103 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï¥Ç¥£¥¹¥¯½ñ¤¹þ¤ß¥¥ã¥Ã¥·¥å¤Î¥Õ¥é¥Ã¥·¥å¤ò
104 ¹Ô¤ï¤Ê¤¤¤Î¤Ç¡¢´øȯÀ¤Î¥Ç¥£¥¹¥¯½ñ¤¹þ¤ß¥¥ã¥Ã¥·¥å¤ò»È¤Ã¤¿¥·¥¹¥Æ¥à¤Ç¤Ï
105 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ç¤Ï¥Ç¡¼¥¿¤Î°ì´ÓÀ¤ò³ÎÊݤǤ¤Ê¤¤¤³¤È¤Ë¤Ê¤ë¡£
107 .B SYNC_FILE_RANGE_WAIT_BEFORE
109 .B SYNC_FILE_RANGE_WAIT_AFTER
112 ¾õÂÖ¤ò¸¡½Ð¤·¡¢¸Æ¤Ó½Ð¤·¸µ¤Ë¤³¤ì¤é¤Î¾ðÊó¤òÊÖ¤¹¡£
115 ¤ÎÌò¤ËΩ¤Ä¥Ó¥Ã¥È¤ÎÁȤ߹ç¤ï¤»¤ò°Ê²¼¤Ë¼¨¤¹:
117 .B SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE
118 »ØÄꤵ¤ì¤¿ÈÏ°ÏÆâ¤Î¥Ú¡¼¥¸¤Ç¡¢
119 .BR sync_file_range ()
120 ¤¬¸Æ¤Ó½Ð¤µ¤ì¤¿ºÝ¤Ë dirty ¤Ç¤¢¤Ã¤¿Á´¤Æ¤Î¥Ú¡¼¥¸¤¬¡¢
121 ³Î¼Â¤Ë½ñ¤½Ð¤·ÂоݤȤʤë¤è¤¦¤Ë¤¹¤ë¡£
122 ¤³¤ì¤Ï¡¢start-write-for-data-integrity Áàºî
123 (¥Ç¡¼¥¿´°Á´À³ÎÊݤΤ¿¤á¤Î½ñ¤¹þ¤ß³«»Ï¤ÎÁàºî) ¤Ç¤¢¤ë¡£
125 .B SYNC_FILE_RANGE_WRITE
126 »ØÄꤵ¤ì¤¿ÈÏ°ÏÆâ¤Î¥Ú¡¼¥¸¤Ç¡¢¸½ºß½ñ¤½Ð¤·Ãæ¤Ç¤Ê¤¤Á´¤Æ¤Î dirty ¥Ú¡¼¥¸¤Î
127 ½ñ¤½Ð¤·¤ò³«»Ï¤¹¤ë¡£¤³¤ì¤ÏÈóƱ´ü¤Î¥Ç¥£¥¹¥¯¤Ø¤Î¥Õ¥é¥Ã¥·¥å (flush-to-disk)
128 Áàºî¤Ç¤¢¤ë¡£¥Ç¡¼¥¿´°Á´À³ÎÊݤ¬É¬ÍפÊÁàºî¤È¤·¤Æ¤ÏŬÀڤǤϤʤ¤¡£
130 .BR SYNC_FILE_RANGE_WAIT_BEFORE " (or " SYNC_FILE_RANGE_WAIT_AFTER )
131 »ØÄꤵ¤ì¤¿ÈÏ°ÏÆâ¤ÎÁ´¤Æ¤Î¥Ú¡¼¥¸¤Î½ñ¤½Ð¤·¤Î´°Î»¤òÂԤġ£
132 ¤³¤Î¥Õ¥é¥°¤Ï¡¢Á°¤Ë¹Ô¤ï¤ì¤¿Áàºî
133 .B SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE
134 ¤Î¸å¤Ë»ÈÍѤǤ¡¢¤³¤ÎÁàºî¤Î´°Î»¤òÂÔ¤Á¡¢·ë²Ì¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
136 .B SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WRITE | \
137 SYNC_FILE_RANGE_WAIT_AFTER
138 ¤³¤ì¤Ï write-for-data-integrity Áàºî
139 (¥Ç¡¼¥¿´°Á´À³ÎÊݤΤ¿¤á¤Î½ñ¤¹þ¤ß) ¤Ç¤¢¤ê¡¢»ØÄꤵ¤ì¤¿ÈÏ°ÏÆâ¤Î¡¢
140 .BR sync_file_range ()
141 ¤¬¸Æ¤Ð¤ì¤¿»þÅÀ¤Ç dirty ¤ÊÁ´¤Æ¤Î¥Ú¡¼¥¸¤¬
142 ¥Ç¥£¥¹¥¯¤Ë³ÊǼ¤µ¤ì¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
145 .BR sync_file_range ()
146 ¤Ï 0 ¤òÊÖ¤¹¡£¼ºÇԤξì¹ç¡¢\-1 ¤òÊÖ¤·¡¢
148 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
153 ¤¬Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ï¤Ê¤¤¡£
157 ¤ËÉÔÀµ¤Ê¥Ó¥Ã¥È¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¡£¤Þ¤¿¤Ï
170 ¥Ç¥£¥¹¥¯ÎΰèÉÔ¤Ǥ¢¤ë¡£
174 ¤¬¡¢Ä̾ï¤Î¥Õ¥¡¥¤¥ë¡¢¥Ö¥í¥Ã¥¯¥Ç¥Ð¥¤¥¹¡¢¥Ç¥£¥ì¥¯¥È¥ê¡¢¥·¥ó¥Ü¥ê¥Ã¥¯¥ê¥ó¥¯
175 °Ê³°¤Î¤â¤Î¤ò»Ø¤·¤Æ¤¤¤ë¡£
176 .\" FIXME . (bug?) Actually, how can 'fd' refer to a symbolic link (S_ISLNK)?
177 .\" (In userspace at least) it isn't possible to obtain a file descriptor
178 .\" for a symbolic link.
180 .BR sync_file_range ()
181 ¤Ï¥«¡¼¥Í¥ë 2.6.17 ¤Ç Linux ¤ËÅо줷¤¿¡£
183 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux Æȼ«¤Ç¤¢¤ê¡¢
184 °Ü¿¢À¤¬É¬Í×¤Ê¥×¥í¥°¥é¥à¤Ç¤Ï»ÈÍѤòÈò¤±¤ë¤Ù¤¤Ç¤¢¤ë¡£