本文整理汇总了C++中VOP_FSYNC函数的典型用法代码示例。如果您正苦于以下问题:C++ VOP_FSYNC函数的具体用法?C++ VOP_FSYNC怎么用?C++ VOP_FSYNC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VOP_FSYNC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ext2fs_sync
/*
* Go through the disk queues to initiate sandbagged IO;
* go through the inodes to write those that have been modified;
* initiate the writing of the super block if it has been modified.
*
* Note: we are always called with the filesystem marked `MPBUSY'.
*/
int
ext2fs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
{
// printf("In file: %s, fun: %s,lineno: %d\n",__FILE__, __func__, __LINE__);
struct vnode *vp;
struct ufsmount *ump = VFSTOUFS(mp);
struct m_ext2fs *fs;
struct vnode_iterator *marker;
int error, allerror = 0;
fs = ump->um_e2fs;
if (fs->e2fs_fmod != 0 && fs->e2fs_ronly != 0) { /* XXX */
printf("fs = %s\n", fs->e2fs_fsmnt);
panic("update: rofs mod");
}
/*
* Write back each (modified) inode.
*/
vfs_vnode_iterator_init(mp, &marker);
while ((vp = vfs_vnode_iterator_next(marker, ext2fs_sync_selector,
NULL)))
{
error = vn_lock(vp, LK_EXCLUSIVE);
if (error) {
vrele(vp);
continue;
}
if (vp->v_type == VREG && waitfor == MNT_LAZY)
error = ext2fs_update(vp, NULL, NULL, 0);
else
error = VOP_FSYNC(vp, cred,
waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0);
if (error)
allerror = error;
vput(vp);
}
vfs_vnode_iterator_destroy(marker);
/*
* Force stale file system control information to be flushed.
*/
if (waitfor != MNT_LAZY) {
vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY);
if ((error = VOP_FSYNC(ump->um_devvp, cred,
waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0)
allerror = error;
VOP_UNLOCK(ump->um_devvp);
}
/*
* Write back modified superblock.
*/
if (fs->e2fs_fmod != 0) {
fs->e2fs_fmod = 0;
fs->e2fs.e2fs_wtime = time_second;
if ((error = ext2fs_cgupdate(ump, waitfor)))
allerror = error;
}
return (allerror);
}
示例2: vnode_fop_fsync
extern int
vnode_fop_fsync(
FILE_T *file_p,
loff_t start,
loff_t end,
int datasync
)
#endif
{
INODE_T *ip;
int err;
CALL_DATA_T cd;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
fsync_ctx ctx;
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
if (file_p == NULL) {
/* NFSD sometimes calls with null file_p and dentry_p filled in. */
ASSERT(dentry_p != NULL);
ip = dentry_p->d_inode;
} else
#endif
ip = file_p->f_dentry->d_inode;
ASSERT_I_SEM_MINE(ip);
ASSERT(MDKI_INOISOURS(ip));
if (!MDKI_INOISMVFS(ip)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
MDKI_VFS_LOG(VFS_LOG_ERR, "%s shouldn't be called? (files swapped "
"at open): file_p=%p dp=%p\n", __func__, file_p, dentry_p);
#else
MDKI_VFS_LOG(VFS_LOG_ERR, "%s shouldn't be called? (files swapped "
"at open): file_p=%p dp=%p\n", __func__, file_p, file_p->f_dentry);
#endif
return 0; /* don't fail the operation, though */
}
mdki_linux_init_call_data(&cd);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
err = VOP_FSYNC(ITOV(ip), datasync == 0 ? FLAG_NODATASYNC : FLAG_DATASYNC,
&cd, (file_ctx *)file_p);
#else
ctx.file_p = file_p;
#if !defined (MRG)
ctx.start = start;
ctx.end = end;
#endif /* !defined (MRG) */
err = VOP_FSYNC(ITOV(ip), datasync == 0 ? FLAG_NODATASYNC : FLAG_DATASYNC,
&cd, &ctx);
#endif /* else LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) */
err = mdki_errno_unix_to_linux(err);
mdki_linux_destroy_call_data(&cd);
return err;
}
示例3: vdev_file_io_start
static int
vdev_file_io_start(zio_t *zio)
{
spa_t *spa = zio->io_spa;
vdev_t *vd = zio->io_vd;
vdev_file_t *vf = vd->vdev_tsd;
if (zio->io_type == ZIO_TYPE_IOCTL) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = ENXIO;
return (ZIO_PIPELINE_CONTINUE);
}
switch (zio->io_cmd) {
case DKIOCFLUSHWRITECACHE:
zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
kcred, NULL);
break;
default:
zio->io_error = ENOTSUP;
}
return (ZIO_PIPELINE_CONTINUE);
}
spa_taskq_dispatch_ent(spa, ZIO_TYPE_FREE, ZIO_TASKQ_ISSUE,
vdev_file_io_strategy, zio, 0, &zio->io_tqent);
return (ZIO_PIPELINE_STOP);
}
示例4: kfclose
static int
kfclose(kfile_t *fp)
{
int rval;
KFDEBUG((CE_CONT, "close: %s\n", fp->kf_fname));
if ((fp->kf_vnflags & FWRITE) && fp->kf_state == 0) {
rval = VOP_FSYNC(fp->kf_vp, FSYNC, kcred);
if (rval != 0) {
KFIOERR((CE_CONT, "%s: sync error %d\n",
fp->kf_fname, rval));
}
KFDEBUG((CE_CONT, "%s: sync ok\n", fp->kf_fname));
}
rval = VOP_CLOSE(fp->kf_vp, fp->kf_vnflags, 1, (offset_t)0, kcred);
if (rval != 0) {
if (fp->kf_state == 0) {
KFIOERR((CE_CONT, "%s: close error %d\n",
fp->kf_fname, rval));
}
} else {
if (fp->kf_state == 0)
KFDEBUG((CE_CONT, "%s: close ok\n", fp->kf_fname));
}
VN_RELE(fp->kf_vp);
kmem_free(fp, sizeof (kfile_t));
return (rval);
}
示例5: nm_close
/*
* Close a mounted file descriptor.
* Remove any locks and apply the VOP_CLOSE operation to the vnode for
* the file descriptor.
*/
static int
nm_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *crp,
caller_context_t *ct)
{
struct namenode *nodep = VTONM(vp);
int error = 0;
(void) cleanlocks(vp, ttoproc(curthread)->p_pid, 0);
cleanshares(vp, ttoproc(curthread)->p_pid);
error = VOP_CLOSE(nodep->nm_filevp, flag, count, offset, crp, ct);
if (count == 1) {
(void) VOP_FSYNC(nodep->nm_filevp, FSYNC, crp, ct);
/*
* Before VN_RELE() we need to remove the vnode from
* the hash table. We should only do so in the NMNMNT case.
* In other cases, nodep->nm_filep keeps a reference
* to nm_filevp and the entry in the hash table doesn't
* hurt.
*/
if ((nodep->nm_flag & NMNMNT) != 0) {
mutex_enter(&ntable_lock);
nameremove(nodep);
mutex_exit(&ntable_lock);
}
VN_RELE(nodep->nm_filevp);
}
return (error);
}
示例6: sfs_close
/*
* Called on the *last* close().
*
* This function should attempt to avoid returning errors, as handling
* them usefully is often not possible.
*/
static
int
sfs_close(struct vnode *v)
{
/* Sync it. */
return VOP_FSYNC(v);
}
示例7: nwfs_sync
/* ARGSUSED */
static int
nwfs_sync(struct mount *mp, int waitfor)
{
struct vnode *vp;
int error, allerror = 0;
/*
* Force stale buffer cache information to be flushed.
*/
loop:
for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist);
vp != NULL;
vp = TAILQ_NEXT(vp, v_nmntvnodes)) {
/*
* If the vnode that we are about to sync is no longer
* associated with this mount point, start over.
*/
if (vp->v_mount != mp)
goto loop;
if (vn_islocked(vp) || RB_EMPTY(&vp->v_rbdirty_tree) ||
(waitfor & MNT_LAZY))
continue;
if (vget(vp, LK_EXCLUSIVE))
goto loop;
/* XXX vp may not be retained */
error = VOP_FSYNC(vp, waitfor, 0);
if (error)
allerror = error;
vput(vp);
}
return (allerror);
}
示例8: vdev_file_io_start
static void
vdev_file_io_start(zio_t *zio)
{
vdev_t *vd = zio->io_vd;
vdev_file_t *vf = vd->vdev_tsd;
ssize_t resid = 0;
if (zio->io_type == ZIO_TYPE_IOCTL) {
if (!vdev_readable(vd)) {
zio->io_error = SET_ERROR(ENXIO);
zio_interrupt(zio);
return;
}
switch (zio->io_cmd) {
case DKIOCFLUSHWRITECACHE:
if (!vnode_getwithvid(vf->vf_vnode, vf->vf_vid)) {
zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
kcred, NULL);
vnode_put(vf->vf_vnode);
}
break;
default:
zio->io_error = SET_ERROR(ENOTSUP);
}
zio_interrupt(zio);
return;
}
ASSERT(zio->io_type == ZIO_TYPE_READ || zio->io_type == ZIO_TYPE_WRITE);
if (!vnode_getwithvid(vf->vf_vnode, vf->vf_vid)) {
/*
VERIFY3U(taskq_dispatch(vdev_file_taskq, vdev_file_io_strategy, zio,
TQ_PUSHPAGE), !=, 0);
*/
zio->io_error = vn_rdwr(zio->io_type == ZIO_TYPE_READ ?
UIO_READ : UIO_WRITE, vf->vf_vnode, zio->io_data,
zio->io_size, zio->io_offset, UIO_SYSSPACE,
0, RLIM64_INFINITY, kcred, &resid);
vnode_put(vf->vf_vnode);
}
if (resid != 0 && zio->io_error == 0)
zio->io_error = SET_ERROR(ENOSPC);
zio_interrupt(zio);
return;
}
示例9: in_fflush
static int
in_fflush(File *fp)
{
int error = 0;
if (fp->count)
error = in_write(fp->vp, &fp->voffset, fp->buf, fp->count);
if (error == 0)
error = VOP_FSYNC(fp->vp, FSYNC, CRED(), NULL);
return (error);
}
示例10: spa_config_write
static int
spa_config_write(spa_config_dirent_t *dp, nvlist_t *nvl)
{
size_t buflen;
char *buf;
vnode_t *vp;
int oflags = FWRITE | FTRUNC | FCREAT | FOFFMAX;
char *temp;
int err;
/*
* If the nvlist is empty (NULL), then remove the old cachefile.
*/
if (nvl == NULL) {
err = vn_remove(dp->scd_path, UIO_SYSSPACE, RMFILE);
return (err);
}
/*
* Pack the configuration into a buffer.
*/
VERIFY(nvlist_size(nvl, &buflen, NV_ENCODE_XDR) == 0);
buf = kmem_alloc(buflen, KM_SLEEP);
temp = kmem_zalloc(MAXPATHLEN, KM_SLEEP);
VERIFY(nvlist_pack(nvl, &buf, &buflen, NV_ENCODE_XDR,
KM_SLEEP) == 0);
/*
* Write the configuration to disk. We need to do the traditional
* 'write to temporary file, sync, move over original' to make sure we
* always have a consistent view of the data.
*/
(void) snprintf(temp, MAXPATHLEN, "%s.tmp", dp->scd_path);
err = vn_open(temp, UIO_SYSSPACE, oflags, 0644, &vp, CRCREAT, 0);
if (err == 0) {
err = vn_rdwr(UIO_WRITE, vp, buf, buflen, 0, UIO_SYSSPACE,
0, RLIM64_INFINITY, kcred, NULL);
if (err == 0)
err = VOP_FSYNC(vp, FSYNC, kcred, NULL);
if (err == 0)
err = vn_rename(temp, dp->scd_path, UIO_SYSSPACE);
(void) VOP_CLOSE(vp, oflags, 1, 0, kcred, NULL);
}
(void) vn_remove(temp, UIO_SYSSPACE, RMFILE);
kmem_free(buf, buflen);
kmem_free(temp, MAXPATHLEN);
return (err);
}
示例11: nm_sync
/*
* Since this file system has no disk blocks of its own, apply
* the VOP_FSYNC operation on the mounted file descriptor.
*/
static int
nm_sync(vfs_t *vfsp, short flag, cred_t *crp)
{
struct namenode *nodep;
if (vfsp == NULL)
return (0);
nodep = (struct namenode *)vfsp->vfs_data;
if (flag & SYNC_CLOSE)
return (nm_umountall(nodep->nm_filevp, crp));
return (VOP_FSYNC(nodep->nm_filevp, FSYNC, crp, NULL));
}
示例12: union_fsync
/*
* union_fsync(struct vnode *a_vp, struct ucred *a_cred, int a_waitfor,
* struct thread *a_td)
*/
static int
union_fsync(struct vop_fsync_args *ap)
{
int error = 0;
struct thread *td = ap->a_td;
struct vnode *targetvp;
struct union_node *un = VTOUNION(ap->a_vp);
if ((targetvp = union_lock_other(un, td)) != NULLVP) {
error = VOP_FSYNC(targetvp, ap->a_waitfor, 0);
union_unlock_other(targetvp, td);
}
return (error);
}
示例13: RUMP_VOP_FSYNC
int
RUMP_VOP_FSYNC(struct vnode *vp,
struct kauth_cred *cred,
int flags,
off_t offlo,
off_t offhi)
{
int error;
rump_schedule();
error = VOP_FSYNC(vp, cred, flags, offlo, offhi);
rump_unschedule();
return error;
}
示例14: xfs_file_fsync
STATIC int
xfs_file_fsync(
struct file *filp,
struct dentry *dentry,
int datasync)
{
struct inode *inode = dentry->d_inode;
vnode_t *vp = vn_from_inode(inode);
int error;
int flags = FSYNC_WAIT;
if (datasync)
flags |= FSYNC_DATA;
VOP_FSYNC(vp, flags, NULL, (xfs_off_t)0, (xfs_off_t)-1, error);
return -error;
}
示例15: vdev_file_io_start
static int
vdev_file_io_start(zio_t *zio)
{
spa_t *spa = zio->io_spa;
vdev_t *vd = zio->io_vd;
vdev_file_t *vf = vd->vdev_tsd;
vdev_buf_t *vb;
buf_t *bp;
if (zio->io_type == ZIO_TYPE_IOCTL) {
/* XXPOLICY */
if (!vdev_readable(vd)) {
zio->io_error = ENXIO;
return (ZIO_PIPELINE_CONTINUE);
}
switch (zio->io_cmd) {
case DKIOCFLUSHWRITECACHE:
zio->io_error = VOP_FSYNC(vf->vf_vnode, FSYNC | FDSYNC,
kcred, NULL);
break;
default:
zio->io_error = ENOTSUP;
}
return (ZIO_PIPELINE_CONTINUE);
}
vb = kmem_alloc(sizeof (vdev_buf_t), KM_SLEEP);
vb->vb_io = zio;
bp = &vb->vb_buf;
bioinit(bp);
bp->b_flags = (zio->io_type == ZIO_TYPE_READ ? B_READ : B_WRITE);
bp->b_bcount = zio->io_size;
bp->b_un.b_addr = zio->io_data;
bp->b_lblkno = lbtodb(zio->io_offset);
bp->b_bufsize = zio->io_size;
bp->b_private = vf->vf_vnode;
bp->b_iodone = (int (*)())vdev_file_io_intr;
taskq_dispatch_ent(spa->spa_zio_taskq[ZIO_TYPE_FREE][ZIO_TASKQ_ISSUE],
vdev_file_io_strategy, bp, 0, &zio->io_tqent);
return (ZIO_PIPELINE_STOP);
}