dir.c (20b8391fff56f64893233a772a81adc392a69121) | dir.c (87182759cd6f94875d6aaaac74eaa52aa6aa6f98) |
---|---|
1/* dir.c: AFS filesystem directory handling 2 * 3 * Copyright (C) 2002, 2018 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 88 unchanged lines hidden (view full) --- 97}; 98 99struct afs_lookup_cookie { 100 struct dir_context ctx; 101 struct qstr name; 102 bool found; 103 bool one_only; 104 unsigned short nr_fids; | 1/* dir.c: AFS filesystem directory handling 2 * 3 * Copyright (C) 2002, 2018 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 88 unchanged lines hidden (view full) --- 97}; 98 99struct afs_lookup_cookie { 100 struct dir_context ctx; 101 struct qstr name; 102 bool found; 103 bool one_only; 104 unsigned short nr_fids; |
105 struct afs_file_status *statuses; 106 struct afs_callback *callbacks; | 105 struct afs_status_cb *statuses; |
107 struct afs_fid fids[50]; 108}; 109 110/* 111 * check that a directory page is valid 112 */ 113static bool afs_dir_check_page(struct afs_vnode *dvnode, struct page *page, 114 loff_t i_size) --- 520 unchanged lines hidden (view full) --- 635 * asked for is returned. 636 */ 637static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, 638 struct key *key) 639{ 640 struct afs_lookup_cookie *cookie; 641 struct afs_cb_interest *cbi = NULL; 642 struct afs_super_info *as = dir->i_sb->s_fs_info; | 106 struct afs_fid fids[50]; 107}; 108 109/* 110 * check that a directory page is valid 111 */ 112static bool afs_dir_check_page(struct afs_vnode *dvnode, struct page *page, 113 loff_t i_size) --- 520 unchanged lines hidden (view full) --- 634 * asked for is returned. 635 */ 636static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, 637 struct key *key) 638{ 639 struct afs_lookup_cookie *cookie; 640 struct afs_cb_interest *cbi = NULL; 641 struct afs_super_info *as = dir->i_sb->s_fs_info; |
642 struct afs_status_cb *scb; |
|
643 struct afs_iget_data data; 644 struct afs_fs_cursor fc; 645 struct afs_vnode *dvnode = AFS_FS_I(dir); 646 struct inode *inode = NULL; 647 int ret, i; 648 649 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry); 650 --- 30 unchanged lines hidden (view full) --- 681 data.volume = dvnode->volume; 682 data.fid = cookie->fids[0]; 683 inode = ilookup5(dir->i_sb, cookie->fids[0].vnode, afs_iget5_test, &data); 684 if (inode) 685 goto out; 686 687 /* Need space for examining all the selected files */ 688 inode = ERR_PTR(-ENOMEM); | 643 struct afs_iget_data data; 644 struct afs_fs_cursor fc; 645 struct afs_vnode *dvnode = AFS_FS_I(dir); 646 struct inode *inode = NULL; 647 int ret, i; 648 649 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry); 650 --- 30 unchanged lines hidden (view full) --- 681 data.volume = dvnode->volume; 682 data.fid = cookie->fids[0]; 683 inode = ilookup5(dir->i_sb, cookie->fids[0].vnode, afs_iget5_test, &data); 684 if (inode) 685 goto out; 686 687 /* Need space for examining all the selected files */ 688 inode = ERR_PTR(-ENOMEM); |
689 cookie->statuses = kcalloc(cookie->nr_fids, sizeof(struct afs_file_status), 690 GFP_KERNEL); | 689 cookie->statuses = kvcalloc(cookie->nr_fids, sizeof(struct afs_status_cb), 690 GFP_KERNEL); |
691 if (!cookie->statuses) 692 goto out; 693 | 691 if (!cookie->statuses) 692 goto out; 693 |
694 cookie->callbacks = kcalloc(cookie->nr_fids, sizeof(struct afs_callback), 695 GFP_KERNEL); 696 if (!cookie->callbacks) 697 goto out_s; 698 | |
699 /* Try FS.InlineBulkStatus first. Abort codes for the individual 700 * lookups contained therein are stored in the reply without aborting 701 * the whole operation. 702 */ 703 if (cookie->one_only) 704 goto no_inline_bulk_status; 705 706 inode = ERR_PTR(-ERESTARTSYS); --- 4 unchanged lines hidden (view full) --- 711 fc.ac.abort_code = RX_INVALID_OPERATION; 712 fc.ac.error = -ECONNABORTED; 713 break; 714 } 715 afs_fs_inline_bulk_status(&fc, 716 afs_v2net(dvnode), 717 cookie->fids, 718 cookie->statuses, | 694 /* Try FS.InlineBulkStatus first. Abort codes for the individual 695 * lookups contained therein are stored in the reply without aborting 696 * the whole operation. 697 */ 698 if (cookie->one_only) 699 goto no_inline_bulk_status; 700 701 inode = ERR_PTR(-ERESTARTSYS); --- 4 unchanged lines hidden (view full) --- 706 fc.ac.abort_code = RX_INVALID_OPERATION; 707 fc.ac.error = -ECONNABORTED; 708 break; 709 } 710 afs_fs_inline_bulk_status(&fc, 711 afs_v2net(dvnode), 712 cookie->fids, 713 cookie->statuses, |
719 cookie->callbacks, | |
720 cookie->nr_fids, NULL); 721 } 722 723 if (fc.ac.error == 0) 724 cbi = afs_get_cb_interest(fc.cbi); 725 if (fc.ac.abort_code == RX_INVALID_OPERATION) 726 set_bit(AFS_SERVER_FL_NO_IBULK, &fc.cbi->server->flags); 727 inode = ERR_PTR(afs_end_vnode_operation(&fc)); --- 8 unchanged lines hidden (view full) --- 736 /* We could try FS.BulkStatus next, but this aborts the entire op if 737 * any of the lookups fails - so, for the moment, revert to 738 * FS.FetchStatus for just the primary fid. 739 */ 740 cookie->nr_fids = 1; 741 inode = ERR_PTR(-ERESTARTSYS); 742 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 743 while (afs_select_fileserver(&fc)) { | 714 cookie->nr_fids, NULL); 715 } 716 717 if (fc.ac.error == 0) 718 cbi = afs_get_cb_interest(fc.cbi); 719 if (fc.ac.abort_code == RX_INVALID_OPERATION) 720 set_bit(AFS_SERVER_FL_NO_IBULK, &fc.cbi->server->flags); 721 inode = ERR_PTR(afs_end_vnode_operation(&fc)); --- 8 unchanged lines hidden (view full) --- 730 /* We could try FS.BulkStatus next, but this aborts the entire op if 731 * any of the lookups fails - so, for the moment, revert to 732 * FS.FetchStatus for just the primary fid. 733 */ 734 cookie->nr_fids = 1; 735 inode = ERR_PTR(-ERESTARTSYS); 736 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 737 while (afs_select_fileserver(&fc)) { |
738 scb = &cookie->statuses[0]; |
|
744 afs_fs_fetch_status(&fc, 745 afs_v2net(dvnode), 746 cookie->fids, | 739 afs_fs_fetch_status(&fc, 740 afs_v2net(dvnode), 741 cookie->fids, |
747 cookie->statuses, 748 cookie->callbacks, | 742 &scb->status, 743 &scb->callback, |
749 NULL); 750 } 751 752 if (fc.ac.error == 0) 753 cbi = afs_get_cb_interest(fc.cbi); 754 inode = ERR_PTR(afs_end_vnode_operation(&fc)); 755 } 756 757 if (IS_ERR(inode)) 758 goto out_c; 759 760 for (i = 0; i < cookie->nr_fids; i++) | 744 NULL); 745 } 746 747 if (fc.ac.error == 0) 748 cbi = afs_get_cb_interest(fc.cbi); 749 inode = ERR_PTR(afs_end_vnode_operation(&fc)); 750 } 751 752 if (IS_ERR(inode)) 753 goto out_c; 754 755 for (i = 0; i < cookie->nr_fids; i++) |
761 cookie->statuses[i].abort_code = 0; | 756 cookie->statuses[i].status.abort_code = 0; |
762 763success: 764 /* Turn all the files into inodes and save the first one - which is the 765 * one we actually want. 766 */ | 757 758success: 759 /* Turn all the files into inodes and save the first one - which is the 760 * one we actually want. 761 */ |
767 if (cookie->statuses[0].abort_code != 0) 768 inode = ERR_PTR(afs_abort_to_error(cookie->statuses[0].abort_code)); | 762 scb = &cookie->statuses[0]; 763 if (scb->status.abort_code != 0) 764 inode = ERR_PTR(afs_abort_to_error(scb->status.abort_code)); |
769 770 for (i = 0; i < cookie->nr_fids; i++) { | 765 766 for (i = 0; i < cookie->nr_fids; i++) { |
767 struct afs_status_cb *scb = &cookie->statuses[i]; |
|
771 struct inode *ti; 772 | 768 struct inode *ti; 769 |
773 if (cookie->statuses[i].abort_code != 0) | 770 if (scb->status.abort_code != 0) |
774 continue; 775 776 ti = afs_iget(dir->i_sb, key, &cookie->fids[i], | 771 continue; 772 773 ti = afs_iget(dir->i_sb, key, &cookie->fids[i], |
777 &cookie->statuses[i], 778 &cookie->callbacks[i], | 774 &scb->status, 775 &scb->callback, |
779 cbi, dvnode); 780 if (i == 0) { 781 inode = ti; 782 } else { 783 if (!IS_ERR(ti)) 784 iput(ti); 785 } 786 } 787 788out_c: 789 afs_put_cb_interest(afs_v2net(dvnode), cbi); | 776 cbi, dvnode); 777 if (i == 0) { 778 inode = ti; 779 } else { 780 if (!IS_ERR(ti)) 781 iput(ti); 782 } 783 } 784 785out_c: 786 afs_put_cb_interest(afs_v2net(dvnode), cbi); |
790 kfree(cookie->callbacks); 791out_s: 792 kfree(cookie->statuses); | 787 kvfree(cookie->statuses); |
793out: 794 kfree(cookie); 795 return inode; 796} 797 798/* 799 * Look up an entry in a directory with @sys substitution. 800 */ --- 1004 unchanged lines hidden --- | 788out: 789 kfree(cookie); 790 return inode; 791} 792 793/* 794 * Look up an entry in a directory with @sys substitution. 795 */ --- 1004 unchanged lines hidden --- |