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

NFS: tidy up nfs_show_mountd_netid

This function is a bit clumsy, incorrectly producing
",mountproto=" if mountd_protocol is 0 and !showdefaults,
and duplicating the code for reporting "auto".

Tidy it up so that it only makes a single seq_printf() call,
and more obviously does the right thing.

Fixes: ee671b016fbf ("NFS: convert proto= option to use netids rather than a protoname")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

NeilBrown and committed by
Anna Schumaker
6f6e3c09 4c3ffd05

+7 -14
+7 -14
fs/nfs/super.c
··· 531 531 int showdefaults) 532 532 { 533 533 struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; 534 + char *proto = NULL; 534 535 535 - seq_printf(m, ",mountproto="); 536 536 switch (sap->sa_family) { 537 537 case AF_INET: 538 538 switch (nfss->mountd_protocol) { 539 539 case IPPROTO_UDP: 540 - seq_printf(m, RPCBIND_NETID_UDP); 540 + proto = RPCBIND_NETID_UDP; 541 541 break; 542 542 case IPPROTO_TCP: 543 - seq_printf(m, RPCBIND_NETID_TCP); 543 + proto = RPCBIND_NETID_TCP; 544 544 break; 545 - default: 546 - if (showdefaults) 547 - seq_printf(m, "auto"); 548 545 } 549 546 break; 550 547 case AF_INET6: 551 548 switch (nfss->mountd_protocol) { 552 549 case IPPROTO_UDP: 553 - seq_printf(m, RPCBIND_NETID_UDP6); 550 + proto = RPCBIND_NETID_UDP6; 554 551 break; 555 552 case IPPROTO_TCP: 556 - seq_printf(m, RPCBIND_NETID_TCP6); 553 + proto = RPCBIND_NETID_TCP6; 557 554 break; 558 - default: 559 - if (showdefaults) 560 - seq_printf(m, "auto"); 561 555 } 562 556 break; 563 - default: 564 - if (showdefaults) 565 - seq_printf(m, "auto"); 566 557 } 558 + if (proto || showdefaults) 559 + seq_printf(m, ",mountproto=%s", proto ?: "auto"); 567 560 } 568 561 569 562 static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,