Commit 4214fb15 authored by Yan, Zheng's avatar Yan, Zheng Committed by Ilya Dryomov

ceph: validate correctness of some mount options

Signed-off-by: default avatar"Yan, Zheng" <zyan@redhat.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 95cca2b4
...@@ -243,21 +243,33 @@ static int parse_fsopt_token(char *c, void *private) ...@@ -243,21 +243,33 @@ static int parse_fsopt_token(char *c, void *private)
fsopt->rsize = ALIGN(intval, PAGE_SIZE); fsopt->rsize = ALIGN(intval, PAGE_SIZE);
break; break;
case Opt_rasize: case Opt_rasize:
fsopt->rasize = intval; if (intval < 0)
return -EINVAL;
fsopt->rasize = ALIGN(intval + PAGE_SIZE - 1, PAGE_SIZE);
break; break;
case Opt_caps_wanted_delay_min: case Opt_caps_wanted_delay_min:
if (intval < 1)
return -EINVAL;
fsopt->caps_wanted_delay_min = intval; fsopt->caps_wanted_delay_min = intval;
break; break;
case Opt_caps_wanted_delay_max: case Opt_caps_wanted_delay_max:
if (intval < 1)
return -EINVAL;
fsopt->caps_wanted_delay_max = intval; fsopt->caps_wanted_delay_max = intval;
break; break;
case Opt_readdir_max_entries: case Opt_readdir_max_entries:
if (intval < 1)
return -EINVAL;
fsopt->max_readdir = intval; fsopt->max_readdir = intval;
break; break;
case Opt_readdir_max_bytes: case Opt_readdir_max_bytes:
if (intval < PAGE_SIZE && intval != 0)
return -EINVAL;
fsopt->max_readdir_bytes = intval; fsopt->max_readdir_bytes = intval;
break; break;
case Opt_congestion_kb: case Opt_congestion_kb:
if (intval < 1024) /* at least 1M */
return -EINVAL;
fsopt->congestion_kb = intval; fsopt->congestion_kb = intval;
break; break;
case Opt_dirstat: case Opt_dirstat:
...@@ -946,12 +958,7 @@ static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc) ...@@ -946,12 +958,7 @@ static int ceph_setup_bdi(struct super_block *sb, struct ceph_fs_client *fsc)
return err; return err;
/* set ra_pages based on rasize mount option? */ /* set ra_pages based on rasize mount option? */
if (fsc->mount_options->rasize >= PAGE_SIZE) sb->s_bdi->ra_pages = fsc->mount_options->rasize >> PAGE_SHIFT;
sb->s_bdi->ra_pages =
(fsc->mount_options->rasize + PAGE_SIZE - 1)
>> PAGE_SHIFT;
else
sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
/* set io_pages based on max osd read size */ /* set io_pages based on max osd read size */
sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT; sb->s_bdi->io_pages = fsc->mount_options->rsize >> PAGE_SHIFT;
......
...@@ -56,6 +56,15 @@ ...@@ -56,6 +56,15 @@
#define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024) #define CEPH_MAX_READDIR_BYTES_DEFAULT (512*1024)
#define CEPH_SNAPDIRNAME_DEFAULT ".snap" #define CEPH_SNAPDIRNAME_DEFAULT ".snap"
/*
* Delay telling the MDS we no longer want caps, in case we reopen
* the file. Delay a minimum amount of time, even if we send a cap
* message for some other reason. Otherwise, take the oppotunity to
* update the mds to avoid sending another message later.
*/
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
struct ceph_mount_options { struct ceph_mount_options {
int flags; int flags;
int sb_flags; int sb_flags;
......
...@@ -84,16 +84,6 @@ struct ceph_options { ...@@ -84,16 +84,6 @@ struct ceph_options {
#define CEPH_AUTH_NAME_DEFAULT "guest" #define CEPH_AUTH_NAME_DEFAULT "guest"
/*
* Delay telling the MDS we no longer want caps, in case we reopen
* the file. Delay a minimum amount of time, even if we send a cap
* message for some other reason. Otherwise, take the oppotunity to
* update the mds to avoid sending another message later.
*/
#define CEPH_CAPS_WANTED_DELAY_MIN_DEFAULT 5 /* cap release delay */
#define CEPH_CAPS_WANTED_DELAY_MAX_DEFAULT 60 /* cap release delay */
/* mount state */ /* mount state */
enum { enum {
CEPH_MOUNT_MOUNTING, CEPH_MOUNT_MOUNTING,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment