[v2] ceph: return -EINVAL if given fsc mount option on kernel w/o support
diff mbox series

Message ID 20191107143932.65798-1-jlayton@kernel.org
State New
Headers show
Series
  • [v2] ceph: return -EINVAL if given fsc mount option on kernel w/o support
Related show

Commit Message

Jeff Layton Nov. 7, 2019, 2:39 p.m. UTC
If someone requests fscache on the mount, and the kernel doesn't
support it, it should fail the mount.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/super.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

I sent a previous version of this patch, but it was based on top of the
mount API rework. I think we're better off reordering this patch before
that though, for easier backports.

Comments

Ilya Dryomov Nov. 7, 2019, 5:15 p.m. UTC | #1
On Thu, Nov 7, 2019 at 3:39 PM Jeff Layton <jlayton@kernel.org> wrote:
>
> If someone requests fscache on the mount, and the kernel doesn't
> support it, it should fail the mount.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/super.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> I sent a previous version of this patch, but it was based on top of the
> mount API rework. I think we're better off reordering this patch before
> that though, for easier backports.
>
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index edfd643a8205..e75b6b82267d 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -268,6 +268,7 @@ static int parse_fsopt_token(char *c, void *private)
>                 }
>                 break;
>         case Opt_fscache_uniq:
> +#ifdef CONFIG_CEPH_FSCACHE
>                 kfree(fsopt->fscache_uniq);
>                 fsopt->fscache_uniq = kstrndup(argstr[0].from,
>                                                argstr[0].to-argstr[0].from,
> @@ -276,7 +277,10 @@ static int parse_fsopt_token(char *c, void *private)
>                         return -ENOMEM;
>                 fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
>                 break;
> -               /* misc */
> +#else
> +               pr_err("ceph: fscache support is disabled\n");
> +               return -EINVAL;
> +#endif
>         case Opt_wsize:
>                 if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
>                         return -EINVAL;
> @@ -353,10 +357,15 @@ static int parse_fsopt_token(char *c, void *private)
>                 fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;
>                 break;
>         case Opt_fscache:
> +#ifdef CONFIG_CEPH_FSCACHE
>                 fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
>                 kfree(fsopt->fscache_uniq);
>                 fsopt->fscache_uniq = NULL;
>                 break;
> +#else
> +               pr_err("ceph: fscache support is disabled\n");
> +               return -EINVAL;
> +#endif
>         case Opt_nofscache:
>                 fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
>                 kfree(fsopt->fscache_uniq);

Applied with a small change: pr_err provides "ceph: " prefix, so
I dropped it.

Thanks,

                Ilya

Patch
diff mbox series

diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index edfd643a8205..e75b6b82267d 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -268,6 +268,7 @@  static int parse_fsopt_token(char *c, void *private)
 		}
 		break;
 	case Opt_fscache_uniq:
+#ifdef CONFIG_CEPH_FSCACHE
 		kfree(fsopt->fscache_uniq);
 		fsopt->fscache_uniq = kstrndup(argstr[0].from,
 					       argstr[0].to-argstr[0].from,
@@ -276,7 +277,10 @@  static int parse_fsopt_token(char *c, void *private)
 			return -ENOMEM;
 		fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
 		break;
-		/* misc */
+#else
+		pr_err("ceph: fscache support is disabled\n");
+		return -EINVAL;
+#endif
 	case Opt_wsize:
 		if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
 			return -EINVAL;
@@ -353,10 +357,15 @@  static int parse_fsopt_token(char *c, void *private)
 		fsopt->flags &= ~CEPH_MOUNT_OPT_INO32;
 		break;
 	case Opt_fscache:
+#ifdef CONFIG_CEPH_FSCACHE
 		fsopt->flags |= CEPH_MOUNT_OPT_FSCACHE;
 		kfree(fsopt->fscache_uniq);
 		fsopt->fscache_uniq = NULL;
 		break;
+#else
+		pr_err("ceph: fscache support is disabled\n");
+		return -EINVAL;
+#endif
 	case Opt_nofscache:
 		fsopt->flags &= ~CEPH_MOUNT_OPT_FSCACHE;
 		kfree(fsopt->fscache_uniq);