@@ -159,14 +159,22 @@ struct dm_writecache {
159159 bool overwrote_committed :1 ;
160160 bool memory_vmapped :1 ;
161161
162+ bool start_sector_set :1 ;
162163 bool high_wm_percent_set :1 ;
163164 bool low_wm_percent_set :1 ;
164165 bool max_writeback_jobs_set :1 ;
165166 bool autocommit_blocks_set :1 ;
166167 bool autocommit_time_set :1 ;
168+ bool max_age_set :1 ;
167169 bool writeback_fua_set :1 ;
168170 bool flush_on_suspend :1 ;
169171 bool cleaner :1 ;
172+ bool cleaner_set :1 ;
173+
174+ unsigned high_wm_percent_value ;
175+ unsigned low_wm_percent_value ;
176+ unsigned autocommit_time_value ;
177+ unsigned max_age_value ;
170178
171179 unsigned writeback_all ;
172180 struct workqueue_struct * writeback_wq ;
@@ -2203,6 +2211,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
22032211 if (sscanf (string , "%llu%c" , & start_sector , & dummy ) != 1 )
22042212 goto invalid_optional ;
22052213 wc -> start_sector = start_sector ;
2214+ wc -> start_sector_set = true;
22062215 if (wc -> start_sector != start_sector ||
22072216 wc -> start_sector >= wc -> memory_map_size >> SECTOR_SHIFT )
22082217 goto invalid_optional ;
@@ -2212,13 +2221,15 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
22122221 goto invalid_optional ;
22132222 if (high_wm_percent < 0 || high_wm_percent > 100 )
22142223 goto invalid_optional ;
2224+ wc -> high_wm_percent_value = high_wm_percent ;
22152225 wc -> high_wm_percent_set = true;
22162226 } else if (!strcasecmp (string , "low_watermark" ) && opt_params >= 1 ) {
22172227 string = dm_shift_arg (& as ), opt_params -- ;
22182228 if (sscanf (string , "%d%c" , & low_wm_percent , & dummy ) != 1 )
22192229 goto invalid_optional ;
22202230 if (low_wm_percent < 0 || low_wm_percent > 100 )
22212231 goto invalid_optional ;
2232+ wc -> low_wm_percent_value = low_wm_percent ;
22222233 wc -> low_wm_percent_set = true;
22232234 } else if (!strcasecmp (string , "writeback_jobs" ) && opt_params >= 1 ) {
22242235 string = dm_shift_arg (& as ), opt_params -- ;
@@ -2238,6 +2249,7 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
22382249 if (autocommit_msecs > 3600000 )
22392250 goto invalid_optional ;
22402251 wc -> autocommit_jiffies = msecs_to_jiffies (autocommit_msecs );
2252+ wc -> autocommit_time_value = autocommit_msecs ;
22412253 wc -> autocommit_time_set = true;
22422254 } else if (!strcasecmp (string , "max_age" ) && opt_params >= 1 ) {
22432255 unsigned max_age_msecs ;
@@ -2247,7 +2259,10 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
22472259 if (max_age_msecs > 86400000 )
22482260 goto invalid_optional ;
22492261 wc -> max_age = msecs_to_jiffies (max_age_msecs );
2262+ wc -> max_age_set = true;
2263+ wc -> max_age_value = max_age_msecs ;
22502264 } else if (!strcasecmp (string , "cleaner" )) {
2265+ wc -> cleaner_set = true;
22512266 wc -> cleaner = true;
22522267 } else if (!strcasecmp (string , "fua" )) {
22532268 if (WC_MODE_PMEM (wc )) {
@@ -2453,7 +2468,6 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
24532468 struct dm_writecache * wc = ti -> private ;
24542469 unsigned extra_args ;
24552470 unsigned sz = 0 ;
2456- uint64_t x ;
24572471
24582472 switch (type ) {
24592473 case STATUSTYPE_INFO :
@@ -2465,49 +2479,41 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
24652479 DMEMIT ("%c %s %s %u " , WC_MODE_PMEM (wc ) ? 'p' : 's' ,
24662480 wc -> dev -> name , wc -> ssd_dev -> name , wc -> block_size );
24672481 extra_args = 0 ;
2468- if (wc -> start_sector )
2482+ if (wc -> start_sector_set )
24692483 extra_args += 2 ;
2470- if (wc -> high_wm_percent_set && ! wc -> cleaner )
2484+ if (wc -> high_wm_percent_set )
24712485 extra_args += 2 ;
2472- if (wc -> low_wm_percent_set && ! wc -> cleaner )
2486+ if (wc -> low_wm_percent_set )
24732487 extra_args += 2 ;
24742488 if (wc -> max_writeback_jobs_set )
24752489 extra_args += 2 ;
24762490 if (wc -> autocommit_blocks_set )
24772491 extra_args += 2 ;
24782492 if (wc -> autocommit_time_set )
24792493 extra_args += 2 ;
2480- if (wc -> max_age != MAX_AGE_UNSPECIFIED )
2494+ if (wc -> max_age_set )
24812495 extra_args += 2 ;
2482- if (wc -> cleaner )
2496+ if (wc -> cleaner_set )
24832497 extra_args ++ ;
24842498 if (wc -> writeback_fua_set )
24852499 extra_args ++ ;
24862500
24872501 DMEMIT ("%u" , extra_args );
2488- if (wc -> start_sector )
2502+ if (wc -> start_sector_set )
24892503 DMEMIT (" start_sector %llu" , (unsigned long long )wc -> start_sector );
2490- if (wc -> high_wm_percent_set && !wc -> cleaner ) {
2491- x = (uint64_t )wc -> freelist_high_watermark * 100 ;
2492- x += wc -> n_blocks / 2 ;
2493- do_div (x , (size_t )wc -> n_blocks );
2494- DMEMIT (" high_watermark %u" , 100 - (unsigned )x );
2495- }
2496- if (wc -> low_wm_percent_set && !wc -> cleaner ) {
2497- x = (uint64_t )wc -> freelist_low_watermark * 100 ;
2498- x += wc -> n_blocks / 2 ;
2499- do_div (x , (size_t )wc -> n_blocks );
2500- DMEMIT (" low_watermark %u" , 100 - (unsigned )x );
2501- }
2504+ if (wc -> high_wm_percent_set )
2505+ DMEMIT (" high_watermark %u" , wc -> high_wm_percent_value );
2506+ if (wc -> low_wm_percent_set )
2507+ DMEMIT (" low_watermark %u" , wc -> low_wm_percent_value );
25022508 if (wc -> max_writeback_jobs_set )
25032509 DMEMIT (" writeback_jobs %u" , wc -> max_writeback_jobs );
25042510 if (wc -> autocommit_blocks_set )
25052511 DMEMIT (" autocommit_blocks %u" , wc -> autocommit_blocks );
25062512 if (wc -> autocommit_time_set )
2507- DMEMIT (" autocommit_time %u" , jiffies_to_msecs ( wc -> autocommit_jiffies ) );
2508- if (wc -> max_age != MAX_AGE_UNSPECIFIED )
2509- DMEMIT (" max_age %u" , jiffies_to_msecs ( wc -> max_age ) );
2510- if (wc -> cleaner )
2513+ DMEMIT (" autocommit_time %u" , wc -> autocommit_time_value );
2514+ if (wc -> max_age_set )
2515+ DMEMIT (" max_age %u" , wc -> max_age_value );
2516+ if (wc -> cleaner_set )
25112517 DMEMIT (" cleaner" );
25122518 if (wc -> writeback_fua_set )
25132519 DMEMIT (" %sfua" , wc -> writeback_fua ? "" : "no" );
@@ -2517,7 +2523,7 @@ static void writecache_status(struct dm_target *ti, status_type_t type,
25172523
25182524static struct target_type writecache_target = {
25192525 .name = "writecache" ,
2520- .version = {1 , 3 , 0 },
2526+ .version = {1 , 4 , 0 },
25212527 .module = THIS_MODULE ,
25222528 .ctr = writecache_ctr ,
25232529 .dtr = writecache_dtr ,
0 commit comments