xref: /netbsd/lib/libpuffs/puffs_flush.3 (revision ff423327)
1*ff423327Spooka.\"	$NetBSD: puffs_flush.3,v 1.7 2008/08/12 19:44:39 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
37*ff423327Spooka.Fo puffs_inval_namecache_dir
38*ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
39*ff423327Spooka.Fc
40809ae5f8Spooka.Ft int
41809ae5f8Spooka.Fn puffs_inval_namecache_all "struct puffs_usermount *pu"
42622f8591Spooka.Ft int
43*ff423327Spooka.Fo puffs_inval_pagecache_node
44*ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
45622f8591Spooka.Fc
46f7d8f113Spooka.Ft int
47*ff423327Spooka.Fo puffs_inval_pagecache_node_range
48*ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie" "off_t start"
49*ff423327Spooka.Fa "off_t end"
50*ff423327Spooka.Fc
51*ff423327Spooka.Ft int
52*ff423327Spooka.Fo puffs_flush_pagecache_node
53*ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie"
54*ff423327Spooka.Fc
55f7d8f113Spooka.Ft int
56f7d8f113Spooka.Fo puffs_flush_pagecache_node_range
57*ff423327Spooka.Fa "struct puffs_usermount *pu" "puffs_cookie_t cookie" "off_t start"
58*ff423327Spooka.Fa "off_t end"
59f7d8f113Spooka.Fc
60809ae5f8Spooka.Sh DESCRIPTION
61809ae5f8Spooka.Em IMPORTANT NOTE!
62809ae5f8SpookaThis document describes interfaces which are not yet guaranteed to be
63809ae5f8Spookastable.
64809ae5f8SpookaIn case you update your system sources, please recompile everything
650b6ffdfeSwizand fix compilation errors.
66809ae5f8SpookaIf your sources are out-of-sync, incorrect operation may result.
67809ae5f8SpookaThe interfaces in this document will most likely be hugely simplified
68809ae5f8Spookain later versions or made transparent to the implementation.
69809ae5f8Spooka.Pp
70809ae5f8SpookaThese routines are used inform the kernel that any information it might
71809ae5f8Spookahave cached is no longer valid.
72809ae5f8Spooka.Fn puffs_inval_namecache_dir
73809ae5f8Spookainvalidates the name cache for a given directory.
74809ae5f8SpookaThe argument
75809ae5f8Spooka.Va cookie
76809ae5f8Spookashould describe an existing and valid directory cookie for the file
77809ae5f8Spookasystem.
78809ae5f8SpookaSimilarly,
79809ae5f8Spooka.Fn puffs_inval_namecache_all
80809ae5f8Spookainvalidates the name cache for the entire file system
81809ae5f8Spooka(this routine might go away).
82622f8591Spooka.Pp
83622f8591SpookaThe cached pages (file contents) for a regular file described by
84622f8591Spooka.Va cookie
85622f8591Spookaare invalidated using
86622f8591Spooka.Fn puffs_inval_pagecache_node .
87622f8591SpookaA specific range can be invalidated using
88622f8591Spooka.Fn puffs_inval_pagecache_node_range
89622f8591Spookafor a platform specific page level granularity.
90622f8591SpookaThe offset
91622f8591Spooka.Va start
92622f8591Spookawill be
93622f8591Spooka.Em truncated
94622f8591Spookato a page boundary while
95622f8591Spooka.Va end
96622f8591Spookawill be
97622f8591Spooka.Em "rounded up"
98622f8591Spookato the next page boundary.
99622f8591SpookaAs a special case, specifying 0 as
100622f8591Spooka.Va end
101622f8591Spookawill invalidate all contents from
102622f8591Spooka.Va start
103622f8591Spookato the end of the file.
104622f8591Spooka.Pp
105622f8591SpookaIt is especially important to note that these routines will not only
106622f8591Spookainvalidate data in the "read cache", but also data in the "write back"
107622f8591Spookacache (conceptually speaking; in reality they are the same cache), which
108622f8591Spookahas not yet been flushed to the file server.
109622f8591SpookaTherefore any unflushed data will be lost.
110f7d8f113Spooka.Pp
111f7d8f113SpookaThe counterparts of the invalidation routines are the flushing routines
112f7d8f113Spooka.Fn puffs_flush_pagecache_node
113f7d8f113Spookaand
114f7d8f113Spooka.Fn puffs_flush_pagecache_node_range ,
115f7d8f113Spookawhich force unwritten data from the kernel page cache to be written.
116f7d8f113SpookaFor the flush range version, the same range rules as with the
117f7d8f113Spookainvalidation routine apply.
118f7d8f113SpookaThe data is flushed asynchronously, i.e. if the routine returns
1199429ef03Swizsuccessfully, all the caller knows is that the data has been queued
120f7d8f113Spookafor writing.
121809ae5f8Spooka.Sh SEE ALSO
122809ae5f8Spooka.Xr puffs 3
123