summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongsheng Yang <dongsheng.yang@easystack.cn>2018-12-18 04:31:48 -0500
committerIlya Dryomov <idryomov@gmail.com>2019-01-07 16:47:48 -0500
commit02b2f549d502b46e68b97ea1452fb8853b3327dd (patch)
tree415c1a23112a0edc7ec00813f64cb65a9ebec5fd
parentbfeffd155283772bbe78c6a05dec7c0128ee500c (diff)
libceph: allow setting abort_on_full for rbd
Introduce a new option abort_on_full, default to false. Then we can get -ENOSPC when the pool is full, or reaches quota. [ Don't show abort_on_full in /proc/mounts. ] Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--fs/ceph/super.c4
-rw-r--r--include/linux/ceph/libceph.h6
-rw-r--r--include/linux/ceph/osd_client.h1
-rw-r--r--net/ceph/ceph_common.c11
-rw-r--r--net/ceph/debugfs.c2
-rw-r--r--net/ceph/osd_client.c4
6 files changed, 19 insertions, 9 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 4e9a7cc488da..da2cd8e89062 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -530,7 +530,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
530 seq_putc(m, ','); 530 seq_putc(m, ',');
531 pos = m->count; 531 pos = m->count;
532 532
533 ret = ceph_print_client_options(m, fsc->client); 533 ret = ceph_print_client_options(m, fsc->client, false);
534 if (ret) 534 if (ret)
535 return ret; 535 return ret;
536 536
@@ -640,7 +640,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
640 opt = NULL; /* fsc->client now owns this */ 640 opt = NULL; /* fsc->client now owns this */
641 641
642 fsc->client->extra_mon_dispatch = extra_mon_dispatch; 642 fsc->client->extra_mon_dispatch = extra_mon_dispatch;
643 fsc->client->osdc.abort_on_full = true; 643 ceph_set_opt(fsc->client, ABORT_ON_FULL);
644 644
645 if (!fsopt->mds_namespace) { 645 if (!fsopt->mds_namespace) {
646 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP, 646 ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index 68bb09c29ce8..a420c07904bc 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -35,6 +35,7 @@
35#define CEPH_OPT_NOMSGAUTH (1<<4) /* don't require msg signing feat */ 35#define CEPH_OPT_NOMSGAUTH (1<<4) /* don't require msg signing feat */
36#define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */ 36#define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */
37#define CEPH_OPT_NOMSGSIGN (1<<6) /* don't sign msgs */ 37#define CEPH_OPT_NOMSGSIGN (1<<6) /* don't sign msgs */
38#define CEPH_OPT_ABORT_ON_FULL (1<<7) /* abort w/ ENOSPC when full */
38 39
39#define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY) 40#define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY)
40 41
@@ -53,7 +54,7 @@ struct ceph_options {
53 unsigned long osd_request_timeout; /* jiffies */ 54 unsigned long osd_request_timeout; /* jiffies */
54 55
55 /* 56 /*
56 * any type that can't be simply compared or doesn't need need 57 * any type that can't be simply compared or doesn't need
57 * to be compared should go beyond this point, 58 * to be compared should go beyond this point,
58 * ceph_compare_options() should be updated accordingly 59 * ceph_compare_options() should be updated accordingly
59 */ 60 */
@@ -281,7 +282,8 @@ extern struct ceph_options *ceph_parse_options(char *options,
281 const char *dev_name, const char *dev_name_end, 282 const char *dev_name, const char *dev_name_end,
282 int (*parse_extra_token)(char *c, void *private), 283 int (*parse_extra_token)(char *c, void *private),
283 void *private); 284 void *private);
284int ceph_print_client_options(struct seq_file *m, struct ceph_client *client); 285int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
286 bool show_all);
285extern void ceph_destroy_options(struct ceph_options *opt); 287extern void ceph_destroy_options(struct ceph_options *opt);
286extern int ceph_compare_options(struct ceph_options *new_opt, 288extern int ceph_compare_options(struct ceph_options *new_opt,
287 struct ceph_client *client); 289 struct ceph_client *client);
diff --git a/include/linux/ceph/osd_client.h b/include/linux/ceph/osd_client.h
index 7a2af5034278..2294f963dab7 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -354,7 +354,6 @@ struct ceph_osd_client {
354 struct rb_root linger_map_checks; 354 struct rb_root linger_map_checks;
355 atomic_t num_requests; 355 atomic_t num_requests;
356 atomic_t num_homeless; 356 atomic_t num_homeless;
357 bool abort_on_full; /* abort w/ ENOSPC when full */
358 int abort_err; 357 int abort_err;
359 struct delayed_work timeout_work; 358 struct delayed_work timeout_work;
360 struct delayed_work osds_timeout_work; 359 struct delayed_work osds_timeout_work;
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 87afb9ec4c68..9cab80207ced 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -255,6 +255,7 @@ enum {
255 Opt_nocephx_sign_messages, 255 Opt_nocephx_sign_messages,
256 Opt_tcp_nodelay, 256 Opt_tcp_nodelay,
257 Opt_notcp_nodelay, 257 Opt_notcp_nodelay,
258 Opt_abort_on_full,
258}; 259};
259 260
260static match_table_t opt_tokens = { 261static match_table_t opt_tokens = {
@@ -280,6 +281,7 @@ static match_table_t opt_tokens = {
280 {Opt_nocephx_sign_messages, "nocephx_sign_messages"}, 281 {Opt_nocephx_sign_messages, "nocephx_sign_messages"},
281 {Opt_tcp_nodelay, "tcp_nodelay"}, 282 {Opt_tcp_nodelay, "tcp_nodelay"},
282 {Opt_notcp_nodelay, "notcp_nodelay"}, 283 {Opt_notcp_nodelay, "notcp_nodelay"},
284 {Opt_abort_on_full, "abort_on_full"},
283 {-1, NULL} 285 {-1, NULL}
284}; 286};
285 287
@@ -535,6 +537,10 @@ ceph_parse_options(char *options, const char *dev_name,
535 opt->flags &= ~CEPH_OPT_TCP_NODELAY; 537 opt->flags &= ~CEPH_OPT_TCP_NODELAY;
536 break; 538 break;
537 539
540 case Opt_abort_on_full:
541 opt->flags |= CEPH_OPT_ABORT_ON_FULL;
542 break;
543
538 default: 544 default:
539 BUG_ON(token); 545 BUG_ON(token);
540 } 546 }
@@ -549,7 +555,8 @@ out:
549} 555}
550EXPORT_SYMBOL(ceph_parse_options); 556EXPORT_SYMBOL(ceph_parse_options);
551 557
552int ceph_print_client_options(struct seq_file *m, struct ceph_client *client) 558int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
559 bool show_all)
553{ 560{
554 struct ceph_options *opt = client->options; 561 struct ceph_options *opt = client->options;
555 size_t pos = m->count; 562 size_t pos = m->count;
@@ -574,6 +581,8 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)
574 seq_puts(m, "nocephx_sign_messages,"); 581 seq_puts(m, "nocephx_sign_messages,");
575 if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0) 582 if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0)
576 seq_puts(m, "notcp_nodelay,"); 583 seq_puts(m, "notcp_nodelay,");
584 if (show_all && (opt->flags & CEPH_OPT_ABORT_ON_FULL))
585 seq_puts(m, "abort_on_full,");
577 586
578 if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT) 587 if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT)
579 seq_printf(m, "mount_timeout=%d,", 588 seq_printf(m, "mount_timeout=%d,",
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c
index 02952605d121..46f65709a6ff 100644
--- a/net/ceph/debugfs.c
+++ b/net/ceph/debugfs.c
@@ -375,7 +375,7 @@ static int client_options_show(struct seq_file *s, void *p)
375 struct ceph_client *client = s->private; 375 struct ceph_client *client = s->private;
376 int ret; 376 int ret;
377 377
378 ret = ceph_print_client_options(s, client); 378 ret = ceph_print_client_options(s, client, true);
379 if (ret) 379 if (ret)
380 return ret; 380 return ret;
381 381
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d23a9f81f3d7..fa9530dd876e 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -2315,7 +2315,7 @@ again:
2315 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || 2315 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
2316 pool_full(osdc, req->r_t.base_oloc.pool))) { 2316 pool_full(osdc, req->r_t.base_oloc.pool))) {
2317 dout("req %p full/pool_full\n", req); 2317 dout("req %p full/pool_full\n", req);
2318 if (osdc->abort_on_full) { 2318 if (ceph_test_opt(osdc->client, ABORT_ON_FULL)) {
2319 err = -ENOSPC; 2319 err = -ENOSPC;
2320 } else { 2320 } else {
2321 pr_warn_ratelimited("FULL or reached pool quota\n"); 2321 pr_warn_ratelimited("FULL or reached pool quota\n");
@@ -2545,7 +2545,7 @@ static void ceph_osdc_abort_on_full(struct ceph_osd_client *osdc)
2545{ 2545{
2546 bool victims = false; 2546 bool victims = false;
2547 2547
2548 if (osdc->abort_on_full && 2548 if (ceph_test_opt(osdc->client, ABORT_ON_FULL) &&
2549 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc))) 2549 (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc)))
2550 for_each_request(osdc, abort_on_full_fn, &victims); 2550 for_each_request(osdc, abort_on_full_fn, &victims);
2551} 2551}