Skip to content

Commit 02b2f54

Browse files
yangdongshengidryomov
authored andcommitted
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>
1 parent bfeffd1 commit 02b2f54

6 files changed

Lines changed: 19 additions & 9 deletions

File tree

‎fs/ceph/super.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
530530
seq_putc(m, ',');
531531
pos = m->count;
532532

533-
ret = ceph_print_client_options(m, fsc->client);
533+
ret = ceph_print_client_options(m, fsc->client, false);
534534
if (ret)
535535
return ret;
536536

@@ -640,7 +640,7 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
640640
opt = NULL; /* fsc->client now owns this */
641641

642642
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);
644644

645645
if (!fsopt->mds_namespace) {
646646
ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,

‎include/linux/ceph/libceph.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define CEPH_OPT_NOMSGAUTH (1<<4) /* don't require msg signing feat */
3636
#define CEPH_OPT_TCP_NODELAY (1<<5) /* TCP_NODELAY on TCP sockets */
3737
#define CEPH_OPT_NOMSGSIGN (1<<6) /* don't sign msgs */
38+
#define CEPH_OPT_ABORT_ON_FULL (1<<7) /* abort w/ ENOSPC when full */
3839

3940
#define CEPH_OPT_DEFAULT (CEPH_OPT_TCP_NODELAY)
4041

@@ -53,7 +54,7 @@ struct ceph_options {
5354
unsigned long osd_request_timeout; /* jiffies */
5455

5556
/*
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
5758
* to be compared should go beyond this point,
5859
* ceph_compare_options() should be updated accordingly
5960
*/
@@ -281,7 +282,8 @@ extern struct ceph_options *ceph_parse_options(char *options,
281282
const char *dev_name, const char *dev_name_end,
282283
int (*parse_extra_token)(char *c, void *private),
283284
void *private);
284-
int ceph_print_client_options(struct seq_file *m, struct ceph_client *client);
285+
int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
286+
bool show_all);
285287
extern void ceph_destroy_options(struct ceph_options *opt);
286288
extern int ceph_compare_options(struct ceph_options *new_opt,
287289
struct ceph_client *client);

‎include/linux/ceph/osd_client.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ struct ceph_osd_client {
354354
struct rb_root linger_map_checks;
355355
atomic_t num_requests;
356356
atomic_t num_homeless;
357-
bool abort_on_full; /* abort w/ ENOSPC when full */
358357
int abort_err;
359358
struct delayed_work timeout_work;
360359
struct delayed_work osds_timeout_work;

‎net/ceph/ceph_common.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ enum {
255255
Opt_nocephx_sign_messages,
256256
Opt_tcp_nodelay,
257257
Opt_notcp_nodelay,
258+
Opt_abort_on_full,
258259
};
259260

260261
static match_table_t opt_tokens = {
@@ -280,6 +281,7 @@ static match_table_t opt_tokens = {
280281
{Opt_nocephx_sign_messages, "nocephx_sign_messages"},
281282
{Opt_tcp_nodelay, "tcp_nodelay"},
282283
{Opt_notcp_nodelay, "notcp_nodelay"},
284+
{Opt_abort_on_full, "abort_on_full"},
283285
{-1, NULL}
284286
};
285287

@@ -535,6 +537,10 @@ ceph_parse_options(char *options, const char *dev_name,
535537
opt->flags &= ~CEPH_OPT_TCP_NODELAY;
536538
break;
537539

540+
case Opt_abort_on_full:
541+
opt->flags |= CEPH_OPT_ABORT_ON_FULL;
542+
break;
543+
538544
default:
539545
BUG_ON(token);
540546
}
@@ -549,7 +555,8 @@ ceph_parse_options(char *options, const char *dev_name,
549555
}
550556
EXPORT_SYMBOL(ceph_parse_options);
551557

552-
int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)
558+
int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
559+
bool show_all)
553560
{
554561
struct ceph_options *opt = client->options;
555562
size_t pos = m->count;
@@ -574,6 +581,8 @@ int ceph_print_client_options(struct seq_file *m, struct ceph_client *client)
574581
seq_puts(m, "nocephx_sign_messages,");
575582
if ((opt->flags & CEPH_OPT_TCP_NODELAY) == 0)
576583
seq_puts(m, "notcp_nodelay,");
584+
if (show_all && (opt->flags & CEPH_OPT_ABORT_ON_FULL))
585+
seq_puts(m, "abort_on_full,");
577586

578587
if (opt->mount_timeout != CEPH_MOUNT_TIMEOUT_DEFAULT)
579588
seq_printf(m, "mount_timeout=%d,",

‎net/ceph/debugfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ static int client_options_show(struct seq_file *s, void *p)
375375
struct ceph_client *client = s->private;
376376
int ret;
377377

378-
ret = ceph_print_client_options(s, client);
378+
ret = ceph_print_client_options(s, client, true);
379379
if (ret)
380380
return ret;
381381

‎net/ceph/osd_client.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,7 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
23152315
(ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
23162316
pool_full(osdc, req->r_t.base_oloc.pool))) {
23172317
dout("req %p full/pool_full\n", req);
2318-
if (osdc->abort_on_full) {
2318+
if (ceph_test_opt(osdc->client, ABORT_ON_FULL)) {
23192319
err = -ENOSPC;
23202320
} else {
23212321
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)
25452545
{
25462546
bool victims = false;
25472547

2548-
if (osdc->abort_on_full &&
2548+
if (ceph_test_opt(osdc->client, ABORT_ON_FULL) &&
25492549
(ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc)))
25502550
for_each_request(osdc, abort_on_full_fn, &victims);
25512551
}

0 commit comments

Comments
 (0)