From 06a5ab4ae4f608f6b1e6cb3fb29ca13df0fb5fc1 Mon Sep 17 00:00:00 2001 From: vjs-px Date: Tue, 29 Sep 2020 18:33:34 -0700 Subject: [PATCH 1/3] px_fuse ioctl to abort ios --- dev.c | 9 +++++++++ fuse_i.h | 2 ++ pxd.c | 21 +++++++++++++++++++++ pxd.h | 8 ++++++++ 4 files changed, 40 insertions(+) diff --git a/dev.c b/dev.c index 248fa000..a6aef62c 100755 --- a/dev.c +++ b/dev.c @@ -1088,6 +1088,15 @@ __acquires(fc->lock) end_requests(fc, &fc->processing); } +void fuse_abort_all_ios(struct fuse_conn *fc) +{ + printk(KERN_INFO "PXD_IOCTL : Aborting all requests..."); + spin_lock(&fc->lock); + fc->allow_disconnected = 0; + end_queued_requests(fc); + spin_unlock(&fc->lock); +} + static void fuse_conn_free_allocs(struct fuse_conn *fc) { if (fc->per_cpu_ids) diff --git a/fuse_i.h b/fuse_i.h index 6266646a..b93c3f8a 100755 --- a/fuse_i.h +++ b/fuse_i.h @@ -228,6 +228,8 @@ struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); void fuse_restart_requests(struct fuse_conn *fc); +void fuse_abort_all_ios(struct fuse_conn *fc); + ssize_t pxd_add(struct fuse_conn *fc, struct pxd_add_ext_out *add); ssize_t pxd_remove(struct fuse_conn *fc, struct pxd_remove_out *remove); ssize_t pxd_update_size(struct fuse_conn *fc, struct pxd_update_size *update_size); diff --git a/pxd.c b/pxd.c index 09a719e9..3eec27b7 100644 --- a/pxd.c +++ b/pxd.c @@ -123,6 +123,25 @@ static long pxd_ioctl_resize(struct file *file, void __user *argp) return ret; } +static long pxd_ioctl_abort_ios(struct file *file, void __user *argp) +{ + struct pxd_context *ctx = NULL; + struct pxd_abort_ios abort_ios_args; + long ret = 0; + + if (copy_from_user(&abort_ios_args, argp, sizeof(abort_ios_args))) { + return -EFAULT; + } + + ctx = &pxd_contexts[abort_ios_args.context_id]; + if (!ctx || ctx->id >= pxd_num_contexts_exported) { + return -EFAULT; + } + + fuse_abort_all_ios(&ctx->fc); + return ret; +} + static long pxd_control_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -168,6 +187,8 @@ static long pxd_control_ioctl(struct file *file, unsigned int cmd, unsigned long break; case PXD_IOC_RESIZE: return pxd_ioctl_resize(file, (void __user *)arg); + case PXD_IOC_ABORT_IOS: + return pxd_ioctl_abort_ios(file, (void __user *)arg); default: break; } diff --git a/pxd.h b/pxd.h index 3a96231b..30e8f86f 100755 --- a/pxd.h +++ b/pxd.h @@ -29,6 +29,7 @@ #define PXD_IOC_GET_VERSION _IO(PXD_IOCTL_MAGIC, 2) /* 0x505802 */ #define PXD_IOC_INIT _IO(PXD_IOCTL_MAGIC, 3) /* 0x505803 */ #define PXD_IOC_RESIZE _IO(PXD_IOCTL_MAGIC, 4) /* 0x505804 */ +#define PXD_IOC_ABORT_IOS _IO(PXD_IOCTL_MAGIC, 4) /* 0x505804 */ #define PXD_MAX_DEVICES 512 /**< maximum number of devices supported */ #define PXD_MAX_IO (1024*1024) /**< maximum io size in bytes */ @@ -155,6 +156,13 @@ struct pxd_update_size { int context_id; }; +/* + * PXD_ABORT_IOS ioctl from user space + */ +struct pxd_abort_ios { + int context_id; +}; + /** * PXD_SET_FASTPATH request from user space */ From d7a55eb3518ce9cf2d14944d4880bc1c98654f83 Mon Sep 17 00:00:00 2001 From: vjs-px Date: Wed, 30 Sep 2020 15:17:15 -0700 Subject: [PATCH 2/3] changed the IOCTL number to be in sync with master branch --- pxd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pxd.h b/pxd.h index 30e8f86f..b0f2fb87 100755 --- a/pxd.h +++ b/pxd.h @@ -29,7 +29,7 @@ #define PXD_IOC_GET_VERSION _IO(PXD_IOCTL_MAGIC, 2) /* 0x505802 */ #define PXD_IOC_INIT _IO(PXD_IOCTL_MAGIC, 3) /* 0x505803 */ #define PXD_IOC_RESIZE _IO(PXD_IOCTL_MAGIC, 4) /* 0x505804 */ -#define PXD_IOC_ABORT_IOS _IO(PXD_IOCTL_MAGIC, 4) /* 0x505804 */ +#define PXD_IOC_ABORT_IOS _IO(PXD_IOCTL_MAGIC, 9) /* 0x505809 */ #define PXD_MAX_DEVICES 512 /**< maximum number of devices supported */ #define PXD_MAX_IO (1024*1024) /**< maximum io size in bytes */ From 51702b95f41ec55a0c41aeaf673366ef09c45828 Mon Sep 17 00:00:00 2001 From: vjs-px Date: Wed, 30 Sep 2020 15:51:10 -0700 Subject: [PATCH 3/3] end_request api changed between 2.5.7 and 2.6.1 --- dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.c b/dev.c index a6aef62c..3cd1bf00 100755 --- a/dev.c +++ b/dev.c @@ -1093,7 +1093,7 @@ void fuse_abort_all_ios(struct fuse_conn *fc) printk(KERN_INFO "PXD_IOCTL : Aborting all requests..."); spin_lock(&fc->lock); fc->allow_disconnected = 0; - end_queued_requests(fc); + fuse_end_queued_requests(fc); spin_unlock(&fc->lock); }