1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 2003 Abhijit Menon-Sen <ams@wiw.org>
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" 2005-04-08 mtk, noted kernel version and added BUGS
26 .\" Japanese Version Copyright (c) 2004-2007 Yuichi SATO
27 .\" all rights reserved.
28 .\" Translated Sun Jun 20 16:23:17 JST 2004
29 .\" by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v1.66
30 .\" Updated & Modified Fri Apr 22 03:05:51 JST 2005 by Yuichi SATO, LDP v2.02
31 .\" Updated & Modified Thu Jan 4 23:55:18 JST 2007 by Yuichi SATO, LDP v2.43
33 .TH POSIX_FADVISE 2 2003-02-14 "Linux" "Linux Programmer's Manual"
36 .\"O posix_fadvise \- predeclare an access pattern for file data
37 posix_fadvise \- ¥Õ¥¡¥¤¥ë¥Ç¡¼¥¿¤Î¥¢¥¯¥»¥¹¥Ñ¥¿¡¼¥ó¤ò¤¢¤é¤«¤¸¤áÀë¸À¤¹¤ë
41 .B #define _XOPEN_SOURCE 600
44 .BI "int posix_fadvise(int " fd ", off_t " offset ", off_t " len \
50 .\"O .BR posix_fadvise ()
51 .\"O to announce an intention to access
52 .\"O file data in a specific pattern in the future, thus allowing the kernel
53 .\"O to perform appropriate optimizations.
54 ¥×¥í¥°¥é¥à¤Ï¡¢¾ÍèÆÃÄê¤Î¥Ñ¥¿¡¼¥ó¤Ç¥Õ¥¡¥¤¥ë¥Ç¡¼¥¿¤Ë
55 ¥¢¥¯¥»¥¹¤¹¤ë°Õ»×¤òÅÁ¤¨¤ë¤¿¤á¤Ë
58 ¤³¤ì¤Ë¤è¤ê¡¢¥«¡¼¥Í¥ë¤¬Å¬ÀڤʺÇŬ²½¤ò¼Â¹Ô¤¹¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤ë¡£
60 .\"O The \fIadvice\fP applies to a (not necessarily existent) region starting
61 .\"O at \fIoffset\fP and extending for \fIlen\fP bytes (or until the end of
62 .\"O the file if \fIlen\fP is 0) within the file referred to by \fIfd\fP.
63 .\"O The advice is not binding; it merely constitutes an expectation on behalf of
65 \fIadvice\fP ¤Ï \fIfd\fP ¤¬»²¾È¤·¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤Î
66 \fIoffset\fP ¤«¤é»Ï¤Þ¤ë \fIlen\fP ¥Ð¥¤¥È¤ÎÈÏ°ÏÆâ
67 (\fIlen\fP ¤¬ 0 ¤Î¾ì¹ç¤Ï¥Õ¥¡¥¤¥ë¤Î½ª¤ê¤Þ¤Ç) ¤Î
68 (ɬ¤º¤·¤â¸ºß¤·¤Ê¤¤) Îΰè¤ËŬÍѤµ¤ì¤ë¡£
69 ¥¢¥É¥Ð¥¤¥¹¤ÏµÁ̳¤Å¤±¤Ç¤Ï¤Ê¤¤¡£
70 ¥¢¥É¥Ð¥¤¥¹¤Ïñ¤Ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¤¿¤á¤Ë²ÄǽÀ¤ò¹½À®¤¹¤ë¤À¤±¤Ç¤¢¤ë¡£
72 .\"O Permissible values for \fIadvice\fP include:
73 \fIadvice\fP ¤Ëµö¤µ¤ì¤ëÃͤˤϡ¢°Ê²¼¤Î¤â¤Î¤¬´Þ¤Þ¤ì¤ë:
76 .\"O Indicates that the application has no advice to give about its access
77 .\"O pattern for the specified data.
78 .\"O If no advice is given for an open file,
79 .\"O this is the default assumption.
80 »ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤Î¥¢¥¯¥»¥¹¥Ñ¥¿¡¼¥ó¤ò»Ø¼¨¤¹¤ë¥¢¥É¥Ð¥¤¥¹¤ò
81 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬²¿¤â»ý¤Ã¤Æ¤¤¤Ê¤¤¤³¤È¤ò¼¨¤¹¡£
82 ¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ë¥¢¥É¥Ð¥¤¥¹¤¬»ØÄꤵ¤ì¤Ê¤¤¾ì¹ç¡¢
83 ¤³¤ì¤¬¥Ç¥Õ¥©¥ë¥È¤Ç²¾Äꤵ¤ì¤ë¡£
85 .B POSIX_FADV_SEQUENTIAL
86 .\"O The application expects to access the specified data sequentially (with
87 .\"O lower offsets read before higher ones).
88 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï»ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤¬¥·¡¼¥±¥ó¥·¥ã¥ë¤Ë
89 (Â礤ʥª¥Õ¥»¥Ã¥È¤ÎÁ°¤Ë¾®¤µ¤Ê¥ª¥Õ¥»¥Ã¥È¤Î¥Ç¡¼¥¿¤òÆɤà¤è¤¦¤Ë)
90 ¥¢¥¯¥»¥¹¤µ¤ì¤ë¤³¤È¤ò´üÂÔ¤¹¤ë¡£
93 .\"O The specified data will be accessed in random order.
94 »ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤¬¥é¥ó¥À¥à¤Ê½çÈ֤ǥ¢¥¯¥»¥¹¤µ¤ì¤ë¡£
97 .\"O The specified data will be accessed only once.
98 »ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤Ï 1 ÅÙ¤·¤«¥¢¥¯¥»¥¹¤µ¤ì¤Ê¤¤¡£
100 .B POSIX_FADV_WILLNEED
101 .\"O The specified data will be accessed in the near future.
102 »ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤Ï¶á¤¤¾Í襢¥¯¥»¥¹¤µ¤ì¤ë¡£
104 .B POSIX_FADV_DONTNEED
105 .\"O The specified data will not be accessed in the near future.
106 »ØÄꤵ¤ì¤¿¥Ç¡¼¥¿¤Ï¶á¤¤¾Í襢¥¯¥»¥¹¤µ¤ì¤Ê¤¤¡£
107 .\"O .SH "RETURN VALUE"
109 .\"O On success, zero is returned.
110 .\"O On error, an error number is returned.
111 À®¸ù¤·¤¿¾ì¹ç¤Ï 0 ¤¬ÊÖ¤µ¤ì¤ë¡£
112 ¼ºÇÔ¤·¤¿¾ì¹ç¤Ï¥¨¥é¡¼Èֹ椬ÊÖ¤µ¤ì¤ë¡£
117 .\"O The \fIfd\fP argument was not a valid file descriptor.
118 \fIfd\fP °ú¤¿ô¤¬Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
121 .\"O An invalid value was specified for \fIadvice\fP.
122 ̵¸ú¤ÊÃͤ¬ \fIadvice\fP ¤Ë»ØÄꤵ¤ì¤¿¡£
125 .\"O returns EINVAL in this case.)
126 .\"O The specified file descriptor refers to a pipe or FIFO.
131 »ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬¥Ñ¥¤¥×¤Þ¤¿¤Ï FIFO ¤ò»²¾È¤·¤Æ¤¤¤ë
132 (¤³¤Î¾ì¹ç¡¢Linux ¤Ï¼ÂºÝ¤Ë¤Ï
137 .\"O .BR posix_fadvise ()
138 .\"O appeared in kernel 2.5.60.
139 .\"O .\" Actually as fadvise64() -- MTK
140 .\"O Glibc support has been provided since version 2.2.
142 ¤Ï¥«¡¼¥Í¥ë 2.5.60 ¤ÇÅо줷¤¿¡£
143 .\" ¼ÂºÝ¤Ë¤Ï fadvise64() ¤È¤·¤ÆÅо줷¤¿¡£-- MTK
144 glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï glibc ¥Ð¡¼¥¸¥ç¥ó 2.2 °Ê¹ß¤Ç¹Ô¤ï¤ì¤Æ¤¤¤ë¡£
145 .\"O .SH "CONFORMING TO"
148 .\"O Note that the type of the
150 .\"O argument was changed from
154 .\"O in POSIX.1-2003 TC1.
156 °ú¤¿ô¤Î·¿¤¬ POSIX.1-2003 TC1 ¤Ë¤ª¤¤¤Æ
160 ¤ËÊѹ¹¤µ¤ì¤¿ÅÀ¤ËÃí°Õ¤¹¤ë¤³¤È¡£
162 .\"O Under Linux, \fBPOSIX_FADV_NORMAL\fP sets the readahead window to the
163 .\"O default size for the backing device; \fBPOSIX_FADV_SEQUENTIAL\fP doubles
164 .\"O this size, and \fBPOSIX_FADV_RANDOM\fP disables file readahead entirely.
166 Linux ¤Ç¤Ï¡¢\fBPOSIX_FADV_NORMAL\fP ¤Ï¥Ð¥Ã¥¥ó¥°¥Ç¥Ð¥¤¥¹¤Î
167 ¥Ç¥Õ¥©¥ë¥È¥µ¥¤¥º¤ËÀèÆÉ¤ß (readahead) ¥¦¥¤¥ó¥É¥¦¤òÀßÄꤹ¤ë¡£
168 \fBPOSIX_FADV_SEQUENTIAL\fP ¤Ï¤³¤Î¥µ¥¤¥º¤ò 2 Çܤ·¡¢
169 \fBPOSIX_FADV_RANDOM\fP ¤ÏÀèÆɤߤòÁ´¤¯Ìµ¸ú¤Ë¤¹¤ë¡£
170 .\"O These changes affect the entire file, not just the specified region
171 .\"O (but other open file handles to the same file are unaffected).
172 ¤³¤ì¤é¤ÎÊѹ¹¤Ï¥Õ¥¡¥¤¥ëÁ´ÂΤ˱ƶÁ¤·¡¢»ØÄꤵ¤ì¤¿Îΰè¤Î¤ß¤Ë±Æ¶Á¤¹¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤
173 (¤·¤«¤·Æ±¤¸¥Õ¥¡¥¤¥ë¤ËÂФ¹¤ë¾¤Î¥ª¡¼¥×¥ó¥Õ¥¡¥¤¥ë¥Ï¥ó¥É¥ë¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤)¡£
175 .\"O \fBPOSIX_FADV_WILLNEED\fP initiates a
176 .\"O nonblocking read of the specified region into the page cache.
177 .\"O The amount of data read may be decreased by the kernel depending
178 .\"O on virtual memory load.
179 .\"O (A few megabytes will usually be fully satisfied,
180 .\"O and more is rarely useful.)
181 \fBPOSIX_FADV_WILLNEED\fP ¤Ï¡¢
182 ¥Ú¡¼¥¸¥¥ã¥Ã¥·¥å¤Ë»ØÄêÎΰè¤Î¥Ö¥í¥Ã¥¯¤µ¤ì¤Ê¤¤Æɤ߹þ¤ß¤ò³«»Ï¤¹¤ë¡£
183 Æɤ߹þ¤Þ¤ì¤ë¥Ç¡¼¥¿¤ÎÁíÎ̤ϡ¢
184 ²¾ÁÛ¥á¥â¥ê¤ÎÉé²Ù¤Ë°Í¤Ã¤Æ¥«¡¼¥Í¥ë¤¬¸º¤é¤¹¤«¤â¤·¤ì¤Ê¤¤
185 (¿ô¥á¥¬¥Ð¥¤¥È¤Ç¤¢¤ì¤ÐÄ̾ï¤ÏÁ´¤¯½½Ê¬¤Ç¤¢¤ê¡¢
186 ¤½¤ì¤è¤ê¿¤¯¤Æ¤â¤á¤Ã¤¿¤ËÌò¤ËΩ¤¿¤Ê¤¤)¡£
188 .\"O In kernels before 2.6.18, \fBPOSIX_FADV_NOREUSE\fP had the
189 .\"O same semantics as \fBPOSIX_FADV_WILLNEED\fP.
190 .\"O This was probably a bug; since kernel 2.6.18, this flag is a no-op.
191 2.6.18 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢\fBPOSIX_FADV_NOREUSE\fP ¤Ï
192 \fBPOSIX_FADV_WILLNEED\fP ¤ÈƱ¤¸°ÕÌ£¤Ç¤¢¤Ã¤¿¡£
193 ¤³¤ì¤Ï¿ʬ¥Ð¥°¤Ç¤¢¤Ã¤¿¡£
194 ¥«¡¼¥Í¥ë 2.6.18 °Ê¹ß¤Ç¤Ï¡¢¤³¤Î¥Õ¥é¥°¤Ï²¿¤â¹Ô¤ï¤Ê¤¤¡£
196 .\"O \fBPOSIX_FADV_DONTNEED\fP attempts to free cached pages associated with
197 .\"O the specified region.
198 .\"O This is useful, for example, while streaming large
200 .\"O A program may periodically request the kernel to free cached data
201 .\"O that has already been used, so that more useful cached pages are not
202 .\"O discarded instead.
203 \fBPOSIX_FADV_DONTNEED\fP ¤Ï»ØÄꤵ¤ì¤¿Îΰè¤Ë´ØÏ¢ÉÕ¤±¤é¤ì¤¿
204 ¥¥ã¥Ã¥·¥å¥Ú¡¼¥¸¤ò²òÊü¤·¤è¤¦¤È¤¹¤ë¡£
205 Î㤨¤Ð¡¢¤³¤ì¤ÏÂ礤ʥե¡¥¤¥ë¤ò¥¹¥È¥ê¡¼¥ß¥ó¥°¤¹¤ë¤È¤¤ËÌòΩ¤Ä¡£
206 ¥×¥í¥°¥é¥à¤Ï¡¢»ÈÍѺѤߤΥ¥ã¥Ã¥·¥å¤µ¤ì¤¿¥Ç¡¼¥¿¤ò²òÊü¤¹¤ë¤è¤¦¤Ë¡¢
207 Äê´üŪ¤Ë¥«¡¼¥Í¥ë¤ËÍ׵᤹¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
208 ¤½¤¦¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢¤µ¤é¤Ë͸ú¤Ê¥¥ã¥Ã¥·¥å¤µ¤ì¤¿¥Ú¡¼¥¸¤¬¡¢
209 Âå¤ï¤ê¤ËÇË´þ¤µ¤ì¤ë¤³¤È¤Ï¤Ê¤¤¡£
211 .\"O Pages that have not yet been written out will be unaffected, so if the
212 .\"O application wishes to guarantee that pages will be released, it should
216 .\"O .BR fdatasync (2)
218 ¤Þ¤À½ñ¤½Ð¤µ¤ì¤Æ¤¤¤Ê¤¤¥Ú¡¼¥¸¤Ï±Æ¶Á¤ò¼õ¤±¤Ê¤¤¤Î¤Ç¡¢
219 ¤½¤Î¥Ú¡¼¥¸¤Î²òÊü¤¬Êݾڤµ¤ì¤ë¤³¤È¤ò¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Ë¾¤ó¤Ç¤¤¤ë¤Ê¤é¡¢
227 .\"O In kernels before 2.6.6, if
229 .\"O was specified as 0, then this was interpreted literally as "zero bytes",
230 .\"O rather than as meaning "all bytes through to the end of the file".
231 2.6.6 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢
233 ¤Ë 0 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
234 ¡Ö¥Õ¥¡¥¤¥ë¤Î½ª¤ê¤Þ¤Ç¤ÎÁ´¤Æ¤Î¥Ð¥¤¥È¡×¤È¤¤¤¦°ÕÌ£¤Ç¤Ï¤Ê¤¯¡¢
235 ʸ»úÄ̤ê¡Ö0 ¥Ð¥¤¥È¡×¤È¤·¤Æ²ò¼á¤µ¤ì¤Æ¤¤¤¿¡£
239 .BR posix_fallocate (3),
240 .BR posix_madvise (3),
241 .\" FIXME . Write a posix_fadvise(3) page.
242 .BR feature_test_macros (7)