Add PUFFS support for fallocate and fdiscard operations
This commit is contained in:
parent
ef586c84dd
commit
78fa995d09
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: puffs_msgif.h,v 1.81 2014/08/16 16:19:41 manu Exp $ */
|
/* $NetBSD: puffs_msgif.h,v 1.82 2014/10/31 13:52:41 manu Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||||
|
@ -86,11 +86,12 @@ enum {
|
||||||
PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT,
|
PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT,
|
||||||
PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR,
|
PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR,
|
||||||
PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR,
|
PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR,
|
||||||
PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR
|
PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR, PUFFS_VN_FALLOCATE,
|
||||||
|
PUFFS_VN_FDISCARD,
|
||||||
/* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */
|
/* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */
|
||||||
};
|
};
|
||||||
#define PUFFS_VN_MAX PUFFS_VN_CLOSEEXTATTR
|
#define PUFFS_VN_MAX PUFFS_VN_FDISCARD
|
||||||
#define PUFFS_VN_SPARE 32
|
#define PUFFS_VN_SPARE 30
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These signal invalid parameters the file system returned.
|
* These signal invalid parameters the file system returned.
|
||||||
|
@ -666,6 +667,18 @@ struct puffs_vnmsg_deleteextattr {
|
||||||
struct puffs_kcred pvnr_cred; /* OUT */
|
struct puffs_kcred pvnr_cred; /* OUT */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct puffs_vnmsg_fallocate {
|
||||||
|
struct puffs_req pvn_pr;
|
||||||
|
off_t pvnr_off; /* OUT */
|
||||||
|
off_t pvnr_len; /* OUT */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct puffs_vnmsg_fdiscard {
|
||||||
|
struct puffs_req pvn_pr;
|
||||||
|
off_t pvnr_off; /* OUT */
|
||||||
|
off_t pvnr_len; /* OUT */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For cache reports. Everything is always out-out-out, no replies
|
* For cache reports. Everything is always out-out-out, no replies
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: puffs_vnops.c,v 1.195 2014/10/31 13:51:33 manu Exp $ */
|
/* $NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.195 2014/10/31 13:51:33 manu Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
|
@ -73,6 +73,8 @@ int puffs_vnop_symlink(void *);
|
||||||
int puffs_vnop_rename(void *);
|
int puffs_vnop_rename(void *);
|
||||||
int puffs_vnop_read(void *);
|
int puffs_vnop_read(void *);
|
||||||
int puffs_vnop_write(void *);
|
int puffs_vnop_write(void *);
|
||||||
|
int puffs_vnop_fallocate(void *);
|
||||||
|
int puffs_vnop_fdiscard(void *);
|
||||||
int puffs_vnop_fcntl(void *);
|
int puffs_vnop_fcntl(void *);
|
||||||
int puffs_vnop_ioctl(void *);
|
int puffs_vnop_ioctl(void *);
|
||||||
int puffs_vnop_inactive(void *);
|
int puffs_vnop_inactive(void *);
|
||||||
|
@ -113,8 +115,8 @@ const struct vnodeopv_entry_desc puffs_vnodeop_entries[] = {
|
||||||
{ &vop_setattr_desc, puffs_vnop_checkop }, /* setattr */
|
{ &vop_setattr_desc, puffs_vnop_checkop }, /* setattr */
|
||||||
{ &vop_read_desc, puffs_vnop_checkop }, /* read */
|
{ &vop_read_desc, puffs_vnop_checkop }, /* read */
|
||||||
{ &vop_write_desc, puffs_vnop_checkop }, /* write */
|
{ &vop_write_desc, puffs_vnop_checkop }, /* write */
|
||||||
{ &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
|
{ &vop_fallocate_desc, puffs_vnop_fallocate }, /* fallocate */
|
||||||
{ &vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */
|
{ &vop_fdiscard_desc, puffs_vnop_fdiscard }, /* fdiscard */
|
||||||
{ &vop_fsync_desc, puffs_vnop_fsync }, /* REAL fsync */
|
{ &vop_fsync_desc, puffs_vnop_fsync }, /* REAL fsync */
|
||||||
{ &vop_seek_desc, puffs_vnop_checkop }, /* seek */
|
{ &vop_seek_desc, puffs_vnop_checkop }, /* seek */
|
||||||
{ &vop_remove_desc, puffs_vnop_checkop }, /* remove */
|
{ &vop_remove_desc, puffs_vnop_checkop }, /* remove */
|
||||||
|
@ -2498,6 +2500,80 @@ puffs_vnop_write(void *v)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
puffs_vnop_fallocate(void *v)
|
||||||
|
{
|
||||||
|
struct vop_fallocate_args /* {
|
||||||
|
const struct vnodeop_desc *a_desc;
|
||||||
|
struct vnode *a_vp;
|
||||||
|
off_t a_pos;
|
||||||
|
off_t a_len;
|
||||||
|
} */ *ap = v;
|
||||||
|
struct vnode *vp = ap->a_vp;
|
||||||
|
struct puffs_node *pn = VPTOPP(vp);
|
||||||
|
struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
|
||||||
|
PUFFS_MSG_VARS(vn, fallocate);
|
||||||
|
int error;
|
||||||
|
|
||||||
|
mutex_enter(&pn->pn_sizemtx);
|
||||||
|
|
||||||
|
PUFFS_MSG_ALLOC(vn, fallocate);
|
||||||
|
fallocate_msg->pvnr_off = ap->a_pos;
|
||||||
|
fallocate_msg->pvnr_len = ap->a_len;
|
||||||
|
puffs_msg_setinfo(park_fallocate, PUFFSOP_VN,
|
||||||
|
PUFFS_VN_FALLOCATE, VPTOPNC(vp));
|
||||||
|
|
||||||
|
PUFFS_MSG_ENQUEUEWAIT2(pmp, park_fallocate, vp->v_data, NULL, error);
|
||||||
|
error = checkerr(pmp, error, __func__);
|
||||||
|
PUFFS_MSG_RELEASE(fallocate);
|
||||||
|
|
||||||
|
switch (error) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case EAGAIN:
|
||||||
|
error = EIO;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
default:
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ap->a_pos + ap->a_len > vp->v_size) {
|
||||||
|
uvm_vnp_setsize(vp, ap->a_pos + ap->a_len);
|
||||||
|
puffs_updatenode(pn, PUFFS_UPDATESIZE, vp->v_size);
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
mutex_exit(&pn->pn_sizemtx);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
puffs_vnop_fdiscard(void *v)
|
||||||
|
{
|
||||||
|
struct vop_fdiscard_args /* {
|
||||||
|
const struct vnodeop_desc *a_desc;
|
||||||
|
struct vnode *a_vp;
|
||||||
|
off_t a_pos;
|
||||||
|
off_t a_len;
|
||||||
|
} */ *ap = v;
|
||||||
|
struct vnode *vp = ap->a_vp;
|
||||||
|
struct puffs_mount *pmp = MPTOPUFFSMP(vp->v_mount);
|
||||||
|
PUFFS_MSG_VARS(vn, fdiscard);
|
||||||
|
int error;
|
||||||
|
|
||||||
|
PUFFS_MSG_ALLOC(vn, fdiscard);
|
||||||
|
fdiscard_msg->pvnr_off = ap->a_pos;
|
||||||
|
fdiscard_msg->pvnr_len = ap->a_len;
|
||||||
|
puffs_msg_setinfo(park_fdiscard, PUFFSOP_VN,
|
||||||
|
PUFFS_VN_FALLOCATE, VPTOPNC(vp));
|
||||||
|
|
||||||
|
PUFFS_MSG_ENQUEUEWAIT2(pmp, park_fdiscard, vp->v_data, NULL, error);
|
||||||
|
error = checkerr(pmp, error, __func__);
|
||||||
|
PUFFS_MSG_RELEASE(fdiscard);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
puffs_vnop_print(void *v)
|
puffs_vnop_print(void *v)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue