Skip to contentSkip to conversation

fuse: cache invalidation calls

PATCH Anand Avati 3 participants 4 messages Jun 3, 2009 – Jun 4, 2009 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · ----- "Miklos Szeredi

John, thanks for the patch. If no problems are found I'd like to add it to the 2.6.31 queue.

Csaba, Anand, does this meet your requirements?

Other comments?

I was wondering how the userland libfuse would be made aware of the presence of these two notification features?

Avati

#2 lore raw
Quoted 2 lines · Anand Avati

I was wondering how the userland libfuse would be made aware of the presence of these two notification features?

Here's a patch against fuse CVS. It's also from John Muir.

I'm still thinking a bit about the API, how it would work in the presence of stacked filesystems or multiple channels.

Thanks,
Miklos

include/fuse_kernel.h +17 -0
Index: fuse/include/fuse_kernel.h
===================================================================
@@ -51,6 +51,8 @@
  *  - add IOCTL message
  *  - add unsolicited notification support
  *  - add POLL message and NOTIFY_POLL notification
+ *  - add notification messages for invalidation of inodes and
+ *    directory entries
  */
 
 #ifndef _LINUX_FUSE_H
@@ -58,6 +60,7 @@
 
 #include <sys/types.h>
 #define __u64 uint64_t
+#define __s64 int64_t
 #define __u32 uint32_t
 #define __s32 int32_t
 
@@ -243,6 +246,8 @@ enum fuse_opcode {
 
 enum fuse_notify_code {
 	FUSE_NOTIFY_POLL   = 1,
+	FUSE_NOTIFY_INVAL_INODE = 2,
+	FUSE_NOTIFY_INVAL_ENTRY = 3,
 	FUSE_NOTIFY_CODE_MAX,
 };
 
@@ -506,4 +511,16 @@ struct fuse_dirent {
 #define FUSE_DIRENT_SIZE(d) \
 	FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
 
+struct fuse_notify_inval_inode_out {
+	__u64	ino;
+	__s64	off;
+	__s64	len;
+};
+
+struct fuse_notify_inval_entry_out {
+	__u64	parent;
+	__u32	namelen;
+	__u32	padding;
+};
+
 #endif /* _LINUX_FUSE_H */
include/fuse_lowlevel.h +34 -0
Index: fuse/include/fuse_lowlevel.h
===================================================================
@@ -1136,6 +1136,32 @@ int fuse_reply_poll(fuse_req_t req, unsi
  */
 int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph);
 
+/**
+ * Notify to invalidate cache for an inode
+ *
+ * @param ch the channel through which to send the invalidation
+ * @param ino the inode number
+ * @param off the offset in the inode where to start invalidating
+ *            or negative to invalidate attributes only
+ * @param len the amount of cache to invalidate or 0 for all
+ * @return zero for success, -errno for failure
+ */
+int fuse_lowlevel_notify_inval_inode(struct fuse_chan *ch, fuse_ino_t ino,
+                                     off_t off, off_t len);
+
+/**
+ * Notify to invalidate parent attributes and the dentry matching
+ * parent/name
+ *
+ * @param ch the channel through which to send the invalidation
+ * @param parent inode number
+ * @param name file name
+ * @param namelen strlen() of file name
+ * @return zero for success, -errno for failure
+ */
+int fuse_lowlevel_notify_inval_entry(struct fuse_chan *ch, fuse_ino_t parent,
+                                     const char *name, size_t namelen);
+
 /* ----------------------------------------------------------- *
  * Utility functions					       *
  * ----------------------------------------------------------- */
@@ -1340,6 +1366,14 @@ void fuse_session_reset(struct fuse_sess
 int fuse_session_exited(struct fuse_session *se);
 
 /**
+ * Get the user data provided to the session
+ *
+ * @param se the session
+ * @return the user data
+ */
+void *fuse_session_data(struct fuse_session *se);
+
+/**
  * Enter a single threaded event loop
  *
  * @param se the session
lib/fuse_lowlevel.c +50 -0

56 lines not on this page · raw message

lib/fuse_session.c +5 -0
Index: fuse/lib/fuse_session.c
===================================================================
@@ -121,6 +121,11 @@ int fuse_session_exited(struct fuse_sess
 		return se->exited;
 }
 
+void *fuse_session_data(struct fuse_session *se)
+{
+	return se->data;
+}
+
 static struct fuse_chan *fuse_chan_new_common(struct fuse_chan_ops *op, int fd,
 					      size_t bufsize, void *data,
 					      int compat)
lib/fuse_versionscript +2 -0
Index: fuse/lib/fuse_versionscript
===================================================================
@@ -165,6 +165,8 @@ FUSE_2.8 {
 		fuse_reply_ioctl;
 		fuse_reply_ioctl_retry;
 		fuse_reply_poll;
+		fuse_lowlevel_notify_inval_inode;
+		fuse_lowlevel_notify_inval_entry;
 
 	local:
 		*;
#3 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 2 lines · Anand Avati

I was wondering how the userland libfuse would be made aware of the presence of these two notification features?

Here's a patch against fuse CVS.  It's also from John Muir.

In fact, what we were meditating about is the lack of the FUSE_KERNEL_MINOR_VERSION bump. Without that, how do the two parties negotiate if the rev inval messages are understood? One of John's patches in his patchset had it bumped though...

Csaba
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 11 lines · Csaba Henk
Quoted 5 lines · Miklos Szeredi
Quoted 2 lines · Anand Avati

I was wondering how the userland libfuse would be made aware of the presence of these two notification features?

Here's a patch against fuse CVS.  It's also from John Muir.

In fact, what we were meditating about is the lack of the FUSE_KERNEL_MINOR_VERSION bump. Without that, how do the two parties negotiate if the rev inval messages are understood? One of John's patches in his patchset had it bumped though...

Yes, I removed that intentionally as hopefully this will go in 2.6.31 with the other 10 -> 11 API changes.

Thanks,
Miklos