xref: /netbsd/lib/libpuffs/puffs_flush.3 (revision f7d8f113)
1*f7d8f113Spooka.\"	$NetBSD: puffs_flush.3,v 1.3 2007/04/06 17:55:10 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
37809ae5f8Spooka.Fn puffs_inval_namecache_dir "struct puffs_usermount *pu" "void *cookie"
38809ae5f8Spooka.Ft int
39809ae5f8Spooka.Fn puffs_inval_namecache_all "struct puffs_usermount *pu"
40622f8591Spooka.Ft int
41622f8591Spooka.Fn puffs_inval_pagecache_node "struct puffs_usermoint *pu" "void *cookie"
42622f8591Spooka.Ft int
43622f8591Spooka.Fo puffs_inval_pagecache_node_range
44622f8591Spooka.Fa "struct puffs_usermoint *pu" "void *cookie" "off_t start" "off_t end"
45622f8591Spooka.Fc
46*f7d8f113Spooka.Ft int
47*f7d8f113Spooka.Fn puffs_flush_pagecache_node "struct puffs_usermoint *pu" "void *cookie"
48*f7d8f113Spooka.Ft int
49*f7d8f113Spooka.Fo puffs_flush_pagecache_node_range
50*f7d8f113Spooka.Fa "struct puffs_usermoint *pu" "void *cookie" "off_t start" "off_t end"
51*f7d8f113Spooka.Fc
52809ae5f8Spooka.Sh DESCRIPTION
53809ae5f8Spooka.Em IMPORTANT NOTE!
54809ae5f8SpookaThis document describes interfaces which are not yet guaranteed to be
55809ae5f8Spookastable.
56809ae5f8SpookaIn case you update your system sources, please recompile everything
57809ae5f8Spookaand fix complation errors.
58809ae5f8SpookaIf your sources are out-of-sync, incorrect operation may result.
59809ae5f8SpookaThe interfaces in this document will most likely be hugely simplified
60809ae5f8Spookain later versions or made transparent to the implementation.
61809ae5f8Spooka.Pp
62809ae5f8SpookaThese routines are used inform the kernel that any information it might
63809ae5f8Spookahave cached is no longer valid.
64809ae5f8Spooka.Fn puffs_inval_namecache_dir
65809ae5f8Spookainvalidates the name cache for a given directory.
66809ae5f8SpookaThe argument
67809ae5f8Spooka.Va cookie
68809ae5f8Spookashould describe an existing and valid directory cookie for the file
69809ae5f8Spookasystem.
70809ae5f8SpookaSimilarly,
71809ae5f8Spooka.Fn puffs_inval_namecache_all
72809ae5f8Spookainvalidates the name cache for the entire file system
73809ae5f8Spooka(this routine might go away).
74622f8591Spooka.Pp
75622f8591SpookaThe cached pages (file contents) for a regular file described by
76622f8591Spooka.Va cookie
77622f8591Spookaare invalidated using
78622f8591Spooka.Fn puffs_inval_pagecache_node .
79622f8591SpookaA specific range can be invalidated using
80622f8591Spooka.Fn puffs_inval_pagecache_node_range
81622f8591Spookafor a platform specific page level granularity.
82622f8591SpookaThe offset
83622f8591Spooka.Va start
84622f8591Spookawill be
85622f8591Spooka.Em truncated
86622f8591Spookato a page boundary while
87622f8591Spooka.Va end
88622f8591Spookawill be
89622f8591Spooka.Em "rounded up"
90622f8591Spookato the next page boundary.
91622f8591SpookaAs a special case, specifying 0 as
92622f8591Spooka.Va end
93622f8591Spookawill invalidate all contents from
94622f8591Spooka.Va start
95622f8591Spookato the end of the file.
96622f8591Spooka.Pp
97622f8591SpookaIt is especially important to note that these routines will not only
98622f8591Spookainvalidate data in the "read cache", but also data in the "write back"
99622f8591Spookacache (conceptually speaking; in reality they are the same cache), which
100622f8591Spookahas not yet been flushed to the file server.
101622f8591SpookaTherefore any unflushed data will be lost.
102*f7d8f113Spooka.Pp
103*f7d8f113SpookaThe counterparts of the invalidation routines are the flushing routines
104*f7d8f113Spooka.Fn puffs_flush_pagecache_node
105*f7d8f113Spookaand
106*f7d8f113Spooka.Fn puffs_flush_pagecache_node_range ,
107*f7d8f113Spookawhich force unwritten data from the kernel page cache to be written.
108*f7d8f113SpookaFor the flush range version, the same range rules as with the
109*f7d8f113Spookainvalidation routine apply.
110*f7d8f113SpookaThe data is flushed asynchronously, i.e. if the routine returns
111*f7d8f113Spookasuccesfully, all the caller knows is that the data has been queued
112*f7d8f113Spookafor writing.
113809ae5f8Spooka.Sh SEE ALSO
114809ae5f8Spooka.Xr puffs 3
115