xref: /netbsd/lib/libpuffs/puffs_flush.3 (revision 229bf1af)
1*229bf1afSpooka.\"	$NetBSD: puffs_flush.3,v 1.8 2009/02/20 14:26:56 pooka Exp $
2809ae5f8Spooka.\"
3809ae5f8Spooka.\" Copyright (c) 2007 Antti Kantee.  All rights reserved.
4809ae5f8Spooka.\"
5809ae5f8Spooka.\" Redistribution and use in source and binary forms, with or without
6809ae5f8Spooka.\" modification, are permitted provided that the following conditions
7809ae5f8Spooka.\" are met:
8809ae5f8Spooka.\" 1. Redistributions of source code must retain the above copyright
9809ae5f8Spooka.\"    notice, this list of conditions and the following disclaimer.
10809ae5f8Spooka.\" 2. Redistributions in binary form must reproduce the above copyright
11809ae5f8Spooka.\"    notice, this list of conditions and the following disclaimer in the
12809ae5f8Spooka.\"    documentation and/or other materials provided with the distribution.
13809ae5f8Spooka.\"
14809ae5f8Spooka.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15809ae5f8Spooka.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16809ae5f8Spooka.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17809ae5f8Spooka.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18809ae5f8Spooka.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19809ae5f8Spooka.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20809ae5f8Spooka.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21809ae5f8Spooka.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22809ae5f8Spooka.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23809ae5f8Spooka.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24809ae5f8Spooka.\" SUCH DAMAGE.
25809ae5f8Spooka.\"
26622f8591Spooka.Dd April 7, 2007
27809ae5f8Spooka.Dt PUFFS_FLUSH 3
28809ae5f8Spooka.Os
29809ae5f8Spooka.Sh NAME
30809ae5f8Spooka.Nm puffs_flush
31809ae5f8Spooka.Nd puffs kernel cache flushing and invalidation routines
32809ae5f8Spooka.Sh LIBRARY
33809ae5f8Spooka.Lb libpuffs
34809ae5f8Spooka.Sh SYNOPSIS
35809ae5f8Spooka.In puffs.h
36809ae5f8Spooka.Ft int
37ff423327Spooka.Fo puffs_inval_namecache_dir
38ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
39ff423327Spooka.Fc
40809ae5f8Spooka.Ft int
41809ae5f8Spooka.Fn puffs_inval_namecache_all "struct puffs_usermount *pu"
42622f8591Spooka.Ft int
43ff423327Spooka.Fo puffs_inval_pagecache_node
44ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
45622f8591Spooka.Fc
46f7d8f113Spooka.Ft int
47ff423327Spooka.Fo puffs_inval_pagecache_node_range
48ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie" "off_t start"
49ff423327Spooka.Fa "off_t end"
50ff423327Spooka.Fc
51ff423327Spooka.Ft int
52ff423327Spooka.Fo puffs_flush_pagecache_node
53ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
54ff423327Spooka.Fc
55f7d8f113Spooka.Ft int
56f7d8f113Spooka.Fo puffs_flush_pagecache_node_range
57ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie" "off_t start"
58ff423327Spooka.Fa "off_t end"
59f7d8f113Spooka.Fc
60809ae5f8Spooka.Sh DESCRIPTION
61809ae5f8SpookaThese routines are used inform the kernel that any information it might
62809ae5f8Spookahave cached is no longer valid.
63809ae5f8Spooka.Fn puffs_inval_namecache_dir
64809ae5f8Spookainvalidates the name cache for a given directory.
65809ae5f8SpookaThe argument
66809ae5f8Spooka.Va cookie
67809ae5f8Spookashould describe an existing and valid directory cookie for the file
68809ae5f8Spookasystem.
69809ae5f8SpookaSimilarly,
70809ae5f8Spooka.Fn puffs_inval_namecache_all
71809ae5f8Spookainvalidates the name cache for the entire file system
72809ae5f8Spooka(this routine might go away).
73622f8591Spooka.Pp
74622f8591SpookaThe cached pages (file contents) for a regular file described by
75622f8591Spooka.Va cookie
76622f8591Spookaare invalidated using
77622f8591Spooka.Fn puffs_inval_pagecache_node .
78622f8591SpookaA specific range can be invalidated using
79622f8591Spooka.Fn puffs_inval_pagecache_node_range
80622f8591Spookafor a platform specific page level granularity.
81622f8591SpookaThe offset
82622f8591Spooka.Va start
83622f8591Spookawill be
84622f8591Spooka.Em truncated
85622f8591Spookato a page boundary while
86622f8591Spooka.Va end
87622f8591Spookawill be
88622f8591Spooka.Em "rounded up"
89622f8591Spookato the next page boundary.
90622f8591SpookaAs a special case, specifying 0 as
91622f8591Spooka.Va end
92622f8591Spookawill invalidate all contents from
93622f8591Spooka.Va start
94622f8591Spookato the end of the file.
95622f8591Spooka.Pp
96622f8591SpookaIt is especially important to note that these routines will not only
97622f8591Spookainvalidate data in the "read cache", but also data in the "write back"
98622f8591Spookacache (conceptually speaking; in reality they are the same cache), which
99622f8591Spookahas not yet been flushed to the file server.
100622f8591SpookaTherefore any unflushed data will be lost.
101f7d8f113Spooka.Pp
102f7d8f113SpookaThe counterparts of the invalidation routines are the flushing routines
103f7d8f113Spooka.Fn puffs_flush_pagecache_node
104f7d8f113Spookaand
105f7d8f113Spooka.Fn puffs_flush_pagecache_node_range ,
106f7d8f113Spookawhich force unwritten data from the kernel page cache to be written.
107f7d8f113SpookaFor the flush range version, the same range rules as with the
108f7d8f113Spookainvalidation routine apply.
109f7d8f113SpookaThe data is flushed asynchronously, i.e. if the routine returns
1109429ef03Swizsuccessfully, all the caller knows is that the data has been queued
111f7d8f113Spookafor writing.
112809ae5f8Spooka.Sh SEE ALSO
113809ae5f8Spooka.Xr puffs 3
114