Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sunrpc: Add a sysfs file for one-step xprt deletion

Previously, the admin would need to set the xprt state to "offline"
before attempting to remove. This patch adds a new sysfs attr that does
both these steps in a single call.

Suggested-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Link: https://lore.kernel.org/r/20250207204225.594002-6-anna@kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

authored by

Anna Schumaker and committed by
Trond Myklebust
4c2226be df210d9b

+46
+46
net/sunrpc/sysfs.c
··· 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) ··· 472 464 return count; 473 465 } 474 466 467 + static ssize_t rpc_sysfs_xprt_del_xprt(struct kobject *kobj, 468 + struct kobj_attribute *attr, 469 + const char *buf, size_t count) 470 + { 471 + struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj); 472 + struct rpc_xprt_switch *xps = rpc_sysfs_xprt_kobj_get_xprt_switch(kobj); 473 + 474 + if (!xprt || !xps) { 475 + count = 0; 476 + goto out; 477 + } 478 + 479 + if (xprt->main) { 480 + count = -EINVAL; 481 + goto release_tasks; 482 + } 483 + 484 + if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) { 485 + count = -EINTR; 486 + goto out_put; 487 + } 488 + 489 + xprt_set_offline_locked(xprt, xps); 490 + xprt_delete_locked(xprt, xps); 491 + 492 + release_tasks: 493 + xprt_release_write(xprt, NULL); 494 + out_put: 495 + xprt_put(xprt); 496 + xprt_switch_put(xps); 497 + out: 498 + return count; 499 + } 500 + 475 501 int rpc_sysfs_init(void) 476 502 { 477 503 rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); ··· 601 559 static struct kobj_attribute rpc_sysfs_xprt_change_state = __ATTR(xprt_state, 602 560 0644, rpc_sysfs_xprt_state_show, rpc_sysfs_xprt_state_change); 603 561 562 + static struct kobj_attribute rpc_sysfs_xprt_del = __ATTR(del_xprt, 563 + 0644, rpc_sysfs_xprt_del_xprt_show, rpc_sysfs_xprt_del_xprt); 564 + 604 565 static struct attribute *rpc_sysfs_xprt_attrs[] = { 605 566 &rpc_sysfs_xprt_dstaddr.attr, 606 567 &rpc_sysfs_xprt_srcaddr.attr, 607 568 &rpc_sysfs_xprt_xprtsec.attr, 608 569 &rpc_sysfs_xprt_info.attr, 609 570 &rpc_sysfs_xprt_change_state.attr, 571 + &rpc_sysfs_xprt_del.attr, 610 572 NULL, 611 573 }; 612 574 ATTRIBUTE_GROUPS(rpc_sysfs_xprt);