@@ -138,20 +138,22 @@ static int dust_add_block(struct dust_device *dd, unsigned long long block,
138
138
return 0 ;
139
139
}
140
140
141
- static int dust_query_block (struct dust_device * dd , unsigned long long block )
141
+ static int dust_query_block (struct dust_device * dd , unsigned long long block , char * result ,
142
+ unsigned int maxlen , unsigned int * sz_ptr )
142
143
{
143
144
struct badblock * bblock ;
144
145
unsigned long flags ;
146
+ unsigned int sz = * sz_ptr ;
145
147
146
148
spin_lock_irqsave (& dd -> dust_lock , flags );
147
149
bblock = dust_rb_search (& dd -> badblocklist , block );
148
150
if (bblock != NULL )
149
- DMINFO ("%s: block %llu found in badblocklist" , __func__ , block );
151
+ DMEMIT ("%s: block %llu found in badblocklist" , __func__ , block );
150
152
else
151
- DMINFO ("%s: block %llu not found in badblocklist" , __func__ , block );
153
+ DMEMIT ("%s: block %llu not found in badblocklist" , __func__ , block );
152
154
spin_unlock_irqrestore (& dd -> dust_lock , flags );
153
155
154
- return 0 ;
156
+ return 1 ;
155
157
}
156
158
157
159
static int __dust_map_read (struct dust_device * dd , sector_t thisblock )
@@ -259,11 +261,13 @@ static bool __dust_clear_badblocks(struct rb_root *tree,
259
261
return true;
260
262
}
261
263
262
- static int dust_clear_badblocks (struct dust_device * dd )
264
+ static int dust_clear_badblocks (struct dust_device * dd , char * result , unsigned int maxlen ,
265
+ unsigned int * sz_ptr )
263
266
{
264
267
unsigned long flags ;
265
268
struct rb_root badblocklist ;
266
269
unsigned long long badblock_count ;
270
+ unsigned int sz = * sz_ptr ;
267
271
268
272
spin_lock_irqsave (& dd -> dust_lock , flags );
269
273
badblocklist = dd -> badblocklist ;
@@ -273,11 +277,11 @@ static int dust_clear_badblocks(struct dust_device *dd)
273
277
spin_unlock_irqrestore (& dd -> dust_lock , flags );
274
278
275
279
if (!__dust_clear_badblocks (& badblocklist , badblock_count ))
276
- DMINFO ("%s: no badblocks found" , __func__ );
280
+ DMEMIT ("%s: no badblocks found" , __func__ );
277
281
else
278
- DMINFO ("%s: badblocks cleared" , __func__ );
282
+ DMEMIT ("%s: badblocks cleared" , __func__ );
279
283
280
- return 0 ;
284
+ return 1 ;
281
285
}
282
286
283
287
/*
@@ -383,7 +387,7 @@ static void dust_dtr(struct dm_target *ti)
383
387
}
384
388
385
389
static int dust_message (struct dm_target * ti , unsigned int argc , char * * argv ,
386
- char * result_buf , unsigned int maxlen )
390
+ char * result , unsigned int maxlen )
387
391
{
388
392
struct dust_device * dd = ti -> private ;
389
393
sector_t size = i_size_read (dd -> dev -> bdev -> bd_inode ) >> SECTOR_SHIFT ;
@@ -393,6 +397,7 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
393
397
unsigned char wr_fail_cnt ;
394
398
unsigned int tmp_ui ;
395
399
unsigned long flags ;
400
+ unsigned int sz = 0 ;
396
401
char dummy ;
397
402
398
403
if (argc == 1 ) {
@@ -410,12 +415,12 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
410
415
r = 0 ;
411
416
} else if (!strcasecmp (argv [0 ], "countbadblocks" )) {
412
417
spin_lock_irqsave (& dd -> dust_lock , flags );
413
- DMINFO ("countbadblocks: %llu badblock(s) found" ,
418
+ DMEMIT ("countbadblocks: %llu badblock(s) found" ,
414
419
dd -> badblock_count );
415
420
spin_unlock_irqrestore (& dd -> dust_lock , flags );
416
- r = 0 ;
421
+ r = 1 ;
417
422
} else if (!strcasecmp (argv [0 ], "clearbadblocks" )) {
418
- r = dust_clear_badblocks (dd );
423
+ r = dust_clear_badblocks (dd , result , maxlen , & sz );
419
424
} else if (!strcasecmp (argv [0 ], "quiet" )) {
420
425
if (!dd -> quiet_mode )
421
426
dd -> quiet_mode = true;
@@ -441,7 +446,7 @@ static int dust_message(struct dm_target *ti, unsigned int argc, char **argv,
441
446
else if (!strcasecmp (argv [0 ], "removebadblock" ))
442
447
r = dust_remove_block (dd , block );
443
448
else if (!strcasecmp (argv [0 ], "queryblock" ))
444
- r = dust_query_block (dd , block );
449
+ r = dust_query_block (dd , block , result , maxlen , & sz );
445
450
else
446
451
invalid_msg = true;
447
452
0 commit comments