@@ -286,6 +286,14 @@ static ssize_t rpc_sysfs_xprt_state_show(struct kobject *kobj,
286
286
return ret ;
287
287
}
288
288
289
+ static ssize_t rpc_sysfs_xprt_del_xprt_show (struct kobject * kobj ,
290
+ struct kobj_attribute * attr ,
291
+ char * buf )
292
+ {
293
+ return sprintf (buf , "# delete this xprt\n" );
294
+ }
295
+
296
+
289
297
static ssize_t rpc_sysfs_xprt_switch_info_show (struct kobject * kobj ,
290
298
struct kobj_attribute * attr ,
291
299
char * buf )
@@ -464,6 +472,40 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj,
464
472
return count ;
465
473
}
466
474
475
+ static ssize_t rpc_sysfs_xprt_del_xprt (struct kobject * kobj ,
476
+ struct kobj_attribute * attr ,
477
+ const char * buf , size_t count )
478
+ {
479
+ struct rpc_xprt * xprt = rpc_sysfs_xprt_kobj_get_xprt (kobj );
480
+ struct rpc_xprt_switch * xps = rpc_sysfs_xprt_kobj_get_xprt_switch (kobj );
481
+
482
+ if (!xprt || !xps ) {
483
+ count = 0 ;
484
+ goto out ;
485
+ }
486
+
487
+ if (xprt -> main ) {
488
+ count = - EINVAL ;
489
+ goto release_tasks ;
490
+ }
491
+
492
+ if (wait_on_bit_lock (& xprt -> state , XPRT_LOCKED , TASK_KILLABLE )) {
493
+ count = - EINTR ;
494
+ goto out_put ;
495
+ }
496
+
497
+ xprt_set_offline_locked (xprt , xps );
498
+ xprt_delete_locked (xprt , xps );
499
+
500
+ release_tasks :
501
+ xprt_release_write (xprt , NULL );
502
+ out_put :
503
+ xprt_put (xprt );
504
+ xprt_switch_put (xps );
505
+ out :
506
+ return count ;
507
+ }
508
+
467
509
int rpc_sysfs_init (void )
468
510
{
469
511
rpc_sunrpc_kset = kset_create_and_add ("sunrpc" , NULL , kernel_kobj );
@@ -559,12 +601,16 @@ static struct kobj_attribute rpc_sysfs_xprt_info = __ATTR(xprt_info,
559
601
static struct kobj_attribute rpc_sysfs_xprt_change_state = __ATTR (xprt_state ,
560
602
0644 , rpc_sysfs_xprt_state_show , rpc_sysfs_xprt_state_change );
561
603
604
+ static struct kobj_attribute rpc_sysfs_xprt_del = __ATTR (del_xprt ,
605
+ 0644 , rpc_sysfs_xprt_del_xprt_show , rpc_sysfs_xprt_del_xprt );
606
+
562
607
static struct attribute * rpc_sysfs_xprt_attrs [] = {
563
608
& rpc_sysfs_xprt_dstaddr .attr ,
564
609
& rpc_sysfs_xprt_srcaddr .attr ,
565
610
& rpc_sysfs_xprt_xprtsec .attr ,
566
611
& rpc_sysfs_xprt_info .attr ,
567
612
& rpc_sysfs_xprt_change_state .attr ,
613
+ & rpc_sysfs_xprt_del .attr ,
568
614
NULL ,
569
615
};
570
616
ATTRIBUTE_GROUPS (rpc_sysfs_xprt );
0 commit comments