Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libperfuse FUSE fallocate support
details: https://anonhg.NetBSD.org/src/rev/dbdd3c816abe
branches: trunk
changeset: 803525:dbdd3c816abe
user: manu <manu%NetBSD.org@localhost>
date: Fri Oct 31 15:12:15 2014 +0000
description:
FUSE fallocate support
There seems to be no fdiscard FUSE operation at the moment, hence that one
is left unused.
diffstat:
lib/libperfuse/fuse.h | 13 ++++++++++++-
lib/libperfuse/ops.c | 43 +++++++++++++++++++++++++++++++++++++++++--
lib/libperfuse/perfuse.c | 5 ++++-
lib/libperfuse/perfuse_priv.h | 5 ++++-
4 files changed, 61 insertions(+), 5 deletions(-)
diffs (138 lines):
diff -r 856c81d7e170 -r dbdd3c816abe lib/libperfuse/fuse.h
--- a/lib/libperfuse/fuse.h Fri Oct 31 14:20:54 2014 +0000
+++ b/lib/libperfuse/fuse.h Fri Oct 31 15:12:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.5 2011/12/28 17:33:53 manu Exp $ */
+/* $NetBSD: fuse.h,v 1.6 2014/10/31 15:12:15 manu Exp $ */
/*-
* Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved.
@@ -169,6 +169,9 @@
FUSE_DESTROY = 38,
FUSE_IOCTL = 39,
FUSE_POLL = 40,
+ FUSE_NOTIFY_REPLY = 41,
+ FUSE_BATCH_FORGET = 42,
+ FUSE_FALLOCATE = 43,
FUSE_OPCODE_MAX,
FUSE_CUSE_INIT = 4096
@@ -441,6 +444,14 @@
uint64_t kh;
};
+struct fuse_fallocate_in {
+ uint64_t fh;
+ uint64_t offset;
+ uint64_t length;
+ uint32_t mode;
+ uint32_t padding;
+};
+
#if 0 /* Duplicated in perfuse.h to avoid making fuse.h public */
/* Send from kernel to proces */
struct fuse_in_header {
diff -r 856c81d7e170 -r dbdd3c816abe lib/libperfuse/ops.c
--- a/lib/libperfuse/ops.c Fri Oct 31 14:20:54 2014 +0000
+++ b/lib/libperfuse/ops.c Fri Oct 31 15:12:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ops.c,v 1.77 2014/10/28 16:54:11 manu Exp $ */
+/* $NetBSD: ops.c,v 1.78 2014/10/31 15:12:15 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -3635,9 +3635,48 @@
error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply);
if (error != 0)
goto out;
-
+
ps->ps_destroy_msg(pm);
+
out:
node_rele(opc);
return error;
}
+
+int
+perfuse_node_fallocate(struct puffs_usermount *pu, puffs_cookie_t opc,
+ off_t off, off_t len)
+{
+ struct perfuse_state *ps;
+ perfuse_msg_t *pm;
+ struct fuse_fallocate_in *fai;
+ int error;
+
+ ps = puffs_getspecific(pu);
+ if (ps->ps_flags & PS_NO_FALLOCATE)
+ return EOPNOTSUPP;
+
+ node_ref(opc);
+
+ pm = ps->ps_new_msg(pu, opc, FUSE_FALLOCATE, sizeof(*fai), NULL);
+
+ fai = GET_INPAYLOAD(ps, pm, fuse_fallocate_in);
+ fai->fh = perfuse_get_fh(opc, FWRITE);
+ fai->offset = off;
+ fai->length = len;
+ fai->mode = 0;
+
+ error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply);
+ if (error == EOPNOTSUPP || error == ENOSYS) {
+ ps->ps_flags |= PS_NO_FALLOCATE;
+ error = EOPNOTSUPP;
+ }
+ if (error != 0)
+ goto out;
+
+ ps->ps_destroy_msg(pm);
+
+out:
+ node_rele(opc);
+ return error;
+}
diff -r 856c81d7e170 -r dbdd3c816abe lib/libperfuse/perfuse.c
--- a/lib/libperfuse/perfuse.c Fri Oct 31 14:20:54 2014 +0000
+++ b/lib/libperfuse/perfuse.c Fri Oct 31 15:12:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse.c,v 1.34 2014/09/03 16:01:45 manu Exp $ */
+/* $NetBSD: perfuse.c,v 1.35 2014/10/31 15:12:15 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -503,6 +503,9 @@
#ifdef PUFFS_OPEN_IO_DIRECT
PUFFSOP_SET(pops, perfuse, node, open2);
#endif /* PUFFS_OPEN_IO_DIRECT */
+#ifdef PUFFS_HAVE_FALLOCATE
+ PUFFSOP_SET(pops, perfuse, node, fallocate);
+#endif /* PUFFS_HAVE_FALLOCATE */
/*
* PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes
diff -r 856c81d7e170 -r dbdd3c816abe lib/libperfuse/perfuse_priv.h
--- a/lib/libperfuse/perfuse_priv.h Fri Oct 31 14:20:54 2014 +0000
+++ b/lib/libperfuse/perfuse_priv.h Fri Oct 31 15:12:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: perfuse_priv.h,v 1.35 2014/09/03 23:59:58 enami Exp $ */
+/* $NetBSD: perfuse_priv.h,v 1.36 2014/10/31 15:12:15 manu Exp $ */
/*-
* Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved.
@@ -67,6 +67,7 @@
#define PS_NO_ACCESS 0x0001 /* access is unimplemented; */
#define PS_NO_CREAT 0x0004 /* create is unimplemented */
#define PS_INLOOP 0x0008 /* puffs mainloop started */
+#define PS_NO_FALLOCATE 0x0010 /* fallocate is unimplemented */
uint64_t ps_fsid;
uint32_t ps_max_readahead;
uint32_t ps_max_write;
@@ -277,6 +278,8 @@
int perfuse_node_setattr_ttl(struct puffs_usermount *,
puffs_cookie_t, struct vattr *, const struct puffs_cred *,
struct timespec *, int);
+int perfuse_node_fallocate(struct puffs_usermount *,
+ puffs_cookie_t, off_t, off_t);
struct perfuse_trace *perfuse_trace_begin(struct perfuse_state *,
puffs_cookie_t, perfuse_msg_t *);
Home |
Main Index |
Thread Index |
Old Index