@@ -741,6 +741,7 @@ enum {
741
741
Opt_read_write ,
742
742
Opt_lock_on_read ,
743
743
Opt_exclusive ,
744
+ Opt_notrim ,
744
745
Opt_err
745
746
};
746
747
@@ -755,6 +756,7 @@ static match_table_t rbd_opts_tokens = {
755
756
{Opt_read_write , "rw" }, /* Alternate spelling */
756
757
{Opt_lock_on_read , "lock_on_read" },
757
758
{Opt_exclusive , "exclusive" },
759
+ {Opt_notrim , "notrim" },
758
760
{Opt_err , NULL }
759
761
};
760
762
@@ -764,13 +766,15 @@ struct rbd_options {
764
766
bool read_only ;
765
767
bool lock_on_read ;
766
768
bool exclusive ;
769
+ bool trim ;
767
770
};
768
771
769
772
#define RBD_QUEUE_DEPTH_DEFAULT BLKDEV_MAX_RQ
770
773
#define RBD_LOCK_TIMEOUT_DEFAULT 0 /* no timeout */
771
774
#define RBD_READ_ONLY_DEFAULT false
772
775
#define RBD_LOCK_ON_READ_DEFAULT false
773
776
#define RBD_EXCLUSIVE_DEFAULT false
777
+ #define RBD_TRIM_DEFAULT true
774
778
775
779
static int parse_rbd_opts_token (char * c , void * private )
776
780
{
@@ -820,6 +824,9 @@ static int parse_rbd_opts_token(char *c, void *private)
820
824
case Opt_exclusive :
821
825
rbd_opts -> exclusive = true;
822
826
break ;
827
+ case Opt_notrim :
828
+ rbd_opts -> trim = false;
829
+ break ;
823
830
default :
824
831
/* libceph prints "bad option" msg */
825
832
return - EINVAL ;
@@ -3976,11 +3983,12 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
3976
3983
blk_queue_io_min (q , objset_bytes );
3977
3984
blk_queue_io_opt (q , objset_bytes );
3978
3985
3979
- /* enable the discard support */
3980
- blk_queue_flag_set (QUEUE_FLAG_DISCARD , q );
3981
- q -> limits .discard_granularity = objset_bytes ;
3982
- blk_queue_max_discard_sectors (q , objset_bytes >> SECTOR_SHIFT );
3983
- blk_queue_max_write_zeroes_sectors (q , objset_bytes >> SECTOR_SHIFT );
3986
+ if (rbd_dev -> opts -> trim ) {
3987
+ blk_queue_flag_set (QUEUE_FLAG_DISCARD , q );
3988
+ q -> limits .discard_granularity = objset_bytes ;
3989
+ blk_queue_max_discard_sectors (q , objset_bytes >> SECTOR_SHIFT );
3990
+ blk_queue_max_write_zeroes_sectors (q , objset_bytes >> SECTOR_SHIFT );
3991
+ }
3984
3992
3985
3993
if (!ceph_test_opt (rbd_dev -> rbd_client -> client , NOCRC ))
3986
3994
q -> backing_dev_info -> capabilities |= BDI_CAP_STABLE_WRITES ;
@@ -5207,6 +5215,7 @@ static int rbd_add_parse_args(const char *buf,
5207
5215
rbd_opts -> lock_timeout = RBD_LOCK_TIMEOUT_DEFAULT ;
5208
5216
rbd_opts -> lock_on_read = RBD_LOCK_ON_READ_DEFAULT ;
5209
5217
rbd_opts -> exclusive = RBD_EXCLUSIVE_DEFAULT ;
5218
+ rbd_opts -> trim = RBD_TRIM_DEFAULT ;
5210
5219
5211
5220
copts = ceph_parse_options (options , mon_addrs ,
5212
5221
mon_addrs + mon_addrs_size - 1 ,
0 commit comments