Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/puffs Add PUFFS support for fallocate and fdiscard op...
details: https://anonhg.NetBSD.org/src/rev/80d51be313ad
branches: trunk
changeset: 803521:80d51be313ad
user: manu <manu%NetBSD.org@localhost>
date: Fri Oct 31 13:52:41 2014 +0000
description:
Add PUFFS support for fallocate and fdiscard operations
diffstat:
sys/fs/puffs/puffs_msgif.h | 21 +++++++++--
sys/fs/puffs/puffs_vnops.c | 84 +++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 97 insertions(+), 8 deletions(-)
diffs (163 lines):
diff -r cde2d489ad8e -r 80d51be313ad sys/fs/puffs/puffs_msgif.h
--- a/sys/fs/puffs/puffs_msgif.h Fri Oct 31 13:51:33 2014 +0000
+++ b/sys/fs/puffs/puffs_msgif.h Fri Oct 31 13:52:41 2014 +0000
@@ -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.
@@ -86,11 +86,12 @@
PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT,
PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR,
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 */
};
-#define PUFFS_VN_MAX PUFFS_VN_CLOSEEXTATTR
-#define PUFFS_VN_SPARE 32
+#define PUFFS_VN_MAX PUFFS_VN_FDISCARD
+#define PUFFS_VN_SPARE 30
/*
* These signal invalid parameters the file system returned.
@@ -666,6 +667,18 @@
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
*/
diff -r cde2d489ad8e -r 80d51be313ad sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c Fri Oct 31 13:51:33 2014 +0000
+++ b/sys/fs/puffs/puffs_vnops.c Fri Oct 31 13:52:41 2014 +0000
@@ -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.
@@ -30,7 +30,7 @@
*/
#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/buf.h>
@@ -73,6 +73,8 @@
int puffs_vnop_rename(void *);
int puffs_vnop_read(void *);
int puffs_vnop_write(void *);
+int puffs_vnop_fallocate(void *);
+int puffs_vnop_fdiscard(void *);
int puffs_vnop_fcntl(void *);
int puffs_vnop_ioctl(void *);
int puffs_vnop_inactive(void *);
@@ -113,8 +115,8 @@
{ &vop_setattr_desc, puffs_vnop_checkop }, /* setattr */
{ &vop_read_desc, puffs_vnop_checkop }, /* read */
{ &vop_write_desc, puffs_vnop_checkop }, /* write */
- { &vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */
- { &vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */
+ { &vop_fallocate_desc, puffs_vnop_fallocate }, /* fallocate */
+ { &vop_fdiscard_desc, puffs_vnop_fdiscard }, /* fdiscard */
{ &vop_fsync_desc, puffs_vnop_fsync }, /* REAL fsync */
{ &vop_seek_desc, puffs_vnop_checkop }, /* seek */
{ &vop_remove_desc, puffs_vnop_checkop }, /* remove */
@@ -2499,6 +2501,80 @@
}
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
puffs_vnop_print(void *v)
{
struct vop_print_args /* {
Home |
Main Index |
Thread Index |
Old Index