2008-08-12 23:44:39 +04:00
|
|
|
/* $NetBSD: flush.c,v 1.16 2008/08/12 19:44:39 pooka Exp $ */
|
2007-01-09 21:15:08 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#if !defined(lint)
|
2008-08-12 23:44:39 +04:00
|
|
|
__RCSID("$NetBSD: flush.c,v 1.16 2008/08/12 19:44:39 pooka Exp $");
|
2007-01-09 21:15:08 +03:00
|
|
|
#endif /* !lint */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flushing / invalidation routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
#include <assert.h>
|
2007-03-20 13:22:22 +03:00
|
|
|
#include <err.h>
|
2007-01-09 21:15:08 +03:00
|
|
|
#include <errno.h>
|
|
|
|
#include <puffs.h>
|
2007-03-20 13:22:22 +03:00
|
|
|
#include <stdio.h>
|
2007-10-11 23:41:13 +04:00
|
|
|
#include <unistd.h>
|
2007-01-09 21:15:08 +03:00
|
|
|
|
2007-04-12 19:09:00 +04:00
|
|
|
#include "puffs_priv.h"
|
|
|
|
|
2007-01-09 21:15:08 +03:00
|
|
|
#if 0
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_inval_namecache_node(struct puffs_usermount *pu, puffs_cookie_t cookie,
|
2007-01-09 21:15:08 +03:00
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
static int
|
2008-08-12 23:44:39 +04:00
|
|
|
doflush(struct puffs_usermount *pu, puffs_cookie_t cookie, int op,
|
2007-10-11 23:41:13 +04:00
|
|
|
off_t start, off_t end)
|
2007-01-09 21:15:08 +03:00
|
|
|
{
|
2007-12-05 15:11:56 +03:00
|
|
|
struct puffs_framebuf *pb;
|
|
|
|
struct puffs_flush *pf;
|
|
|
|
size_t winlen;
|
2007-12-05 21:55:19 +03:00
|
|
|
int rv;
|
2007-10-11 23:41:13 +04:00
|
|
|
|
2007-12-05 15:11:56 +03:00
|
|
|
pb = puffs_framebuf_make();
|
|
|
|
if (pb == NULL)
|
|
|
|
return ENOMEM;
|
2007-01-09 21:15:08 +03:00
|
|
|
|
2007-12-05 15:11:56 +03:00
|
|
|
winlen = sizeof(struct puffs_flush);
|
2007-12-05 21:55:19 +03:00
|
|
|
if ((rv = puffs_framebuf_getwindow(pb, 0, (void *)&pf, &winlen)) == -1)
|
|
|
|
goto out;
|
2007-12-05 15:11:56 +03:00
|
|
|
assert(winlen == sizeof(struct puffs_flush));
|
2007-01-09 21:15:08 +03:00
|
|
|
|
2007-12-05 15:11:56 +03:00
|
|
|
pf->pf_req.preq_buflen = sizeof(struct puffs_flush);
|
|
|
|
pf->pf_req.preq_opclass = PUFFSOP_FLUSH;
|
|
|
|
pf->pf_req.preq_id = puffs__nextreq(pu);
|
2007-10-11 23:41:13 +04:00
|
|
|
|
2007-12-05 15:11:56 +03:00
|
|
|
pf->pf_op = op;
|
|
|
|
pf->pf_cookie = cookie;
|
|
|
|
pf->pf_start = start;
|
|
|
|
pf->pf_end = end;
|
|
|
|
|
2007-12-05 21:55:19 +03:00
|
|
|
rv = puffs_framev_enqueue_cc(puffs_cc_getcc(pu),
|
2007-12-05 15:11:56 +03:00
|
|
|
puffs_getselectable(pu), pb, 0);
|
2007-12-05 21:55:19 +03:00
|
|
|
|
|
|
|
out:
|
|
|
|
puffs_framebuf_destroy(pb);
|
|
|
|
return rv;
|
2007-01-09 21:15:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_inval_namecache_dir(struct puffs_usermount *pu, puffs_cookie_t cookie)
|
2007-01-09 21:15:08 +03:00
|
|
|
{
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, cookie, PUFFS_INVAL_NAMECACHE_DIR, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
puffs_inval_namecache_all(struct puffs_usermount *pu)
|
|
|
|
{
|
2007-01-09 21:15:08 +03:00
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, NULL, PUFFS_INVAL_NAMECACHE_ALL, 0, 0);
|
2007-01-09 21:15:08 +03:00
|
|
|
}
|
2007-03-20 13:22:22 +03:00
|
|
|
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_inval_pagecache_node(struct puffs_usermount *pu, puffs_cookie_t cookie)
|
2007-03-20 13:22:22 +03:00
|
|
|
{
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, cookie, PUFFS_INVAL_PAGECACHE_NODE_RANGE, 0, 0);
|
2007-03-20 13:22:22 +03:00
|
|
|
}
|
2007-04-06 20:38:03 +04:00
|
|
|
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_inval_pagecache_node_range(struct puffs_usermount *pu,
|
|
|
|
puffs_cookie_t cookie, off_t start, off_t end)
|
2007-04-06 20:38:03 +04:00
|
|
|
{
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, cookie, PUFFS_INVAL_PAGECACHE_NODE_RANGE, start,end);
|
2007-04-06 20:38:03 +04:00
|
|
|
}
|
2007-04-06 21:49:11 +04:00
|
|
|
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_flush_pagecache_node(struct puffs_usermount *pu, puffs_cookie_t cookie)
|
2007-04-06 21:49:11 +04:00
|
|
|
{
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, cookie, PUFFS_FLUSH_PAGECACHE_NODE_RANGE, 0, 0);
|
2007-04-06 21:49:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2008-08-12 23:44:39 +04:00
|
|
|
puffs_flush_pagecache_node_range(struct puffs_usermount *pu,
|
|
|
|
puffs_cookie_t cookie, off_t start, off_t end)
|
2007-04-06 21:49:11 +04:00
|
|
|
{
|
|
|
|
|
2007-10-11 23:41:13 +04:00
|
|
|
return doflush(pu, cookie, PUFFS_FLUSH_PAGECACHE_NODE_RANGE, start,end);
|
2007-04-06 21:49:11 +04:00
|
|
|
}
|