Re: c/r support on FUSE filesystems.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

patch re-submitted!!!
I will make necessary changes with respect to unlinked files and update you
soon.

regards,
Vishnumurthy Prabhu
diff --git a/fs/checkpoint.c b/fs/checkpoint.c
index 87d7c6e..4b4b83d 100644
--- a/fs/checkpoint.c
+++ b/fs/checkpoint.c
@@ -711,6 +711,8 @@ struct restore_file_ops {
 				  struct ckpt_hdr_file *ptr);
 };
 
+extern struct file *fuse_file_restore(struct ckpt_ctx *ctx, struct ckpt_hdr_file *ptr);
+
 static struct restore_file_ops restore_file_ops[] = {
 	/* ignored file */
 	{
@@ -760,6 +762,11 @@ static struct restore_file_ops restore_file_ops[] = {
 		.file_type = CKPT_FILE_EVENTFD,
 		.restore = eventfd_restore,
 	},
+	{
+		.file_name = "FUSE",
+		.file_type = CKPT_FILE_FUSE,
+		.restore = fuse_file_restore,
+	},	
 };
 
 static void *restore_file(struct ckpt_ctx *ctx)
diff --git a/fs/fuse/Makefile b/fs/fuse/Makefile
index e95eeb4..6a25407 100644
--- a/fs/fuse/Makefile
+++ b/fs/fuse/Makefile
@@ -5,4 +5,4 @@
 obj-$(CONFIG_FUSE_FS) += fuse.o
 obj-$(CONFIG_CUSE) += cuse.o
 
-fuse-objs := dev.o dir.o file.o inode.o control.o
+fuse-objs := dev.o dir.o file.o inode.o control.o fuse_kcr.o
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a9f5e13..8115e60 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1991,6 +1991,9 @@ static const struct file_operations fuse_file_operations = {
 	.unlocked_ioctl	= fuse_file_ioctl,
 	.compat_ioctl	= fuse_file_compat_ioctl,
 	.poll		= fuse_file_poll,
+#ifdef CONFIG_CHECKPOINT
+	.checkpoint	= fuse_file_checkpoint,
+#endif
 };
 
 static const struct file_operations fuse_direct_io_file_operations = {
@@ -2007,6 +2010,9 @@ static const struct file_operations fuse_direct_io_file_operations = {
 	.unlocked_ioctl	= fuse_file_ioctl,
 	.compat_ioctl	= fuse_file_compat_ioctl,
 	.poll		= fuse_file_poll,
+#ifdef CONFIG_CHECKPOINT
+	.checkpoint	= fuse_file_checkpoint,
+#endif	
 	/* no splice_read */
 };
 
diff --git a/include/linux/checkpoint_hdr.h b/include/linux/checkpoint_hdr.h
index f4f9577..0eace6e 100644
--- a/include/linux/checkpoint_hdr.h
+++ b/include/linux/checkpoint_hdr.h
@@ -561,6 +561,8 @@ enum file_type {
 #define CKPT_FILE_EPOLL CKPT_FILE_EPOLL
 	CKPT_FILE_EVENTFD,
 #define CKPT_FILE_EVENTFD CKPT_FILE_EVENTFD
+	CKPT_FILE_FUSE,
+#define CKPT_FILE_FUSE CKPT_FILE_FUSE
 	CKPT_FILE_MAX
 #define CKPT_FILE_MAX CKPT_FILE_MAX
 };
@@ -581,6 +583,11 @@ struct ckpt_hdr_file_generic {
 	struct ckpt_hdr_file common;
 } __attribute__((aligned(8)));
 
+struct ckpt_hdr_file_fuse {
+	struct ckpt_hdr_file common;
+	
+} __attribute__((aligned(8)));
+
 struct ckpt_hdr_file_pipe {
 	struct ckpt_hdr_file common;
 	__s32 pipe_objref;
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 3e2925a..104c67d 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -249,6 +249,10 @@ enum fuse_opcode {
 	FUSE_IOCTL         = 39,
 	FUSE_POLL          = 40,
 
+#ifdef CONFIG_CHECKPOINT
+	FUSE_CHECKPOINT    = 1024,
+#endif                                  /*CONFIG_CHECKPOINT*/
+	
 	/* CUSE specific operations */
 	CUSE_INIT          = 4096,
 };
@@ -565,4 +569,16 @@ struct fuse_notify_inval_entry_out {
 	__u32	padding;
 };
 
+#ifdef CONFIG_CHECKPOINT
+	struct fuse_checkpoint_in{
+	__u64	fh;
+	__u32	flags;
+	__u32	padding;
+        };
+
+        struct fuse_checkpoint_out{
+        __u32 status;
+        };
+#endif                                                  /*CONFIG_CHECKPOINT*/
+
 #endif /* _LINUX_FUSE_H */
#ifdef CONFIG_CHECKPOINT
#ifndef _FUSE_KCR_H_
#define _FUSE_KCR_H_

#include <linux/fuse.h>
#include <linux/checkpoint.h>
#include "fuse_i.h"

int fuse_file_checkpoint(struct ckpt_ctx *ctx, struct file *file);
struct file *fuse_file_restore(struct ckpt_ctx *ctx, struct ckpt_hdr_file *ptr);
#endif
#endif
/*
fuse_cr: Checkpoint-Restart implementation for FUSE filesystem kernel module.

Authors: Manoj Kumar and Vishnumurthy Prabhu 
         NITK Surathkal
*/

#include <linux/file.h>
#include "fuse_kcr.h"

int fuse_file_ckpt_send(struct file *file)
{
    struct inode *inode  = file->f_path.dentry->d_inode;
	struct fuse_conn *fc = get_fuse_conn(inode);
	struct fuse_req *req;
	struct fuse_checkpoint_in inarg;
	struct fuse_checkpoint_out outarg;
	__u64 nodeid;
	int err;
	struct fuse_file *ff;

    ff = file->private_data;
	if (is_bad_inode(inode))
		return -EIO;

    nodeid = get_node_id(inode);
	req = fuse_get_req(fc);
	memset(&inarg, 0, sizeof(inarg));
// inargs must be supplied.	
    inarg.fh = ff->fh;
    inarg.flags &= ~(0);
//inargs to be supplied    
    
    req->in.h.opcode = FUSE_CHECKPOINT;
	req->in.h.nodeid = nodeid;
	req->in.numargs = 1;
	req->in.args[0].size = sizeof(inarg);
	req->in.args[0].value = &inarg;
	req->out.numargs = 1;
	req->out.args[0].size = sizeof(outarg);
	req->out.args[0].value = &outarg;

//aboue is sample inargs need to be changed...
	fuse_request_send(fc, req);
	err = req->out.h.error;
	fuse_put_request(fc, req);
	if (err == -ENOSYS) {
		fc->no_flush = 1;
		err = 0;
	}
	return outarg.status;
}

int fuse_file_checkpoint(struct ckpt_ctx *ctx, struct file *file)
{
   int ret;
   struct ckpt_hdr_file_fuse *h;
   
	if (d_unlinked(file->f_dentry)) {
		ckpt_err(ctx, -EBADF, "%(T)%(P)Unlinked files unsupported\n",
			 file);
		return -EBADF;
	}

	h = ckpt_hdr_get_type(ctx, sizeof(*h), CKPT_HDR_FILE);
	if (!h)
		return -ENOMEM;

	h->common.f_type = CKPT_FILE_FUSE;   
   
	ret = checkpoint_file_common(ctx, file, &h->common);
	if (ret < 0)
		goto out;
	ret = ckpt_write_obj(ctx, &h->common.h);
	if (ret < 0)
		goto out;
	ret = checkpoint_fname(ctx, &file->f_path, &ctx->root_fs_path);
	   
//   ret = fuse_file_ckpt_send(file);
    out:
	  ckpt_hdr_put(ctx, h);
	  return ret;	

}
EXPORT_SYMBOL(fuse_file_checkpoint);

/******************************************************************************************************************************************************
Restart
*/

struct file *fuse_file_restore(struct ckpt_ctx *ctx, struct ckpt_hdr_file *ptr)
{
    struct file *file;
	int ret;

	if (ptr->h.type != CKPT_HDR_FILE  ||
	    ptr->h.len != sizeof(*ptr) || ptr->f_type != CKPT_FILE_FUSE)
		return ERR_PTR(-EINVAL);

	file = restore_open_fname(ctx, ptr->f_flags);
	if (IS_ERR(file))
		return file;

	ret = restore_file_common(ctx, file, ptr);
	if (ret < 0) {
		fput(file);
		file = ERR_PTR(ret);
	}
	return file;
}

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux