summaryrefslogtreecommitdiffstats
path: root/fs/afs/dir.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-05-09 11:17:05 -0400
committerDavid Howells <dhowells@redhat.com>2019-05-16 11:25:21 -0400
commit87182759cd6f94875d6aaaac74eaa52aa6aa6f98 (patch)
tree3a143ae4a411fd26b1d98bffff3f66770e027901 /fs/afs/dir.c
parentffba718e935402e7f42b8cd5d1e00e4a3907d361 (diff)
afs: Fix order-1 allocation in afs_do_lookup()
afs_do_lookup() will do an order-1 allocation to allocate status records if there are more than 39 vnodes to stat. Fix this by allocating an array of {status,callback} records for each vnode we want to examine using vmalloc() if larger than a page. This not only gets rid of the order-1 allocation, but makes it easier to grow beyond 50 records for YFS servers. It also allows us to move to {status,callback} tuples for other calls too and makes it easier to lock across the application of the status and the callback to the vnode. Fixes: 5cf9dd55a0ec ("afs: Prospectively look up extra files when doing a single lookup") Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/afs/dir.c')
-rw-r--r--fs/afs/dir.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index c15550310f62..0f14bcfe233d 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -102,8 +102,7 @@ struct afs_lookup_cookie {
102 bool found; 102 bool found;
103 bool one_only; 103 bool one_only;
104 unsigned short nr_fids; 104 unsigned short nr_fids;
105 struct afs_file_status *statuses; 105 struct afs_status_cb *statuses;
106 struct afs_callback *callbacks;
107 struct afs_fid fids[50]; 106 struct afs_fid fids[50];
108}; 107};
109 108
@@ -640,6 +639,7 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
640 struct afs_lookup_cookie *cookie; 639 struct afs_lookup_cookie *cookie;
641 struct afs_cb_interest *cbi = NULL; 640 struct afs_cb_interest *cbi = NULL;
642 struct afs_super_info *as = dir->i_sb->s_fs_info; 641 struct afs_super_info *as = dir->i_sb->s_fs_info;
642 struct afs_status_cb *scb;
643 struct afs_iget_data data; 643 struct afs_iget_data data;
644 struct afs_fs_cursor fc; 644 struct afs_fs_cursor fc;
645 struct afs_vnode *dvnode = AFS_FS_I(dir); 645 struct afs_vnode *dvnode = AFS_FS_I(dir);
@@ -686,16 +686,11 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
686 686
687 /* Need space for examining all the selected files */ 687 /* Need space for examining all the selected files */
688 inode = ERR_PTR(-ENOMEM); 688 inode = ERR_PTR(-ENOMEM);
689 cookie->statuses = kcalloc(cookie->nr_fids, sizeof(struct afs_file_status), 689 cookie->statuses = kvcalloc(cookie->nr_fids, sizeof(struct afs_status_cb),
690 GFP_KERNEL); 690 GFP_KERNEL);
691 if (!cookie->statuses) 691 if (!cookie->statuses)
692 goto out; 692 goto out;
693 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 694 /* Try FS.InlineBulkStatus first. Abort codes for the individual
700 * lookups contained therein are stored in the reply without aborting 695 * lookups contained therein are stored in the reply without aborting
701 * the whole operation. 696 * the whole operation.
@@ -716,7 +711,6 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry,
716 afs_v2net(dvnode), 711 afs_v2net(dvnode),
717 cookie->fids, 712 cookie->fids,
718 cookie->statuses, 713 cookie->statuses,
719 cookie->callbacks,
720 cookie->nr_fids, NULL); 714 cookie->nr_fids, NULL);
721 } 715 }
722 716
@@ -741,11 +735,12 @@ no_inline_bulk_status:
741 inode = ERR_PTR(-ERESTARTSYS); 735 inode = ERR_PTR(-ERESTARTSYS);
742 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 736 if (afs_begin_vnode_operation(&fc, dvnode, key, true)) {
743 while (afs_select_fileserver(&fc)) { 737 while (afs_select_fileserver(&fc)) {
738 scb = &cookie->statuses[0];
744 afs_fs_fetch_status(&fc, 739 afs_fs_fetch_status(&fc,
745 afs_v2net(dvnode), 740 afs_v2net(dvnode),
746 cookie->fids, 741 cookie->fids,
747 cookie->statuses, 742 &scb->status,
748 cookie->callbacks, 743 &scb->callback,
749 NULL); 744 NULL);
750 } 745 }
751 746
@@ -758,24 +753,26 @@ no_inline_bulk_status:
758 goto out_c; 753 goto out_c;
759 754
760 for (i = 0; i < cookie->nr_fids; i++) 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 757
763success: 758success:
764 /* Turn all the files into inodes and save the first one - which is the 759 /* Turn all the files into inodes and save the first one - which is the
765 * one we actually want. 760 * one we actually want.
766 */ 761 */
767 if (cookie->statuses[0].abort_code != 0) 762 scb = &cookie->statuses[0];
768 inode = ERR_PTR(afs_abort_to_error(cookie->statuses[0].abort_code)); 763 if (scb->status.abort_code != 0)
764 inode = ERR_PTR(afs_abort_to_error(scb->status.abort_code));
769 765
770 for (i = 0; i < cookie->nr_fids; i++) { 766 for (i = 0; i < cookie->nr_fids; i++) {
767 struct afs_status_cb *scb = &cookie->statuses[i];
771 struct inode *ti; 768 struct inode *ti;
772 769
773 if (cookie->statuses[i].abort_code != 0) 770 if (scb->status.abort_code != 0)
774 continue; 771 continue;
775 772
776 ti = afs_iget(dir->i_sb, key, &cookie->fids[i], 773 ti = afs_iget(dir->i_sb, key, &cookie->fids[i],
777 &cookie->statuses[i], 774 &scb->status,
778 &cookie->callbacks[i], 775 &scb->callback,
779 cbi, dvnode); 776 cbi, dvnode);
780 if (i == 0) { 777 if (i == 0) {
781 inode = ti; 778 inode = ti;
@@ -787,9 +784,7 @@ success:
787 784
788out_c: 785out_c:
789 afs_put_cb_interest(afs_v2net(dvnode), cbi); 786 afs_put_cb_interest(afs_v2net(dvnode), cbi);
790 kfree(cookie->callbacks); 787 kvfree(cookie->statuses);
791out_s:
792 kfree(cookie->statuses);
793out: 788out:
794 kfree(cookie); 789 kfree(cookie);
795 return inode; 790 return inode;