Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add capability to attach external memory to files on rumpfs....
details: https://anonhg.NetBSD.org/src/rev/2f04251b94e3
branches: trunk
changeset: 343404:2f04251b94e3
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Feb 02 12:22:23 2016 +0000
description:
Add capability to attach external memory to files on rumpfs. This
feature is useful e.g. for tight-memory systems where you don't need
block storage, but still need to provide some data via files.
diffstat:
distrib/sets/lists/comp/mi | 3 +-
sys/rump/include/rump/Makefile | 3 +-
sys/rump/include/rump/rumpfs.h | 42 +++++++++++++++++++
sys/rump/librump/rumpvfs/rumpfs.c | 86 ++++++++++++++++++++++++++++++++++++--
4 files changed, 127 insertions(+), 7 deletions(-)
diffs (236 lines):
diff -r a9e3b23ddc17 -r 2f04251b94e3 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Tue Feb 02 01:15:58 2016 +0000
+++ b/distrib/sets/lists/comp/mi Tue Feb 02 12:22:23 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2016 2016/01/31 23:14:34 pooka Exp $
+# $NetBSD: mi,v 1.2017 2016/02/02 12:22:23 pooka Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -2666,6 +2666,7 @@
./usr/include/rump/rumpdefs.h comp-c-include rump
./usr/include/rump/rumperr.h comp-c-include rump
./usr/include/rump/rumperrno2host.h comp-c-include rump
+./usr/include/rump/rumpfs.h comp-c-include rump
./usr/include/rump/rumpkern_if_pub.h comp-c-include rump
./usr/include/rump/rumpnet_if_pub.h comp-c-include rump
./usr/include/rump/rumpuser.h comp-c-include rump
diff -r a9e3b23ddc17 -r 2f04251b94e3 sys/rump/include/rump/Makefile
--- a/sys/rump/include/rump/Makefile Tue Feb 02 01:15:58 2016 +0000
+++ b/sys/rump/include/rump/Makefile Tue Feb 02 12:22:23 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.9 2016/01/31 23:14:34 pooka Exp $
+# $NetBSD: Makefile,v 1.10 2016/02/02 12:22:23 pooka Exp $
.include <bsd.own.mk>
@@ -8,6 +8,7 @@
INCS= rump.h rump_namei.h rump_syscalls.h rump_syscalls_compat.h
INCS+= rump_syscallshotgun.h
INCS+= rumpdefs.h rumperr.h rumperrno2host.h rumpuser.h rumpvnode_if.h
+INCS+= rumpfs.h
INCS+= rumpkern_if_pub.h rumpvfs_if_pub.h rumpnet_if_pub.h
.endif
diff -r a9e3b23ddc17 -r 2f04251b94e3 sys/rump/include/rump/rumpfs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/include/rump/rumpfs.h Tue Feb 02 12:22:23 2016 +0000
@@ -0,0 +1,42 @@
+/* $NetBSD: rumpfs.h,v 1.1 2016/02/02 12:22:23 pooka Exp $ */
+
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#ifndef _RUMP_RUMPFS_H_
+#define _RUMP_RUMPFS_H_
+
+#include <rump/rumpdefs.h>
+
+struct rumpfs_extstorage {
+ void *rfse_data;
+ size_t rfse_dlen;
+ int rfse_flags;
+};
+
+#define RUMPFS_FCNTL_EXTSTORAGE_ADD \
+ RUMP__FCNR_FSPRIV('R', 1, struct rumpfs_extstorage)
+
+#endif /* _RUMP_RUMPFS_H_ */
diff -r a9e3b23ddc17 -r 2f04251b94e3 sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Tue Feb 02 01:15:58 2016 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Tue Feb 02 12:22:23 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpfs.c,v 1.136 2016/01/26 23:12:18 pooka Exp $ */
+/* $NetBSD: rumpfs.c,v 1.137 2016/02/02 12:22:23 pooka Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.136 2016/01/26 23:12:18 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.137 2016/02/02 12:22:23 pooka Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -58,6 +58,7 @@
#include <rump-sys/kern.h>
#include <rump-sys/vfs.h>
+#include <rump/rumpfs.h>
#include <rump/rumpuser.h>
static int rump_vop_lookup(void *);
@@ -84,6 +85,7 @@
static int rump_vop_strategy(void *);
static int rump_vop_advlock(void *);
static int rump_vop_access(void *);
+static int rump_vop_fcntl(void *);
int (**fifo_vnodeop_p)(void *);
const struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
@@ -128,6 +130,7 @@
{ &vop_bmap_desc, rump_vop_bmap },
{ &vop_strategy_desc, rump_vop_strategy },
{ &vop_advlock_desc, rump_vop_advlock },
+ { &vop_fcntl_desc, rump_vop_fcntl },
{ NULL, NULL }
};
const struct vnodeopv_desc rump_vnodeop_opv_desc =
@@ -209,6 +212,7 @@
#define RUMPNODE_DIR_ET 0x02
#define RUMPNODE_DIR_ETSUBS 0x04
#define RUMPNODE_ET_PHONE_HOST 0x10
+#define RUMPNODE_EXTSTORAGE 0x20
struct rumpfs_mount {
struct vnode *rfsmp_rvp;
@@ -931,7 +935,12 @@
copylen = MIN(rn->rn_dlen, newlen);
memset(newdata, 0, newlen);
memcpy(newdata, rn->rn_data, copylen);
- rump_hyperfree(rn->rn_data, rn->rn_dlen);
+
+ if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) {
+ rump_hyperfree(rn->rn_data, rn->rn_dlen);
+ } else {
+ rn->rn_flags &= ~RUMPNODE_EXTSTORAGE;
+ }
rn->rn_data = newdata;
rn->rn_dlen = newlen;
@@ -1456,7 +1465,11 @@
rn->rn_dlen = oldlen;
uvm_vnp_setsize(vp, oldlen);
} else {
- rump_hyperfree(olddata, oldlen);
+ if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) {
+ rump_hyperfree(olddata, oldlen);
+ } else {
+ rn->rn_flags &= ~RUMPNODE_EXTSTORAGE;
+ }
}
}
@@ -1620,7 +1633,11 @@
if (vp->v_type == VREG
&& (rn->rn_flags & RUMPNODE_ET_PHONE_HOST) == 0
&& rn->rn_data) {
- rump_hyperfree(rn->rn_data, rn->rn_dlen);
+ if ((rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) {
+ rump_hyperfree(rn->rn_data, rn->rn_dlen);
+ } else {
+ rn->rn_flags &= ~RUMPNODE_EXTSTORAGE;
+ }
rn->rn_data = NULL;
}
@@ -1676,6 +1693,65 @@
return lf_advlock(ap, &rn->rn_lockf, vp->v_size);
}
+static int
+rump_vop_fcntl(void *v)
+{
+ struct vop_fcntl_args /* {
+ struct vnode *a_vp;
+ u_int a_command;
+ void *a_data;
+ int a_fflag;
+ kauth_cred_t a_cred;
+ } */ *ap = v;
+ struct proc *p = curproc;
+ struct vnode *vp = ap->a_vp;
+ struct rumpfs_node *rn = vp->v_data;
+ u_int cmd = ap->a_command;
+ int fflag = ap->a_fflag;
+ struct rumpfs_extstorage *rfse = ap->a_data;
+ int error = 0;
+
+ /* none of the current rumpfs fcntlops are defined for remotes */
+ if (!RUMP_LOCALPROC_P(p))
+ return EINVAL;
+
+ switch (cmd) {
+ case RUMPFS_FCNTL_EXTSTORAGE_ADD:
+ break;
+ default:
+ return EINVAL;
+ }
+
+ if ((fflag & FWRITE) == 0)
+ return EBADF;
+
+ if (vp->v_type != VREG || (rn->rn_flags & RUMPNODE_ET_PHONE_HOST))
+ return EINVAL;
+
+ if (rfse->rfse_flags != 0)
+ return EINVAL;
+
+ /*
+ * Ok, we are good to go. Process.
+ */
+
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+
+ KASSERT(cmd == RUMPFS_FCNTL_EXTSTORAGE_ADD);
+ if (rn->rn_data && (rn->rn_flags & RUMPNODE_EXTSTORAGE) == 0) {
+ rump_hyperfree(rn->rn_data, rn->rn_dlen);
+ }
+
+ rn->rn_data = rfse->rfse_data;
+ rn->rn_dlen = rfse->rfse_dlen;
+ uvm_vnp_setsize(vp, rn->rn_dlen);
+ rn->rn_flags |= RUMPNODE_EXTSTORAGE;
+
+ VOP_UNLOCK(vp);
+
+ return error;
+}
+
/*
* Begin vfs-level stuff
*/
Home |
Main Index |
Thread Index |
Old Index