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

Revert "[PATCH] RPC,NFS: new rpc_pipefs patch"

This reverts 17f4e6febca160a9f9dd4bdece9784577a2f4524 commit.

+216 -149
+7 -3
fs/nfs/idmap.c
··· 66 66 }; 67 67 68 68 struct idmap { 69 + char idmap_path[48]; 69 70 struct dentry *idmap_dentry; 70 71 wait_queue_head_t idmap_wq; 71 72 struct idmap_msg idmap_im; ··· 102 101 103 102 memset(idmap, 0, sizeof(*idmap)); 104 103 105 - idmap->idmap_dentry = rpc_mkpipe(clp->cl_rpcclient->cl_dentry, 106 - "idmap", idmap, &idmap_upcall_ops, 0); 104 + snprintf(idmap->idmap_path, sizeof(idmap->idmap_path), 105 + "%s/idmap", clp->cl_rpcclient->cl_pathname); 106 + 107 + idmap->idmap_dentry = rpc_mkpipe(idmap->idmap_path, 108 + idmap, &idmap_upcall_ops, 0); 107 109 if (IS_ERR(idmap->idmap_dentry)) { 108 110 kfree(idmap); 109 111 return; ··· 128 124 129 125 if (!idmap) 130 126 return; 131 - rpc_unlink(idmap->idmap_dentry); 127 + rpc_unlink(idmap->idmap_path); 132 128 clp->cl_idmap = NULL; 133 129 kfree(idmap); 134 130 }
+1 -1
include/linux/sunrpc/clnt.h
··· 59 59 60 60 int cl_nodelen; /* nodename length */ 61 61 char cl_nodename[UNX_MAXNODENAME]; 62 - struct dentry * __cl_parent_dentry; 62 + char cl_pathname[30];/* Path in rpc_pipe_fs */ 63 63 struct dentry * cl_dentry; /* inode */ 64 64 struct rpc_clnt * cl_parent; /* Points to parent of clones */ 65 65 struct rpc_rtt cl_rtt_default;
+4 -5
include/linux/sunrpc/rpc_pipe_fs.h
··· 41 41 42 42 extern int rpc_queue_upcall(struct inode *, struct rpc_pipe_msg *); 43 43 44 - extern struct dentry *rpc_mkdir(struct dentry *, char *, struct rpc_clnt *); 45 - extern void rpc_rmdir(struct dentry *); 46 - extern struct dentry *rpc_mkpipe(struct dentry *, char *, void *, 47 - struct rpc_pipe_ops *, int flags); 48 - extern void rpc_unlink(struct dentry *); 44 + extern struct dentry *rpc_mkdir(char *, struct rpc_clnt *); 45 + extern int rpc_rmdir(char *); 46 + extern struct dentry *rpc_mkpipe(char *, void *, struct rpc_pipe_ops *, int flags); 47 + extern int rpc_unlink(char *); 49 48 50 49 #endif 51 50 #endif
+6 -3
net/sunrpc/auth_gss/auth_gss.c
··· 87 87 struct list_head upcalls; 88 88 struct rpc_clnt *client; 89 89 struct dentry *dentry; 90 + char path[48]; 90 91 spinlock_t lock; 91 92 }; 92 93 ··· 690 689 if (err) 691 690 goto err_put_mech; 692 691 693 - gss_auth->dentry = rpc_mkpipe(clnt->cl_dentry, gss_auth->mech->gm_name, 694 - clnt, &gss_upcall_ops, RPC_PIPE_WAIT_FOR_OPEN); 692 + snprintf(gss_auth->path, sizeof(gss_auth->path), "%s/%s", 693 + clnt->cl_pathname, 694 + gss_auth->mech->gm_name); 695 + gss_auth->dentry = rpc_mkpipe(gss_auth->path, clnt, &gss_upcall_ops, RPC_PIPE_WAIT_FOR_OPEN); 695 696 if (IS_ERR(gss_auth->dentry)) { 696 697 err = PTR_ERR(gss_auth->dentry); 697 698 goto err_put_mech; ··· 718 715 auth, auth->au_flavor); 719 716 720 717 gss_auth = container_of(auth, struct gss_auth, rpc_auth); 721 - rpc_unlink(gss_auth->dentry); 718 + rpc_unlink(gss_auth->path); 722 719 gss_mech_put(gss_auth->mech); 723 720 724 721 rpcauth_free_credcache(auth);
+17 -36
net/sunrpc/clnt.c
··· 67 67 static int 68 68 rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) 69 69 { 70 - static unsigned int clntid; 71 - char name[128]; 70 + static uint32_t clntid; 72 71 int error; 73 72 74 73 if (dir_name == NULL) 75 74 return 0; 76 - 77 - retry_parent: 78 - clnt->__cl_parent_dentry = rpc_mkdir(NULL, dir_name, NULL); 79 - if (IS_ERR(clnt->__cl_parent_dentry)) { 80 - error = PTR_ERR(clnt->__cl_parent_dentry); 81 - if (error == -EEXIST) 82 - goto retry_parent; /* XXX(hch): WTF? */ 83 - 84 - printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", 85 - dir_name, error); 86 - return error; 87 - } 88 - 89 - 90 - retry_child: 91 - snprintf(name, sizeof(name), "clnt%x", clntid++); 92 - name[sizeof(name) - 1] = '\0'; 93 - 94 - clnt->cl_dentry = rpc_mkdir(clnt->__cl_parent_dentry, name, clnt); 95 - if (IS_ERR(clnt->cl_dentry)) { 75 + for (;;) { 76 + snprintf(clnt->cl_pathname, sizeof(clnt->cl_pathname), 77 + "%s/clnt%x", dir_name, 78 + (unsigned int)clntid++); 79 + clnt->cl_pathname[sizeof(clnt->cl_pathname) - 1] = '\0'; 80 + clnt->cl_dentry = rpc_mkdir(clnt->cl_pathname, clnt); 81 + if (!IS_ERR(clnt->cl_dentry)) 82 + return 0; 96 83 error = PTR_ERR(clnt->cl_dentry); 97 - if (error == -EEXIST) 98 - goto retry_child; 99 - printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", 100 - name, error); 101 - rpc_rmdir(clnt->__cl_parent_dentry); 102 - return error; 84 + if (error != -EEXIST) { 85 + printk(KERN_INFO "RPC: Couldn't create pipefs entry %s, error %d\n", 86 + clnt->cl_pathname, error); 87 + return error; 88 + } 103 89 } 104 - 105 - return 0; 106 90 } 107 91 108 92 /* ··· 174 190 return clnt; 175 191 176 192 out_no_auth: 177 - rpc_rmdir(clnt->cl_dentry); 178 - rpc_rmdir(clnt->__cl_parent_dentry); 193 + rpc_rmdir(clnt->cl_pathname); 179 194 out_no_path: 180 195 if (clnt->cl_server != clnt->cl_inline_name) 181 196 kfree(clnt->cl_server); ··· 302 319 rpc_destroy_client(clnt->cl_parent); 303 320 goto out_free; 304 321 } 305 - if (clnt->cl_dentry) 306 - rpc_rmdir(clnt->cl_dentry); 307 - if (clnt->__cl_parent_dentry) 308 - rpc_rmdir(clnt->__cl_parent_dentry); 322 + if (clnt->cl_pathname[0]) 323 + rpc_rmdir(clnt->cl_pathname); 309 324 if (clnt->cl_xprt) { 310 325 xprt_destroy(clnt->cl_xprt); 311 326 clnt->cl_xprt = NULL;
+181 -101
net/sunrpc/rpc_pipe.c
··· 414 414 simple_release_fs(&rpc_mount, &rpc_mount_count); 415 415 } 416 416 417 + static int 418 + rpc_lookup_parent(char *path, struct nameidata *nd) 419 + { 420 + if (path[0] == '\0') 421 + return -ENOENT; 422 + if (rpc_get_mount()) { 423 + printk(KERN_WARNING "%s: %s failed to mount " 424 + "pseudofilesystem \n", __FILE__, __FUNCTION__); 425 + return -ENODEV; 426 + } 427 + nd->mnt = mntget(rpc_mount); 428 + nd->dentry = dget(rpc_mount->mnt_root); 429 + nd->last_type = LAST_ROOT; 430 + nd->flags = LOOKUP_PARENT; 431 + nd->depth = 0; 432 + 433 + if (path_walk(path, nd)) { 434 + printk(KERN_WARNING "%s: %s failed to find path %s\n", 435 + __FILE__, __FUNCTION__, path); 436 + rpc_put_mount(); 437 + return -ENOENT; 438 + } 439 + return 0; 440 + } 441 + 442 + static void 443 + rpc_release_path(struct nameidata *nd) 444 + { 445 + path_release(nd); 446 + rpc_put_mount(); 447 + } 448 + 417 449 static struct inode * 418 450 rpc_get_inode(struct super_block *sb, int mode) 419 451 { ··· 550 518 return -ENOMEM; 551 519 } 552 520 553 - struct dentry * 554 - rpc_mkdir(struct dentry *parent, char *name, struct rpc_clnt *rpc_client) 521 + static int 522 + __rpc_mkdir(struct inode *dir, struct dentry *dentry) 555 523 { 556 - struct inode *dir; 557 - struct dentry *dentry; 558 524 struct inode *inode; 559 - int error; 560 - 561 - if (!parent) 562 - parent = rpc_mount->mnt_root; 563 - 564 - dir = parent->d_inode; 565 - 566 - error = rpc_get_mount(); 567 - if (error) 568 - return ERR_PTR(error); 569 - 570 - down(&dir->i_sem); 571 - dentry = lookup_one_len(name, parent, strlen(name)); 572 - if (IS_ERR(dentry)) 573 - goto out_unlock; 574 - if (dentry->d_inode) { 575 - dentry = ERR_PTR(-EEXIST); 576 - goto out_dput; 577 - } 578 525 579 526 inode = rpc_get_inode(dir->i_sb, S_IFDIR | S_IRUSR | S_IXUSR); 580 527 if (!inode) 581 - goto out_dput; 528 + goto out_err; 582 529 inode->i_ino = iunique(dir->i_sb, 100); 583 - dir->i_nlink++; 584 - RPC_I(dentry->d_inode)->private = rpc_client; 585 - 586 530 d_instantiate(dentry, inode); 587 - dget(dentry); 588 - up(&dir->i_sem); 589 - 531 + dir->i_nlink++; 590 532 inode_dir_notify(dir, DN_CREATE); 591 - 592 - error = rpc_populate(dentry, authfiles, 593 - RPCAUTH_info, RPCAUTH_EOF); 594 - if (error) 595 - goto out_depopulate; 596 - 597 - return dentry; 598 - 599 - out_depopulate: 600 - rpc_rmdir(dentry); 601 - out_dput: 602 - dput(dentry); 603 - out_unlock: 604 - up(&dir->i_sem); 605 - rpc_put_mount(); 606 - return dentry; 533 + rpc_get_mount(); 534 + return 0; 535 + out_err: 536 + printk(KERN_WARNING "%s: %s failed to allocate inode for dentry %s\n", 537 + __FILE__, __FUNCTION__, dentry->d_name.name); 538 + return -ENOMEM; 607 539 } 608 540 609 - void 610 - rpc_rmdir(struct dentry *dentry) 541 + static int 542 + __rpc_rmdir(struct inode *dir, struct dentry *dentry) 611 543 { 612 - struct dentry *parent = dentry->d_parent; 544 + int error; 613 545 614 - rpc_depopulate(dentry); 615 - 616 - down(&parent->d_inode->i_sem); 546 + shrink_dcache_parent(dentry); 617 547 if (dentry->d_inode) { 618 548 rpc_close_pipes(dentry->d_inode); 619 549 rpc_inode_setowner(dentry->d_inode, NULL); 620 - simple_rmdir(parent->d_inode, dentry); 621 550 } 622 - up(&parent->d_inode->i_sem); 551 + if ((error = simple_rmdir(dir, dentry)) != 0) 552 + return error; 553 + if (!error) { 554 + inode_dir_notify(dir, DN_DELETE); 555 + d_drop(dentry); 556 + rpc_put_mount(); 557 + } 558 + return 0; 559 + } 623 560 624 - inode_dir_notify(parent->d_inode, DN_DELETE); 625 - rpc_put_mount(); 561 + static struct dentry * 562 + rpc_lookup_negative(char *path, struct nameidata *nd) 563 + { 564 + struct dentry *dentry; 565 + struct inode *dir; 566 + int error; 567 + 568 + if ((error = rpc_lookup_parent(path, nd)) != 0) 569 + return ERR_PTR(error); 570 + dir = nd->dentry->d_inode; 571 + down(&dir->i_sem); 572 + dentry = lookup_hash(&nd->last, nd->dentry); 573 + if (IS_ERR(dentry)) 574 + goto out_err; 575 + if (dentry->d_inode) { 576 + dput(dentry); 577 + dentry = ERR_PTR(-EEXIST); 578 + goto out_err; 579 + } 580 + return dentry; 581 + out_err: 582 + up(&dir->i_sem); 583 + rpc_release_path(nd); 584 + return dentry; 585 + } 586 + 587 + 588 + struct dentry * 589 + rpc_mkdir(char *path, struct rpc_clnt *rpc_client) 590 + { 591 + struct nameidata nd; 592 + struct dentry *dentry; 593 + struct inode *dir; 594 + int error; 595 + 596 + dentry = rpc_lookup_negative(path, &nd); 597 + if (IS_ERR(dentry)) 598 + return dentry; 599 + dir = nd.dentry->d_inode; 600 + if ((error = __rpc_mkdir(dir, dentry)) != 0) 601 + goto err_dput; 602 + RPC_I(dentry->d_inode)->private = rpc_client; 603 + error = rpc_populate(dentry, authfiles, 604 + RPCAUTH_info, RPCAUTH_EOF); 605 + if (error) 606 + goto err_depopulate; 607 + out: 608 + up(&dir->i_sem); 609 + rpc_release_path(&nd); 610 + return dentry; 611 + err_depopulate: 612 + rpc_depopulate(dentry); 613 + __rpc_rmdir(dir, dentry); 614 + err_dput: 615 + dput(dentry); 616 + printk(KERN_WARNING "%s: %s() failed to create directory %s (errno = %d)\n", 617 + __FILE__, __FUNCTION__, path, error); 618 + dentry = ERR_PTR(error); 619 + goto out; 620 + } 621 + 622 + int 623 + rpc_rmdir(char *path) 624 + { 625 + struct nameidata nd; 626 + struct dentry *dentry; 627 + struct inode *dir; 628 + int error; 629 + 630 + if ((error = rpc_lookup_parent(path, &nd)) != 0) 631 + return error; 632 + dir = nd.dentry->d_inode; 633 + down(&dir->i_sem); 634 + dentry = lookup_hash(&nd.last, nd.dentry); 635 + if (IS_ERR(dentry)) { 636 + error = PTR_ERR(dentry); 637 + goto out_release; 638 + } 639 + rpc_depopulate(dentry); 640 + error = __rpc_rmdir(dir, dentry); 641 + dput(dentry); 642 + out_release: 643 + up(&dir->i_sem); 644 + rpc_release_path(&nd); 645 + return error; 626 646 } 627 647 628 648 struct dentry * 629 - rpc_mkpipe(struct dentry *parent, char *name, void *private, 630 - struct rpc_pipe_ops *ops, int flags) 649 + rpc_mkpipe(char *path, void *private, struct rpc_pipe_ops *ops, int flags) 631 650 { 632 - struct inode *dir = parent->d_inode; 651 + struct nameidata nd; 633 652 struct dentry *dentry; 634 - struct inode *inode; 653 + struct inode *dir, *inode; 635 654 struct rpc_inode *rpci; 636 - int error; 637 655 638 - error = rpc_get_mount(); 639 - if (error) 640 - return ERR_PTR(error); 641 - 642 - down(&parent->d_inode->i_sem); 643 - dentry = lookup_one_len(name, parent, strlen(name)); 656 + dentry = rpc_lookup_negative(path, &nd); 644 657 if (IS_ERR(dentry)) 645 - goto out_unlock; 646 - if (dentry->d_inode) { 647 - dentry = ERR_PTR(-EEXIST); 648 - goto out_dput; 649 - } 650 - 651 - inode = rpc_get_inode(parent->d_inode->i_sb, 652 - S_IFSOCK | S_IRUSR | S_IWUSR); 653 - if (!inode) { 654 - dentry = ERR_PTR(-ENOMEM); 655 - goto out_dput; 656 - } 657 - 658 + return dentry; 659 + dir = nd.dentry->d_inode; 660 + inode = rpc_get_inode(dir->i_sb, S_IFSOCK | S_IRUSR | S_IWUSR); 661 + if (!inode) 662 + goto err_dput; 658 663 inode->i_ino = iunique(dir->i_sb, 100); 659 664 inode->i_fop = &rpc_pipe_fops; 660 - 665 + d_instantiate(dentry, inode); 661 666 rpci = RPC_I(inode); 662 667 rpci->private = private; 663 668 rpci->flags = flags; 664 669 rpci->ops = ops; 665 - 666 - d_instantiate(dentry, inode); 667 - dget(dentry); 668 - up(&parent->d_inode->i_sem); 669 - 670 670 inode_dir_notify(dir, DN_CREATE); 671 + out: 672 + up(&dir->i_sem); 673 + rpc_release_path(&nd); 671 674 return dentry; 672 - 673 - out_dput: 675 + err_dput: 674 676 dput(dentry); 675 - out_unlock: 676 - up(&parent->d_inode->i_sem); 677 - rpc_put_mount(); 678 - return dentry; 677 + dentry = ERR_PTR(-ENOMEM); 678 + printk(KERN_WARNING "%s: %s() failed to create pipe %s (errno = %d)\n", 679 + __FILE__, __FUNCTION__, path, -ENOMEM); 680 + goto out; 679 681 } 680 682 681 - void 682 - rpc_unlink(struct dentry *dentry) 683 + int 684 + rpc_unlink(char *path) 683 685 { 684 - struct dentry *parent = dentry->d_parent; 686 + struct nameidata nd; 687 + struct dentry *dentry; 688 + struct inode *dir; 689 + int error; 685 690 686 - down(&parent->d_inode->i_sem); 691 + if ((error = rpc_lookup_parent(path, &nd)) != 0) 692 + return error; 693 + dir = nd.dentry->d_inode; 694 + down(&dir->i_sem); 695 + dentry = lookup_hash(&nd.last, nd.dentry); 696 + if (IS_ERR(dentry)) { 697 + error = PTR_ERR(dentry); 698 + goto out_release; 699 + } 700 + d_drop(dentry); 687 701 if (dentry->d_inode) { 688 702 rpc_close_pipes(dentry->d_inode); 689 703 rpc_inode_setowner(dentry->d_inode, NULL); 690 - simple_unlink(parent->d_inode, dentry); 704 + error = simple_unlink(dir, dentry); 691 705 } 692 - up(&parent->d_inode->i_sem); 693 - 694 - inode_dir_notify(parent->d_inode, DN_DELETE); 695 - rpc_put_mount(); 706 + dput(dentry); 707 + inode_dir_notify(dir, DN_DELETE); 708 + out_release: 709 + up(&dir->i_sem); 710 + rpc_release_path(&nd); 711 + return error; 696 712 } 697 713 698 714 /*