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

afs: Build an abstraction around an "operation" concept

Turn the afs_operation struct into the main way that most fileserver
operations are managed. Various things are added to the struct, including
the following:

(1) All the parameters and results of the relevant operations are moved
into it, removing corresponding fields from the afs_call struct.
afs_call gets a pointer to the op.

(2) The target volume is made the main focus of the operation, rather than
the target vnode(s), and a bunch of op->vnode->volume are made
op->volume instead.

(3) Two vnode records are defined (op->file[]) for the vnode(s) involved
in most operations. The vnode record (struct afs_vnode_param)
contains:

- The vnode pointer.

- The fid of the vnode to be included in the parameters or that was
returned in the reply (eg. FS.MakeDir).

- The status and callback information that may be returned in the
reply about the vnode.

- Callback break and data version tracking for detecting
simultaneous third-parth changes.

(4) Pointers to dentries to be updated with new inodes.

(5) An operations table pointer. The table includes pointers to functions
for issuing AFS and YFS-variant RPCs, handling the success and abort
of an operation and handling post-I/O-lock local editing of a
directory.

To make this work, the following function restructuring is made:

(A) The rotation loop that issues calls to fileservers that can be found
in each function that wants to issue an RPC (such as afs_mkdir()) is
extracted out into common code, in a new file called fs_operation.c.

(B) The rotation loops, such as the one in afs_mkdir(), are replaced with
a much smaller piece of code that allocates an operation, sets the
parameters and then calls out to the common code to do the actual
work.

(C) The code for handling the success and failure of an operation are
moved into operation functions (as (5) above) and these are called
from the core code at appropriate times.

(D) The pseudo inode getting stuff used by the dynamic root code is moved
over into dynroot.c.

(E) struct afs_iget_data is absorbed into the operation struct and
afs_iget() expects to be given an op pointer and a vnode record.

(F) Point (E) doesn't work for the root dir of a volume, but we know the
FID in advance (it's always vnode 1, unique 1), so a separate inode
getter, afs_root_iget(), is provided to special-case that.

(G) The inode status init/update functions now also take an op and a vnode
record.

(H) The RPC marshalling functions now, for the most part, just take an
afs_operation struct as their only argument. All the data they need
is held there. The result delivery functions write their answers
there as well.

(I) The call is attached to the operation and then the operation core does
the waiting.

And then the new operation code is, for the moment, made to just initialise
the operation, get the appropriate vnode I/O locks and do the same rotation
loop as before.

This lays the foundation for the following changes in the future:

(*) Overhauling the rotation (again).

(*) Support for asynchronous I/O, where the fileserver rotation must be
done asynchronously also.

Signed-off-by: David Howells <dhowells@redhat.com>

+2661 -2845
+1
fs/afs/Makefile
··· 18 18 file.o \ 19 19 flock.o \ 20 20 fsclient.o \ 21 + fs_operation.o \ 21 22 fs_probe.o \ 22 23 inode.o \ 23 24 main.o \
-1
fs/afs/afs.h
··· 146 146 struct afs_status_cb { 147 147 struct afs_file_status status; 148 148 struct afs_callback callback; 149 - unsigned int cb_break; /* Pre-op callback break counter */ 150 149 bool have_status; /* True if status record was retrieved */ 151 150 bool have_cb; /* True if cb record was retrieved */ 152 151 bool have_error; /* True if status.abort_code indicates an error */
+1 -6
fs/afs/callback.c
··· 46 46 47 47 refcount_set(&new->usage, 1); 48 48 new->sb = vnode->vfs_inode.i_sb; 49 - new->vid = vnode->volume->vid; 50 49 new->server = afs_get_server(server, afs_server_trace_get_new_cbi); 51 50 INIT_HLIST_NODE(&new->cb_vlink); 52 51 ··· 285 286 struct afs_vol_interest *vi) 286 287 { 287 288 struct afs_cb_interest *cbi; 288 - struct afs_iget_data data; 289 289 struct afs_vnode *vnode; 290 290 struct inode *inode; 291 291 ··· 303 305 afs_cb_break_for_volume_callback, false); 304 306 write_unlock(&volume->cb_v_break_lock); 305 307 } else { 306 - data.volume = NULL; 307 - data.fid = *fid; 308 - 309 308 /* See if we can find a matching inode - even an I_NEW 310 309 * inode needs to be marked as it can have its callback 311 310 * broken before we finish setting up the local inode. 312 311 */ 313 312 inode = find_inode_rcu(cbi->sb, fid->vnode, 314 - afs_iget5_test, &data); 313 + afs_ilookup5_test_by_fid, fid); 315 314 if (inode) { 316 315 vnode = AFS_FS_I(inode); 317 316 afs_break_callback(vnode, afs_cb_break_for_callback);
+548 -667
fs/afs/dir.c
··· 99 99 bool found; 100 100 bool one_only; 101 101 unsigned short nr_fids; 102 - struct inode **inodes; 103 - struct afs_status_cb *statuses; 104 102 struct afs_fid fids[50]; 105 103 }; 106 104 ··· 616 618 } 617 619 } else if (cookie->name.len == nlen && 618 620 memcmp(cookie->name.name, name, nlen) == 0) { 619 - cookie->fids[0].vnode = ino; 620 - cookie->fids[0].unique = dtype; 621 + cookie->fids[1].vnode = ino; 622 + cookie->fids[1].unique = dtype; 621 623 cookie->found = 1; 622 624 if (cookie->one_only) 623 625 return -1; ··· 629 631 } 630 632 631 633 /* 634 + * Deal with the result of a successful lookup operation. Turn all the files 635 + * into inodes and save the first one - which is the one we actually want. 636 + */ 637 + static void afs_do_lookup_success(struct afs_operation *op) 638 + { 639 + struct afs_vnode_param *vp; 640 + struct afs_vnode *vnode; 641 + struct inode *inode; 642 + u32 abort_code; 643 + int i; 644 + 645 + _enter(""); 646 + 647 + for (i = 0; i < op->nr_files; i++) { 648 + switch (i) { 649 + case 0: 650 + vp = &op->file[0]; 651 + abort_code = vp->scb.status.abort_code; 652 + if (abort_code != 0) { 653 + op->abort_code = abort_code; 654 + op->error = afs_abort_to_error(abort_code); 655 + } 656 + break; 657 + 658 + case 1: 659 + vp = &op->file[1]; 660 + break; 661 + 662 + default: 663 + vp = &op->more_files[i - 2]; 664 + break; 665 + } 666 + 667 + if (!vp->scb.have_status && !vp->scb.have_error) 668 + continue; 669 + 670 + _debug("do [%u]", i); 671 + if (vp->vnode) { 672 + if (!test_bit(AFS_VNODE_UNSET, &vp->vnode->flags)) 673 + afs_vnode_commit_status(op, vp); 674 + } else if (vp->scb.status.abort_code == 0) { 675 + inode = afs_iget(op, vp); 676 + if (!IS_ERR(inode)) { 677 + vnode = AFS_FS_I(inode); 678 + afs_cache_permit(vnode, op->key, 679 + 0 /* Assume vnode->cb_break is 0 */ + 680 + op->cb_v_break, 681 + &vp->scb); 682 + vp->vnode = vnode; 683 + vp->put_vnode = true; 684 + } 685 + } else { 686 + _debug("- abort %d %llx:%llx.%x", 687 + vp->scb.status.abort_code, 688 + vp->fid.vid, vp->fid.vnode, vp->fid.unique); 689 + } 690 + } 691 + 692 + _leave(""); 693 + } 694 + 695 + static const struct afs_operation_ops afs_inline_bulk_status_operation = { 696 + .issue_afs_rpc = afs_fs_inline_bulk_status, 697 + .issue_yfs_rpc = yfs_fs_inline_bulk_status, 698 + .success = afs_do_lookup_success, 699 + }; 700 + 701 + static const struct afs_operation_ops afs_fetch_status_operation = { 702 + .issue_afs_rpc = afs_fs_fetch_status, 703 + .issue_yfs_rpc = yfs_fs_fetch_status, 704 + .success = afs_do_lookup_success, 705 + }; 706 + 707 + /* 632 708 * Do a lookup in a directory. We make use of bulk lookup to query a slew of 633 709 * files in one go and create inodes for them. The inode of the file we were 634 710 * asked for is returned. ··· 711 639 struct key *key) 712 640 { 713 641 struct afs_lookup_cookie *cookie; 714 - struct afs_cb_interest *dcbi, *cbi = NULL; 715 - struct afs_super_info *as = dir->i_sb->s_fs_info; 716 - struct afs_status_cb *scb; 717 - struct afs_iget_data iget_data; 718 - struct afs_operation fc; 642 + struct afs_cb_interest *dcbi; 643 + struct afs_vnode_param *vp; 644 + struct afs_operation *op; 719 645 struct afs_server *server; 720 646 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode; 721 647 struct inode *inode = NULL, *ti; 722 648 afs_dataversion_t data_version = READ_ONCE(dvnode->status.data_version); 723 - int ret, i; 649 + long ret; 650 + int i; 724 651 725 652 _enter("{%lu},%p{%pd},", dir->i_ino, dentry, dentry); 726 653 ··· 727 656 if (!cookie) 728 657 return ERR_PTR(-ENOMEM); 729 658 659 + for (i = 0; i < ARRAY_SIZE(cookie->fids); i++) 660 + cookie->fids[i].vid = dvnode->fid.vid; 730 661 cookie->ctx.actor = afs_lookup_filldir; 731 662 cookie->name = dentry->d_name; 732 663 cookie->nr_fids = 2; /* slot 0 is saved for the fid we actually want ··· 745 672 } 746 673 read_sequnlock_excl(&dvnode->cb_lock); 747 674 748 - for (i = 0; i < 50; i++) 749 - cookie->fids[i].vid = as->volume->vid; 750 - 751 675 /* search the directory */ 752 676 ret = afs_dir_iterate(dir, &cookie->ctx, key, &data_version); 753 - if (ret < 0) { 754 - inode = ERR_PTR(ret); 677 + if (ret < 0) 755 678 goto out; 756 - } 757 679 758 680 dentry->d_fsdata = (void *)(unsigned long)data_version; 759 681 760 - inode = ERR_PTR(-ENOENT); 682 + ret = -ENOENT; 761 683 if (!cookie->found) 762 684 goto out; 763 685 764 686 /* Check to see if we already have an inode for the primary fid. */ 765 - iget_data.fid = cookie->fids[0]; 766 - iget_data.volume = dvnode->volume; 767 - iget_data.cb_v_break = dvnode->volume->cb_v_break; 768 - iget_data.cb_s_break = 0; 769 - inode = ilookup5(dir->i_sb, cookie->fids[0].vnode, 770 - afs_iget5_test, &iget_data); 687 + inode = ilookup5(dir->i_sb, cookie->fids[1].vnode, 688 + afs_ilookup5_test_by_fid, &cookie->fids[1]); 771 689 if (inode) 690 + goto out; /* We do */ 691 + 692 + /* Okay, we didn't find it. We need to query the server - and whilst 693 + * we're doing that, we're going to attempt to look up a bunch of other 694 + * vnodes also. 695 + */ 696 + op = afs_alloc_operation(NULL, dvnode->volume); 697 + if (IS_ERR(op)) { 698 + ret = PTR_ERR(op); 772 699 goto out; 700 + } 701 + 702 + afs_op_set_vnode(op, 0, dvnode); 703 + afs_op_set_fid(op, 1, &cookie->fids[1]); 704 + 705 + op->nr_files = cookie->nr_fids; 706 + _debug("nr_files %u", op->nr_files); 773 707 774 708 /* Need space for examining all the selected files */ 775 - inode = ERR_PTR(-ENOMEM); 776 - cookie->statuses = kvcalloc(cookie->nr_fids, sizeof(struct afs_status_cb), 777 - GFP_KERNEL); 778 - if (!cookie->statuses) 779 - goto out; 709 + op->error = -ENOMEM; 710 + if (op->nr_files > 2) { 711 + op->more_files = kvcalloc(op->nr_files - 2, 712 + sizeof(struct afs_vnode_param), 713 + GFP_KERNEL); 714 + if (!op->more_files) 715 + goto out_op; 780 716 781 - cookie->inodes = kcalloc(cookie->nr_fids, sizeof(struct inode *), 782 - GFP_KERNEL); 783 - if (!cookie->inodes) 784 - goto out_s; 717 + for (i = 2; i < op->nr_files; i++) { 718 + vp = &op->more_files[i - 2]; 719 + vp->fid = cookie->fids[i]; 785 720 786 - cookie->fids[1] = dvnode->fid; 787 - cookie->statuses[1].cb_break = afs_calc_vnode_cb_break(dvnode); 788 - cookie->inodes[1] = igrab(&dvnode->vfs_inode); 789 - 790 - for (i = 2; i < cookie->nr_fids; i++) { 791 - scb = &cookie->statuses[i]; 792 - 793 - /* Find any inodes that already exist and get their 794 - * callback counters. 795 - */ 796 - iget_data.fid = cookie->fids[i]; 797 - ti = ilookup5_nowait(dir->i_sb, iget_data.fid.vnode, 798 - afs_iget5_test, &iget_data); 799 - if (!IS_ERR_OR_NULL(ti)) { 800 - vnode = AFS_FS_I(ti); 801 - scb->cb_break = afs_calc_vnode_cb_break(vnode); 802 - cookie->inodes[i] = ti; 721 + /* Find any inodes that already exist and get their 722 + * callback counters. 723 + */ 724 + ti = ilookup5_nowait(dir->i_sb, vp->fid.vnode, 725 + afs_ilookup5_test_by_fid, &vp->fid); 726 + if (!IS_ERR_OR_NULL(ti)) { 727 + vnode = AFS_FS_I(ti); 728 + vp->dv_before = vnode->status.data_version; 729 + vp->cb_break_before = afs_calc_vnode_cb_break(vnode); 730 + vp->vnode = vnode; 731 + vp->put_vnode = true; 732 + } 803 733 } 804 734 } 805 735 ··· 810 734 * lookups contained therein are stored in the reply without aborting 811 735 * the whole operation. 812 736 */ 813 - if (cookie->one_only) 814 - goto no_inline_bulk_status; 815 - 816 - inode = ERR_PTR(-ERESTARTSYS); 817 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 818 - while (afs_select_fileserver(&fc)) { 819 - if (test_bit(AFS_SERVER_FL_NO_IBULK, 820 - &fc.cbi->server->flags)) { 821 - fc.ac.abort_code = RX_INVALID_OPERATION; 822 - fc.ac.error = -ECONNABORTED; 823 - break; 824 - } 825 - iget_data.cb_v_break = dvnode->volume->cb_v_break; 826 - iget_data.cb_s_break = fc.cbi->server->cb_s_break; 827 - afs_fs_inline_bulk_status(&fc, 828 - afs_v2net(dvnode), 829 - cookie->fids, 830 - cookie->statuses, 831 - cookie->nr_fids, NULL); 832 - } 833 - 834 - if (fc.ac.error == 0) 835 - cbi = afs_get_cb_interest(fc.cbi); 836 - if (fc.ac.abort_code == RX_INVALID_OPERATION) 837 - set_bit(AFS_SERVER_FL_NO_IBULK, &fc.cbi->server->flags); 838 - inode = ERR_PTR(afs_end_vnode_operation(&fc)); 737 + op->error = -ENOTSUPP; 738 + if (!cookie->one_only) { 739 + op->ops = &afs_inline_bulk_status_operation; 740 + afs_begin_vnode_operation(op); 741 + afs_wait_for_operation(op); 839 742 } 840 743 841 - if (!IS_ERR(inode)) 842 - goto success; 843 - if (fc.ac.abort_code != RX_INVALID_OPERATION) 844 - goto out_c; 744 + if (op->error == -ENOTSUPP) { 745 + /* We could try FS.BulkStatus next, but this aborts the entire 746 + * op if any of the lookups fails - so, for the moment, revert 747 + * to FS.FetchStatus for op->file[1]. 748 + */ 749 + op->fetch_status.which = 1; 750 + op->ops = &afs_fetch_status_operation; 751 + afs_begin_vnode_operation(op); 752 + afs_wait_for_operation(op); 753 + } 754 + inode = ERR_PTR(op->error); 845 755 846 - no_inline_bulk_status: 847 - /* We could try FS.BulkStatus next, but this aborts the entire op if 848 - * any of the lookups fails - so, for the moment, revert to 849 - * FS.FetchStatus for just the primary fid. 850 - */ 851 - inode = ERR_PTR(-ERESTARTSYS); 852 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 853 - while (afs_select_fileserver(&fc)) { 854 - iget_data.cb_v_break = dvnode->volume->cb_v_break; 855 - iget_data.cb_s_break = fc.cbi->server->cb_s_break; 856 - scb = &cookie->statuses[0]; 857 - afs_fs_fetch_status(&fc, 858 - afs_v2net(dvnode), 859 - cookie->fids, 860 - scb, 861 - NULL); 862 - } 863 - 864 - if (fc.ac.error == 0) 865 - cbi = afs_get_cb_interest(fc.cbi); 866 - inode = ERR_PTR(afs_end_vnode_operation(&fc)); 756 + out_op: 757 + if (op->error == 0) { 758 + inode = &op->file[1].vnode->vfs_inode; 759 + op->file[1].vnode = NULL; 867 760 } 868 761 869 - if (IS_ERR(inode)) 870 - goto out_c; 871 - 872 - success: 873 - /* Turn all the files into inodes and save the first one - which is the 874 - * one we actually want. 875 - */ 876 - scb = &cookie->statuses[0]; 877 - if (scb->status.abort_code != 0) 878 - inode = ERR_PTR(afs_abort_to_error(scb->status.abort_code)); 879 - 880 - for (i = 0; i < cookie->nr_fids; i++) { 881 - struct afs_status_cb *scb = &cookie->statuses[i]; 882 - 883 - if (!scb->have_status && !scb->have_error) 884 - continue; 885 - 886 - if (cookie->inodes[i]) { 887 - struct afs_vnode *iv = AFS_FS_I(cookie->inodes[i]); 888 - 889 - if (test_bit(AFS_VNODE_UNSET, &iv->flags)) 890 - continue; 891 - 892 - afs_vnode_commit_status(&fc, iv, 893 - scb->cb_break, NULL, scb); 894 - continue; 895 - } 896 - 897 - if (scb->status.abort_code != 0) 898 - continue; 899 - 900 - iget_data.fid = cookie->fids[i]; 901 - ti = afs_iget(dir->i_sb, key, &iget_data, scb, cbi, dvnode); 902 - if (!IS_ERR(ti)) 903 - afs_cache_permit(AFS_FS_I(ti), key, 904 - 0 /* Assume vnode->cb_break is 0 */ + 905 - iget_data.cb_v_break, 906 - scb); 907 - if (i == 0) { 908 - inode = ti; 909 - } else { 910 - if (!IS_ERR(ti)) 911 - iput(ti); 912 - } 913 - } 914 - 915 - out_c: 916 - afs_put_cb_interest(afs_v2net(dvnode), cbi); 917 - if (cookie->inodes) { 918 - for (i = 0; i < cookie->nr_fids; i++) 919 - iput(cookie->inodes[i]); 920 - kfree(cookie->inodes); 921 - } 922 - out_s: 923 - kvfree(cookie->statuses); 762 + if (op->file[0].scb.have_status) 763 + dentry->d_fsdata = (void *)(unsigned long)op->file[0].scb.status.data_version; 764 + else 765 + dentry->d_fsdata = (void *)(unsigned long)op->file[0].dv_before; 766 + ret = afs_put_operation(op); 924 767 out: 925 768 kfree(cookie); 926 - return inode; 769 + _leave(""); 770 + return inode ?: ERR_PTR(ret); 927 771 } 928 772 929 773 /* ··· 959 963 if (!IS_ERR_OR_NULL(inode)) 960 964 fid = AFS_FS_I(inode)->fid; 961 965 966 + _debug("splice %px", dentry->d_inode); 962 967 d = d_splice_alias(inode, dentry); 963 968 if (!IS_ERR_OR_NULL(d)) { 964 969 d->d_fsdata = dentry->d_fsdata; ··· 967 970 } else { 968 971 trace_afs_lookup(dvnode, &dentry->d_name, &fid); 969 972 } 973 + _leave(""); 970 974 return d; 971 975 } 972 976 ··· 1218 1220 /* 1219 1221 * Create a new inode for create/mkdir/symlink 1220 1222 */ 1221 - static void afs_vnode_new_inode(struct afs_operation *fc, 1222 - struct dentry *new_dentry, 1223 - struct afs_iget_data *new_data, 1224 - struct afs_status_cb *new_scb) 1223 + static void afs_vnode_new_inode(struct afs_operation *op) 1225 1224 { 1225 + struct afs_vnode_param *vp = &op->file[1]; 1226 1226 struct afs_vnode *vnode; 1227 1227 struct inode *inode; 1228 1228 1229 - if (fc->ac.error < 0) 1230 - return; 1229 + _enter(""); 1231 1230 1232 - inode = afs_iget(fc->vnode->vfs_inode.i_sb, fc->key, 1233 - new_data, new_scb, fc->cbi, fc->vnode); 1231 + ASSERTCMP(op->error, ==, 0); 1232 + 1233 + inode = afs_iget(op, vp); 1234 1234 if (IS_ERR(inode)) { 1235 1235 /* ENOMEM or EINTR at a really inconvenient time - just abandon 1236 1236 * the new directory on the server. 1237 1237 */ 1238 - fc->ac.error = PTR_ERR(inode); 1238 + op->error = PTR_ERR(inode); 1239 1239 return; 1240 1240 } 1241 1241 1242 1242 vnode = AFS_FS_I(inode); 1243 1243 set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); 1244 - if (fc->ac.error == 0) 1245 - afs_cache_permit(vnode, fc->key, vnode->cb_break, new_scb); 1246 - d_instantiate(new_dentry, inode); 1244 + if (!op->error) 1245 + afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb); 1246 + d_instantiate(op->dentry, inode); 1247 1247 } 1248 1248 1249 - static void afs_prep_for_new_inode(struct afs_operation *fc, 1250 - struct afs_iget_data *iget_data) 1249 + static void afs_create_success(struct afs_operation *op) 1251 1250 { 1252 - iget_data->volume = fc->vnode->volume; 1253 - iget_data->cb_v_break = fc->vnode->volume->cb_v_break; 1254 - iget_data->cb_s_break = fc->cbi->server->cb_s_break; 1251 + _enter("op=%08x", op->debug_id); 1252 + afs_check_for_remote_deletion(op, op->file[0].vnode); 1253 + afs_vnode_commit_status(op, &op->file[0]); 1254 + afs_update_dentry_version(op, &op->file[0], op->dentry); 1255 + afs_vnode_new_inode(op); 1255 1256 } 1256 1257 1257 - /* 1258 - * Note that a dentry got changed. We need to set d_fsdata to the data version 1259 - * number derived from the result of the operation. It doesn't matter if 1260 - * d_fsdata goes backwards as we'll just revalidate. 1261 - */ 1262 - static void afs_update_dentry_version(struct afs_operation *fc, 1263 - struct dentry *dentry, 1264 - struct afs_status_cb *scb) 1258 + static void afs_create_edit_dir(struct afs_operation *op) 1265 1259 { 1266 - if (fc->ac.error == 0) 1267 - dentry->d_fsdata = 1268 - (void *)(unsigned long)scb->status.data_version; 1260 + struct afs_vnode_param *dvp = &op->file[0]; 1261 + struct afs_vnode_param *vp = &op->file[1]; 1262 + struct afs_vnode *dvnode = dvp->vnode; 1263 + 1264 + _enter("op=%08x", op->debug_id); 1265 + 1266 + down_write(&dvnode->validate_lock); 1267 + if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1268 + dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) 1269 + afs_edit_dir_add(dvnode, &op->dentry->d_name, &vp->fid, 1270 + op->create.reason); 1271 + up_write(&dvnode->validate_lock); 1269 1272 } 1273 + 1274 + static void afs_create_put(struct afs_operation *op) 1275 + { 1276 + _enter("op=%08x", op->debug_id); 1277 + 1278 + if (op->error) 1279 + d_drop(op->dentry); 1280 + } 1281 + 1282 + static const struct afs_operation_ops afs_mkdir_operation = { 1283 + .issue_afs_rpc = afs_fs_make_dir, 1284 + .issue_yfs_rpc = yfs_fs_make_dir, 1285 + .success = afs_create_success, 1286 + .edit_dir = afs_create_edit_dir, 1287 + .put = afs_create_put, 1288 + }; 1270 1289 1271 1290 /* 1272 1291 * create a directory on an AFS filesystem 1273 1292 */ 1274 1293 static int afs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 1275 1294 { 1276 - struct afs_iget_data iget_data; 1277 - struct afs_status_cb *scb; 1278 - struct afs_operation fc; 1295 + struct afs_operation *op; 1279 1296 struct afs_vnode *dvnode = AFS_FS_I(dir); 1280 - struct key *key; 1281 - afs_dataversion_t data_version; 1282 - int ret; 1283 - 1284 - mode |= S_IFDIR; 1285 1297 1286 1298 _enter("{%llx:%llu},{%pd},%ho", 1287 1299 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode); 1288 1300 1289 - ret = -ENOMEM; 1290 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1291 - if (!scb) 1292 - goto error; 1293 - 1294 - key = afs_request_key(dvnode->volume->cell); 1295 - if (IS_ERR(key)) { 1296 - ret = PTR_ERR(key); 1297 - goto error_scb; 1301 + op = afs_alloc_operation(NULL, dvnode->volume); 1302 + if (IS_ERR(op)) { 1303 + d_drop(dentry); 1304 + return PTR_ERR(op); 1298 1305 } 1299 1306 1300 - ret = -ERESTARTSYS; 1301 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1302 - data_version = dvnode->status.data_version + 1; 1303 - 1304 - while (afs_select_fileserver(&fc)) { 1305 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1306 - afs_prep_for_new_inode(&fc, &iget_data); 1307 - afs_fs_create(&fc, dentry->d_name.name, mode, 1308 - &scb[0], &iget_data.fid, &scb[1]); 1309 - } 1310 - 1311 - afs_check_for_remote_deletion(&fc, dvnode); 1312 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1313 - &data_version, &scb[0]); 1314 - afs_update_dentry_version(&fc, dentry, &scb[0]); 1315 - afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]); 1316 - ret = afs_end_vnode_operation(&fc); 1317 - if (ret < 0) 1318 - goto error_key; 1319 - } else { 1320 - goto error_key; 1321 - } 1322 - 1323 - if (ret == 0) { 1324 - down_write(&dvnode->validate_lock); 1325 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1326 - dvnode->status.data_version == data_version) 1327 - afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid, 1328 - afs_edit_dir_for_create); 1329 - up_write(&dvnode->validate_lock); 1330 - } 1331 - 1332 - key_put(key); 1333 - kfree(scb); 1334 - _leave(" = 0"); 1335 - return 0; 1336 - 1337 - error_key: 1338 - key_put(key); 1339 - error_scb: 1340 - kfree(scb); 1341 - error: 1342 - d_drop(dentry); 1343 - _leave(" = %d", ret); 1344 - return ret; 1307 + afs_op_set_vnode(op, 0, dvnode); 1308 + op->file[0].dv_delta = 1; 1309 + op->dentry = dentry; 1310 + op->create.mode = S_IFDIR | mode; 1311 + op->create.reason = afs_edit_dir_for_mkdir; 1312 + op->ops = &afs_mkdir_operation; 1313 + return afs_do_sync_operation(op); 1345 1314 } 1346 1315 1347 1316 /* ··· 1326 1361 } 1327 1362 } 1328 1363 1364 + static void afs_rmdir_success(struct afs_operation *op) 1365 + { 1366 + _enter("op=%08x", op->debug_id); 1367 + afs_check_for_remote_deletion(op, op->file[0].vnode); 1368 + afs_vnode_commit_status(op, &op->file[0]); 1369 + afs_update_dentry_version(op, &op->file[0], op->dentry); 1370 + } 1371 + 1372 + static void afs_rmdir_edit_dir(struct afs_operation *op) 1373 + { 1374 + struct afs_vnode_param *dvp = &op->file[0]; 1375 + struct afs_vnode *dvnode = dvp->vnode; 1376 + 1377 + _enter("op=%08x", op->debug_id); 1378 + afs_dir_remove_subdir(op->dentry); 1379 + 1380 + down_write(&dvnode->validate_lock); 1381 + if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1382 + dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) 1383 + afs_edit_dir_remove(dvnode, &op->dentry->d_name, 1384 + afs_edit_dir_for_rmdir); 1385 + up_write(&dvnode->validate_lock); 1386 + } 1387 + 1388 + static void afs_rmdir_put(struct afs_operation *op) 1389 + { 1390 + _enter("op=%08x", op->debug_id); 1391 + if (op->file[1].vnode) 1392 + up_write(&op->file[1].vnode->rmdir_lock); 1393 + } 1394 + 1395 + static const struct afs_operation_ops afs_rmdir_operation = { 1396 + .issue_afs_rpc = afs_fs_remove_dir, 1397 + .issue_yfs_rpc = yfs_fs_remove_dir, 1398 + .success = afs_rmdir_success, 1399 + .edit_dir = afs_rmdir_edit_dir, 1400 + .put = afs_rmdir_put, 1401 + }; 1402 + 1329 1403 /* 1330 1404 * remove a directory from an AFS filesystem 1331 1405 */ 1332 1406 static int afs_rmdir(struct inode *dir, struct dentry *dentry) 1333 1407 { 1334 - struct afs_status_cb *scb; 1335 - struct afs_operation fc; 1408 + struct afs_operation *op; 1336 1409 struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL; 1337 - struct key *key; 1338 - afs_dataversion_t data_version; 1339 1410 int ret; 1340 1411 1341 1412 _enter("{%llx:%llu},{%pd}", 1342 1413 dvnode->fid.vid, dvnode->fid.vnode, dentry); 1343 1414 1344 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 1345 - if (!scb) 1346 - return -ENOMEM; 1415 + op = afs_alloc_operation(NULL, dvnode->volume); 1416 + if (IS_ERR(op)) 1417 + return PTR_ERR(op); 1347 1418 1348 - key = afs_request_key(dvnode->volume->cell); 1349 - if (IS_ERR(key)) { 1350 - ret = PTR_ERR(key); 1351 - goto error; 1352 - } 1419 + afs_op_set_vnode(op, 0, dvnode); 1420 + op->file[0].dv_delta = 1; 1421 + 1422 + op->dentry = dentry; 1423 + op->ops = &afs_rmdir_operation; 1353 1424 1354 1425 /* Try to make sure we have a callback promise on the victim. */ 1355 1426 if (d_really_is_positive(dentry)) { 1356 1427 vnode = AFS_FS_I(d_inode(dentry)); 1357 - ret = afs_validate(vnode, key); 1428 + ret = afs_validate(vnode, op->key); 1358 1429 if (ret < 0) 1359 - goto error_key; 1430 + goto error; 1360 1431 } 1361 1432 1362 1433 if (vnode) { 1363 1434 ret = down_write_killable(&vnode->rmdir_lock); 1364 1435 if (ret < 0) 1365 - goto error_key; 1436 + goto error; 1437 + op->file[1].vnode = vnode; 1366 1438 } 1367 1439 1368 - ret = -ERESTARTSYS; 1369 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1370 - data_version = dvnode->status.data_version + 1; 1440 + return afs_do_sync_operation(op); 1371 1441 1372 - while (afs_select_fileserver(&fc)) { 1373 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1374 - afs_fs_remove(&fc, vnode, dentry->d_name.name, true, scb); 1375 - } 1376 - 1377 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1378 - &data_version, scb); 1379 - afs_update_dentry_version(&fc, dentry, scb); 1380 - ret = afs_end_vnode_operation(&fc); 1381 - if (ret == 0) { 1382 - afs_dir_remove_subdir(dentry); 1383 - down_write(&dvnode->validate_lock); 1384 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1385 - dvnode->status.data_version == data_version) 1386 - afs_edit_dir_remove(dvnode, &dentry->d_name, 1387 - afs_edit_dir_for_rmdir); 1388 - up_write(&dvnode->validate_lock); 1389 - } 1390 - } 1391 - 1392 - if (vnode) 1393 - up_write(&vnode->rmdir_lock); 1394 - error_key: 1395 - key_put(key); 1396 1442 error: 1397 - kfree(scb); 1398 - return ret; 1443 + return afs_put_operation(op); 1399 1444 } 1400 1445 1401 1446 /* ··· 1418 1443 * However, if we didn't have a callback promise outstanding, or it was 1419 1444 * outstanding on a different server, then it won't break it either... 1420 1445 */ 1421 - static int afs_dir_remove_link(struct afs_vnode *dvnode, struct dentry *dentry, 1422 - struct key *key) 1446 + static void afs_dir_remove_link(struct afs_operation *op) 1423 1447 { 1424 - int ret = 0; 1448 + struct afs_vnode *dvnode = op->file[0].vnode; 1449 + struct afs_vnode *vnode = op->file[1].vnode; 1450 + struct dentry *dentry = op->dentry; 1451 + int ret; 1425 1452 1426 - if (d_really_is_positive(dentry)) { 1427 - struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 1453 + if (op->error != 0 || 1454 + (op->file[1].scb.have_status && op->file[1].scb.have_error)) 1455 + return; 1456 + if (d_really_is_positive(dentry)) 1457 + return; 1428 1458 1429 - if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) { 1430 - /* Already done */ 1431 - } else if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) { 1432 - write_seqlock(&vnode->cb_lock); 1433 - drop_nlink(&vnode->vfs_inode); 1434 - if (vnode->vfs_inode.i_nlink == 0) { 1435 - set_bit(AFS_VNODE_DELETED, &vnode->flags); 1436 - __afs_break_callback(vnode, afs_cb_break_for_unlink); 1437 - } 1438 - write_sequnlock(&vnode->cb_lock); 1439 - ret = 0; 1440 - } else { 1441 - afs_break_callback(vnode, afs_cb_break_for_unlink); 1442 - 1443 - if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) 1444 - kdebug("AFS_VNODE_DELETED"); 1445 - 1446 - ret = afs_validate(vnode, key); 1447 - if (ret == -ESTALE) 1448 - ret = 0; 1459 + if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) { 1460 + /* Already done */ 1461 + } else if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags)) { 1462 + write_seqlock(&vnode->cb_lock); 1463 + drop_nlink(&vnode->vfs_inode); 1464 + if (vnode->vfs_inode.i_nlink == 0) { 1465 + set_bit(AFS_VNODE_DELETED, &vnode->flags); 1466 + __afs_break_callback(vnode, afs_cb_break_for_unlink); 1449 1467 } 1450 - _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, ret); 1468 + write_sequnlock(&vnode->cb_lock); 1469 + } else { 1470 + afs_break_callback(vnode, afs_cb_break_for_unlink); 1471 + 1472 + if (test_bit(AFS_VNODE_DELETED, &vnode->flags)) 1473 + _debug("AFS_VNODE_DELETED"); 1474 + 1475 + ret = afs_validate(vnode, op->key); 1476 + if (ret != -ESTALE) 1477 + op->error = ret; 1451 1478 } 1452 1479 1453 - return ret; 1480 + _debug("nlink %d [val %d]", vnode->vfs_inode.i_nlink, op->error); 1454 1481 } 1482 + 1483 + static void afs_unlink_success(struct afs_operation *op) 1484 + { 1485 + _enter("op=%08x", op->debug_id); 1486 + afs_check_for_remote_deletion(op, op->file[0].vnode); 1487 + afs_vnode_commit_status(op, &op->file[0]); 1488 + afs_vnode_commit_status(op, &op->file[1]); 1489 + afs_update_dentry_version(op, &op->file[0], op->dentry); 1490 + afs_dir_remove_link(op); 1491 + } 1492 + 1493 + static void afs_unlink_edit_dir(struct afs_operation *op) 1494 + { 1495 + struct afs_vnode_param *dvp = &op->file[0]; 1496 + struct afs_vnode *dvnode = dvp->vnode; 1497 + 1498 + _enter("op=%08x", op->debug_id); 1499 + down_write(&dvnode->validate_lock); 1500 + if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1501 + dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) 1502 + afs_edit_dir_remove(dvnode, &op->dentry->d_name, 1503 + afs_edit_dir_for_unlink); 1504 + up_write(&dvnode->validate_lock); 1505 + } 1506 + 1507 + static void afs_unlink_put(struct afs_operation *op) 1508 + { 1509 + _enter("op=%08x", op->debug_id); 1510 + if (op->unlink.need_rehash && op->error < 0 && op->error != -ENOENT) 1511 + d_rehash(op->dentry); 1512 + } 1513 + 1514 + static const struct afs_operation_ops afs_unlink_operation = { 1515 + .issue_afs_rpc = afs_fs_remove_file, 1516 + .issue_yfs_rpc = yfs_fs_remove_file, 1517 + .success = afs_unlink_success, 1518 + .edit_dir = afs_unlink_edit_dir, 1519 + .put = afs_unlink_put, 1520 + }; 1455 1521 1456 1522 /* 1457 1523 * Remove a file or symlink from an AFS filesystem. 1458 1524 */ 1459 1525 static int afs_unlink(struct inode *dir, struct dentry *dentry) 1460 1526 { 1461 - struct afs_operation fc; 1462 - struct afs_status_cb *scb; 1527 + struct afs_operation *op; 1463 1528 struct afs_vnode *dvnode = AFS_FS_I(dir); 1464 1529 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 1465 - struct key *key; 1466 - bool need_rehash = false; 1467 1530 int ret; 1468 1531 1469 1532 _enter("{%llx:%llu},{%pd}", ··· 1510 1497 if (dentry->d_name.len >= AFSNAMEMAX) 1511 1498 return -ENAMETOOLONG; 1512 1499 1513 - ret = -ENOMEM; 1514 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1515 - if (!scb) 1516 - goto error; 1500 + op = afs_alloc_operation(NULL, dvnode->volume); 1501 + if (IS_ERR(op)) 1502 + return PTR_ERR(op); 1517 1503 1518 - key = afs_request_key(dvnode->volume->cell); 1519 - if (IS_ERR(key)) { 1520 - ret = PTR_ERR(key); 1521 - goto error_scb; 1522 - } 1504 + afs_op_set_vnode(op, 0, dvnode); 1505 + op->file[0].dv_delta = 1; 1523 1506 1524 1507 /* Try to make sure we have a callback promise on the victim. */ 1525 - ret = afs_validate(vnode, key); 1526 - if (ret < 0) 1527 - goto error_key; 1508 + ret = afs_validate(vnode, op->key); 1509 + if (ret < 0) { 1510 + op->error = ret; 1511 + goto error; 1512 + } 1528 1513 1529 1514 spin_lock(&dentry->d_lock); 1530 1515 if (d_count(dentry) > 1) { 1531 1516 spin_unlock(&dentry->d_lock); 1532 1517 /* Start asynchronous writeout of the inode */ 1533 1518 write_inode_now(d_inode(dentry), 0); 1534 - ret = afs_sillyrename(dvnode, vnode, dentry, key); 1535 - goto error_key; 1519 + op->error = afs_sillyrename(dvnode, vnode, dentry, op->key); 1520 + goto error; 1536 1521 } 1537 1522 if (!d_unhashed(dentry)) { 1538 1523 /* Prevent a race with RCU lookup. */ 1539 1524 __d_drop(dentry); 1540 - need_rehash = true; 1525 + op->unlink.need_rehash = true; 1541 1526 } 1542 1527 spin_unlock(&dentry->d_lock); 1543 1528 1544 - ret = -ERESTARTSYS; 1545 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1546 - afs_dataversion_t data_version = dvnode->status.data_version + 1; 1547 - afs_dataversion_t data_version_2 = vnode->status.data_version; 1529 + op->file[1].vnode = vnode; 1530 + op->dentry = dentry; 1531 + op->ops = &afs_unlink_operation; 1532 + return afs_do_sync_operation(op); 1548 1533 1549 - while (afs_select_fileserver(&fc)) { 1550 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1551 - fc.cb_break_2 = afs_calc_vnode_cb_break(vnode); 1552 - 1553 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) && 1554 - !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) { 1555 - yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name, 1556 - &scb[0], &scb[1]); 1557 - if (fc.ac.error != -ECONNABORTED || 1558 - fc.ac.abort_code != RXGEN_OPCODE) 1559 - continue; 1560 - set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags); 1561 - } 1562 - 1563 - afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]); 1564 - } 1565 - 1566 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1567 - &data_version, &scb[0]); 1568 - afs_vnode_commit_status(&fc, vnode, fc.cb_break_2, 1569 - &data_version_2, &scb[1]); 1570 - afs_update_dentry_version(&fc, dentry, &scb[0]); 1571 - ret = afs_end_vnode_operation(&fc); 1572 - if (ret == 0 && !(scb[1].have_status || scb[1].have_error)) 1573 - ret = afs_dir_remove_link(dvnode, dentry, key); 1574 - 1575 - if (ret == 0) { 1576 - down_write(&dvnode->validate_lock); 1577 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1578 - dvnode->status.data_version == data_version) 1579 - afs_edit_dir_remove(dvnode, &dentry->d_name, 1580 - afs_edit_dir_for_unlink); 1581 - up_write(&dvnode->validate_lock); 1582 - } 1583 - } 1584 - 1585 - if (need_rehash && ret < 0 && ret != -ENOENT) 1586 - d_rehash(dentry); 1587 - 1588 - error_key: 1589 - key_put(key); 1590 - error_scb: 1591 - kfree(scb); 1592 1534 error: 1593 - _leave(" = %d", ret); 1594 - return ret; 1535 + return afs_put_operation(op); 1595 1536 } 1537 + 1538 + static const struct afs_operation_ops afs_create_operation = { 1539 + .issue_afs_rpc = afs_fs_create_file, 1540 + .issue_yfs_rpc = yfs_fs_create_file, 1541 + .success = afs_create_success, 1542 + .edit_dir = afs_create_edit_dir, 1543 + .put = afs_create_put, 1544 + }; 1596 1545 1597 1546 /* 1598 1547 * create a regular file on an AFS filesystem ··· 1562 1587 static int afs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 1563 1588 bool excl) 1564 1589 { 1565 - struct afs_iget_data iget_data; 1566 - struct afs_operation fc; 1567 - struct afs_status_cb *scb; 1590 + struct afs_operation *op; 1568 1591 struct afs_vnode *dvnode = AFS_FS_I(dir); 1569 - struct key *key; 1570 - afs_dataversion_t data_version; 1571 - int ret; 1592 + int ret = -ENAMETOOLONG; 1572 1593 1573 - mode |= S_IFREG; 1574 - 1575 - _enter("{%llx:%llu},{%pd},%ho,", 1594 + _enter("{%llx:%llu},{%pd},%ho", 1576 1595 dvnode->fid.vid, dvnode->fid.vnode, dentry, mode); 1577 1596 1578 - ret = -ENAMETOOLONG; 1579 1597 if (dentry->d_name.len >= AFSNAMEMAX) 1580 1598 goto error; 1581 1599 1582 - key = afs_request_key(dvnode->volume->cell); 1583 - if (IS_ERR(key)) { 1584 - ret = PTR_ERR(key); 1600 + op = afs_alloc_operation(NULL, dvnode->volume); 1601 + if (IS_ERR(op)) { 1602 + ret = PTR_ERR(op); 1585 1603 goto error; 1586 1604 } 1587 1605 1588 - ret = -ENOMEM; 1589 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1590 - if (!scb) 1591 - goto error_scb; 1606 + afs_op_set_vnode(op, 0, dvnode); 1607 + op->file[0].dv_delta = 1; 1592 1608 1593 - ret = -ERESTARTSYS; 1594 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1595 - data_version = dvnode->status.data_version + 1; 1609 + op->dentry = dentry; 1610 + op->create.mode = S_IFREG | mode; 1611 + op->create.reason = afs_edit_dir_for_create; 1612 + op->ops = &afs_create_operation; 1613 + return afs_do_sync_operation(op); 1596 1614 1597 - while (afs_select_fileserver(&fc)) { 1598 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1599 - afs_prep_for_new_inode(&fc, &iget_data); 1600 - afs_fs_create(&fc, dentry->d_name.name, mode, 1601 - &scb[0], &iget_data.fid, &scb[1]); 1602 - } 1603 - 1604 - afs_check_for_remote_deletion(&fc, dvnode); 1605 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1606 - &data_version, &scb[0]); 1607 - afs_update_dentry_version(&fc, dentry, &scb[0]); 1608 - afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]); 1609 - ret = afs_end_vnode_operation(&fc); 1610 - if (ret < 0) 1611 - goto error_key; 1612 - } else { 1613 - goto error_key; 1614 - } 1615 - 1616 - down_write(&dvnode->validate_lock); 1617 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1618 - dvnode->status.data_version == data_version) 1619 - afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid, 1620 - afs_edit_dir_for_create); 1621 - up_write(&dvnode->validate_lock); 1622 - 1623 - kfree(scb); 1624 - key_put(key); 1625 - _leave(" = 0"); 1626 - return 0; 1627 - 1628 - error_scb: 1629 - kfree(scb); 1630 - error_key: 1631 - key_put(key); 1632 1615 error: 1633 1616 d_drop(dentry); 1634 1617 _leave(" = %d", ret); 1635 1618 return ret; 1636 1619 } 1620 + 1621 + static void afs_link_success(struct afs_operation *op) 1622 + { 1623 + struct afs_vnode_param *dvp = &op->file[0]; 1624 + struct afs_vnode_param *vp = &op->file[1]; 1625 + 1626 + _enter("op=%08x", op->debug_id); 1627 + afs_vnode_commit_status(op, dvp); 1628 + afs_vnode_commit_status(op, vp); 1629 + afs_update_dentry_version(op, dvp, op->dentry); 1630 + if (op->dentry_2->d_parent == op->dentry->d_parent) 1631 + afs_update_dentry_version(op, dvp, op->dentry_2); 1632 + ihold(&vp->vnode->vfs_inode); 1633 + d_instantiate(op->dentry, &vp->vnode->vfs_inode); 1634 + } 1635 + 1636 + static void afs_link_put(struct afs_operation *op) 1637 + { 1638 + _enter("op=%08x", op->debug_id); 1639 + if (op->error) 1640 + d_drop(op->dentry); 1641 + } 1642 + 1643 + static const struct afs_operation_ops afs_link_operation = { 1644 + .issue_afs_rpc = afs_fs_link, 1645 + .issue_yfs_rpc = yfs_fs_link, 1646 + .success = afs_link_success, 1647 + .edit_dir = afs_create_edit_dir, 1648 + .put = afs_link_put, 1649 + }; 1637 1650 1638 1651 /* 1639 1652 * create a hard link between files in an AFS filesystem ··· 1629 1666 static int afs_link(struct dentry *from, struct inode *dir, 1630 1667 struct dentry *dentry) 1631 1668 { 1632 - struct afs_operation fc; 1633 - struct afs_status_cb *scb; 1669 + struct afs_operation *op; 1634 1670 struct afs_vnode *dvnode = AFS_FS_I(dir); 1635 1671 struct afs_vnode *vnode = AFS_FS_I(d_inode(from)); 1636 - struct key *key; 1637 - afs_dataversion_t data_version; 1638 - int ret; 1672 + int ret = -ENAMETOOLONG; 1639 1673 1640 1674 _enter("{%llx:%llu},{%llx:%llu},{%pd}", 1641 1675 vnode->fid.vid, vnode->fid.vnode, 1642 1676 dvnode->fid.vid, dvnode->fid.vnode, 1643 1677 dentry); 1644 1678 1645 - ret = -ENAMETOOLONG; 1646 1679 if (dentry->d_name.len >= AFSNAMEMAX) 1647 1680 goto error; 1648 1681 1649 - ret = -ENOMEM; 1650 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1651 - if (!scb) 1682 + op = afs_alloc_operation(NULL, dvnode->volume); 1683 + if (IS_ERR(op)) { 1684 + ret = PTR_ERR(op); 1652 1685 goto error; 1653 - 1654 - key = afs_request_key(dvnode->volume->cell); 1655 - if (IS_ERR(key)) { 1656 - ret = PTR_ERR(key); 1657 - goto error_scb; 1658 1686 } 1659 1687 1660 - ret = -ERESTARTSYS; 1661 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1662 - data_version = dvnode->status.data_version + 1; 1688 + afs_op_set_vnode(op, 0, dvnode); 1689 + afs_op_set_vnode(op, 1, vnode); 1690 + op->file[0].dv_delta = 1; 1663 1691 1664 - if (mutex_lock_interruptible_nested(&vnode->io_lock, 1) < 0) { 1665 - afs_end_vnode_operation(&fc); 1666 - goto error_key; 1667 - } 1692 + op->dentry = dentry; 1693 + op->dentry_2 = from; 1694 + op->ops = &afs_link_operation; 1695 + op->create.reason = afs_edit_dir_for_link; 1696 + return afs_do_sync_operation(op); 1668 1697 1669 - while (afs_select_fileserver(&fc)) { 1670 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1671 - fc.cb_break_2 = afs_calc_vnode_cb_break(vnode); 1672 - afs_fs_link(&fc, vnode, dentry->d_name.name, 1673 - &scb[0], &scb[1]); 1674 - } 1675 - 1676 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1677 - &data_version, &scb[0]); 1678 - afs_vnode_commit_status(&fc, vnode, fc.cb_break_2, 1679 - NULL, &scb[1]); 1680 - ihold(&vnode->vfs_inode); 1681 - afs_update_dentry_version(&fc, dentry, &scb[0]); 1682 - d_instantiate(dentry, &vnode->vfs_inode); 1683 - 1684 - mutex_unlock(&vnode->io_lock); 1685 - ret = afs_end_vnode_operation(&fc); 1686 - if (ret < 0) 1687 - goto error_key; 1688 - } else { 1689 - goto error_key; 1690 - } 1691 - 1692 - down_write(&dvnode->validate_lock); 1693 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1694 - dvnode->status.data_version == data_version) 1695 - afs_edit_dir_add(dvnode, &dentry->d_name, &vnode->fid, 1696 - afs_edit_dir_for_link); 1697 - up_write(&dvnode->validate_lock); 1698 - 1699 - key_put(key); 1700 - kfree(scb); 1701 - _leave(" = 0"); 1702 - return 0; 1703 - 1704 - error_key: 1705 - key_put(key); 1706 - error_scb: 1707 - kfree(scb); 1708 1698 error: 1709 1699 d_drop(dentry); 1710 1700 _leave(" = %d", ret); 1711 1701 return ret; 1712 1702 } 1703 + 1704 + static const struct afs_operation_ops afs_symlink_operation = { 1705 + .issue_afs_rpc = afs_fs_symlink, 1706 + .issue_yfs_rpc = yfs_fs_symlink, 1707 + .success = afs_create_success, 1708 + .edit_dir = afs_create_edit_dir, 1709 + .put = afs_create_put, 1710 + }; 1713 1711 1714 1712 /* 1715 1713 * create a symlink in an AFS filesystem ··· 1678 1754 static int afs_symlink(struct inode *dir, struct dentry *dentry, 1679 1755 const char *content) 1680 1756 { 1681 - struct afs_iget_data iget_data; 1682 - struct afs_operation fc; 1683 - struct afs_status_cb *scb; 1757 + struct afs_operation *op; 1684 1758 struct afs_vnode *dvnode = AFS_FS_I(dir); 1685 - struct key *key; 1686 - afs_dataversion_t data_version; 1687 1759 int ret; 1688 1760 1689 1761 _enter("{%llx:%llu},{%pd},%s", ··· 1694 1774 if (strlen(content) >= AFSPATHMAX) 1695 1775 goto error; 1696 1776 1697 - ret = -ENOMEM; 1698 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1699 - if (!scb) 1777 + op = afs_alloc_operation(NULL, dvnode->volume); 1778 + if (IS_ERR(op)) { 1779 + ret = PTR_ERR(op); 1700 1780 goto error; 1701 - 1702 - key = afs_request_key(dvnode->volume->cell); 1703 - if (IS_ERR(key)) { 1704 - ret = PTR_ERR(key); 1705 - goto error_scb; 1706 1781 } 1707 1782 1708 - ret = -ERESTARTSYS; 1709 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 1710 - data_version = dvnode->status.data_version + 1; 1783 + afs_op_set_vnode(op, 0, dvnode); 1784 + op->file[0].dv_delta = 1; 1711 1785 1712 - while (afs_select_fileserver(&fc)) { 1713 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 1714 - afs_prep_for_new_inode(&fc, &iget_data); 1715 - afs_fs_symlink(&fc, dentry->d_name.name, content, 1716 - &scb[0], &iget_data.fid, &scb[1]); 1717 - } 1786 + op->dentry = dentry; 1787 + op->ops = &afs_symlink_operation; 1788 + op->create.reason = afs_edit_dir_for_symlink; 1789 + op->create.symlink = content; 1790 + return afs_do_sync_operation(op); 1718 1791 1719 - afs_check_for_remote_deletion(&fc, dvnode); 1720 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 1721 - &data_version, &scb[0]); 1722 - afs_update_dentry_version(&fc, dentry, &scb[0]); 1723 - afs_vnode_new_inode(&fc, dentry, &iget_data, &scb[1]); 1724 - ret = afs_end_vnode_operation(&fc); 1725 - if (ret < 0) 1726 - goto error_key; 1727 - } else { 1728 - goto error_key; 1729 - } 1730 - 1731 - down_write(&dvnode->validate_lock); 1732 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 1733 - dvnode->status.data_version == data_version) 1734 - afs_edit_dir_add(dvnode, &dentry->d_name, &iget_data.fid, 1735 - afs_edit_dir_for_symlink); 1736 - up_write(&dvnode->validate_lock); 1737 - 1738 - key_put(key); 1739 - kfree(scb); 1740 - _leave(" = 0"); 1741 - return 0; 1742 - 1743 - error_key: 1744 - key_put(key); 1745 - error_scb: 1746 - kfree(scb); 1747 1792 error: 1748 1793 d_drop(dentry); 1749 1794 _leave(" = %d", ret); 1750 1795 return ret; 1751 1796 } 1797 + 1798 + static void afs_rename_success(struct afs_operation *op) 1799 + { 1800 + _enter("op=%08x", op->debug_id); 1801 + 1802 + afs_vnode_commit_status(op, &op->file[0]); 1803 + if (op->file[1].vnode != op->file[0].vnode) 1804 + afs_vnode_commit_status(op, &op->file[1]); 1805 + } 1806 + 1807 + static void afs_rename_edit_dir(struct afs_operation *op) 1808 + { 1809 + struct afs_vnode_param *orig_dvp = &op->file[0]; 1810 + struct afs_vnode_param *new_dvp = &op->file[1]; 1811 + struct afs_vnode *orig_dvnode = orig_dvp->vnode; 1812 + struct afs_vnode *new_dvnode = new_dvp->vnode; 1813 + struct afs_vnode *vnode = AFS_FS_I(d_inode(op->dentry)); 1814 + struct dentry *old_dentry = op->dentry; 1815 + struct dentry *new_dentry = op->dentry_2; 1816 + struct inode *new_inode; 1817 + 1818 + _enter("op=%08x", op->debug_id); 1819 + 1820 + if (op->rename.rehash) { 1821 + d_rehash(op->rename.rehash); 1822 + op->rename.rehash = NULL; 1823 + } 1824 + 1825 + down_write(&orig_dvnode->validate_lock); 1826 + if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) && 1827 + orig_dvnode->status.data_version == orig_dvp->dv_before + orig_dvp->dv_delta) 1828 + afs_edit_dir_remove(orig_dvnode, &old_dentry->d_name, 1829 + afs_edit_dir_for_rename_0); 1830 + 1831 + if (new_dvnode != orig_dvnode) { 1832 + up_write(&orig_dvnode->validate_lock); 1833 + down_write(&new_dvnode->validate_lock); 1834 + } 1835 + 1836 + if (test_bit(AFS_VNODE_DIR_VALID, &new_dvnode->flags) && 1837 + new_dvnode->status.data_version == new_dvp->dv_before + new_dvp->dv_delta) { 1838 + if (!op->rename.new_negative) 1839 + afs_edit_dir_remove(new_dvnode, &new_dentry->d_name, 1840 + afs_edit_dir_for_rename_1); 1841 + 1842 + afs_edit_dir_add(new_dvnode, &new_dentry->d_name, 1843 + &vnode->fid, afs_edit_dir_for_rename_2); 1844 + } 1845 + 1846 + new_inode = d_inode(new_dentry); 1847 + if (new_inode) { 1848 + spin_lock(&new_inode->i_lock); 1849 + if (new_inode->i_nlink > 0) 1850 + drop_nlink(new_inode); 1851 + spin_unlock(&new_inode->i_lock); 1852 + } 1853 + 1854 + /* Now we can update d_fsdata on the dentries to reflect their 1855 + * new parent's data_version. 1856 + * 1857 + * Note that if we ever implement RENAME_EXCHANGE, we'll have 1858 + * to update both dentries with opposing dir versions. 1859 + */ 1860 + afs_update_dentry_version(op, new_dvp, op->dentry); 1861 + afs_update_dentry_version(op, new_dvp, op->dentry_2); 1862 + 1863 + d_move(old_dentry, new_dentry); 1864 + 1865 + up_write(&new_dvnode->validate_lock); 1866 + } 1867 + 1868 + static void afs_rename_put(struct afs_operation *op) 1869 + { 1870 + _enter("op=%08x", op->debug_id); 1871 + if (op->rename.rehash) 1872 + d_rehash(op->rename.rehash); 1873 + dput(op->rename.tmp); 1874 + if (op->error) 1875 + d_rehash(op->dentry); 1876 + } 1877 + 1878 + static const struct afs_operation_ops afs_rename_operation = { 1879 + .issue_afs_rpc = afs_fs_rename, 1880 + .issue_yfs_rpc = yfs_fs_rename, 1881 + .success = afs_rename_success, 1882 + .edit_dir = afs_rename_edit_dir, 1883 + .put = afs_rename_put, 1884 + }; 1752 1885 1753 1886 /* 1754 1887 * rename a file in an AFS filesystem and/or move it between directories ··· 1810 1837 struct inode *new_dir, struct dentry *new_dentry, 1811 1838 unsigned int flags) 1812 1839 { 1813 - struct afs_operation fc; 1814 - struct afs_status_cb *scb; 1840 + struct afs_operation *op; 1815 1841 struct afs_vnode *orig_dvnode, *new_dvnode, *vnode; 1816 - struct dentry *tmp = NULL, *rehash = NULL; 1817 - struct inode *new_inode; 1818 - struct key *key; 1819 - afs_dataversion_t orig_data_version; 1820 - afs_dataversion_t new_data_version; 1821 - bool new_negative = d_is_negative(new_dentry); 1822 1842 int ret; 1823 1843 1824 1844 if (flags) ··· 1831 1865 new_dvnode->fid.vid, new_dvnode->fid.vnode, 1832 1866 new_dentry); 1833 1867 1834 - ret = -ENOMEM; 1835 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 1836 - if (!scb) 1837 - goto error; 1868 + op = afs_alloc_operation(NULL, orig_dvnode->volume); 1869 + if (IS_ERR(op)) 1870 + return PTR_ERR(op); 1838 1871 1839 - key = afs_request_key(orig_dvnode->volume->cell); 1840 - if (IS_ERR(key)) { 1841 - ret = PTR_ERR(key); 1842 - goto error_scb; 1843 - } 1872 + afs_op_set_vnode(op, 0, orig_dvnode); 1873 + afs_op_set_vnode(op, 1, new_dvnode); /* May be same as orig_dvnode */ 1874 + op->file[0].dv_delta = 1; 1875 + op->file[1].dv_delta = 1; 1876 + 1877 + op->dentry = old_dentry; 1878 + op->dentry_2 = new_dentry; 1879 + op->rename.new_negative = d_is_negative(new_dentry); 1880 + op->ops = &afs_rename_operation; 1844 1881 1845 1882 /* For non-directories, check whether the target is busy and if so, 1846 1883 * make a copy of the dentry and then do a silly-rename. If the ··· 1856 1887 */ 1857 1888 if (!d_unhashed(new_dentry)) { 1858 1889 d_drop(new_dentry); 1859 - rehash = new_dentry; 1890 + op->rename.rehash = new_dentry; 1860 1891 } 1861 1892 1862 1893 if (d_count(new_dentry) > 2) { 1863 1894 /* copy the target dentry's name */ 1864 1895 ret = -ENOMEM; 1865 - tmp = d_alloc(new_dentry->d_parent, 1866 - &new_dentry->d_name); 1867 - if (!tmp) 1868 - goto error_rehash; 1896 + op->rename.tmp = d_alloc(new_dentry->d_parent, 1897 + &new_dentry->d_name); 1898 + if (!op->rename.tmp) 1899 + goto error; 1869 1900 1870 1901 ret = afs_sillyrename(new_dvnode, 1871 1902 AFS_FS_I(d_inode(new_dentry)), 1872 - new_dentry, key); 1903 + new_dentry, op->key); 1873 1904 if (ret) 1874 - goto error_rehash; 1905 + goto error; 1875 1906 1876 - new_dentry = tmp; 1877 - rehash = NULL; 1878 - new_negative = true; 1907 + op->dentry_2 = op->rename.tmp; 1908 + op->rename.rehash = NULL; 1909 + op->rename.new_negative = true; 1879 1910 } 1880 1911 } 1881 1912 ··· 1890 1921 */ 1891 1922 d_drop(old_dentry); 1892 1923 1893 - ret = -ERESTARTSYS; 1894 - if (afs_begin_vnode_operation(&fc, orig_dvnode, key, true)) { 1895 - orig_data_version = orig_dvnode->status.data_version + 1; 1924 + return afs_do_sync_operation(op); 1896 1925 1897 - if (orig_dvnode != new_dvnode) { 1898 - if (mutex_lock_interruptible_nested(&new_dvnode->io_lock, 1) < 0) { 1899 - afs_end_vnode_operation(&fc); 1900 - goto error_rehash_old; 1901 - } 1902 - new_data_version = new_dvnode->status.data_version + 1; 1903 - } else { 1904 - new_data_version = orig_data_version; 1905 - } 1906 - 1907 - while (afs_select_fileserver(&fc)) { 1908 - fc.cb_break = afs_calc_vnode_cb_break(orig_dvnode); 1909 - fc.cb_break_2 = afs_calc_vnode_cb_break(new_dvnode); 1910 - afs_fs_rename(&fc, old_dentry->d_name.name, 1911 - new_dvnode, new_dentry->d_name.name, 1912 - &scb[0], &scb[1]); 1913 - } 1914 - 1915 - afs_vnode_commit_status(&fc, orig_dvnode, fc.cb_break, 1916 - &orig_data_version, &scb[0]); 1917 - if (new_dvnode != orig_dvnode) { 1918 - afs_vnode_commit_status(&fc, new_dvnode, fc.cb_break_2, 1919 - &new_data_version, &scb[1]); 1920 - mutex_unlock(&new_dvnode->io_lock); 1921 - } 1922 - ret = afs_end_vnode_operation(&fc); 1923 - if (ret < 0) 1924 - goto error_rehash_old; 1925 - } 1926 - 1927 - if (ret == 0) { 1928 - if (rehash) 1929 - d_rehash(rehash); 1930 - down_write(&orig_dvnode->validate_lock); 1931 - if (test_bit(AFS_VNODE_DIR_VALID, &orig_dvnode->flags) && 1932 - orig_dvnode->status.data_version == orig_data_version) 1933 - afs_edit_dir_remove(orig_dvnode, &old_dentry->d_name, 1934 - afs_edit_dir_for_rename_0); 1935 - if (orig_dvnode != new_dvnode) { 1936 - up_write(&orig_dvnode->validate_lock); 1937 - 1938 - down_write(&new_dvnode->validate_lock); 1939 - } 1940 - if (test_bit(AFS_VNODE_DIR_VALID, &new_dvnode->flags) && 1941 - orig_dvnode->status.data_version == new_data_version) { 1942 - if (!new_negative) 1943 - afs_edit_dir_remove(new_dvnode, &new_dentry->d_name, 1944 - afs_edit_dir_for_rename_1); 1945 - 1946 - afs_edit_dir_add(new_dvnode, &new_dentry->d_name, 1947 - &vnode->fid, afs_edit_dir_for_rename_2); 1948 - } 1949 - 1950 - new_inode = d_inode(new_dentry); 1951 - if (new_inode) { 1952 - spin_lock(&new_inode->i_lock); 1953 - if (new_inode->i_nlink > 0) 1954 - drop_nlink(new_inode); 1955 - spin_unlock(&new_inode->i_lock); 1956 - } 1957 - 1958 - /* Now we can update d_fsdata on the dentries to reflect their 1959 - * new parent's data_version. 1960 - * 1961 - * Note that if we ever implement RENAME_EXCHANGE, we'll have 1962 - * to update both dentries with opposing dir versions. 1963 - */ 1964 - afs_update_dentry_version(&fc, old_dentry, &scb[1]); 1965 - afs_update_dentry_version(&fc, new_dentry, &scb[1]); 1966 - d_move(old_dentry, new_dentry); 1967 - up_write(&new_dvnode->validate_lock); 1968 - goto error_tmp; 1969 - } 1970 - 1971 - error_rehash_old: 1972 - d_rehash(new_dentry); 1973 - error_rehash: 1974 - if (rehash) 1975 - d_rehash(rehash); 1976 - error_tmp: 1977 - if (tmp) 1978 - dput(tmp); 1979 - key_put(key); 1980 - error_scb: 1981 - kfree(scb); 1982 1926 error: 1983 - _leave(" = %d", ret); 1984 - return ret; 1927 + return afs_put_operation(op); 1985 1928 } 1986 1929 1987 1930 /*
+101 -93
fs/afs/dir_silly.c
··· 12 12 #include <linux/fsnotify.h> 13 13 #include "internal.h" 14 14 15 + static void afs_silly_rename_success(struct afs_operation *op) 16 + { 17 + _enter("op=%08x", op->debug_id); 18 + 19 + afs_vnode_commit_status(op, &op->file[0]); 20 + } 21 + 22 + static void afs_silly_rename_edit_dir(struct afs_operation *op) 23 + { 24 + struct afs_vnode_param *dvp = &op->file[0]; 25 + struct afs_vnode *dvnode = dvp->vnode; 26 + struct afs_vnode *vnode = AFS_FS_I(d_inode(op->dentry)); 27 + struct dentry *old = op->dentry; 28 + struct dentry *new = op->dentry_2; 29 + 30 + spin_lock(&old->d_lock); 31 + old->d_flags |= DCACHE_NFSFS_RENAMED; 32 + spin_unlock(&old->d_lock); 33 + if (dvnode->silly_key != op->key) { 34 + key_put(dvnode->silly_key); 35 + dvnode->silly_key = key_get(op->key); 36 + } 37 + 38 + down_write(&dvnode->validate_lock); 39 + if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 40 + dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) { 41 + afs_edit_dir_remove(dvnode, &old->d_name, 42 + afs_edit_dir_for_silly_0); 43 + afs_edit_dir_add(dvnode, &new->d_name, 44 + &vnode->fid, afs_edit_dir_for_silly_1); 45 + } 46 + up_write(&dvnode->validate_lock); 47 + } 48 + 49 + static const struct afs_operation_ops afs_silly_rename_operation = { 50 + .issue_afs_rpc = afs_fs_rename, 51 + .issue_yfs_rpc = yfs_fs_rename, 52 + .success = afs_silly_rename_success, 53 + .edit_dir = afs_silly_rename_edit_dir, 54 + }; 55 + 15 56 /* 16 57 * Actually perform the silly rename step. 17 58 */ ··· 60 19 struct dentry *old, struct dentry *new, 61 20 struct key *key) 62 21 { 63 - struct afs_operation fc; 64 - struct afs_status_cb *scb; 65 - afs_dataversion_t dir_data_version; 66 - int ret = -ERESTARTSYS; 22 + struct afs_operation *op; 67 23 68 24 _enter("%pd,%pd", old, new); 69 25 70 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 71 - if (!scb) 72 - return -ENOMEM; 26 + op = afs_alloc_operation(key, dvnode->volume); 27 + if (IS_ERR(op)) 28 + return PTR_ERR(op); 29 + 30 + afs_op_set_vnode(op, 0, dvnode); 31 + 32 + op->dentry = old; 33 + op->dentry_2 = new; 34 + op->ops = &afs_silly_rename_operation; 73 35 74 36 trace_afs_silly_rename(vnode, false); 75 - if (afs_begin_vnode_operation(&fc, dvnode, key, true)) { 76 - dir_data_version = dvnode->status.data_version + 1; 77 - 78 - while (afs_select_fileserver(&fc)) { 79 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 80 - afs_fs_rename(&fc, old->d_name.name, 81 - dvnode, new->d_name.name, 82 - scb, scb); 83 - } 84 - 85 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 86 - &dir_data_version, scb); 87 - ret = afs_end_vnode_operation(&fc); 88 - } 89 - 90 - if (ret == 0) { 91 - spin_lock(&old->d_lock); 92 - old->d_flags |= DCACHE_NFSFS_RENAMED; 93 - spin_unlock(&old->d_lock); 94 - if (dvnode->silly_key != key) { 95 - key_put(dvnode->silly_key); 96 - dvnode->silly_key = key_get(key); 97 - } 98 - 99 - down_write(&dvnode->validate_lock); 100 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 101 - dvnode->status.data_version == dir_data_version) { 102 - afs_edit_dir_remove(dvnode, &old->d_name, 103 - afs_edit_dir_for_silly_0); 104 - afs_edit_dir_add(dvnode, &new->d_name, 105 - &vnode->fid, afs_edit_dir_for_silly_1); 106 - } 107 - up_write(&dvnode->validate_lock); 108 - } 109 - 110 - kfree(scb); 111 - _leave(" = %d", ret); 112 - return ret; 37 + return afs_do_sync_operation(op); 113 38 } 114 39 115 40 /** ··· 146 139 return ret; 147 140 } 148 141 142 + static void afs_silly_unlink_success(struct afs_operation *op) 143 + { 144 + struct afs_vnode *vnode = op->file[1].vnode; 145 + 146 + _enter("op=%08x", op->debug_id); 147 + afs_check_for_remote_deletion(op, op->file[0].vnode); 148 + afs_vnode_commit_status(op, &op->file[0]); 149 + afs_vnode_commit_status(op, &op->file[1]); 150 + afs_update_dentry_version(op, &op->file[0], op->dentry); 151 + 152 + drop_nlink(&vnode->vfs_inode); 153 + if (vnode->vfs_inode.i_nlink == 0) { 154 + set_bit(AFS_VNODE_DELETED, &vnode->flags); 155 + clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); 156 + } 157 + } 158 + 159 + static void afs_silly_unlink_edit_dir(struct afs_operation *op) 160 + { 161 + struct afs_vnode_param *dvp = &op->file[0]; 162 + struct afs_vnode *dvnode = dvp->vnode; 163 + 164 + _enter("op=%08x", op->debug_id); 165 + down_write(&dvnode->validate_lock); 166 + if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 167 + dvnode->status.data_version == dvp->dv_before + dvp->dv_delta) 168 + afs_edit_dir_remove(dvnode, &op->dentry->d_name, 169 + afs_edit_dir_for_unlink); 170 + up_write(&dvnode->validate_lock); 171 + } 172 + 173 + static const struct afs_operation_ops afs_silly_unlink_operation = { 174 + .issue_afs_rpc = afs_fs_remove_file, 175 + .issue_yfs_rpc = yfs_fs_remove_file, 176 + .success = afs_silly_unlink_success, 177 + .edit_dir = afs_silly_unlink_edit_dir, 178 + }; 179 + 149 180 /* 150 181 * Tell the server to remove a sillyrename file. 151 182 */ 152 183 static int afs_do_silly_unlink(struct afs_vnode *dvnode, struct afs_vnode *vnode, 153 184 struct dentry *dentry, struct key *key) 154 185 { 155 - struct afs_operation fc; 156 - struct afs_status_cb *scb; 157 - int ret = -ERESTARTSYS; 186 + struct afs_operation *op; 158 187 159 188 _enter(""); 160 189 161 - scb = kcalloc(2, sizeof(struct afs_status_cb), GFP_KERNEL); 162 - if (!scb) 163 - return -ENOMEM; 190 + op = afs_alloc_operation(NULL, dvnode->volume); 191 + if (IS_ERR(op)) 192 + return PTR_ERR(op); 193 + 194 + afs_op_set_vnode(op, 0, dvnode); 195 + afs_op_set_vnode(op, 1, vnode); 196 + 197 + op->dentry = dentry; 198 + op->ops = &afs_silly_unlink_operation; 164 199 165 200 trace_afs_silly_rename(vnode, true); 166 - if (afs_begin_vnode_operation(&fc, dvnode, key, false)) { 167 - afs_dataversion_t dir_data_version = dvnode->status.data_version + 1; 168 - 169 - while (afs_select_fileserver(&fc)) { 170 - fc.cb_break = afs_calc_vnode_cb_break(dvnode); 171 - 172 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc.cbi->server->flags) && 173 - !test_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags)) { 174 - yfs_fs_remove_file2(&fc, vnode, dentry->d_name.name, 175 - &scb[0], &scb[1]); 176 - if (fc.ac.error != -ECONNABORTED || 177 - fc.ac.abort_code != RXGEN_OPCODE) 178 - continue; 179 - set_bit(AFS_SERVER_FL_NO_RM2, &fc.cbi->server->flags); 180 - } 181 - 182 - afs_fs_remove(&fc, vnode, dentry->d_name.name, false, &scb[0]); 183 - } 184 - 185 - afs_vnode_commit_status(&fc, dvnode, fc.cb_break, 186 - &dir_data_version, &scb[0]); 187 - ret = afs_end_vnode_operation(&fc); 188 - if (ret == 0) { 189 - drop_nlink(&vnode->vfs_inode); 190 - if (vnode->vfs_inode.i_nlink == 0) { 191 - set_bit(AFS_VNODE_DELETED, &vnode->flags); 192 - clear_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); 193 - } 194 - } 195 - if (ret == 0) { 196 - down_write(&dvnode->validate_lock); 197 - if (test_bit(AFS_VNODE_DIR_VALID, &dvnode->flags) && 198 - dvnode->status.data_version == dir_data_version) 199 - afs_edit_dir_remove(dvnode, &dentry->d_name, 200 - afs_edit_dir_for_unlink); 201 - up_write(&dvnode->validate_lock); 202 - } 203 - } 204 - 205 - kfree(scb); 206 - _leave(" = %d", ret); 207 - return ret; 201 + return afs_do_sync_operation(op); 208 202 } 209 203 210 204 /*
+93
fs/afs/dynroot.c
··· 10 10 #include <linux/dns_resolver.h> 11 11 #include "internal.h" 12 12 13 + static atomic_t afs_autocell_ino; 14 + 15 + /* 16 + * iget5() comparator for inode created by autocell operations 17 + * 18 + * These pseudo inodes don't match anything. 19 + */ 20 + static int afs_iget5_pseudo_test(struct inode *inode, void *opaque) 21 + { 22 + return 0; 23 + } 24 + 25 + /* 26 + * iget5() inode initialiser 27 + */ 28 + static int afs_iget5_pseudo_set(struct inode *inode, void *opaque) 29 + { 30 + struct afs_super_info *as = AFS_FS_S(inode->i_sb); 31 + struct afs_vnode *vnode = AFS_FS_I(inode); 32 + struct afs_fid *fid = opaque; 33 + 34 + vnode->volume = as->volume; 35 + vnode->fid = *fid; 36 + inode->i_ino = fid->vnode; 37 + inode->i_generation = fid->unique; 38 + return 0; 39 + } 40 + 41 + /* 42 + * Create an inode for a dynamic root directory or an autocell dynamic 43 + * automount dir. 44 + */ 45 + struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root) 46 + { 47 + struct afs_super_info *as = AFS_FS_S(sb); 48 + struct afs_vnode *vnode; 49 + struct inode *inode; 50 + struct afs_fid fid = {}; 51 + 52 + _enter(""); 53 + 54 + if (as->volume) 55 + fid.vid = as->volume->vid; 56 + if (root) { 57 + fid.vnode = 1; 58 + fid.unique = 1; 59 + } else { 60 + fid.vnode = atomic_inc_return(&afs_autocell_ino); 61 + fid.unique = 0; 62 + } 63 + 64 + inode = iget5_locked(sb, fid.vnode, 65 + afs_iget5_pseudo_test, afs_iget5_pseudo_set, &fid); 66 + if (!inode) { 67 + _leave(" = -ENOMEM"); 68 + return ERR_PTR(-ENOMEM); 69 + } 70 + 71 + _debug("GOT INODE %p { ino=%lu, vl=%llx, vn=%llx, u=%x }", 72 + inode, inode->i_ino, fid.vid, fid.vnode, fid.unique); 73 + 74 + vnode = AFS_FS_I(inode); 75 + 76 + /* there shouldn't be an existing inode */ 77 + BUG_ON(!(inode->i_state & I_NEW)); 78 + 79 + inode->i_size = 0; 80 + inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 81 + if (root) { 82 + inode->i_op = &afs_dynroot_inode_operations; 83 + inode->i_fop = &simple_dir_operations; 84 + } else { 85 + inode->i_op = &afs_autocell_inode_operations; 86 + } 87 + set_nlink(inode, 2); 88 + inode->i_uid = GLOBAL_ROOT_UID; 89 + inode->i_gid = GLOBAL_ROOT_GID; 90 + inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode); 91 + inode->i_blocks = 0; 92 + inode->i_generation = 0; 93 + 94 + set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags); 95 + if (!root) { 96 + set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); 97 + inode->i_flags |= S_AUTOMOUNT; 98 + } 99 + 100 + inode->i_flags |= S_NOATIME; 101 + unlock_new_inode(inode); 102 + _leave(" = %p", inode); 103 + return inode; 104 + } 105 + 13 106 /* 14 107 * Probe to see if a cell may exist. This prevents positive dentries from 15 108 * being created unnecessarily.
+32 -30
fs/afs/file.c
··· 69 69 */ 70 70 void afs_put_wb_key(struct afs_wb_key *wbk) 71 71 { 72 - if (refcount_dec_and_test(&wbk->usage)) { 72 + if (wbk && refcount_dec_and_test(&wbk->usage)) { 73 73 key_put(wbk->key); 74 74 kfree(wbk); 75 75 } ··· 220 220 } 221 221 #endif 222 222 223 + static void afs_fetch_data_success(struct afs_operation *op) 224 + { 225 + struct afs_vnode *vnode = op->file[0].vnode; 226 + 227 + _enter("op=%08x", op->debug_id); 228 + afs_check_for_remote_deletion(op, vnode); 229 + afs_vnode_commit_status(op, &op->file[0]); 230 + afs_stat_v(vnode, n_fetches); 231 + atomic_long_add(op->fetch.req->actual_len, &op->net->n_fetch_bytes); 232 + } 233 + 234 + static void afs_fetch_data_put(struct afs_operation *op) 235 + { 236 + afs_put_read(op->fetch.req); 237 + } 238 + 239 + static const struct afs_operation_ops afs_fetch_data_operation = { 240 + .issue_afs_rpc = afs_fs_fetch_data, 241 + .issue_yfs_rpc = yfs_fs_fetch_data, 242 + .success = afs_fetch_data_success, 243 + .put = afs_fetch_data_put, 244 + }; 245 + 223 246 /* 224 247 * Fetch file data from the volume. 225 248 */ 226 249 int afs_fetch_data(struct afs_vnode *vnode, struct key *key, struct afs_read *req) 227 250 { 228 - struct afs_operation fc; 229 - struct afs_status_cb *scb; 230 - int ret; 251 + struct afs_operation *op; 231 252 232 253 _enter("%s{%llx:%llu.%u},%x,,,", 233 254 vnode->volume->name, ··· 257 236 vnode->fid.unique, 258 237 key_serial(key)); 259 238 260 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 261 - if (!scb) 262 - return -ENOMEM; 239 + op = afs_alloc_operation(key, vnode->volume); 240 + if (IS_ERR(op)) 241 + return PTR_ERR(op); 263 242 264 - ret = -ERESTARTSYS; 265 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 266 - afs_dataversion_t data_version = vnode->status.data_version; 243 + afs_op_set_vnode(op, 0, vnode); 267 244 268 - while (afs_select_fileserver(&fc)) { 269 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 270 - afs_fs_fetch_data(&fc, scb, req); 271 - } 272 - 273 - afs_check_for_remote_deletion(&fc, vnode); 274 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 275 - &data_version, scb); 276 - ret = afs_end_vnode_operation(&fc); 277 - } 278 - 279 - if (ret == 0) { 280 - afs_stat_v(vnode, n_fetches); 281 - atomic_long_add(req->actual_len, 282 - &afs_v2net(vnode)->n_fetch_bytes); 283 - } 284 - 285 - kfree(scb); 286 - _leave(" = %d", ret); 287 - return ret; 245 + op->fetch.req = afs_get_read(req); 246 + op->ops = &afs_fetch_data_operation; 247 + return afs_do_sync_operation(op); 288 248 } 289 249 290 250 /*
+53 -61
fs/afs/flock.c
··· 70 70 */ 71 71 void afs_lock_op_done(struct afs_call *call) 72 72 { 73 - struct afs_vnode *vnode = call->lvnode; 73 + struct afs_operation *op = call->op; 74 + struct afs_vnode *vnode = op->lock.lvnode; 74 75 75 76 if (call->error == 0) { 76 77 spin_lock(&vnode->lock); ··· 173 172 vnode->lock_key = NULL; 174 173 } 175 174 175 + static void afs_lock_success(struct afs_operation *op) 176 + { 177 + struct afs_vnode *vnode = op->file[0].vnode; 178 + 179 + _enter("op=%08x", op->debug_id); 180 + afs_check_for_remote_deletion(op, vnode); 181 + afs_vnode_commit_status(op, &op->file[0]); 182 + } 183 + 184 + static const struct afs_operation_ops afs_set_lock_operation = { 185 + .issue_afs_rpc = afs_fs_set_lock, 186 + .issue_yfs_rpc = yfs_fs_set_lock, 187 + .success = afs_lock_success, 188 + }; 189 + 176 190 /* 177 191 * Get a lock on a file 178 192 */ 179 193 static int afs_set_lock(struct afs_vnode *vnode, struct key *key, 180 194 afs_lock_type_t type) 181 195 { 182 - struct afs_status_cb *scb; 183 - struct afs_operation fc; 184 - int ret; 196 + struct afs_operation *op; 185 197 186 198 _enter("%s{%llx:%llu.%u},%x,%u", 187 199 vnode->volume->name, ··· 203 189 vnode->fid.unique, 204 190 key_serial(key), type); 205 191 206 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 207 - if (!scb) 208 - return -ENOMEM; 192 + op = afs_alloc_operation(key, vnode->volume); 193 + if (IS_ERR(op)) 194 + return PTR_ERR(op); 209 195 210 - ret = -ERESTARTSYS; 211 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 212 - while (afs_select_fileserver(&fc)) { 213 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 214 - afs_fs_set_lock(&fc, type, scb); 215 - } 196 + afs_op_set_vnode(op, 0, vnode); 216 197 217 - afs_check_for_remote_deletion(&fc, vnode); 218 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb); 219 - ret = afs_end_vnode_operation(&fc); 220 - } 221 - 222 - kfree(scb); 223 - _leave(" = %d", ret); 224 - return ret; 198 + op->lock.type = type; 199 + op->ops = &afs_set_lock_operation; 200 + return afs_do_sync_operation(op); 225 201 } 202 + 203 + static const struct afs_operation_ops afs_extend_lock_operation = { 204 + .issue_afs_rpc = afs_fs_extend_lock, 205 + .issue_yfs_rpc = yfs_fs_extend_lock, 206 + .success = afs_lock_success, 207 + }; 226 208 227 209 /* 228 210 * Extend a lock on a file 229 211 */ 230 212 static int afs_extend_lock(struct afs_vnode *vnode, struct key *key) 231 213 { 232 - struct afs_status_cb *scb; 233 - struct afs_operation fc; 234 - int ret; 214 + struct afs_operation *op; 235 215 236 216 _enter("%s{%llx:%llu.%u},%x", 237 217 vnode->volume->name, ··· 234 226 vnode->fid.unique, 235 227 key_serial(key)); 236 228 237 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 238 - if (!scb) 239 - return -ENOMEM; 229 + op = afs_alloc_operation(key, vnode->volume); 230 + if (IS_ERR(op)) 231 + return PTR_ERR(op); 240 232 241 - ret = -ERESTARTSYS; 242 - if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 243 - while (afs_select_current_fileserver(&fc)) { 244 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 245 - afs_fs_extend_lock(&fc, scb); 246 - } 233 + afs_op_set_vnode(op, 0, vnode); 247 234 248 - afs_check_for_remote_deletion(&fc, vnode); 249 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb); 250 - ret = afs_end_vnode_operation(&fc); 251 - } 252 - 253 - kfree(scb); 254 - _leave(" = %d", ret); 255 - return ret; 235 + op->flags |= AFS_OPERATION_UNINTR; 236 + op->ops = &afs_extend_lock_operation; 237 + return afs_do_sync_operation(op); 256 238 } 239 + 240 + static const struct afs_operation_ops afs_release_lock_operation = { 241 + .issue_afs_rpc = afs_fs_release_lock, 242 + .issue_yfs_rpc = yfs_fs_release_lock, 243 + .success = afs_lock_success, 244 + }; 257 245 258 246 /* 259 247 * Release a lock on a file 260 248 */ 261 249 static int afs_release_lock(struct afs_vnode *vnode, struct key *key) 262 250 { 263 - struct afs_status_cb *scb; 264 - struct afs_operation fc; 265 - int ret; 251 + struct afs_operation *op; 266 252 267 253 _enter("%s{%llx:%llu.%u},%x", 268 254 vnode->volume->name, ··· 265 263 vnode->fid.unique, 266 264 key_serial(key)); 267 265 268 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 269 - if (!scb) 270 - return -ENOMEM; 266 + op = afs_alloc_operation(key, vnode->volume); 267 + if (IS_ERR(op)) 268 + return PTR_ERR(op); 271 269 272 - ret = -ERESTARTSYS; 273 - if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 274 - while (afs_select_current_fileserver(&fc)) { 275 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 276 - afs_fs_release_lock(&fc, scb); 277 - } 270 + afs_op_set_vnode(op, 0, vnode); 278 271 279 - afs_check_for_remote_deletion(&fc, vnode); 280 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, NULL, scb); 281 - ret = afs_end_vnode_operation(&fc); 282 - } 283 - 284 - kfree(scb); 285 - _leave(" = %d", ret); 286 - return ret; 272 + op->flags |= AFS_OPERATION_UNINTR; 273 + op->ops = &afs_release_lock_operation; 274 + return afs_do_sync_operation(op); 287 275 } 288 276 289 277 /*
+246
fs/afs/fs_operation.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* Fileserver-directed operation handling. 3 + * 4 + * Copyright (C) 2020 Red Hat, Inc. All Rights Reserved. 5 + * Written by David Howells (dhowells@redhat.com) 6 + */ 7 + 8 + #include <linux/kernel.h> 9 + #include <linux/slab.h> 10 + #include <linux/fs.h> 11 + #include "internal.h" 12 + 13 + static atomic_t afs_operation_debug_counter; 14 + 15 + /* 16 + * Create an operation against a volume. 17 + */ 18 + struct afs_operation *afs_alloc_operation(struct key *key, struct afs_volume *volume) 19 + { 20 + struct afs_operation *op; 21 + 22 + _enter(""); 23 + 24 + op = kzalloc(sizeof(*op), GFP_KERNEL); 25 + if (!op) 26 + return ERR_PTR(-ENOMEM); 27 + 28 + if (!key) { 29 + key = afs_request_key(volume->cell); 30 + if (IS_ERR(key)) { 31 + kfree(op); 32 + return ERR_CAST(key); 33 + } 34 + } else { 35 + key_get(key); 36 + } 37 + 38 + op->key = key; 39 + op->volume = afs_get_volume(volume); 40 + op->net = volume->cell->net; 41 + op->cb_v_break = volume->cb_v_break; 42 + op->debug_id = atomic_inc_return(&afs_operation_debug_counter); 43 + op->error = -EDESTADDRREQ; 44 + op->ac.error = SHRT_MAX; 45 + 46 + _leave(" = [op=%08x]", op->debug_id); 47 + return op; 48 + } 49 + 50 + /* 51 + * Lock the vnode(s) being operated upon. 52 + */ 53 + static bool afs_get_io_locks(struct afs_operation *op) 54 + { 55 + struct afs_vnode *vnode = op->file[0].vnode; 56 + struct afs_vnode *vnode2 = op->file[1].vnode; 57 + 58 + _enter(""); 59 + 60 + if (op->flags & AFS_OPERATION_UNINTR) { 61 + mutex_lock(&vnode->io_lock); 62 + op->flags |= AFS_OPERATION_LOCK_0; 63 + _leave(" = t [1]"); 64 + return true; 65 + } 66 + 67 + if (!vnode2 || !op->file[1].need_io_lock || vnode == vnode2) 68 + vnode2 = NULL; 69 + 70 + if (vnode2 > vnode) 71 + swap(vnode, vnode2); 72 + 73 + if (mutex_lock_interruptible(&vnode->io_lock) < 0) { 74 + op->error = -EINTR; 75 + op->flags |= AFS_OPERATION_STOP; 76 + _leave(" = f [I 0]"); 77 + return false; 78 + } 79 + op->flags |= AFS_OPERATION_LOCK_0; 80 + 81 + if (vnode2) { 82 + if (mutex_lock_interruptible_nested(&vnode2->io_lock, 1) < 0) { 83 + op->error = -EINTR; 84 + op->flags |= AFS_OPERATION_STOP; 85 + mutex_unlock(&vnode->io_lock); 86 + op->flags &= ~AFS_OPERATION_LOCK_0; 87 + _leave(" = f [I 1]"); 88 + return false; 89 + } 90 + op->flags |= AFS_OPERATION_LOCK_1; 91 + } 92 + 93 + _leave(" = t [2]"); 94 + return true; 95 + } 96 + 97 + static void afs_drop_io_locks(struct afs_operation *op) 98 + { 99 + struct afs_vnode *vnode = op->file[0].vnode; 100 + struct afs_vnode *vnode2 = op->file[1].vnode; 101 + 102 + _enter(""); 103 + 104 + if (op->flags & AFS_OPERATION_LOCK_1) 105 + mutex_unlock(&vnode2->io_lock); 106 + if (op->flags & AFS_OPERATION_LOCK_0) 107 + mutex_unlock(&vnode->io_lock); 108 + } 109 + 110 + static void afs_prepare_vnode(struct afs_operation *op, struct afs_vnode_param *vp, 111 + unsigned int index) 112 + { 113 + struct afs_vnode *vnode = vp->vnode; 114 + 115 + if (vnode) { 116 + vp->fid = vnode->fid; 117 + vp->dv_before = vnode->status.data_version; 118 + vp->cb_break_before = afs_calc_vnode_cb_break(vnode); 119 + if (vnode->lock_state != AFS_VNODE_LOCK_NONE) 120 + op->flags |= AFS_OPERATION_CUR_ONLY; 121 + } 122 + 123 + if (vp->fid.vnode) 124 + _debug("PREP[%u] {%llx:%llu.%u}", 125 + index, vp->fid.vid, vp->fid.vnode, vp->fid.unique); 126 + } 127 + 128 + /* 129 + * Begin an operation on the fileserver. 130 + * 131 + * Fileserver operations are serialised on the server by vnode, so we serialise 132 + * them here also using the io_lock. 133 + */ 134 + bool afs_begin_vnode_operation(struct afs_operation *op) 135 + { 136 + struct afs_vnode *vnode = op->file[0].vnode; 137 + 138 + ASSERT(vnode); 139 + 140 + _enter(""); 141 + 142 + if (op->file[0].need_io_lock) 143 + if (!afs_get_io_locks(op)) 144 + return false; 145 + 146 + read_seqlock_excl(&vnode->cb_lock); 147 + op->cbi = afs_get_cb_interest( 148 + rcu_dereference_protected(vnode->cb_interest, 149 + lockdep_is_held(&vnode->cb_lock.lock))); 150 + read_sequnlock_excl(&vnode->cb_lock); 151 + 152 + afs_prepare_vnode(op, &op->file[0], 0); 153 + afs_prepare_vnode(op, &op->file[1], 1); 154 + op->cb_v_break = op->volume->cb_v_break; 155 + _leave(" = true"); 156 + return true; 157 + } 158 + 159 + /* 160 + * Tidy up a filesystem cursor and unlock the vnode. 161 + */ 162 + static void afs_end_vnode_operation(struct afs_operation *op) 163 + { 164 + _enter(""); 165 + 166 + if (op->error == -EDESTADDRREQ || 167 + op->error == -EADDRNOTAVAIL || 168 + op->error == -ENETUNREACH || 169 + op->error == -EHOSTUNREACH) 170 + afs_dump_edestaddrreq(op); 171 + 172 + afs_drop_io_locks(op); 173 + 174 + if (op->error == -ECONNABORTED) 175 + op->error = afs_abort_to_error(op->ac.abort_code); 176 + } 177 + 178 + /* 179 + * Wait for an in-progress operation to complete. 180 + */ 181 + void afs_wait_for_operation(struct afs_operation *op) 182 + { 183 + _enter(""); 184 + 185 + while (afs_select_fileserver(op)) { 186 + op->cb_s_break = op->cbi->server->cb_s_break; 187 + if (test_bit(AFS_SERVER_FL_IS_YFS, &op->cbi->server->flags) && 188 + op->ops->issue_yfs_rpc) 189 + op->ops->issue_yfs_rpc(op); 190 + else 191 + op->ops->issue_afs_rpc(op); 192 + 193 + op->error = afs_wait_for_call_to_complete(op->call, &op->ac); 194 + } 195 + 196 + if (op->error == 0) { 197 + _debug("success"); 198 + op->ops->success(op); 199 + } 200 + 201 + afs_end_vnode_operation(op); 202 + 203 + if (op->error == 0 && op->ops->edit_dir) { 204 + _debug("edit_dir"); 205 + op->ops->edit_dir(op); 206 + } 207 + _leave(""); 208 + } 209 + 210 + /* 211 + * Dispose of an operation. 212 + */ 213 + int afs_put_operation(struct afs_operation *op) 214 + { 215 + int i, ret = op->error; 216 + 217 + _enter("op=%08x,%d", op->debug_id, ret); 218 + 219 + if (op->ops && op->ops->put) 220 + op->ops->put(op); 221 + if (op->file[0].put_vnode) 222 + iput(&op->file[0].vnode->vfs_inode); 223 + if (op->file[1].put_vnode) 224 + iput(&op->file[1].vnode->vfs_inode); 225 + 226 + if (op->more_files) { 227 + for (i = 0; i < op->nr_files - 2; i++) 228 + if (op->more_files[i].put_vnode) 229 + iput(&op->more_files[i].vnode->vfs_inode); 230 + kfree(op->more_files); 231 + } 232 + 233 + afs_end_cursor(&op->ac); 234 + afs_put_cb_interest(op->net, op->cbi); 235 + afs_put_serverlist(op->net, op->server_list); 236 + afs_put_volume(op->net, op->volume); 237 + kfree(op); 238 + return ret; 239 + } 240 + 241 + int afs_do_sync_operation(struct afs_operation *op) 242 + { 243 + afs_begin_vnode_operation(op); 244 + afs_wait_for_operation(op); 245 + return afs_put_operation(op); 246 + }
+486 -727
fs/afs/fsclient.c
··· 13 13 #include "internal.h" 14 14 #include "afs_fs.h" 15 15 #include "xdr_fs.h" 16 - #include "protocol_yfs.h" 17 - 18 - static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi) 19 - { 20 - call->cbi = afs_get_cb_interest(cbi); 21 - } 22 16 23 17 /* 24 18 * decode an AFSFid block ··· 234 240 /* 235 241 * deliver reply data to an FS.FetchStatus 236 242 */ 237 - static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call) 243 + static int afs_deliver_fs_fetch_status(struct afs_call *call) 238 244 { 245 + struct afs_operation *op = call->op; 246 + struct afs_vnode_param *vp = &op->file[op->fetch_status.which]; 239 247 const __be32 *bp; 240 248 int ret; 241 249 ··· 247 251 248 252 /* unmarshall the reply once we've received all of it */ 249 253 bp = call->buffer; 250 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 251 - xdr_decode_AFSCallBack(&bp, call, call->out_scb); 252 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 254 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 255 + xdr_decode_AFSCallBack(&bp, call, &vp->scb); 256 + xdr_decode_AFSVolSync(&bp, &op->volsync); 253 257 254 258 _leave(" = 0 [done]"); 255 259 return 0; ··· 258 262 /* 259 263 * FS.FetchStatus operation type 260 264 */ 261 - static const struct afs_call_type afs_RXFSFetchStatus_vnode = { 262 - .name = "FS.FetchStatus(vnode)", 265 + static const struct afs_call_type afs_RXFSFetchStatus = { 266 + .name = "FS.FetchStatus", 263 267 .op = afs_FS_FetchStatus, 264 - .deliver = afs_deliver_fs_fetch_status_vnode, 268 + .deliver = afs_deliver_fs_fetch_status, 265 269 .destructor = afs_flat_call_destructor, 266 270 }; 267 271 268 272 /* 269 273 * fetch the status information for a file 270 274 */ 271 - int afs_fs_fetch_file_status(struct afs_operation *fc, struct afs_status_cb *scb, 272 - struct afs_volsync *volsync) 275 + void afs_fs_fetch_status(struct afs_operation *op) 273 276 { 274 - struct afs_vnode *vnode = fc->vnode; 277 + struct afs_vnode_param *vp = &op->file[op->fetch_status.which]; 275 278 struct afs_call *call; 276 - struct afs_net *net = afs_v2net(vnode); 277 279 __be32 *bp; 278 280 279 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 280 - return yfs_fs_fetch_file_status(fc, scb, volsync); 281 - 282 281 _enter(",%x,{%llx:%llu},,", 283 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 282 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 284 283 285 - call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus_vnode, 284 + call = afs_alloc_flat_call(op->net, &afs_RXFSFetchStatus, 286 285 16, (21 + 3 + 6) * 4); 287 - if (!call) { 288 - fc->ac.error = -ENOMEM; 289 - return -ENOMEM; 290 - } 291 - 292 - call->key = fc->key; 293 - call->out_scb = scb; 294 - call->out_volsync = volsync; 286 + if (!call) 287 + return afs_op_nomem(op); 295 288 296 289 /* marshall the parameters */ 297 290 bp = call->request; 298 291 bp[0] = htonl(FSFETCHSTATUS); 299 - bp[1] = htonl(vnode->fid.vid); 300 - bp[2] = htonl(vnode->fid.vnode); 301 - bp[3] = htonl(vnode->fid.unique); 292 + bp[1] = htonl(vp->fid.vid); 293 + bp[2] = htonl(vp->fid.vnode); 294 + bp[3] = htonl(vp->fid.unique); 302 295 303 - afs_use_fs_server(call, fc->cbi); 304 - trace_afs_make_fs_call(call, &vnode->fid); 305 - 306 - afs_set_fc_call(call, fc); 307 - afs_make_call(&fc->ac, call, GFP_NOFS); 308 - return afs_wait_for_call_to_complete(call, &fc->ac); 296 + trace_afs_make_fs_call(call, &vp->fid); 297 + afs_make_op_call(op, call, GFP_NOFS); 309 298 } 310 299 311 300 /* ··· 298 317 */ 299 318 static int afs_deliver_fs_fetch_data(struct afs_call *call) 300 319 { 301 - struct afs_read *req = call->read_request; 320 + struct afs_operation *op = call->op; 321 + struct afs_vnode_param *vp = &op->file[0]; 322 + struct afs_read *req = op->fetch.req; 302 323 const __be32 *bp; 303 324 unsigned int size; 304 325 int ret; ··· 397 414 return ret; 398 415 399 416 bp = call->buffer; 400 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 401 - xdr_decode_AFSCallBack(&bp, call, call->out_scb); 402 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 417 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 418 + xdr_decode_AFSCallBack(&bp, call, &vp->scb); 419 + xdr_decode_AFSVolSync(&bp, &op->volsync); 403 420 404 - req->data_version = call->out_scb->status.data_version; 405 - req->file_size = call->out_scb->status.size; 421 + req->data_version = vp->scb.status.data_version; 422 + req->file_size = vp->scb.status.size; 406 423 407 424 call->unmarshall++; 408 425 ··· 425 442 return 0; 426 443 } 427 444 428 - static void afs_fetch_data_destructor(struct afs_call *call) 429 - { 430 - struct afs_read *req = call->read_request; 431 - 432 - afs_put_read(req); 433 - afs_flat_call_destructor(call); 434 - } 435 - 436 445 /* 437 446 * FS.FetchData operation type 438 447 */ ··· 432 457 .name = "FS.FetchData", 433 458 .op = afs_FS_FetchData, 434 459 .deliver = afs_deliver_fs_fetch_data, 435 - .destructor = afs_fetch_data_destructor, 460 + .destructor = afs_flat_call_destructor, 436 461 }; 437 462 438 463 static const struct afs_call_type afs_RXFSFetchData64 = { 439 464 .name = "FS.FetchData64", 440 465 .op = afs_FS_FetchData64, 441 466 .deliver = afs_deliver_fs_fetch_data, 442 - .destructor = afs_fetch_data_destructor, 467 + .destructor = afs_flat_call_destructor, 443 468 }; 444 469 445 470 /* 446 471 * fetch data from a very large file 447 472 */ 448 - static int afs_fs_fetch_data64(struct afs_operation *fc, 449 - struct afs_status_cb *scb, 450 - struct afs_read *req) 473 + static void afs_fs_fetch_data64(struct afs_operation *op) 451 474 { 452 - struct afs_vnode *vnode = fc->vnode; 475 + struct afs_vnode_param *vp = &op->file[0]; 476 + struct afs_read *req = op->fetch.req; 453 477 struct afs_call *call; 454 - struct afs_net *net = afs_v2net(vnode); 455 478 __be32 *bp; 456 479 457 480 _enter(""); 458 481 459 - call = afs_alloc_flat_call(net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4); 482 + call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4); 460 483 if (!call) 461 - return -ENOMEM; 462 - 463 - call->key = fc->key; 464 - call->out_scb = scb; 465 - call->out_volsync = NULL; 466 - call->read_request = afs_get_read(req); 484 + return afs_op_nomem(op); 467 485 468 486 /* marshall the parameters */ 469 487 bp = call->request; 470 488 bp[0] = htonl(FSFETCHDATA64); 471 - bp[1] = htonl(vnode->fid.vid); 472 - bp[2] = htonl(vnode->fid.vnode); 473 - bp[3] = htonl(vnode->fid.unique); 489 + bp[1] = htonl(vp->fid.vid); 490 + bp[2] = htonl(vp->fid.vnode); 491 + bp[3] = htonl(vp->fid.unique); 474 492 bp[4] = htonl(upper_32_bits(req->pos)); 475 493 bp[5] = htonl(lower_32_bits(req->pos)); 476 494 bp[6] = 0; 477 495 bp[7] = htonl(lower_32_bits(req->len)); 478 496 479 - afs_use_fs_server(call, fc->cbi); 480 - trace_afs_make_fs_call(call, &vnode->fid); 481 - afs_set_fc_call(call, fc); 482 - afs_make_call(&fc->ac, call, GFP_NOFS); 483 - return afs_wait_for_call_to_complete(call, &fc->ac); 497 + trace_afs_make_fs_call(call, &vp->fid); 498 + afs_make_op_call(op, call, GFP_NOFS); 484 499 } 485 500 486 501 /* 487 502 * fetch data from a file 488 503 */ 489 - int afs_fs_fetch_data(struct afs_operation *fc, 490 - struct afs_status_cb *scb, 491 - struct afs_read *req) 504 + void afs_fs_fetch_data(struct afs_operation *op) 492 505 { 493 - struct afs_vnode *vnode = fc->vnode; 506 + struct afs_vnode_param *vp = &op->file[0]; 494 507 struct afs_call *call; 495 - struct afs_net *net = afs_v2net(vnode); 508 + struct afs_read *req = op->fetch.req; 496 509 __be32 *bp; 497 - 498 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 499 - return yfs_fs_fetch_data(fc, scb, req); 500 510 501 511 if (upper_32_bits(req->pos) || 502 512 upper_32_bits(req->len) || 503 513 upper_32_bits(req->pos + req->len)) 504 - return afs_fs_fetch_data64(fc, scb, req); 514 + return afs_fs_fetch_data64(op); 505 515 506 516 _enter(""); 507 517 508 - call = afs_alloc_flat_call(net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4); 518 + call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4); 509 519 if (!call) 510 - return -ENOMEM; 511 - 512 - call->key = fc->key; 513 - call->out_scb = scb; 514 - call->out_volsync = NULL; 515 - call->read_request = afs_get_read(req); 520 + return afs_op_nomem(op); 516 521 517 522 /* marshall the parameters */ 518 523 bp = call->request; 519 524 bp[0] = htonl(FSFETCHDATA); 520 - bp[1] = htonl(vnode->fid.vid); 521 - bp[2] = htonl(vnode->fid.vnode); 522 - bp[3] = htonl(vnode->fid.unique); 525 + bp[1] = htonl(vp->fid.vid); 526 + bp[2] = htonl(vp->fid.vnode); 527 + bp[3] = htonl(vp->fid.unique); 523 528 bp[4] = htonl(lower_32_bits(req->pos)); 524 529 bp[5] = htonl(lower_32_bits(req->len)); 525 530 526 - afs_use_fs_server(call, fc->cbi); 527 - trace_afs_make_fs_call(call, &vnode->fid); 528 - afs_set_fc_call(call, fc); 529 - afs_make_call(&fc->ac, call, GFP_NOFS); 530 - return afs_wait_for_call_to_complete(call, &fc->ac); 531 + trace_afs_make_fs_call(call, &vp->fid); 532 + afs_make_op_call(op, call, GFP_NOFS); 531 533 } 532 534 533 535 /* ··· 512 560 */ 513 561 static int afs_deliver_fs_create_vnode(struct afs_call *call) 514 562 { 563 + struct afs_operation *op = call->op; 564 + struct afs_vnode_param *dvp = &op->file[0]; 565 + struct afs_vnode_param *vp = &op->file[1]; 515 566 const __be32 *bp; 516 567 int ret; 517 568 ··· 524 569 525 570 /* unmarshall the reply once we've received all of it */ 526 571 bp = call->buffer; 527 - xdr_decode_AFSFid(&bp, call->out_fid); 528 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 529 - xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb); 530 - xdr_decode_AFSCallBack(&bp, call, call->out_scb); 531 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 572 + xdr_decode_AFSFid(&bp, &op->file[1].fid); 573 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 574 + xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb); 575 + xdr_decode_AFSCallBack(&bp, call, &vp->scb); 576 + xdr_decode_AFSVolSync(&bp, &op->volsync); 532 577 533 578 _leave(" = 0 [done]"); 534 579 return 0; ··· 544 589 .destructor = afs_flat_call_destructor, 545 590 }; 546 591 592 + /* 593 + * Create a file. 594 + */ 595 + void afs_fs_create_file(struct afs_operation *op) 596 + { 597 + const struct qstr *name = &op->dentry->d_name; 598 + struct afs_vnode_param *dvp = &op->file[0]; 599 + struct afs_call *call; 600 + size_t namesz, reqsz, padsz; 601 + __be32 *bp; 602 + 603 + _enter(""); 604 + 605 + namesz = name->len; 606 + padsz = (4 - (namesz & 3)) & 3; 607 + reqsz = (5 * 4) + namesz + padsz + (6 * 4); 608 + 609 + call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile, 610 + reqsz, (3 + 21 + 21 + 3 + 6) * 4); 611 + if (!call) 612 + return afs_op_nomem(op); 613 + 614 + /* marshall the parameters */ 615 + bp = call->request; 616 + *bp++ = htonl(FSCREATEFILE); 617 + *bp++ = htonl(dvp->fid.vid); 618 + *bp++ = htonl(dvp->fid.vnode); 619 + *bp++ = htonl(dvp->fid.unique); 620 + *bp++ = htonl(namesz); 621 + memcpy(bp, name->name, namesz); 622 + bp = (void *) bp + namesz; 623 + if (padsz > 0) { 624 + memset(bp, 0, padsz); 625 + bp = (void *) bp + padsz; 626 + } 627 + *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME); 628 + *bp++ = htonl(op->mtime.tv_sec); /* mtime */ 629 + *bp++ = 0; /* owner */ 630 + *bp++ = 0; /* group */ 631 + *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */ 632 + *bp++ = 0; /* segment size */ 633 + 634 + trace_afs_make_fs_call1(call, &dvp->fid, name); 635 + afs_make_op_call(op, call, GFP_NOFS); 636 + } 637 + 547 638 static const struct afs_call_type afs_RXFSMakeDir = { 548 639 .name = "FS.MakeDir", 549 640 .op = afs_FS_MakeDir, ··· 598 597 }; 599 598 600 599 /* 601 - * create a file or make a directory 600 + * Create a new directory 602 601 */ 603 - int afs_fs_create(struct afs_operation *fc, 604 - const char *name, 605 - umode_t mode, 606 - struct afs_status_cb *dvnode_scb, 607 - struct afs_fid *newfid, 608 - struct afs_status_cb *new_scb) 602 + void afs_fs_make_dir(struct afs_operation *op) 609 603 { 610 - struct afs_vnode *dvnode = fc->vnode; 604 + const struct qstr *name = &op->dentry->d_name; 605 + struct afs_vnode_param *dvp = &op->file[0]; 611 606 struct afs_call *call; 612 - struct afs_net *net = afs_v2net(dvnode); 613 607 size_t namesz, reqsz, padsz; 614 608 __be32 *bp; 615 609 616 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){ 617 - if (S_ISDIR(mode)) 618 - return yfs_fs_make_dir(fc, name, mode, dvnode_scb, 619 - newfid, new_scb); 620 - else 621 - return yfs_fs_create_file(fc, name, mode, dvnode_scb, 622 - newfid, new_scb); 623 - } 624 - 625 610 _enter(""); 626 611 627 - namesz = strlen(name); 612 + namesz = name->len; 628 613 padsz = (4 - (namesz & 3)) & 3; 629 614 reqsz = (5 * 4) + namesz + padsz + (6 * 4); 630 615 631 - call = afs_alloc_flat_call( 632 - net, S_ISDIR(mode) ? &afs_RXFSMakeDir : &afs_RXFSCreateFile, 633 - reqsz, (3 + 21 + 21 + 3 + 6) * 4); 616 + call = afs_alloc_flat_call(op->net, &afs_RXFSMakeDir, 617 + reqsz, (3 + 21 + 21 + 3 + 6) * 4); 634 618 if (!call) 635 - return -ENOMEM; 636 - 637 - call->key = fc->key; 638 - call->out_dir_scb = dvnode_scb; 639 - call->out_fid = newfid; 640 - call->out_scb = new_scb; 619 + return afs_op_nomem(op); 641 620 642 621 /* marshall the parameters */ 643 622 bp = call->request; 644 - *bp++ = htonl(S_ISDIR(mode) ? FSMAKEDIR : FSCREATEFILE); 645 - *bp++ = htonl(dvnode->fid.vid); 646 - *bp++ = htonl(dvnode->fid.vnode); 647 - *bp++ = htonl(dvnode->fid.unique); 623 + *bp++ = htonl(FSMAKEDIR); 624 + *bp++ = htonl(dvp->fid.vid); 625 + *bp++ = htonl(dvp->fid.vnode); 626 + *bp++ = htonl(dvp->fid.unique); 648 627 *bp++ = htonl(namesz); 649 - memcpy(bp, name, namesz); 628 + memcpy(bp, name->name, namesz); 650 629 bp = (void *) bp + namesz; 651 630 if (padsz > 0) { 652 631 memset(bp, 0, padsz); 653 632 bp = (void *) bp + padsz; 654 633 } 655 634 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME); 656 - *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec); /* mtime */ 635 + *bp++ = htonl(op->mtime.tv_sec); /* mtime */ 657 636 *bp++ = 0; /* owner */ 658 637 *bp++ = 0; /* group */ 659 - *bp++ = htonl(mode & S_IALLUGO); /* unix mode */ 638 + *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */ 660 639 *bp++ = 0; /* segment size */ 661 640 662 - afs_use_fs_server(call, fc->cbi); 663 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 664 - afs_set_fc_call(call, fc); 665 - afs_make_call(&fc->ac, call, GFP_NOFS); 666 - return afs_wait_for_call_to_complete(call, &fc->ac); 641 + trace_afs_make_fs_call1(call, &dvp->fid, name); 642 + afs_make_op_call(op, call, GFP_NOFS); 667 643 } 668 644 669 645 /* 670 - * Deliver reply data to any operation that returns directory status and volume 671 - * sync. 646 + * Deliver reply data to any operation that returns status and volume sync. 672 647 */ 673 - static int afs_deliver_fs_dir_status_and_vol(struct afs_call *call) 648 + static int afs_deliver_fs_file_status_and_vol(struct afs_call *call) 674 649 { 650 + struct afs_operation *op = call->op; 651 + struct afs_vnode_param *vp = &op->file[0]; 675 652 const __be32 *bp; 676 653 int ret; 677 654 ··· 659 680 660 681 /* unmarshall the reply once we've received all of it */ 661 682 bp = call->buffer; 662 - xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb); 663 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 683 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 684 + xdr_decode_AFSVolSync(&bp, &op->volsync); 664 685 665 686 _leave(" = 0 [done]"); 666 687 return 0; 667 688 } 668 689 669 690 /* 670 - * FS.RemoveDir/FS.RemoveFile operation type 691 + * FS.RemoveFile operation type 671 692 */ 672 693 static const struct afs_call_type afs_RXFSRemoveFile = { 673 694 .name = "FS.RemoveFile", 674 695 .op = afs_FS_RemoveFile, 675 - .deliver = afs_deliver_fs_dir_status_and_vol, 676 - .destructor = afs_flat_call_destructor, 677 - }; 678 - 679 - static const struct afs_call_type afs_RXFSRemoveDir = { 680 - .name = "FS.RemoveDir", 681 - .op = afs_FS_RemoveDir, 682 - .deliver = afs_deliver_fs_dir_status_and_vol, 696 + .deliver = afs_deliver_fs_file_status_and_vol, 683 697 .destructor = afs_flat_call_destructor, 684 698 }; 685 699 686 700 /* 687 - * remove a file or directory 701 + * Remove a file. 688 702 */ 689 - int afs_fs_remove(struct afs_operation *fc, struct afs_vnode *vnode, 690 - const char *name, bool isdir, struct afs_status_cb *dvnode_scb) 703 + void afs_fs_remove_file(struct afs_operation *op) 691 704 { 692 - struct afs_vnode *dvnode = fc->vnode; 705 + const struct qstr *name = &op->dentry->d_name; 706 + struct afs_vnode_param *dvp = &op->file[0]; 693 707 struct afs_call *call; 694 - struct afs_net *net = afs_v2net(dvnode); 695 708 size_t namesz, reqsz, padsz; 696 709 __be32 *bp; 697 710 698 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 699 - return yfs_fs_remove(fc, vnode, name, isdir, dvnode_scb); 700 - 701 711 _enter(""); 702 712 703 - namesz = strlen(name); 713 + namesz = name->len; 704 714 padsz = (4 - (namesz & 3)) & 3; 705 715 reqsz = (5 * 4) + namesz + padsz; 706 716 707 - call = afs_alloc_flat_call( 708 - net, isdir ? &afs_RXFSRemoveDir : &afs_RXFSRemoveFile, 709 - reqsz, (21 + 6) * 4); 717 + call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveFile, 718 + reqsz, (21 + 6) * 4); 710 719 if (!call) 711 - return -ENOMEM; 712 - 713 - call->key = fc->key; 714 - call->out_dir_scb = dvnode_scb; 720 + return afs_op_nomem(op); 715 721 716 722 /* marshall the parameters */ 717 723 bp = call->request; 718 - *bp++ = htonl(isdir ? FSREMOVEDIR : FSREMOVEFILE); 719 - *bp++ = htonl(dvnode->fid.vid); 720 - *bp++ = htonl(dvnode->fid.vnode); 721 - *bp++ = htonl(dvnode->fid.unique); 724 + *bp++ = htonl(FSREMOVEFILE); 725 + *bp++ = htonl(dvp->fid.vid); 726 + *bp++ = htonl(dvp->fid.vnode); 727 + *bp++ = htonl(dvp->fid.unique); 722 728 *bp++ = htonl(namesz); 723 - memcpy(bp, name, namesz); 729 + memcpy(bp, name->name, namesz); 724 730 bp = (void *) bp + namesz; 725 731 if (padsz > 0) { 726 732 memset(bp, 0, padsz); 727 733 bp = (void *) bp + padsz; 728 734 } 729 735 730 - afs_use_fs_server(call, fc->cbi); 731 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 732 - afs_set_fc_call(call, fc); 733 - afs_make_call(&fc->ac, call, GFP_NOFS); 734 - return afs_wait_for_call_to_complete(call, &fc->ac); 736 + trace_afs_make_fs_call1(call, &dvp->fid, name); 737 + afs_make_op_call(op, call, GFP_NOFS); 738 + } 739 + 740 + static const struct afs_call_type afs_RXFSRemoveDir = { 741 + .name = "FS.RemoveDir", 742 + .op = afs_FS_RemoveDir, 743 + .deliver = afs_deliver_fs_file_status_and_vol, 744 + .destructor = afs_flat_call_destructor, 745 + }; 746 + 747 + /* 748 + * Remove a directory. 749 + */ 750 + void afs_fs_remove_dir(struct afs_operation *op) 751 + { 752 + const struct qstr *name = &op->dentry->d_name; 753 + struct afs_vnode_param *dvp = &op->file[0]; 754 + struct afs_call *call; 755 + size_t namesz, reqsz, padsz; 756 + __be32 *bp; 757 + 758 + _enter(""); 759 + 760 + namesz = name->len; 761 + padsz = (4 - (namesz & 3)) & 3; 762 + reqsz = (5 * 4) + namesz + padsz; 763 + 764 + call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveDir, 765 + reqsz, (21 + 6) * 4); 766 + if (!call) 767 + return afs_op_nomem(op); 768 + 769 + /* marshall the parameters */ 770 + bp = call->request; 771 + *bp++ = htonl(FSREMOVEDIR); 772 + *bp++ = htonl(dvp->fid.vid); 773 + *bp++ = htonl(dvp->fid.vnode); 774 + *bp++ = htonl(dvp->fid.unique); 775 + *bp++ = htonl(namesz); 776 + memcpy(bp, name->name, namesz); 777 + bp = (void *) bp + namesz; 778 + if (padsz > 0) { 779 + memset(bp, 0, padsz); 780 + bp = (void *) bp + padsz; 781 + } 782 + 783 + trace_afs_make_fs_call1(call, &dvp->fid, name); 784 + afs_make_op_call(op, call, GFP_NOFS); 735 785 } 736 786 737 787 /* ··· 768 760 */ 769 761 static int afs_deliver_fs_link(struct afs_call *call) 770 762 { 763 + struct afs_operation *op = call->op; 764 + struct afs_vnode_param *dvp = &op->file[0]; 765 + struct afs_vnode_param *vp = &op->file[1]; 771 766 const __be32 *bp; 772 767 int ret; 773 768 ··· 782 771 783 772 /* unmarshall the reply once we've received all of it */ 784 773 bp = call->buffer; 785 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 786 - xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb); 787 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 774 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 775 + xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb); 776 + xdr_decode_AFSVolSync(&bp, &op->volsync); 788 777 789 778 _leave(" = 0 [done]"); 790 779 return 0; ··· 803 792 /* 804 793 * make a hard link 805 794 */ 806 - int afs_fs_link(struct afs_operation *fc, struct afs_vnode *vnode, 807 - const char *name, 808 - struct afs_status_cb *dvnode_scb, 809 - struct afs_status_cb *vnode_scb) 795 + void afs_fs_link(struct afs_operation *op) 810 796 { 811 - struct afs_vnode *dvnode = fc->vnode; 797 + const struct qstr *name = &op->dentry->d_name; 798 + struct afs_vnode_param *dvp = &op->file[0]; 799 + struct afs_vnode_param *vp = &op->file[1]; 812 800 struct afs_call *call; 813 - struct afs_net *net = afs_v2net(vnode); 814 801 size_t namesz, reqsz, padsz; 815 802 __be32 *bp; 816 803 817 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 818 - return yfs_fs_link(fc, vnode, name, dvnode_scb, vnode_scb); 819 - 820 804 _enter(""); 821 805 822 - namesz = strlen(name); 806 + namesz = name->len; 823 807 padsz = (4 - (namesz & 3)) & 3; 824 808 reqsz = (5 * 4) + namesz + padsz + (3 * 4); 825 809 826 - call = afs_alloc_flat_call(net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4); 810 + call = afs_alloc_flat_call(op->net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4); 827 811 if (!call) 828 - return -ENOMEM; 829 - 830 - call->key = fc->key; 831 - call->out_dir_scb = dvnode_scb; 832 - call->out_scb = vnode_scb; 812 + return afs_op_nomem(op); 833 813 834 814 /* marshall the parameters */ 835 815 bp = call->request; 836 816 *bp++ = htonl(FSLINK); 837 - *bp++ = htonl(dvnode->fid.vid); 838 - *bp++ = htonl(dvnode->fid.vnode); 839 - *bp++ = htonl(dvnode->fid.unique); 817 + *bp++ = htonl(dvp->fid.vid); 818 + *bp++ = htonl(dvp->fid.vnode); 819 + *bp++ = htonl(dvp->fid.unique); 840 820 *bp++ = htonl(namesz); 841 - memcpy(bp, name, namesz); 821 + memcpy(bp, name->name, namesz); 842 822 bp = (void *) bp + namesz; 843 823 if (padsz > 0) { 844 824 memset(bp, 0, padsz); 845 825 bp = (void *) bp + padsz; 846 826 } 847 - *bp++ = htonl(vnode->fid.vid); 848 - *bp++ = htonl(vnode->fid.vnode); 849 - *bp++ = htonl(vnode->fid.unique); 827 + *bp++ = htonl(vp->fid.vid); 828 + *bp++ = htonl(vp->fid.vnode); 829 + *bp++ = htonl(vp->fid.unique); 850 830 851 - afs_use_fs_server(call, fc->cbi); 852 - trace_afs_make_fs_call1(call, &vnode->fid, name); 853 - afs_set_fc_call(call, fc); 854 - afs_make_call(&fc->ac, call, GFP_NOFS); 855 - return afs_wait_for_call_to_complete(call, &fc->ac); 831 + trace_afs_make_fs_call1(call, &vp->fid, name); 832 + afs_make_op_call(op, call, GFP_NOFS); 856 833 } 857 834 858 835 /* ··· 848 849 */ 849 850 static int afs_deliver_fs_symlink(struct afs_call *call) 850 851 { 852 + struct afs_operation *op = call->op; 853 + struct afs_vnode_param *dvp = &op->file[0]; 854 + struct afs_vnode_param *vp = &op->file[1]; 851 855 const __be32 *bp; 852 856 int ret; 853 857 ··· 862 860 863 861 /* unmarshall the reply once we've received all of it */ 864 862 bp = call->buffer; 865 - xdr_decode_AFSFid(&bp, call->out_fid); 866 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 867 - xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb); 868 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 863 + xdr_decode_AFSFid(&bp, &vp->fid); 864 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 865 + xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb); 866 + xdr_decode_AFSVolSync(&bp, &op->volsync); 869 867 870 868 _leave(" = 0 [done]"); 871 869 return 0; ··· 884 882 /* 885 883 * create a symbolic link 886 884 */ 887 - int afs_fs_symlink(struct afs_operation *fc, 888 - const char *name, 889 - const char *contents, 890 - struct afs_status_cb *dvnode_scb, 891 - struct afs_fid *newfid, 892 - struct afs_status_cb *new_scb) 885 + void afs_fs_symlink(struct afs_operation *op) 893 886 { 894 - struct afs_vnode *dvnode = fc->vnode; 887 + const struct qstr *name = &op->dentry->d_name; 888 + struct afs_vnode_param *dvp = &op->file[0]; 895 889 struct afs_call *call; 896 - struct afs_net *net = afs_v2net(dvnode); 897 890 size_t namesz, reqsz, padsz, c_namesz, c_padsz; 898 891 __be32 *bp; 899 892 900 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 901 - return yfs_fs_symlink(fc, name, contents, dvnode_scb, 902 - newfid, new_scb); 903 - 904 893 _enter(""); 905 894 906 - namesz = strlen(name); 895 + namesz = name->len; 907 896 padsz = (4 - (namesz & 3)) & 3; 908 897 909 - c_namesz = strlen(contents); 898 + c_namesz = strlen(op->create.symlink); 910 899 c_padsz = (4 - (c_namesz & 3)) & 3; 911 900 912 901 reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4); 913 902 914 - call = afs_alloc_flat_call(net, &afs_RXFSSymlink, reqsz, 903 + call = afs_alloc_flat_call(op->net, &afs_RXFSSymlink, reqsz, 915 904 (3 + 21 + 21 + 6) * 4); 916 905 if (!call) 917 - return -ENOMEM; 918 - 919 - call->key = fc->key; 920 - call->out_dir_scb = dvnode_scb; 921 - call->out_fid = newfid; 922 - call->out_scb = new_scb; 906 + return afs_op_nomem(op); 923 907 924 908 /* marshall the parameters */ 925 909 bp = call->request; 926 910 *bp++ = htonl(FSSYMLINK); 927 - *bp++ = htonl(dvnode->fid.vid); 928 - *bp++ = htonl(dvnode->fid.vnode); 929 - *bp++ = htonl(dvnode->fid.unique); 911 + *bp++ = htonl(dvp->fid.vid); 912 + *bp++ = htonl(dvp->fid.vnode); 913 + *bp++ = htonl(dvp->fid.unique); 930 914 *bp++ = htonl(namesz); 931 - memcpy(bp, name, namesz); 915 + memcpy(bp, name->name, namesz); 932 916 bp = (void *) bp + namesz; 933 917 if (padsz > 0) { 934 918 memset(bp, 0, padsz); 935 919 bp = (void *) bp + padsz; 936 920 } 937 921 *bp++ = htonl(c_namesz); 938 - memcpy(bp, contents, c_namesz); 922 + memcpy(bp, op->create.symlink, c_namesz); 939 923 bp = (void *) bp + c_namesz; 940 924 if (c_padsz > 0) { 941 925 memset(bp, 0, c_padsz); 942 926 bp = (void *) bp + c_padsz; 943 927 } 944 928 *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME); 945 - *bp++ = htonl(dvnode->vfs_inode.i_mtime.tv_sec); /* mtime */ 929 + *bp++ = htonl(op->mtime.tv_sec); /* mtime */ 946 930 *bp++ = 0; /* owner */ 947 931 *bp++ = 0; /* group */ 948 932 *bp++ = htonl(S_IRWXUGO); /* unix mode */ 949 933 *bp++ = 0; /* segment size */ 950 934 951 - afs_use_fs_server(call, fc->cbi); 952 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 953 - afs_set_fc_call(call, fc); 954 - afs_make_call(&fc->ac, call, GFP_NOFS); 955 - return afs_wait_for_call_to_complete(call, &fc->ac); 935 + trace_afs_make_fs_call1(call, &dvp->fid, name); 936 + afs_make_op_call(op, call, GFP_NOFS); 956 937 } 957 938 958 939 /* ··· 943 958 */ 944 959 static int afs_deliver_fs_rename(struct afs_call *call) 945 960 { 961 + struct afs_operation *op = call->op; 962 + struct afs_vnode_param *orig_dvp = &op->file[0]; 963 + struct afs_vnode_param *new_dvp = &op->file[1]; 946 964 const __be32 *bp; 947 965 int ret; 948 966 ··· 957 969 /* If the two dirs are the same, we have two copies of the same status 958 970 * report, so we just decode it twice. 959 971 */ 960 - xdr_decode_AFSFetchStatus(&bp, call, call->out_dir_scb); 961 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 962 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 972 + xdr_decode_AFSFetchStatus(&bp, call, &orig_dvp->scb); 973 + xdr_decode_AFSFetchStatus(&bp, call, &new_dvp->scb); 974 + xdr_decode_AFSVolSync(&bp, &op->volsync); 963 975 964 976 _leave(" = 0 [done]"); 965 977 return 0; ··· 978 990 /* 979 991 * Rename/move a file or directory. 980 992 */ 981 - int afs_fs_rename(struct afs_operation *fc, 982 - const char *orig_name, 983 - struct afs_vnode *new_dvnode, 984 - const char *new_name, 985 - struct afs_status_cb *orig_dvnode_scb, 986 - struct afs_status_cb *new_dvnode_scb) 993 + void afs_fs_rename(struct afs_operation *op) 987 994 { 988 - struct afs_vnode *orig_dvnode = fc->vnode; 995 + struct afs_vnode_param *orig_dvp = &op->file[0]; 996 + struct afs_vnode_param *new_dvp = &op->file[1]; 997 + const struct qstr *orig_name = &op->dentry->d_name; 998 + const struct qstr *new_name = &op->dentry_2->d_name; 989 999 struct afs_call *call; 990 - struct afs_net *net = afs_v2net(orig_dvnode); 991 1000 size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz; 992 1001 __be32 *bp; 993 1002 994 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 995 - return yfs_fs_rename(fc, orig_name, 996 - new_dvnode, new_name, 997 - orig_dvnode_scb, 998 - new_dvnode_scb); 999 - 1000 1003 _enter(""); 1001 1004 1002 - o_namesz = strlen(orig_name); 1005 + o_namesz = orig_name->len; 1003 1006 o_padsz = (4 - (o_namesz & 3)) & 3; 1004 1007 1005 - n_namesz = strlen(new_name); 1008 + n_namesz = new_name->len; 1006 1009 n_padsz = (4 - (n_namesz & 3)) & 3; 1007 1010 1008 1011 reqsz = (4 * 4) + ··· 1001 1022 (3 * 4) + 1002 1023 4 + n_namesz + n_padsz; 1003 1024 1004 - call = afs_alloc_flat_call(net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4); 1025 + call = afs_alloc_flat_call(op->net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4); 1005 1026 if (!call) 1006 - return -ENOMEM; 1007 - 1008 - call->key = fc->key; 1009 - call->out_dir_scb = orig_dvnode_scb; 1010 - call->out_scb = new_dvnode_scb; 1027 + return afs_op_nomem(op); 1011 1028 1012 1029 /* marshall the parameters */ 1013 1030 bp = call->request; 1014 1031 *bp++ = htonl(FSRENAME); 1015 - *bp++ = htonl(orig_dvnode->fid.vid); 1016 - *bp++ = htonl(orig_dvnode->fid.vnode); 1017 - *bp++ = htonl(orig_dvnode->fid.unique); 1032 + *bp++ = htonl(orig_dvp->fid.vid); 1033 + *bp++ = htonl(orig_dvp->fid.vnode); 1034 + *bp++ = htonl(orig_dvp->fid.unique); 1018 1035 *bp++ = htonl(o_namesz); 1019 - memcpy(bp, orig_name, o_namesz); 1036 + memcpy(bp, orig_name->name, o_namesz); 1020 1037 bp = (void *) bp + o_namesz; 1021 1038 if (o_padsz > 0) { 1022 1039 memset(bp, 0, o_padsz); 1023 1040 bp = (void *) bp + o_padsz; 1024 1041 } 1025 1042 1026 - *bp++ = htonl(new_dvnode->fid.vid); 1027 - *bp++ = htonl(new_dvnode->fid.vnode); 1028 - *bp++ = htonl(new_dvnode->fid.unique); 1043 + *bp++ = htonl(new_dvp->fid.vid); 1044 + *bp++ = htonl(new_dvp->fid.vnode); 1045 + *bp++ = htonl(new_dvp->fid.unique); 1029 1046 *bp++ = htonl(n_namesz); 1030 - memcpy(bp, new_name, n_namesz); 1047 + memcpy(bp, new_name->name, n_namesz); 1031 1048 bp = (void *) bp + n_namesz; 1032 1049 if (n_padsz > 0) { 1033 1050 memset(bp, 0, n_padsz); 1034 1051 bp = (void *) bp + n_padsz; 1035 1052 } 1036 1053 1037 - afs_use_fs_server(call, fc->cbi); 1038 - trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name); 1039 - afs_set_fc_call(call, fc); 1040 - afs_make_call(&fc->ac, call, GFP_NOFS); 1041 - return afs_wait_for_call_to_complete(call, &fc->ac); 1054 + trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name); 1055 + afs_make_op_call(op, call, GFP_NOFS); 1042 1056 } 1043 1057 1044 1058 /* 1045 - * deliver reply data to an FS.StoreData 1059 + * Deliver reply data to FS.StoreData or FS.StoreStatus 1046 1060 */ 1047 1061 static int afs_deliver_fs_store_data(struct afs_call *call) 1048 1062 { 1063 + struct afs_operation *op = call->op; 1064 + struct afs_vnode_param *vp = &op->file[0]; 1049 1065 const __be32 *bp; 1050 1066 int ret; 1051 1067 ··· 1052 1078 1053 1079 /* unmarshall the reply once we've received all of it */ 1054 1080 bp = call->buffer; 1055 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 1056 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 1081 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 1082 + xdr_decode_AFSVolSync(&bp, &op->volsync); 1057 1083 1058 1084 _leave(" = 0 [done]"); 1059 1085 return 0; ··· 1079 1105 /* 1080 1106 * store a set of pages to a very large file 1081 1107 */ 1082 - static int afs_fs_store_data64(struct afs_operation *fc, 1083 - struct address_space *mapping, 1084 - pgoff_t first, pgoff_t last, 1085 - unsigned offset, unsigned to, 1086 - loff_t size, loff_t pos, loff_t i_size, 1087 - struct afs_status_cb *scb) 1108 + static void afs_fs_store_data64(struct afs_operation *op, 1109 + loff_t pos, loff_t size, loff_t i_size) 1088 1110 { 1089 - struct afs_vnode *vnode = fc->vnode; 1111 + struct afs_vnode_param *vp = &op->file[0]; 1090 1112 struct afs_call *call; 1091 - struct afs_net *net = afs_v2net(vnode); 1092 1113 __be32 *bp; 1093 1114 1094 1115 _enter(",%x,{%llx:%llu},,", 1095 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1116 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1096 1117 1097 - call = afs_alloc_flat_call(net, &afs_RXFSStoreData64, 1118 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64, 1098 1119 (4 + 6 + 3 * 2) * 4, 1099 1120 (21 + 6) * 4); 1100 1121 if (!call) 1101 - return -ENOMEM; 1122 + return afs_op_nomem(op); 1102 1123 1103 - call->key = fc->key; 1104 - call->mapping = mapping; 1105 - call->first = first; 1106 - call->last = last; 1107 - call->first_offset = offset; 1108 - call->last_to = to; 1109 1124 call->send_pages = true; 1110 - call->out_scb = scb; 1111 1125 1112 1126 /* marshall the parameters */ 1113 1127 bp = call->request; 1114 1128 *bp++ = htonl(FSSTOREDATA64); 1115 - *bp++ = htonl(vnode->fid.vid); 1116 - *bp++ = htonl(vnode->fid.vnode); 1117 - *bp++ = htonl(vnode->fid.unique); 1129 + *bp++ = htonl(vp->fid.vid); 1130 + *bp++ = htonl(vp->fid.vnode); 1131 + *bp++ = htonl(vp->fid.unique); 1118 1132 1119 1133 *bp++ = htonl(AFS_SET_MTIME); /* mask */ 1120 - *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */ 1134 + *bp++ = htonl(op->mtime.tv_sec); /* mtime */ 1121 1135 *bp++ = 0; /* owner */ 1122 1136 *bp++ = 0; /* group */ 1123 1137 *bp++ = 0; /* unix mode */ 1124 1138 *bp++ = 0; /* segment size */ 1125 1139 1126 - *bp++ = htonl(pos >> 32); 1127 - *bp++ = htonl((u32) pos); 1128 - *bp++ = htonl(size >> 32); 1129 - *bp++ = htonl((u32) size); 1130 - *bp++ = htonl(i_size >> 32); 1131 - *bp++ = htonl((u32) i_size); 1140 + *bp++ = htonl(upper_32_bits(pos)); 1141 + *bp++ = htonl(lower_32_bits(pos)); 1142 + *bp++ = htonl(upper_32_bits(size)); 1143 + *bp++ = htonl(lower_32_bits(size)); 1144 + *bp++ = htonl(upper_32_bits(i_size)); 1145 + *bp++ = htonl(lower_32_bits(i_size)); 1132 1146 1133 - trace_afs_make_fs_call(call, &vnode->fid); 1134 - afs_set_fc_call(call, fc); 1135 - afs_make_call(&fc->ac, call, GFP_NOFS); 1136 - return afs_wait_for_call_to_complete(call, &fc->ac); 1147 + trace_afs_make_fs_call(call, &vp->fid); 1148 + afs_make_op_call(op, call, GFP_NOFS); 1137 1149 } 1138 1150 1139 1151 /* 1140 1152 * store a set of pages 1141 1153 */ 1142 - int afs_fs_store_data(struct afs_operation *fc, struct address_space *mapping, 1143 - pgoff_t first, pgoff_t last, 1144 - unsigned offset, unsigned to, 1145 - struct afs_status_cb *scb) 1154 + void afs_fs_store_data(struct afs_operation *op) 1146 1155 { 1147 - struct afs_vnode *vnode = fc->vnode; 1156 + struct afs_vnode_param *vp = &op->file[0]; 1148 1157 struct afs_call *call; 1149 - struct afs_net *net = afs_v2net(vnode); 1150 1158 loff_t size, pos, i_size; 1151 1159 __be32 *bp; 1152 1160 1153 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1154 - return yfs_fs_store_data(fc, mapping, first, last, offset, to, scb); 1155 - 1156 1161 _enter(",%x,{%llx:%llu},,", 1157 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1162 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1158 1163 1159 - size = (loff_t)to - (loff_t)offset; 1160 - if (first != last) 1161 - size += (loff_t)(last - first) << PAGE_SHIFT; 1162 - pos = (loff_t)first << PAGE_SHIFT; 1163 - pos += offset; 1164 + size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset; 1165 + if (op->store.first != op->store.last) 1166 + size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT; 1167 + pos = (loff_t)op->store.first << PAGE_SHIFT; 1168 + pos += op->store.first_offset; 1164 1169 1165 - i_size = i_size_read(&vnode->vfs_inode); 1170 + i_size = i_size_read(&vp->vnode->vfs_inode); 1166 1171 if (pos + size > i_size) 1167 1172 i_size = size + pos; 1168 1173 ··· 1149 1196 (unsigned long long) size, (unsigned long long) pos, 1150 1197 (unsigned long long) i_size); 1151 1198 1152 - if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32) 1153 - return afs_fs_store_data64(fc, mapping, first, last, offset, to, 1154 - size, pos, i_size, scb); 1199 + if (upper_32_bits(pos) || upper_32_bits(i_size) || upper_32_bits(size) || 1200 + upper_32_bits(pos + size)) 1201 + return afs_fs_store_data64(op, pos, size, i_size); 1155 1202 1156 - call = afs_alloc_flat_call(net, &afs_RXFSStoreData, 1203 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData, 1157 1204 (4 + 6 + 3) * 4, 1158 1205 (21 + 6) * 4); 1159 1206 if (!call) 1160 - return -ENOMEM; 1207 + return afs_op_nomem(op); 1161 1208 1162 - call->key = fc->key; 1163 - call->mapping = mapping; 1164 - call->first = first; 1165 - call->last = last; 1166 - call->first_offset = offset; 1167 - call->last_to = to; 1168 1209 call->send_pages = true; 1169 - call->out_scb = scb; 1170 1210 1171 1211 /* marshall the parameters */ 1172 1212 bp = call->request; 1173 1213 *bp++ = htonl(FSSTOREDATA); 1174 - *bp++ = htonl(vnode->fid.vid); 1175 - *bp++ = htonl(vnode->fid.vnode); 1176 - *bp++ = htonl(vnode->fid.unique); 1214 + *bp++ = htonl(vp->fid.vid); 1215 + *bp++ = htonl(vp->fid.vnode); 1216 + *bp++ = htonl(vp->fid.unique); 1177 1217 1178 1218 *bp++ = htonl(AFS_SET_MTIME); /* mask */ 1179 - *bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */ 1219 + *bp++ = htonl(op->mtime.tv_sec); /* mtime */ 1180 1220 *bp++ = 0; /* owner */ 1181 1221 *bp++ = 0; /* group */ 1182 1222 *bp++ = 0; /* unix mode */ 1183 1223 *bp++ = 0; /* segment size */ 1184 1224 1185 - *bp++ = htonl(pos); 1186 - *bp++ = htonl(size); 1187 - *bp++ = htonl(i_size); 1225 + *bp++ = htonl(lower_32_bits(pos)); 1226 + *bp++ = htonl(lower_32_bits(size)); 1227 + *bp++ = htonl(lower_32_bits(i_size)); 1188 1228 1189 - afs_use_fs_server(call, fc->cbi); 1190 - trace_afs_make_fs_call(call, &vnode->fid); 1191 - afs_set_fc_call(call, fc); 1192 - afs_make_call(&fc->ac, call, GFP_NOFS); 1193 - return afs_wait_for_call_to_complete(call, &fc->ac); 1194 - } 1195 - 1196 - /* 1197 - * deliver reply data to an FS.StoreStatus 1198 - */ 1199 - static int afs_deliver_fs_store_status(struct afs_call *call) 1200 - { 1201 - const __be32 *bp; 1202 - int ret; 1203 - 1204 - _enter(""); 1205 - 1206 - ret = afs_transfer_reply(call); 1207 - if (ret < 0) 1208 - return ret; 1209 - 1210 - /* unmarshall the reply once we've received all of it */ 1211 - bp = call->buffer; 1212 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 1213 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 1214 - 1215 - _leave(" = 0 [done]"); 1216 - return 0; 1229 + trace_afs_make_fs_call(call, &vp->fid); 1230 + afs_make_op_call(op, call, GFP_NOFS); 1217 1231 } 1218 1232 1219 1233 /* ··· 1189 1269 static const struct afs_call_type afs_RXFSStoreStatus = { 1190 1270 .name = "FS.StoreStatus", 1191 1271 .op = afs_FS_StoreStatus, 1192 - .deliver = afs_deliver_fs_store_status, 1272 + .deliver = afs_deliver_fs_store_data, 1193 1273 .destructor = afs_flat_call_destructor, 1194 1274 }; 1195 1275 1196 1276 static const struct afs_call_type afs_RXFSStoreData_as_Status = { 1197 1277 .name = "FS.StoreData", 1198 1278 .op = afs_FS_StoreData, 1199 - .deliver = afs_deliver_fs_store_status, 1279 + .deliver = afs_deliver_fs_store_data, 1200 1280 .destructor = afs_flat_call_destructor, 1201 1281 }; 1202 1282 1203 1283 static const struct afs_call_type afs_RXFSStoreData64_as_Status = { 1204 1284 .name = "FS.StoreData64", 1205 1285 .op = afs_FS_StoreData64, 1206 - .deliver = afs_deliver_fs_store_status, 1286 + .deliver = afs_deliver_fs_store_data, 1207 1287 .destructor = afs_flat_call_destructor, 1208 1288 }; 1209 1289 ··· 1211 1291 * set the attributes on a very large file, using FS.StoreData rather than 1212 1292 * FS.StoreStatus so as to alter the file size also 1213 1293 */ 1214 - static int afs_fs_setattr_size64(struct afs_operation *fc, struct iattr *attr, 1215 - struct afs_status_cb *scb) 1294 + static void afs_fs_setattr_size64(struct afs_operation *op) 1216 1295 { 1217 - struct afs_vnode *vnode = fc->vnode; 1296 + struct afs_vnode_param *vp = &op->file[0]; 1218 1297 struct afs_call *call; 1219 - struct afs_net *net = afs_v2net(vnode); 1298 + struct iattr *attr = op->setattr.attr; 1220 1299 __be32 *bp; 1221 1300 1222 1301 _enter(",%x,{%llx:%llu},,", 1223 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1302 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1224 1303 1225 1304 ASSERT(attr->ia_valid & ATTR_SIZE); 1226 1305 1227 - call = afs_alloc_flat_call(net, &afs_RXFSStoreData64_as_Status, 1306 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64_as_Status, 1228 1307 (4 + 6 + 3 * 2) * 4, 1229 1308 (21 + 6) * 4); 1230 1309 if (!call) 1231 - return -ENOMEM; 1232 - 1233 - call->key = fc->key; 1234 - call->out_scb = scb; 1310 + return afs_op_nomem(op); 1235 1311 1236 1312 /* marshall the parameters */ 1237 1313 bp = call->request; 1238 1314 *bp++ = htonl(FSSTOREDATA64); 1239 - *bp++ = htonl(vnode->fid.vid); 1240 - *bp++ = htonl(vnode->fid.vnode); 1241 - *bp++ = htonl(vnode->fid.unique); 1315 + *bp++ = htonl(vp->fid.vid); 1316 + *bp++ = htonl(vp->fid.vnode); 1317 + *bp++ = htonl(vp->fid.unique); 1242 1318 1243 1319 xdr_encode_AFS_StoreStatus(&bp, attr); 1244 1320 1245 - *bp++ = htonl(attr->ia_size >> 32); /* position of start of write */ 1246 - *bp++ = htonl((u32) attr->ia_size); 1247 - *bp++ = 0; /* size of write */ 1321 + *bp++ = htonl(upper_32_bits(attr->ia_size)); /* position of start of write */ 1322 + *bp++ = htonl(lower_32_bits(attr->ia_size)); 1323 + *bp++ = 0; /* size of write */ 1248 1324 *bp++ = 0; 1249 - *bp++ = htonl(attr->ia_size >> 32); /* new file length */ 1250 - *bp++ = htonl((u32) attr->ia_size); 1325 + *bp++ = htonl(upper_32_bits(attr->ia_size)); /* new file length */ 1326 + *bp++ = htonl(lower_32_bits(attr->ia_size)); 1251 1327 1252 - afs_use_fs_server(call, fc->cbi); 1253 - trace_afs_make_fs_call(call, &vnode->fid); 1254 - afs_set_fc_call(call, fc); 1255 - afs_make_call(&fc->ac, call, GFP_NOFS); 1256 - return afs_wait_for_call_to_complete(call, &fc->ac); 1328 + trace_afs_make_fs_call(call, &vp->fid); 1329 + afs_make_op_call(op, call, GFP_NOFS); 1257 1330 } 1258 1331 1259 1332 /* 1260 1333 * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus 1261 1334 * so as to alter the file size also 1262 1335 */ 1263 - static int afs_fs_setattr_size(struct afs_operation *fc, struct iattr *attr, 1264 - struct afs_status_cb *scb) 1336 + static void afs_fs_setattr_size(struct afs_operation *op) 1265 1337 { 1266 - struct afs_vnode *vnode = fc->vnode; 1338 + struct afs_vnode_param *vp = &op->file[0]; 1267 1339 struct afs_call *call; 1268 - struct afs_net *net = afs_v2net(vnode); 1340 + struct iattr *attr = op->setattr.attr; 1269 1341 __be32 *bp; 1270 1342 1271 1343 _enter(",%x,{%llx:%llu},,", 1272 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1344 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1273 1345 1274 1346 ASSERT(attr->ia_valid & ATTR_SIZE); 1275 - if (attr->ia_size >> 32) 1276 - return afs_fs_setattr_size64(fc, attr, scb); 1347 + if (upper_32_bits(attr->ia_size)) 1348 + return afs_fs_setattr_size64(op); 1277 1349 1278 - call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status, 1350 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData_as_Status, 1279 1351 (4 + 6 + 3) * 4, 1280 1352 (21 + 6) * 4); 1281 1353 if (!call) 1282 - return -ENOMEM; 1283 - 1284 - call->key = fc->key; 1285 - call->out_scb = scb; 1354 + return afs_op_nomem(op); 1286 1355 1287 1356 /* marshall the parameters */ 1288 1357 bp = call->request; 1289 1358 *bp++ = htonl(FSSTOREDATA); 1290 - *bp++ = htonl(vnode->fid.vid); 1291 - *bp++ = htonl(vnode->fid.vnode); 1292 - *bp++ = htonl(vnode->fid.unique); 1359 + *bp++ = htonl(vp->fid.vid); 1360 + *bp++ = htonl(vp->fid.vnode); 1361 + *bp++ = htonl(vp->fid.unique); 1293 1362 1294 1363 xdr_encode_AFS_StoreStatus(&bp, attr); 1295 1364 ··· 1286 1377 *bp++ = 0; /* size of write */ 1287 1378 *bp++ = htonl(attr->ia_size); /* new file length */ 1288 1379 1289 - afs_use_fs_server(call, fc->cbi); 1290 - trace_afs_make_fs_call(call, &vnode->fid); 1291 - afs_set_fc_call(call, fc); 1292 - afs_make_call(&fc->ac, call, GFP_NOFS); 1293 - return afs_wait_for_call_to_complete(call, &fc->ac); 1380 + trace_afs_make_fs_call(call, &vp->fid); 1381 + afs_make_op_call(op, call, GFP_NOFS); 1294 1382 } 1295 1383 1296 1384 /* 1297 1385 * set the attributes on a file, using FS.StoreData if there's a change in file 1298 1386 * size, and FS.StoreStatus otherwise 1299 1387 */ 1300 - int afs_fs_setattr(struct afs_operation *fc, struct iattr *attr, 1301 - struct afs_status_cb *scb) 1388 + void afs_fs_setattr(struct afs_operation *op) 1302 1389 { 1303 - struct afs_vnode *vnode = fc->vnode; 1390 + struct afs_vnode_param *vp = &op->file[0]; 1304 1391 struct afs_call *call; 1305 - struct afs_net *net = afs_v2net(vnode); 1392 + struct iattr *attr = op->setattr.attr; 1306 1393 __be32 *bp; 1307 1394 1308 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1309 - return yfs_fs_setattr(fc, attr, scb); 1310 - 1311 1395 if (attr->ia_valid & ATTR_SIZE) 1312 - return afs_fs_setattr_size(fc, attr, scb); 1396 + return afs_fs_setattr_size(op); 1313 1397 1314 1398 _enter(",%x,{%llx:%llu},,", 1315 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1399 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1316 1400 1317 - call = afs_alloc_flat_call(net, &afs_RXFSStoreStatus, 1401 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreStatus, 1318 1402 (4 + 6) * 4, 1319 1403 (21 + 6) * 4); 1320 1404 if (!call) 1321 - return -ENOMEM; 1322 - 1323 - call->key = fc->key; 1324 - call->out_scb = scb; 1405 + return afs_op_nomem(op); 1325 1406 1326 1407 /* marshall the parameters */ 1327 1408 bp = call->request; 1328 1409 *bp++ = htonl(FSSTORESTATUS); 1329 - *bp++ = htonl(vnode->fid.vid); 1330 - *bp++ = htonl(vnode->fid.vnode); 1331 - *bp++ = htonl(vnode->fid.unique); 1410 + *bp++ = htonl(vp->fid.vid); 1411 + *bp++ = htonl(vp->fid.vnode); 1412 + *bp++ = htonl(vp->fid.unique); 1332 1413 1333 - xdr_encode_AFS_StoreStatus(&bp, attr); 1414 + xdr_encode_AFS_StoreStatus(&bp, op->setattr.attr); 1334 1415 1335 - afs_use_fs_server(call, fc->cbi); 1336 - trace_afs_make_fs_call(call, &vnode->fid); 1337 - afs_set_fc_call(call, fc); 1338 - afs_make_call(&fc->ac, call, GFP_NOFS); 1339 - return afs_wait_for_call_to_complete(call, &fc->ac); 1416 + trace_afs_make_fs_call(call, &vp->fid); 1417 + afs_make_op_call(op, call, GFP_NOFS); 1340 1418 } 1341 1419 1342 1420 /* ··· 1331 1435 */ 1332 1436 static int afs_deliver_fs_get_volume_status(struct afs_call *call) 1333 1437 { 1438 + struct afs_operation *op = call->op; 1334 1439 const __be32 *bp; 1335 1440 char *p; 1336 1441 u32 size; ··· 1353 1456 return ret; 1354 1457 1355 1458 bp = call->buffer; 1356 - xdr_decode_AFSFetchVolumeStatus(&bp, call->out_volstatus); 1459 + xdr_decode_AFSFetchVolumeStatus(&bp, &op->volstatus.vs); 1357 1460 call->unmarshall++; 1358 1461 afs_extract_to_tmp(call); 1359 1462 /* Fall through */ ··· 1466 1569 /* 1467 1570 * fetch the status of a volume 1468 1571 */ 1469 - int afs_fs_get_volume_status(struct afs_operation *fc, 1470 - struct afs_volume_status *vs) 1572 + void afs_fs_get_volume_status(struct afs_operation *op) 1471 1573 { 1472 - struct afs_vnode *vnode = fc->vnode; 1574 + struct afs_vnode_param *vp = &op->file[0]; 1473 1575 struct afs_call *call; 1474 - struct afs_net *net = afs_v2net(vnode); 1475 1576 __be32 *bp; 1476 - 1477 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1478 - return yfs_fs_get_volume_status(fc, vs); 1479 1577 1480 1578 _enter(""); 1481 1579 1482 - call = afs_alloc_flat_call(net, &afs_RXFSGetVolumeStatus, 2 * 4, 1580 + call = afs_alloc_flat_call(op->net, &afs_RXFSGetVolumeStatus, 2 * 4, 1483 1581 max(12 * 4, AFSOPAQUEMAX + 1)); 1484 1582 if (!call) 1485 - return -ENOMEM; 1486 - 1487 - call->key = fc->key; 1488 - call->out_volstatus = vs; 1583 + return afs_op_nomem(op); 1489 1584 1490 1585 /* marshall the parameters */ 1491 1586 bp = call->request; 1492 1587 bp[0] = htonl(FSGETVOLUMESTATUS); 1493 - bp[1] = htonl(vnode->fid.vid); 1588 + bp[1] = htonl(vp->fid.vid); 1494 1589 1495 - afs_use_fs_server(call, fc->cbi); 1496 - trace_afs_make_fs_call(call, &vnode->fid); 1497 - afs_set_fc_call(call, fc); 1498 - afs_make_call(&fc->ac, call, GFP_NOFS); 1499 - return afs_wait_for_call_to_complete(call, &fc->ac); 1590 + trace_afs_make_fs_call(call, &vp->fid); 1591 + afs_make_op_call(op, call, GFP_NOFS); 1500 1592 } 1501 1593 1502 1594 /* ··· 1493 1607 */ 1494 1608 static int afs_deliver_fs_xxxx_lock(struct afs_call *call) 1495 1609 { 1610 + struct afs_operation *op = call->op; 1496 1611 const __be32 *bp; 1497 1612 int ret; 1498 1613 ··· 1505 1618 1506 1619 /* unmarshall the reply once we've received all of it */ 1507 1620 bp = call->buffer; 1508 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 1621 + xdr_decode_AFSVolSync(&bp, &op->volsync); 1509 1622 1510 1623 _leave(" = 0 [done]"); 1511 1624 return 0; ··· 1546 1659 /* 1547 1660 * Set a lock on a file 1548 1661 */ 1549 - int afs_fs_set_lock(struct afs_operation *fc, afs_lock_type_t type, 1550 - struct afs_status_cb *scb) 1662 + void afs_fs_set_lock(struct afs_operation *op) 1551 1663 { 1552 - struct afs_vnode *vnode = fc->vnode; 1664 + struct afs_vnode_param *vp = &op->file[0]; 1553 1665 struct afs_call *call; 1554 - struct afs_net *net = afs_v2net(vnode); 1555 1666 __be32 *bp; 1556 - 1557 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1558 - return yfs_fs_set_lock(fc, type, scb); 1559 1667 1560 1668 _enter(""); 1561 1669 1562 - call = afs_alloc_flat_call(net, &afs_RXFSSetLock, 5 * 4, 6 * 4); 1670 + call = afs_alloc_flat_call(op->net, &afs_RXFSSetLock, 5 * 4, 6 * 4); 1563 1671 if (!call) 1564 - return -ENOMEM; 1565 - 1566 - call->key = fc->key; 1567 - call->lvnode = vnode; 1568 - call->out_scb = scb; 1672 + return afs_op_nomem(op); 1569 1673 1570 1674 /* marshall the parameters */ 1571 1675 bp = call->request; 1572 1676 *bp++ = htonl(FSSETLOCK); 1573 - *bp++ = htonl(vnode->fid.vid); 1574 - *bp++ = htonl(vnode->fid.vnode); 1575 - *bp++ = htonl(vnode->fid.unique); 1576 - *bp++ = htonl(type); 1677 + *bp++ = htonl(vp->fid.vid); 1678 + *bp++ = htonl(vp->fid.vnode); 1679 + *bp++ = htonl(vp->fid.unique); 1680 + *bp++ = htonl(op->lock.type); 1577 1681 1578 - afs_use_fs_server(call, fc->cbi); 1579 - trace_afs_make_fs_calli(call, &vnode->fid, type); 1580 - afs_set_fc_call(call, fc); 1581 - afs_make_call(&fc->ac, call, GFP_NOFS); 1582 - return afs_wait_for_call_to_complete(call, &fc->ac); 1682 + trace_afs_make_fs_calli(call, &vp->fid, op->lock.type); 1683 + afs_make_op_call(op, call, GFP_NOFS); 1583 1684 } 1584 1685 1585 1686 /* 1586 1687 * extend a lock on a file 1587 1688 */ 1588 - int afs_fs_extend_lock(struct afs_operation *fc, struct afs_status_cb *scb) 1689 + void afs_fs_extend_lock(struct afs_operation *op) 1589 1690 { 1590 - struct afs_vnode *vnode = fc->vnode; 1691 + struct afs_vnode_param *vp = &op->file[0]; 1591 1692 struct afs_call *call; 1592 - struct afs_net *net = afs_v2net(vnode); 1593 1693 __be32 *bp; 1594 - 1595 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1596 - return yfs_fs_extend_lock(fc, scb); 1597 1694 1598 1695 _enter(""); 1599 1696 1600 - call = afs_alloc_flat_call(net, &afs_RXFSExtendLock, 4 * 4, 6 * 4); 1697 + call = afs_alloc_flat_call(op->net, &afs_RXFSExtendLock, 4 * 4, 6 * 4); 1601 1698 if (!call) 1602 - return -ENOMEM; 1603 - 1604 - call->key = fc->key; 1605 - call->lvnode = vnode; 1606 - call->out_scb = scb; 1699 + return afs_op_nomem(op); 1607 1700 1608 1701 /* marshall the parameters */ 1609 1702 bp = call->request; 1610 1703 *bp++ = htonl(FSEXTENDLOCK); 1611 - *bp++ = htonl(vnode->fid.vid); 1612 - *bp++ = htonl(vnode->fid.vnode); 1613 - *bp++ = htonl(vnode->fid.unique); 1704 + *bp++ = htonl(vp->fid.vid); 1705 + *bp++ = htonl(vp->fid.vnode); 1706 + *bp++ = htonl(vp->fid.unique); 1614 1707 1615 - afs_use_fs_server(call, fc->cbi); 1616 - trace_afs_make_fs_call(call, &vnode->fid); 1617 - afs_set_fc_call(call, fc); 1618 - afs_make_call(&fc->ac, call, GFP_NOFS); 1619 - return afs_wait_for_call_to_complete(call, &fc->ac); 1708 + trace_afs_make_fs_call(call, &vp->fid); 1709 + afs_make_op_call(op, call, GFP_NOFS); 1620 1710 } 1621 1711 1622 1712 /* 1623 1713 * release a lock on a file 1624 1714 */ 1625 - int afs_fs_release_lock(struct afs_operation *fc, struct afs_status_cb *scb) 1715 + void afs_fs_release_lock(struct afs_operation *op) 1626 1716 { 1627 - struct afs_vnode *vnode = fc->vnode; 1717 + struct afs_vnode_param *vp = &op->file[0]; 1628 1718 struct afs_call *call; 1629 - struct afs_net *net = afs_v2net(vnode); 1630 1719 __be32 *bp; 1631 - 1632 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1633 - return yfs_fs_release_lock(fc, scb); 1634 1720 1635 1721 _enter(""); 1636 1722 1637 - call = afs_alloc_flat_call(net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4); 1723 + call = afs_alloc_flat_call(op->net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4); 1638 1724 if (!call) 1639 - return -ENOMEM; 1640 - 1641 - call->key = fc->key; 1642 - call->lvnode = vnode; 1643 - call->out_scb = scb; 1725 + return afs_op_nomem(op); 1644 1726 1645 1727 /* marshall the parameters */ 1646 1728 bp = call->request; 1647 1729 *bp++ = htonl(FSRELEASELOCK); 1648 - *bp++ = htonl(vnode->fid.vid); 1649 - *bp++ = htonl(vnode->fid.vnode); 1650 - *bp++ = htonl(vnode->fid.unique); 1730 + *bp++ = htonl(vp->fid.vid); 1731 + *bp++ = htonl(vp->fid.vnode); 1732 + *bp++ = htonl(vp->fid.unique); 1651 1733 1652 - afs_use_fs_server(call, fc->cbi); 1653 - trace_afs_make_fs_call(call, &vnode->fid); 1654 - afs_set_fc_call(call, fc); 1655 - afs_make_call(&fc->ac, call, GFP_NOFS); 1656 - return afs_wait_for_call_to_complete(call, &fc->ac); 1734 + trace_afs_make_fs_call(call, &vp->fid); 1735 + afs_make_op_call(op, call, GFP_NOFS); 1657 1736 } 1658 1737 1659 1738 /* ··· 1760 1907 } 1761 1908 1762 1909 /* 1763 - * Deliver reply data to an FS.FetchStatus with no vnode. 1764 - */ 1765 - static int afs_deliver_fs_fetch_status(struct afs_call *call) 1766 - { 1767 - const __be32 *bp; 1768 - int ret; 1769 - 1770 - ret = afs_transfer_reply(call); 1771 - if (ret < 0) 1772 - return ret; 1773 - 1774 - /* unmarshall the reply once we've received all of it */ 1775 - bp = call->buffer; 1776 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 1777 - xdr_decode_AFSCallBack(&bp, call, call->out_scb); 1778 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 1779 - 1780 - _leave(" = 0 [done]"); 1781 - return 0; 1782 - } 1783 - 1784 - /* 1785 - * FS.FetchStatus operation type 1786 - */ 1787 - static const struct afs_call_type afs_RXFSFetchStatus = { 1788 - .name = "FS.FetchStatus", 1789 - .op = afs_FS_FetchStatus, 1790 - .deliver = afs_deliver_fs_fetch_status, 1791 - .destructor = afs_flat_call_destructor, 1792 - }; 1793 - 1794 - /* 1795 - * Fetch the status information for a fid without needing a vnode handle. 1796 - */ 1797 - int afs_fs_fetch_status(struct afs_operation *fc, 1798 - struct afs_net *net, 1799 - struct afs_fid *fid, 1800 - struct afs_status_cb *scb, 1801 - struct afs_volsync *volsync) 1802 - { 1803 - struct afs_call *call; 1804 - __be32 *bp; 1805 - 1806 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1807 - return yfs_fs_fetch_status(fc, net, fid, scb, volsync); 1808 - 1809 - _enter(",%x,{%llx:%llu},,", 1810 - key_serial(fc->key), fid->vid, fid->vnode); 1811 - 1812 - call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus, 16, (21 + 3 + 6) * 4); 1813 - if (!call) { 1814 - fc->ac.error = -ENOMEM; 1815 - return -ENOMEM; 1816 - } 1817 - 1818 - call->key = fc->key; 1819 - call->out_fid = fid; 1820 - call->out_scb = scb; 1821 - call->out_volsync = volsync; 1822 - 1823 - /* marshall the parameters */ 1824 - bp = call->request; 1825 - bp[0] = htonl(FSFETCHSTATUS); 1826 - bp[1] = htonl(fid->vid); 1827 - bp[2] = htonl(fid->vnode); 1828 - bp[3] = htonl(fid->unique); 1829 - 1830 - afs_use_fs_server(call, fc->cbi); 1831 - trace_afs_make_fs_call(call, fid); 1832 - afs_set_fc_call(call, fc); 1833 - afs_make_call(&fc->ac, call, GFP_NOFS); 1834 - return afs_wait_for_call_to_complete(call, &fc->ac); 1835 - } 1836 - 1837 - /* 1838 1910 * Deliver reply data to an FS.InlineBulkStatus call 1839 1911 */ 1840 1912 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call) 1841 1913 { 1914 + struct afs_operation *op = call->op; 1842 1915 struct afs_status_cb *scb; 1843 1916 const __be32 *bp; 1844 1917 u32 tmp; ··· 1786 2007 return ret; 1787 2008 1788 2009 tmp = ntohl(call->tmp); 1789 - _debug("status count: %u/%u", tmp, call->count2); 1790 - if (tmp != call->count2) 2010 + _debug("status count: %u/%u", tmp, op->nr_files); 2011 + if (tmp != op->nr_files) 1791 2012 return afs_protocol_error(call, afs_eproto_ibulkst_count); 1792 2013 1793 2014 call->count = 0; ··· 1802 2023 if (ret < 0) 1803 2024 return ret; 1804 2025 2026 + switch (call->count) { 2027 + case 0: 2028 + scb = &op->file[0].scb; 2029 + break; 2030 + case 1: 2031 + scb = &op->file[1].scb; 2032 + break; 2033 + default: 2034 + scb = &op->more_files[call->count - 2].scb; 2035 + break; 2036 + } 2037 + 1805 2038 bp = call->buffer; 1806 - scb = &call->out_scb[call->count]; 1807 2039 xdr_decode_AFSFetchStatus(&bp, call, scb); 2040 + 1808 2041 call->count++; 1809 - if (call->count < call->count2) 2042 + if (call->count < op->nr_files) 1810 2043 goto more_counts; 1811 2044 1812 2045 call->count = 0; ··· 1835 2044 1836 2045 tmp = ntohl(call->tmp); 1837 2046 _debug("CB count: %u", tmp); 1838 - if (tmp != call->count2) 2047 + if (tmp != op->nr_files) 1839 2048 return afs_protocol_error(call, afs_eproto_ibulkst_cb_count); 1840 2049 call->count = 0; 1841 2050 call->unmarshall++; ··· 1850 2059 return ret; 1851 2060 1852 2061 _debug("unmarshall CB array"); 2062 + switch (call->count) { 2063 + case 0: 2064 + scb = &op->file[0].scb; 2065 + break; 2066 + case 1: 2067 + scb = &op->file[1].scb; 2068 + break; 2069 + default: 2070 + scb = &op->more_files[call->count - 2].scb; 2071 + break; 2072 + } 2073 + 1853 2074 bp = call->buffer; 1854 - scb = &call->out_scb[call->count]; 1855 2075 xdr_decode_AFSCallBack(&bp, call, scb); 1856 2076 call->count++; 1857 - if (call->count < call->count2) 2077 + if (call->count < op->nr_files) 1858 2078 goto more_cbs; 1859 2079 1860 2080 afs_extract_to_buf(call, 6 * sizeof(__be32)); ··· 1878 2076 return ret; 1879 2077 1880 2078 bp = call->buffer; 1881 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 2079 + xdr_decode_AFSVolSync(&bp, &op->volsync); 1882 2080 1883 2081 call->unmarshall++; 1884 2082 ··· 1890 2088 return 0; 1891 2089 } 1892 2090 2091 + static void afs_done_fs_inline_bulk_status(struct afs_call *call) 2092 + { 2093 + if (call->error == -ECONNABORTED && 2094 + call->abort_code == RX_INVALID_OPERATION) 2095 + set_bit(AFS_SERVER_FL_NO_IBULK, &call->server->flags); 2096 + } 2097 + 1893 2098 /* 1894 2099 * FS.InlineBulkStatus operation type 1895 2100 */ ··· 1904 2095 .name = "FS.InlineBulkStatus", 1905 2096 .op = afs_FS_InlineBulkStatus, 1906 2097 .deliver = afs_deliver_fs_inline_bulk_status, 2098 + .done = afs_done_fs_inline_bulk_status, 1907 2099 .destructor = afs_flat_call_destructor, 1908 2100 }; 1909 2101 1910 2102 /* 1911 2103 * Fetch the status information for up to 50 files 1912 2104 */ 1913 - int afs_fs_inline_bulk_status(struct afs_operation *fc, 1914 - struct afs_net *net, 1915 - struct afs_fid *fids, 1916 - struct afs_status_cb *statuses, 1917 - unsigned int nr_fids, 1918 - struct afs_volsync *volsync) 2105 + void afs_fs_inline_bulk_status(struct afs_operation *op) 1919 2106 { 2107 + struct afs_vnode_param *dvp = &op->file[0]; 2108 + struct afs_vnode_param *vp = &op->file[1]; 1920 2109 struct afs_call *call; 1921 2110 __be32 *bp; 1922 2111 int i; 1923 2112 1924 - if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)) 1925 - return yfs_fs_inline_bulk_status(fc, net, fids, statuses, 1926 - nr_fids, volsync); 1927 - 1928 - _enter(",%x,{%llx:%llu},%u", 1929 - key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids); 1930 - 1931 - call = afs_alloc_flat_call(net, &afs_RXFSInlineBulkStatus, 1932 - (2 + nr_fids * 3) * 4, 1933 - 21 * 4); 1934 - if (!call) { 1935 - fc->ac.error = -ENOMEM; 1936 - return -ENOMEM; 2113 + if (test_bit(AFS_SERVER_FL_NO_IBULK, &op->cbi->server->flags)) { 2114 + op->error = -ENOTSUPP; 2115 + return; 1937 2116 } 1938 2117 1939 - call->key = fc->key; 1940 - call->out_scb = statuses; 1941 - call->out_volsync = volsync; 1942 - call->count2 = nr_fids; 2118 + _enter(",%x,{%llx:%llu},%u", 2119 + key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files); 2120 + 2121 + call = afs_alloc_flat_call(op->net, &afs_RXFSInlineBulkStatus, 2122 + (2 + op->nr_files * 3) * 4, 2123 + 21 * 4); 2124 + if (!call) 2125 + return afs_op_nomem(op); 1943 2126 1944 2127 /* marshall the parameters */ 1945 2128 bp = call->request; 1946 2129 *bp++ = htonl(FSINLINEBULKSTATUS); 1947 - *bp++ = htonl(nr_fids); 1948 - for (i = 0; i < nr_fids; i++) { 1949 - *bp++ = htonl(fids[i].vid); 1950 - *bp++ = htonl(fids[i].vnode); 1951 - *bp++ = htonl(fids[i].unique); 2130 + *bp++ = htonl(op->nr_files); 2131 + *bp++ = htonl(dvp->fid.vid); 2132 + *bp++ = htonl(dvp->fid.vnode); 2133 + *bp++ = htonl(dvp->fid.unique); 2134 + *bp++ = htonl(vp->fid.vid); 2135 + *bp++ = htonl(vp->fid.vnode); 2136 + *bp++ = htonl(vp->fid.unique); 2137 + for (i = 0; i < op->nr_files - 2; i++) { 2138 + *bp++ = htonl(op->more_files[i].fid.vid); 2139 + *bp++ = htonl(op->more_files[i].fid.vnode); 2140 + *bp++ = htonl(op->more_files[i].fid.unique); 1952 2141 } 1953 2142 1954 - afs_use_fs_server(call, fc->cbi); 1955 - trace_afs_make_fs_call(call, &fids[0]); 1956 - afs_set_fc_call(call, fc); 1957 - afs_make_call(&fc->ac, call, GFP_NOFS); 1958 - return afs_wait_for_call_to_complete(call, &fc->ac); 2143 + trace_afs_make_fs_call(call, &vp->fid); 2144 + afs_make_op_call(op, call, GFP_NOFS); 1959 2145 } 1960 2146 1961 2147 /* ··· 1958 2154 */ 1959 2155 static int afs_deliver_fs_fetch_acl(struct afs_call *call) 1960 2156 { 2157 + struct afs_operation *op = call->op; 2158 + struct afs_vnode_param *vp = &op->file[0]; 1961 2159 struct afs_acl *acl; 1962 2160 const __be32 *bp; 1963 2161 unsigned int size; ··· 1985 2179 acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL); 1986 2180 if (!acl) 1987 2181 return -ENOMEM; 1988 - call->ret_acl = acl; 2182 + op->acl = acl; 1989 2183 acl->size = call->count2; 1990 2184 afs_extract_begin(call, acl->data, size); 1991 2185 call->unmarshall++; ··· 2008 2202 return ret; 2009 2203 2010 2204 bp = call->buffer; 2011 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 2012 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 2205 + xdr_decode_AFSFetchStatus(&bp, call, &vp->scb); 2206 + xdr_decode_AFSVolSync(&bp, &op->volsync); 2013 2207 2014 2208 call->unmarshall++; 2015 2209 ··· 2021 2215 return 0; 2022 2216 } 2023 2217 2024 - static void afs_destroy_fs_fetch_acl(struct afs_call *call) 2025 - { 2026 - kfree(call->ret_acl); 2027 - afs_flat_call_destructor(call); 2028 - } 2029 - 2030 2218 /* 2031 2219 * FS.FetchACL operation type 2032 2220 */ ··· 2028 2228 .name = "FS.FetchACL", 2029 2229 .op = afs_FS_FetchACL, 2030 2230 .deliver = afs_deliver_fs_fetch_acl, 2031 - .destructor = afs_destroy_fs_fetch_acl, 2032 2231 }; 2033 2232 2034 2233 /* 2035 2234 * Fetch the ACL for a file. 2036 2235 */ 2037 - struct afs_acl *afs_fs_fetch_acl(struct afs_operation *fc, 2038 - struct afs_status_cb *scb) 2236 + void afs_fs_fetch_acl(struct afs_operation *op) 2039 2237 { 2040 - struct afs_vnode *vnode = fc->vnode; 2238 + struct afs_vnode_param *vp = &op->file[0]; 2041 2239 struct afs_call *call; 2042 - struct afs_net *net = afs_v2net(vnode); 2043 2240 __be32 *bp; 2044 2241 2045 2242 _enter(",%x,{%llx:%llu},,", 2046 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 2243 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 2047 2244 2048 - call = afs_alloc_flat_call(net, &afs_RXFSFetchACL, 16, (21 + 6) * 4); 2049 - if (!call) { 2050 - fc->ac.error = -ENOMEM; 2051 - return ERR_PTR(-ENOMEM); 2052 - } 2053 - 2054 - call->key = fc->key; 2055 - call->ret_acl = NULL; 2056 - call->out_scb = scb; 2057 - call->out_volsync = NULL; 2245 + call = afs_alloc_flat_call(op->net, &afs_RXFSFetchACL, 16, (21 + 6) * 4); 2246 + if (!call) 2247 + return afs_op_nomem(op); 2058 2248 2059 2249 /* marshall the parameters */ 2060 2250 bp = call->request; 2061 2251 bp[0] = htonl(FSFETCHACL); 2062 - bp[1] = htonl(vnode->fid.vid); 2063 - bp[2] = htonl(vnode->fid.vnode); 2064 - bp[3] = htonl(vnode->fid.unique); 2252 + bp[1] = htonl(vp->fid.vid); 2253 + bp[2] = htonl(vp->fid.vnode); 2254 + bp[3] = htonl(vp->fid.unique); 2065 2255 2066 - afs_use_fs_server(call, fc->cbi); 2067 - trace_afs_make_fs_call(call, &vnode->fid); 2068 - afs_make_call(&fc->ac, call, GFP_KERNEL); 2069 - return (struct afs_acl *)afs_wait_for_call_to_complete(call, &fc->ac); 2070 - } 2071 - 2072 - /* 2073 - * Deliver reply data to any operation that returns file status and volume 2074 - * sync. 2075 - */ 2076 - static int afs_deliver_fs_file_status_and_vol(struct afs_call *call) 2077 - { 2078 - const __be32 *bp; 2079 - int ret; 2080 - 2081 - ret = afs_transfer_reply(call); 2082 - if (ret < 0) 2083 - return ret; 2084 - 2085 - bp = call->buffer; 2086 - xdr_decode_AFSFetchStatus(&bp, call, call->out_scb); 2087 - xdr_decode_AFSVolSync(&bp, call->out_volsync); 2088 - 2089 - _leave(" = 0 [done]"); 2090 - return 0; 2256 + trace_afs_make_fs_call(call, &vp->fid); 2257 + afs_make_op_call(op, call, GFP_KERNEL); 2091 2258 } 2092 2259 2093 2260 /* ··· 2070 2303 /* 2071 2304 * Fetch the ACL for a file. 2072 2305 */ 2073 - int afs_fs_store_acl(struct afs_operation *fc, const struct afs_acl *acl, 2074 - struct afs_status_cb *scb) 2306 + void afs_fs_store_acl(struct afs_operation *op) 2075 2307 { 2076 - struct afs_vnode *vnode = fc->vnode; 2308 + struct afs_vnode_param *vp = &op->file[0]; 2077 2309 struct afs_call *call; 2078 - struct afs_net *net = afs_v2net(vnode); 2310 + const struct afs_acl *acl = op->acl; 2079 2311 size_t size; 2080 2312 __be32 *bp; 2081 2313 2082 2314 _enter(",%x,{%llx:%llu},,", 2083 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 2315 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 2084 2316 2085 2317 size = round_up(acl->size, 4); 2086 - call = afs_alloc_flat_call(net, &afs_RXFSStoreACL, 2318 + call = afs_alloc_flat_call(op->net, &afs_RXFSStoreACL, 2087 2319 5 * 4 + size, (21 + 6) * 4); 2088 - if (!call) { 2089 - fc->ac.error = -ENOMEM; 2090 - return -ENOMEM; 2091 - } 2092 - 2093 - call->key = fc->key; 2094 - call->out_scb = scb; 2095 - call->out_volsync = NULL; 2320 + if (!call) 2321 + return afs_op_nomem(op); 2096 2322 2097 2323 /* marshall the parameters */ 2098 2324 bp = call->request; 2099 2325 bp[0] = htonl(FSSTOREACL); 2100 - bp[1] = htonl(vnode->fid.vid); 2101 - bp[2] = htonl(vnode->fid.vnode); 2102 - bp[3] = htonl(vnode->fid.unique); 2326 + bp[1] = htonl(vp->fid.vid); 2327 + bp[2] = htonl(vp->fid.vnode); 2328 + bp[3] = htonl(vp->fid.unique); 2103 2329 bp[4] = htonl(acl->size); 2104 2330 memcpy(&bp[5], acl->data, acl->size); 2105 2331 if (acl->size != size) 2106 2332 memset((void *)&bp[5] + acl->size, 0, size - acl->size); 2107 2333 2108 - trace_afs_make_fs_call(call, &vnode->fid); 2109 - afs_make_call(&fc->ac, call, GFP_KERNEL); 2110 - return afs_wait_for_call_to_complete(call, &fc->ac); 2334 + trace_afs_make_fs_call(call, &vp->fid); 2335 + afs_make_op_call(op, call, GFP_KERNEL); 2111 2336 }
+207 -241
fs/afs/inode.c
··· 67 67 /* 68 68 * Initialise an inode from the vnode status. 69 69 */ 70 - static int afs_inode_init_from_status(struct afs_vnode *vnode, struct key *key, 71 - struct afs_cb_interest *cbi, 72 - struct afs_vnode *parent_vnode, 73 - struct afs_status_cb *scb) 70 + static int afs_inode_init_from_status(struct afs_operation *op, 71 + struct afs_vnode_param *vp, 72 + struct afs_vnode *vnode) 74 73 { 75 74 struct afs_cb_interest *old_cbi = NULL; 76 - struct afs_file_status *status = &scb->status; 75 + struct afs_file_status *status = &vp->scb.status; 77 76 struct inode *inode = AFS_VNODE_TO_I(vnode); 78 77 struct timespec64 t; 78 + 79 + _enter("{%llx:%llu.%u} %s", 80 + vp->fid.vid, vp->fid.vnode, vp->fid.unique, 81 + op->type ? op->type->name : "???"); 79 82 80 83 _debug("FS: ft=%d lk=%d sz=%llu ver=%Lu mod=%hu", 81 84 status->type, ··· 89 86 90 87 write_seqlock(&vnode->cb_lock); 91 88 89 + vnode->cb_v_break = op->cb_v_break; 90 + vnode->cb_s_break = op->cb_s_break; 92 91 vnode->status = *status; 93 92 94 93 t = status->mtime_client; 95 94 inode->i_ctime = t; 96 95 inode->i_mtime = t; 97 96 inode->i_atime = t; 97 + inode->i_flags |= S_NOATIME; 98 98 inode->i_uid = make_kuid(&init_user_ns, status->owner); 99 99 inode->i_gid = make_kgid(&init_user_ns, status->group); 100 100 set_nlink(&vnode->vfs_inode, status->nlink); ··· 134 128 inode_nohighmem(inode); 135 129 break; 136 130 default: 137 - dump_vnode(vnode, parent_vnode); 131 + dump_vnode(vnode, op->file[0].vnode != vnode ? op->file[0].vnode : NULL); 138 132 write_sequnlock(&vnode->cb_lock); 139 133 return afs_protocol_error(NULL, afs_eproto_file_type); 140 134 } ··· 144 138 vnode->invalid_before = status->data_version; 145 139 inode_set_iversion_raw(&vnode->vfs_inode, status->data_version); 146 140 147 - if (!scb->have_cb) { 141 + if (!vp->scb.have_cb) { 148 142 /* it's a symlink we just created (the fileserver 149 143 * didn't give us a callback) */ 150 144 vnode->cb_expires_at = ktime_get_real_seconds(); 151 145 } else { 152 - vnode->cb_expires_at = scb->callback.expires_at; 146 + vnode->cb_expires_at = vp->scb.callback.expires_at; 153 147 old_cbi = rcu_dereference_protected(vnode->cb_interest, 154 148 lockdep_is_held(&vnode->cb_lock.lock)); 155 - if (cbi != old_cbi) 156 - rcu_assign_pointer(vnode->cb_interest, afs_get_cb_interest(cbi)); 149 + if (op->cbi != old_cbi) 150 + rcu_assign_pointer(vnode->cb_interest, 151 + afs_get_cb_interest(op->cbi)); 157 152 else 158 153 old_cbi = NULL; 159 154 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); ··· 168 161 /* 169 162 * Update the core inode struct from a returned status record. 170 163 */ 171 - static void afs_apply_status(struct afs_operation *fc, 172 - struct afs_vnode *vnode, 173 - struct afs_status_cb *scb, 174 - const afs_dataversion_t *expected_version) 164 + static void afs_apply_status(struct afs_operation *op, 165 + struct afs_vnode_param *vp) 175 166 { 176 - struct afs_file_status *status = &scb->status; 167 + struct afs_file_status *status = &vp->scb.status; 168 + struct afs_vnode *vnode = vp->vnode; 177 169 struct timespec64 t; 178 170 umode_t mode; 179 171 bool data_changed = false; 172 + 173 + _enter("{%llx:%llu.%u} %s", 174 + vp->fid.vid, vp->fid.vnode, vp->fid.unique, 175 + op->type ? op->type->name : "???"); 180 176 181 177 BUG_ON(test_bit(AFS_VNODE_UNSET, &vnode->flags)); 182 178 ··· 219 209 220 210 vnode->status = *status; 221 211 222 - if (expected_version && 223 - *expected_version != status->data_version) { 212 + if (vp->dv_before + vp->dv_delta != status->data_version) { 224 213 if (test_bit(AFS_VNODE_CB_PROMISED, &vnode->flags)) 225 214 pr_warn("kAFS: vnode modified {%llx:%llu} %llx->%llx %s\n", 226 215 vnode->fid.vid, vnode->fid.vnode, 227 - (unsigned long long)*expected_version, 216 + (unsigned long long)vp->dv_before + vp->dv_delta, 228 217 (unsigned long long)status->data_version, 229 - fc->type ? fc->type->name : "???"); 218 + op->type ? op->type->name : "???"); 230 219 231 220 vnode->invalid_before = status->data_version; 232 221 if (vnode->status.type == AFS_FTYPE_DIR) { ··· 252 243 /* 253 244 * Apply a callback to a vnode. 254 245 */ 255 - static void afs_apply_callback(struct afs_operation *fc, 256 - struct afs_vnode *vnode, 257 - struct afs_status_cb *scb, 258 - unsigned int cb_break) 246 + static void afs_apply_callback(struct afs_operation *op, 247 + struct afs_vnode_param *vp) 259 248 { 260 249 struct afs_cb_interest *old; 261 - struct afs_callback *cb = &scb->callback; 250 + struct afs_callback *cb = &vp->scb.callback; 251 + struct afs_vnode *vnode = vp->vnode; 262 252 263 - if (!afs_cb_is_broken(cb_break, vnode, fc->cbi)) { 253 + if (!afs_cb_is_broken(vp->cb_break_before, vnode, op->cbi)) { 264 254 vnode->cb_expires_at = cb->expires_at; 265 255 old = rcu_dereference_protected(vnode->cb_interest, 266 256 lockdep_is_held(&vnode->cb_lock.lock)); 267 - if (old != fc->cbi) { 268 - rcu_assign_pointer(vnode->cb_interest, afs_get_cb_interest(fc->cbi)); 257 + if (old != op->cbi) { 258 + rcu_assign_pointer(vnode->cb_interest, afs_get_cb_interest(op->cbi)); 269 259 afs_put_cb_interest(afs_v2net(vnode), old); 270 260 } 271 261 set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags); ··· 275 267 * Apply the received status and callback to an inode all in the same critical 276 268 * section to avoid races with afs_validate(). 277 269 */ 278 - void afs_vnode_commit_status(struct afs_operation *fc, 279 - struct afs_vnode *vnode, 280 - unsigned int cb_break, 281 - const afs_dataversion_t *expected_version, 282 - struct afs_status_cb *scb) 270 + void afs_vnode_commit_status(struct afs_operation *op, struct afs_vnode_param *vp) 283 271 { 284 - if (fc->ac.error != 0) 285 - return; 272 + struct afs_vnode *vnode = vp->vnode; 273 + 274 + _enter(""); 275 + 276 + ASSERTCMP(op->error, ==, 0); 286 277 287 278 write_seqlock(&vnode->cb_lock); 288 279 289 - if (scb->have_error) { 290 - if (scb->status.abort_code == VNOVNODE) { 280 + if (vp->scb.have_error) { 281 + if (vp->scb.status.abort_code == VNOVNODE) { 291 282 set_bit(AFS_VNODE_DELETED, &vnode->flags); 292 283 clear_nlink(&vnode->vfs_inode); 293 284 __afs_break_callback(vnode, afs_cb_break_for_deleted); 294 285 } 295 286 } else { 296 - if (scb->have_status) 297 - afs_apply_status(fc, vnode, scb, expected_version); 298 - if (scb->have_cb) 299 - afs_apply_callback(fc, vnode, scb, cb_break); 287 + if (vp->scb.have_status) 288 + afs_apply_status(op, vp); 289 + if (vp->scb.have_cb) 290 + afs_apply_callback(op, vp); 300 291 } 301 292 302 293 write_sequnlock(&vnode->cb_lock); 303 294 304 - if (fc->ac.error == 0 && scb->have_status) 305 - afs_cache_permit(vnode, fc->key, cb_break, scb); 295 + if (op->error == 0 && vp->scb.have_status) 296 + afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb); 306 297 } 298 + 299 + static void afs_fetch_status_success(struct afs_operation *op) 300 + { 301 + struct afs_vnode_param *vp = &op->file[0]; 302 + struct afs_vnode *vnode = vp->vnode; 303 + int ret; 304 + 305 + if (vnode->vfs_inode.i_state & I_NEW) { 306 + ret = afs_inode_init_from_status(op, vp, vnode); 307 + op->error = ret; 308 + if (ret == 0) 309 + afs_cache_permit(vnode, op->key, vp->cb_break_before, &vp->scb); 310 + } else { 311 + afs_vnode_commit_status(op, vp); 312 + } 313 + } 314 + 315 + static const struct afs_operation_ops afs_fetch_status_operation = { 316 + .issue_afs_rpc = afs_fs_fetch_status, 317 + .issue_yfs_rpc = yfs_fs_fetch_status, 318 + .success = afs_fetch_status_success, 319 + }; 307 320 308 321 /* 309 322 * Fetch file status from the volume. ··· 332 303 int afs_fetch_status(struct afs_vnode *vnode, struct key *key, bool is_new, 333 304 afs_access_t *_caller_access) 334 305 { 335 - struct afs_status_cb *scb; 336 - struct afs_operation fc; 337 - int ret; 306 + struct afs_operation *op; 338 307 339 308 _enter("%s,{%llx:%llu.%u,S=%lx}", 340 309 vnode->volume->name, 341 310 vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique, 342 311 vnode->flags); 343 312 344 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 345 - if (!scb) 346 - return -ENOMEM; 313 + op = afs_alloc_operation(key, vnode->volume); 314 + if (IS_ERR(op)) 315 + return PTR_ERR(op); 347 316 348 - ret = -ERESTARTSYS; 349 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 350 - afs_dataversion_t data_version = vnode->status.data_version; 317 + afs_op_set_vnode(op, 0, vnode); 351 318 352 - while (afs_select_fileserver(&fc)) { 353 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 354 - afs_fs_fetch_file_status(&fc, scb, NULL); 355 - } 319 + op->nr_files = 1; 320 + op->ops = &afs_fetch_status_operation; 321 + afs_begin_vnode_operation(op); 322 + afs_wait_for_operation(op); 356 323 357 - if (fc.error) { 358 - /* Do nothing. */ 359 - } else if (is_new) { 360 - ret = afs_inode_init_from_status(vnode, key, fc.cbi, 361 - NULL, scb); 362 - fc.error = ret; 363 - if (ret == 0) 364 - afs_cache_permit(vnode, key, fc.cb_break, scb); 365 - } else { 366 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 367 - &data_version, scb); 368 - } 369 - afs_check_for_remote_deletion(&fc, vnode); 370 - ret = afs_end_vnode_operation(&fc); 371 - } 324 + if (_caller_access) 325 + *_caller_access = op->file[0].scb.status.caller_access; 326 + return afs_put_operation(op); 327 + } 372 328 373 - if (ret == 0 && _caller_access) 374 - *_caller_access = scb->status.caller_access; 375 - kfree(scb); 376 - _leave(" = %d", ret); 377 - return ret; 329 + /* 330 + * ilookup() comparator 331 + */ 332 + int afs_ilookup5_test_by_fid(struct inode *inode, void *opaque) 333 + { 334 + struct afs_vnode *vnode = AFS_FS_I(inode); 335 + struct afs_fid *fid = opaque; 336 + 337 + return (fid->vnode == vnode->fid.vnode && 338 + fid->vnode_hi == vnode->fid.vnode_hi && 339 + fid->unique == vnode->fid.unique); 378 340 } 379 341 380 342 /* 381 343 * iget5() comparator 382 344 */ 383 - int afs_iget5_test(struct inode *inode, void *opaque) 345 + static int afs_iget5_test(struct inode *inode, void *opaque) 384 346 { 385 - struct afs_iget_data *iget_data = opaque; 386 - struct afs_vnode *vnode = AFS_FS_I(inode); 347 + struct afs_vnode_param *vp = opaque; 348 + //struct afs_vnode *vnode = AFS_FS_I(inode); 387 349 388 - return memcmp(&vnode->fid, &iget_data->fid, sizeof(iget_data->fid)) == 0; 389 - } 390 - 391 - /* 392 - * iget5() comparator for inode created by autocell operations 393 - * 394 - * These pseudo inodes don't match anything. 395 - */ 396 - static int afs_iget5_pseudo_dir_test(struct inode *inode, void *opaque) 397 - { 398 - return 0; 350 + return afs_ilookup5_test_by_fid(inode, &vp->fid); 399 351 } 400 352 401 353 /* ··· 384 374 */ 385 375 static int afs_iget5_set(struct inode *inode, void *opaque) 386 376 { 387 - struct afs_iget_data *iget_data = opaque; 377 + struct afs_vnode_param *vp = opaque; 378 + struct afs_super_info *as = AFS_FS_S(inode->i_sb); 388 379 struct afs_vnode *vnode = AFS_FS_I(inode); 389 380 390 - vnode->fid = iget_data->fid; 391 - vnode->volume = iget_data->volume; 392 - vnode->cb_v_break = iget_data->cb_v_break; 393 - vnode->cb_s_break = iget_data->cb_s_break; 381 + vnode->volume = as->volume; 382 + vnode->fid = vp->fid; 394 383 395 384 /* YFS supports 96-bit vnode IDs, but Linux only supports 396 385 * 64-bit inode numbers. 397 386 */ 398 - inode->i_ino = iget_data->fid.vnode; 399 - inode->i_generation = iget_data->fid.unique; 387 + inode->i_ino = vnode->fid.vnode; 388 + inode->i_generation = vnode->fid.unique; 400 389 return 0; 401 - } 402 - 403 - /* 404 - * Create an inode for a dynamic root directory or an autocell dynamic 405 - * automount dir. 406 - */ 407 - struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root) 408 - { 409 - struct afs_super_info *as; 410 - struct afs_vnode *vnode; 411 - struct inode *inode; 412 - static atomic_t afs_autocell_ino; 413 - 414 - struct afs_iget_data iget_data = { 415 - .cb_v_break = 0, 416 - .cb_s_break = 0, 417 - }; 418 - 419 - _enter(""); 420 - 421 - as = sb->s_fs_info; 422 - if (as->volume) { 423 - iget_data.volume = as->volume; 424 - iget_data.fid.vid = as->volume->vid; 425 - } 426 - if (root) { 427 - iget_data.fid.vnode = 1; 428 - iget_data.fid.unique = 1; 429 - } else { 430 - iget_data.fid.vnode = atomic_inc_return(&afs_autocell_ino); 431 - iget_data.fid.unique = 0; 432 - } 433 - 434 - inode = iget5_locked(sb, iget_data.fid.vnode, 435 - afs_iget5_pseudo_dir_test, afs_iget5_set, 436 - &iget_data); 437 - if (!inode) { 438 - _leave(" = -ENOMEM"); 439 - return ERR_PTR(-ENOMEM); 440 - } 441 - 442 - _debug("GOT INODE %p { ino=%lu, vl=%llx, vn=%llx, u=%x }", 443 - inode, inode->i_ino, iget_data.fid.vid, iget_data.fid.vnode, 444 - iget_data.fid.unique); 445 - 446 - vnode = AFS_FS_I(inode); 447 - 448 - /* there shouldn't be an existing inode */ 449 - BUG_ON(!(inode->i_state & I_NEW)); 450 - 451 - inode->i_size = 0; 452 - inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO; 453 - if (root) { 454 - inode->i_op = &afs_dynroot_inode_operations; 455 - inode->i_fop = &simple_dir_operations; 456 - } else { 457 - inode->i_op = &afs_autocell_inode_operations; 458 - } 459 - set_nlink(inode, 2); 460 - inode->i_uid = GLOBAL_ROOT_UID; 461 - inode->i_gid = GLOBAL_ROOT_GID; 462 - inode->i_ctime = inode->i_atime = inode->i_mtime = current_time(inode); 463 - inode->i_blocks = 0; 464 - inode_set_iversion_raw(inode, 0); 465 - inode->i_generation = 0; 466 - 467 - set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags); 468 - if (!root) { 469 - set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); 470 - inode->i_flags |= S_AUTOMOUNT; 471 - } 472 - 473 - inode->i_flags |= S_NOATIME; 474 - unlock_new_inode(inode); 475 - _leave(" = %p", inode); 476 - return inode; 477 390 } 478 391 479 392 /* ··· 434 501 /* 435 502 * inode retrieval 436 503 */ 437 - struct inode *afs_iget(struct super_block *sb, struct key *key, 438 - struct afs_iget_data *iget_data, 439 - struct afs_status_cb *scb, 440 - struct afs_cb_interest *cbi, 441 - struct afs_vnode *parent_vnode) 504 + struct inode *afs_iget(struct afs_operation *op, struct afs_vnode_param *vp) 442 505 { 443 - struct afs_super_info *as; 506 + struct afs_vnode_param *dvp = &op->file[0]; 507 + struct super_block *sb = dvp->vnode->vfs_inode.i_sb; 444 508 struct afs_vnode *vnode; 445 - struct afs_fid *fid = &iget_data->fid; 446 509 struct inode *inode; 447 510 int ret; 448 511 449 - _enter(",{%llx:%llu.%u},,", fid->vid, fid->vnode, fid->unique); 512 + _enter(",{%llx:%llu.%u},,", vp->fid.vid, vp->fid.vnode, vp->fid.unique); 450 513 451 - as = sb->s_fs_info; 452 - iget_data->volume = as->volume; 453 - 454 - inode = iget5_locked(sb, fid->vnode, afs_iget5_test, afs_iget5_set, 455 - iget_data); 514 + inode = iget5_locked(sb, vp->fid.vnode, afs_iget5_test, afs_iget5_set, vp); 456 515 if (!inode) { 457 516 _leave(" = -ENOMEM"); 458 517 return ERR_PTR(-ENOMEM); 459 518 } 460 519 461 - _debug("GOT INODE %p { vl=%llx vn=%llx, u=%x }", 462 - inode, fid->vid, fid->vnode, fid->unique); 463 - 464 520 vnode = AFS_FS_I(inode); 521 + 522 + _debug("GOT INODE %p { vl=%llx vn=%llx, u=%x }", 523 + inode, vnode->fid.vid, vnode->fid.vnode, vnode->fid.unique); 465 524 466 525 /* deal with an existing inode */ 467 526 if (!(inode->i_state & I_NEW)) { ··· 461 536 return inode; 462 537 } 463 538 464 - if (!scb) { 465 - /* it's a remotely extant inode */ 466 - ret = afs_fetch_status(vnode, key, true, NULL); 467 - if (ret < 0) 468 - goto bad_inode; 469 - } else { 470 - ret = afs_inode_init_from_status(vnode, key, cbi, parent_vnode, 471 - scb); 472 - if (ret < 0) 473 - goto bad_inode; 474 - } 539 + ret = afs_inode_init_from_status(op, vp, vnode); 540 + if (ret < 0) 541 + goto bad_inode; 475 542 476 543 afs_get_inode_cache(vnode); 477 544 478 545 /* success */ 479 546 clear_bit(AFS_VNODE_UNSET, &vnode->flags); 480 - inode->i_flags |= S_NOATIME; 481 547 unlock_new_inode(inode); 482 548 _leave(" = %p", inode); 483 549 return inode; 484 550 485 551 /* failure */ 486 552 bad_inode: 553 + iget_failed(inode); 554 + _leave(" = %d [bad]", ret); 555 + return ERR_PTR(ret); 556 + } 557 + 558 + static int afs_iget5_set_root(struct inode *inode, void *opaque) 559 + { 560 + struct afs_super_info *as = AFS_FS_S(inode->i_sb); 561 + struct afs_vnode *vnode = AFS_FS_I(inode); 562 + 563 + vnode->volume = as->volume; 564 + vnode->fid.vid = as->volume->vid, 565 + vnode->fid.vnode = 1; 566 + vnode->fid.unique = 1; 567 + inode->i_ino = 1; 568 + inode->i_generation = 1; 569 + return 0; 570 + } 571 + 572 + /* 573 + * Set up the root inode for a volume. This is always vnode 1, unique 1 within 574 + * the volume. 575 + */ 576 + struct inode *afs_root_iget(struct super_block *sb, struct key *key) 577 + { 578 + struct afs_super_info *as = AFS_FS_S(sb); 579 + struct afs_operation *op; 580 + struct afs_vnode *vnode; 581 + struct inode *inode; 582 + int ret; 583 + 584 + _enter(",{%llx},,", as->volume->vid); 585 + 586 + inode = iget5_locked(sb, 1, NULL, afs_iget5_set_root, NULL); 587 + if (!inode) { 588 + _leave(" = -ENOMEM"); 589 + return ERR_PTR(-ENOMEM); 590 + } 591 + 592 + _debug("GOT ROOT INODE %p { vl=%llx }", inode, as->volume->vid); 593 + 594 + BUG_ON(!(inode->i_state & I_NEW)); 595 + 596 + vnode = AFS_FS_I(inode); 597 + vnode->cb_v_break = as->volume->cb_v_break, 598 + 599 + op = afs_alloc_operation(key, as->volume); 600 + if (IS_ERR(op)) { 601 + ret = PTR_ERR(op); 602 + goto error; 603 + } 604 + 605 + afs_op_set_vnode(op, 0, vnode); 606 + 607 + op->nr_files = 1; 608 + op->ops = &afs_fetch_status_operation; 609 + ret = afs_do_sync_operation(op); 610 + if (ret < 0) 611 + goto error; 612 + 613 + afs_get_inode_cache(vnode); 614 + 615 + clear_bit(AFS_VNODE_UNSET, &vnode->flags); 616 + unlock_new_inode(inode); 617 + _leave(" = %p", inode); 618 + return inode; 619 + 620 + error: 487 621 iget_failed(inode); 488 622 _leave(" = %d [bad]", ret); 489 623 return ERR_PTR(ret); ··· 792 808 _leave(""); 793 809 } 794 810 811 + static void afs_setattr_success(struct afs_operation *op) 812 + { 813 + afs_vnode_commit_status(op, &op->file[0]); 814 + } 815 + 816 + static const struct afs_operation_ops afs_setattr_operation = { 817 + .issue_afs_rpc = afs_fs_setattr, 818 + .issue_yfs_rpc = yfs_fs_setattr, 819 + .success = afs_setattr_success, 820 + }; 821 + 795 822 /* 796 823 * set the attributes of an inode 797 824 */ 798 825 int afs_setattr(struct dentry *dentry, struct iattr *attr) 799 826 { 800 - struct afs_operation fc; 801 - struct afs_status_cb *scb; 827 + struct afs_operation *op; 802 828 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 803 - struct key *key; 804 - int ret = -ENOMEM; 805 829 806 830 _enter("{%llx:%llu},{n=%pd},%x", 807 831 vnode->fid.vid, vnode->fid.vnode, dentry, ··· 821 829 return 0; 822 830 } 823 831 824 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_KERNEL); 825 - if (!scb) 826 - goto error; 827 - 828 832 /* flush any dirty data outstanding on a regular file */ 829 833 if (S_ISREG(vnode->vfs_inode.i_mode)) 830 834 filemap_write_and_wait(vnode->vfs_inode.i_mapping); 831 835 832 - if (attr->ia_valid & ATTR_FILE) { 833 - key = afs_file_key(attr->ia_file); 834 - } else { 835 - key = afs_request_key(vnode->volume->cell); 836 - if (IS_ERR(key)) { 837 - ret = PTR_ERR(key); 838 - goto error_scb; 839 - } 840 - } 836 + op = afs_alloc_operation(((attr->ia_valid & ATTR_FILE) ? 837 + afs_file_key(attr->ia_file) : NULL), 838 + vnode->volume); 839 + if (IS_ERR(op)) 840 + return PTR_ERR(op); 841 841 842 - ret = -ERESTARTSYS; 843 - if (afs_begin_vnode_operation(&fc, vnode, key, false)) { 844 - afs_dataversion_t data_version = vnode->status.data_version; 842 + afs_op_set_vnode(op, 0, vnode); 843 + op->setattr.attr = attr; 845 844 846 - if (attr->ia_valid & ATTR_SIZE) 847 - data_version++; 845 + if (attr->ia_valid & ATTR_SIZE) 846 + op->file[0].dv_delta = 1; 848 847 849 - while (afs_select_fileserver(&fc)) { 850 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 851 - afs_fs_setattr(&fc, attr, scb); 852 - } 853 - 854 - afs_check_for_remote_deletion(&fc, vnode); 855 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 856 - &data_version, scb); 857 - ret = afs_end_vnode_operation(&fc); 858 - } 859 - 860 - if (!(attr->ia_valid & ATTR_FILE)) 861 - key_put(key); 862 - 863 - error_scb: 864 - kfree(scb); 865 - error: 866 - _leave(" = %d", ret); 867 - return ret; 848 + op->ops = &afs_setattr_operation; 849 + return afs_do_sync_operation(op); 868 850 }
+194 -119
fs/afs/internal.h
··· 59 59 struct key *key; /* key to use for secure mounting */ 60 60 }; 61 61 62 - struct afs_iget_data { 63 - struct afs_fid fid; 64 - struct afs_volume *volume; /* volume on which resides */ 65 - unsigned int cb_v_break; /* Pre-fetch volume break count */ 66 - unsigned int cb_s_break; /* Pre-fetch server break count */ 67 - }; 68 - 69 62 enum afs_call_state { 70 63 AFS_CALL_CL_REQUESTING, /* Client: Request is being sent */ 71 64 AFS_CALL_CL_AWAIT_REPLY, /* Client: Awaiting reply */ ··· 104 111 struct afs_server *server; /* The fileserver record if fs op (pins ref) */ 105 112 struct afs_vlserver *vlserver; /* The vlserver record if vl op */ 106 113 struct afs_cb_interest *cbi; /* Callback interest for server used */ 107 - struct afs_vnode *lvnode; /* vnode being locked */ 108 114 void *request; /* request data (first part) */ 109 - struct address_space *mapping; /* Pages being written from */ 110 115 struct iov_iter def_iter; /* Default buffer/data iterator */ 111 116 struct iov_iter *iter; /* Iterator currently in use */ 112 117 union { /* Convenience for ->def_iter */ ··· 116 125 long ret0; /* Value to reply with instead of 0 */ 117 126 struct afs_addr_list *ret_alist; 118 127 struct afs_vldb_entry *ret_vldb; 119 - struct afs_acl *ret_acl; 120 128 }; 121 - struct afs_fid *out_fid; 122 - struct afs_status_cb *out_dir_scb; 123 - struct afs_status_cb *out_scb; 124 - struct yfs_acl *out_yacl; 125 - struct afs_volsync *out_volsync; 126 - struct afs_volume_status *out_volstatus; 127 - struct afs_read *read_request; 129 + struct afs_operation *op; 128 130 unsigned int server_index; 129 - pgoff_t first; /* first page in mapping to deal with */ 130 - pgoff_t last; /* last page in mapping to deal with */ 131 131 atomic_t usage; 132 132 enum afs_call_state state; 133 133 spinlock_t state_lock; ··· 128 146 unsigned int max_lifespan; /* Maximum lifespan to set if not 0 */ 129 147 unsigned request_size; /* size of request data */ 130 148 unsigned reply_max; /* maximum size of reply */ 131 - unsigned first_offset; /* offset into mapping[first] */ 132 - union { 133 - unsigned last_to; /* amount of mapping[last] */ 134 - unsigned count2; /* count used in unmarshalling */ 135 - }; 149 + unsigned count2; /* count used in unmarshalling */ 136 150 unsigned char unmarshall; /* unmarshalling phase */ 137 151 unsigned char addr_ix; /* Address in ->alist */ 138 152 bool drop_ref; /* T if need to drop ref for incoming call */ ··· 548 570 struct afs_vol_interest *vol_interest; 549 571 struct afs_server *server; /* Server on which this interest resides */ 550 572 struct super_block *sb; /* Superblock on which inodes reside */ 551 - union { 552 - struct rcu_head rcu; 553 - afs_volid_t vid; /* Volume ID to match */ 554 - }; 573 + struct rcu_head rcu; 555 574 refcount_t usage; 556 575 }; 557 576 ··· 739 764 }; 740 765 741 766 /* 742 - * Cursor for iterating over a set of fileservers. 767 + * Fileserver operation methods. 768 + */ 769 + struct afs_operation_ops { 770 + void (*issue_afs_rpc)(struct afs_operation *op); 771 + void (*issue_yfs_rpc)(struct afs_operation *op); 772 + void (*success)(struct afs_operation *op); 773 + void (*aborted)(struct afs_operation *op); 774 + void (*edit_dir)(struct afs_operation *op); 775 + void (*put)(struct afs_operation *op); 776 + }; 777 + 778 + struct afs_vnode_param { 779 + struct afs_vnode *vnode; 780 + struct afs_fid fid; /* Fid to access */ 781 + struct afs_status_cb scb; /* Returned status and callback promise */ 782 + afs_dataversion_t dv_before; /* Data version before the call */ 783 + unsigned int cb_break_before; /* cb_break + cb_s_break before the call */ 784 + u8 dv_delta; /* Expected change in data version */ 785 + bool put_vnode; /* T if we have a ref on the vnode */ 786 + bool need_io_lock; /* T if we need the I/O lock on this */ 787 + }; 788 + 789 + /* 790 + * Fileserver operation wrapper, handling server and address rotation 791 + * asynchronously. May make simultaneous calls to multiple servers. 743 792 */ 744 793 struct afs_operation { 794 + struct afs_net *net; /* Network namespace */ 795 + struct key *key; /* Key for the cell */ 745 796 const struct afs_call_type *type; /* Type of call done */ 797 + const struct afs_operation_ops *ops; 798 + 799 + /* Parameters/results for the operation */ 800 + struct afs_volume *volume; /* Volume being accessed */ 801 + struct afs_vnode_param file[2]; 802 + struct afs_vnode_param *more_files; 803 + struct afs_volsync volsync; 804 + struct dentry *dentry; /* Dentry to be altered */ 805 + struct dentry *dentry_2; /* Second dentry to be altered */ 806 + struct timespec64 mtime; /* Modification time to record */ 807 + short nr_files; /* Number of entries in file[], more_files */ 808 + short error; 809 + unsigned int abort_code; 810 + unsigned int debug_id; 811 + 812 + unsigned int cb_v_break; /* Volume break counter before op */ 813 + unsigned int cb_s_break; /* Server break counter before op */ 814 + 815 + union { 816 + struct { 817 + int which; /* Which ->file[] to fetch for */ 818 + } fetch_status; 819 + struct { 820 + int reason; /* enum afs_edit_dir_reason */ 821 + mode_t mode; 822 + const char *symlink; 823 + } create; 824 + struct { 825 + bool need_rehash; 826 + } unlink; 827 + struct { 828 + struct dentry *rehash; 829 + struct dentry *tmp; 830 + bool new_negative; 831 + } rename; 832 + struct { 833 + struct afs_read *req; 834 + } fetch; 835 + struct { 836 + struct afs_vnode *lvnode; /* vnode being locked */ 837 + afs_lock_type_t type; 838 + } lock; 839 + struct { 840 + struct address_space *mapping; /* Pages being written from */ 841 + pgoff_t first; /* first page in mapping to deal with */ 842 + pgoff_t last; /* last page in mapping to deal with */ 843 + unsigned first_offset; /* offset into mapping[first] */ 844 + unsigned last_to; /* amount of mapping[last] */ 845 + } store; 846 + struct { 847 + struct iattr *attr; 848 + } setattr; 849 + struct afs_acl *acl; 850 + struct yfs_acl *yacl; 851 + struct { 852 + struct afs_volume_status vs; 853 + struct kstatfs *buf; 854 + } volstatus; 855 + }; 856 + 857 + /* Fileserver iteration state */ 746 858 struct afs_addr_cursor ac; 747 - struct afs_vnode *vnode; 748 859 struct afs_server_list *server_list; /* Current server list (pins ref) */ 749 860 struct afs_cb_interest *cbi; /* Server on which this resides (pins ref) */ 750 - struct key *key; /* Key for the server */ 861 + struct afs_call *call; 751 862 unsigned long untried; /* Bitmask of untried servers */ 752 - unsigned int cb_break; /* cb_break + cb_s_break before the call */ 753 - unsigned int cb_break_2; /* cb_break + cb_s_break (2nd vnode) */ 754 863 short index; /* Current server */ 755 - short error; 756 - unsigned short flags; 864 + unsigned short nr_iterations; /* Number of server iterations */ 865 + 866 + unsigned int flags; 757 867 #define AFS_OPERATION_STOP 0x0001 /* Set to cease iteration */ 758 868 #define AFS_OPERATION_VBUSY 0x0002 /* Set if seen VBUSY */ 759 869 #define AFS_OPERATION_VMOVED 0x0004 /* Set if seen VMOVED */ 760 870 #define AFS_OPERATION_VNOVOL 0x0008 /* Set if seen VNOVOL */ 761 871 #define AFS_OPERATION_CUR_ONLY 0x0010 /* Set if current server only (file lock held) */ 762 872 #define AFS_OPERATION_NO_VSLEEP 0x0020 /* Set to prevent sleep on VBUSY, VOFFLINE, ... */ 763 - #define AFS_OPERATION_INTR 0x0040 /* Set if op is interruptible */ 764 - unsigned short nr_iterations; /* Number of server iterations */ 873 + #define AFS_OPERATION_UNINTR 0x0040 /* Set if op is uninterruptible */ 874 + #define AFS_OPERATION_DOWNGRADE 0x0080 /* Set to retry with downgraded opcode */ 875 + #define AFS_OPERATION_LOCK_0 0x0100 /* Set if have io_lock on file[0] */ 876 + #define AFS_OPERATION_LOCK_1 0x0200 /* Set if have io_lock on file[1] */ 765 877 }; 766 878 767 879 /* ··· 1020 958 /* 1021 959 * fsclient.c 1022 960 */ 1023 - extern int afs_fs_fetch_file_status(struct afs_operation *, struct afs_status_cb *, 1024 - struct afs_volsync *); 1025 - extern int afs_fs_fetch_data(struct afs_operation *, struct afs_status_cb *, struct afs_read *); 1026 - extern int afs_fs_create(struct afs_operation *, const char *, umode_t, 1027 - struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *); 1028 - extern int afs_fs_remove(struct afs_operation *, struct afs_vnode *, const char *, bool, 1029 - struct afs_status_cb *); 1030 - extern int afs_fs_link(struct afs_operation *, struct afs_vnode *, const char *, 1031 - struct afs_status_cb *, struct afs_status_cb *); 1032 - extern int afs_fs_symlink(struct afs_operation *, const char *, const char *, 1033 - struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *); 1034 - extern int afs_fs_rename(struct afs_operation *, const char *, 1035 - struct afs_vnode *, const char *, 1036 - struct afs_status_cb *, struct afs_status_cb *); 1037 - extern int afs_fs_store_data(struct afs_operation *, struct address_space *, 1038 - pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *); 1039 - extern int afs_fs_setattr(struct afs_operation *, struct iattr *, struct afs_status_cb *); 1040 - extern int afs_fs_get_volume_status(struct afs_operation *, struct afs_volume_status *); 1041 - extern int afs_fs_set_lock(struct afs_operation *, afs_lock_type_t, struct afs_status_cb *); 1042 - extern int afs_fs_extend_lock(struct afs_operation *, struct afs_status_cb *); 1043 - extern int afs_fs_release_lock(struct afs_operation *, struct afs_status_cb *); 961 + extern void afs_fs_fetch_status(struct afs_operation *); 962 + extern void afs_fs_fetch_data(struct afs_operation *); 963 + extern void afs_fs_create_file(struct afs_operation *); 964 + extern void afs_fs_make_dir(struct afs_operation *); 965 + extern void afs_fs_remove_file(struct afs_operation *); 966 + extern void afs_fs_remove_dir(struct afs_operation *); 967 + extern void afs_fs_link(struct afs_operation *); 968 + extern void afs_fs_symlink(struct afs_operation *); 969 + extern void afs_fs_rename(struct afs_operation *); 970 + extern void afs_fs_store_data(struct afs_operation *); 971 + extern void afs_fs_setattr(struct afs_operation *); 972 + extern void afs_fs_get_volume_status(struct afs_operation *); 973 + extern void afs_fs_set_lock(struct afs_operation *); 974 + extern void afs_fs_extend_lock(struct afs_operation *); 975 + extern void afs_fs_release_lock(struct afs_operation *); 1044 976 extern int afs_fs_give_up_all_callbacks(struct afs_net *, struct afs_server *, 1045 977 struct afs_addr_cursor *, struct key *); 1046 978 extern bool afs_fs_get_capabilities(struct afs_net *, struct afs_server *, 1047 979 struct afs_addr_cursor *, struct key *); 1048 - extern int afs_fs_inline_bulk_status(struct afs_operation *, struct afs_net *, 1049 - struct afs_fid *, struct afs_status_cb *, 1050 - unsigned int, struct afs_volsync *); 1051 - extern int afs_fs_fetch_status(struct afs_operation *, struct afs_net *, 1052 - struct afs_fid *, struct afs_status_cb *, 1053 - struct afs_volsync *); 980 + extern void afs_fs_inline_bulk_status(struct afs_operation *); 1054 981 1055 982 struct afs_acl { 1056 983 u32 size; 1057 984 u8 data[]; 1058 985 }; 1059 986 1060 - extern struct afs_acl *afs_fs_fetch_acl(struct afs_operation *, struct afs_status_cb *); 1061 - extern int afs_fs_store_acl(struct afs_operation *, const struct afs_acl *, 1062 - struct afs_status_cb *); 987 + extern void afs_fs_fetch_acl(struct afs_operation *); 988 + extern void afs_fs_store_acl(struct afs_operation *); 989 + 990 + /* 991 + * fs_operation.c 992 + */ 993 + extern struct afs_operation *afs_alloc_operation(struct key *, struct afs_volume *); 994 + extern int afs_put_operation(struct afs_operation *); 995 + extern bool afs_begin_vnode_operation(struct afs_operation *); 996 + extern void afs_wait_for_operation(struct afs_operation *); 997 + extern int afs_do_sync_operation(struct afs_operation *); 998 + 999 + static inline void afs_op_nomem(struct afs_operation *op) 1000 + { 1001 + op->error = -ENOMEM; 1002 + } 1003 + 1004 + static inline void afs_op_set_vnode(struct afs_operation *op, unsigned int n, 1005 + struct afs_vnode *vnode) 1006 + { 1007 + op->file[n].vnode = vnode; 1008 + op->file[n].need_io_lock = true; 1009 + } 1010 + 1011 + static inline void afs_op_set_fid(struct afs_operation *op, unsigned int n, 1012 + const struct afs_fid *fid) 1013 + { 1014 + op->file[n].fid = *fid; 1015 + } 1063 1016 1064 1017 /* 1065 1018 * fs_probe.c ··· 1087 1010 /* 1088 1011 * inode.c 1089 1012 */ 1090 - extern void afs_vnode_commit_status(struct afs_operation *, 1091 - struct afs_vnode *, 1092 - unsigned int, 1093 - const afs_dataversion_t *, 1094 - struct afs_status_cb *); 1013 + extern void afs_vnode_commit_status(struct afs_operation *, struct afs_vnode_param *); 1095 1014 extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t *); 1096 - extern int afs_iget5_test(struct inode *, void *); 1015 + extern int afs_ilookup5_test_by_fid(struct inode *, void *); 1097 1016 extern struct inode *afs_iget_pseudo_dir(struct super_block *, bool); 1098 - extern struct inode *afs_iget(struct super_block *, struct key *, 1099 - struct afs_iget_data *, struct afs_status_cb *, 1100 - struct afs_cb_interest *, 1101 - struct afs_vnode *); 1017 + extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *); 1018 + extern struct inode *afs_root_iget(struct super_block *, struct key *); 1102 1019 extern void afs_zap_data(struct afs_vnode *); 1103 1020 extern bool afs_check_validity(struct afs_vnode *); 1104 1021 extern int afs_validate(struct afs_vnode *, struct key *); ··· 1180 1109 /* 1181 1110 * rotate.c 1182 1111 */ 1183 - extern bool afs_begin_vnode_operation(struct afs_operation *, struct afs_vnode *, 1184 - struct key *, bool); 1185 1112 extern bool afs_select_fileserver(struct afs_operation *); 1186 1113 extern bool afs_select_current_fileserver(struct afs_operation *); 1187 - extern int afs_end_vnode_operation(struct afs_operation *); 1114 + extern void afs_dump_edestaddrreq(const struct afs_operation *); 1188 1115 1189 1116 /* 1190 1117 * rxrpc.c ··· 1204 1135 extern int afs_extract_data(struct afs_call *, bool); 1205 1136 extern int afs_protocol_error(struct afs_call *, enum afs_eproto_cause); 1206 1137 1207 - static inline void afs_set_fc_call(struct afs_call *call, struct afs_operation *op) 1138 + static inline void afs_make_op_call(struct afs_operation *op, struct afs_call *call, 1139 + gfp_t gfp) 1208 1140 { 1209 - call->intr = op->flags & AFS_OPERATION_INTR; 1141 + op->call = call; 1210 1142 op->type = call->type; 1143 + call->op = op; 1144 + call->key = op->key; 1145 + call->cbi = afs_get_cb_interest(op->cbi); 1146 + call->intr = !(op->flags & AFS_OPERATION_UNINTR); 1147 + afs_make_call(&op->ac, call, gfp); 1211 1148 } 1212 1149 1213 1150 static inline void afs_extract_begin(struct afs_call *call, void *buf, size_t size) ··· 1422 1347 /* 1423 1348 * volume.c 1424 1349 */ 1425 - static inline struct afs_volume *__afs_get_volume(struct afs_volume *volume) 1350 + static inline struct afs_volume *afs_get_volume(struct afs_volume *volume) 1426 1351 { 1427 1352 if (volume) 1428 1353 atomic_inc(&volume->usage); ··· 1432 1357 extern struct afs_volume *afs_create_volume(struct afs_fs_context *); 1433 1358 extern void afs_activate_volume(struct afs_volume *); 1434 1359 extern void afs_deactivate_volume(struct afs_volume *); 1435 - extern void afs_put_volume(struct afs_cell *, struct afs_volume *); 1360 + extern void afs_put_volume(struct afs_net *, struct afs_volume *); 1436 1361 extern int afs_check_volume_status(struct afs_volume *, struct afs_operation *); 1437 1362 1438 1363 /* ··· 1462 1387 /* 1463 1388 * yfsclient.c 1464 1389 */ 1465 - extern int yfs_fs_fetch_file_status(struct afs_operation *, struct afs_status_cb *, 1466 - struct afs_volsync *); 1467 - extern int yfs_fs_fetch_data(struct afs_operation *, struct afs_status_cb *, struct afs_read *); 1468 - extern int yfs_fs_create_file(struct afs_operation *, const char *, umode_t, struct afs_status_cb *, 1469 - struct afs_fid *, struct afs_status_cb *); 1470 - extern int yfs_fs_make_dir(struct afs_operation *, const char *, umode_t, struct afs_status_cb *, 1471 - struct afs_fid *, struct afs_status_cb *); 1472 - extern int yfs_fs_remove_file2(struct afs_operation *, struct afs_vnode *, const char *, 1473 - struct afs_status_cb *, struct afs_status_cb *); 1474 - extern int yfs_fs_remove(struct afs_operation *, struct afs_vnode *, const char *, bool, 1475 - struct afs_status_cb *); 1476 - extern int yfs_fs_link(struct afs_operation *, struct afs_vnode *, const char *, 1477 - struct afs_status_cb *, struct afs_status_cb *); 1478 - extern int yfs_fs_symlink(struct afs_operation *, const char *, const char *, 1479 - struct afs_status_cb *, struct afs_fid *, struct afs_status_cb *); 1480 - extern int yfs_fs_rename(struct afs_operation *, const char *, struct afs_vnode *, const char *, 1481 - struct afs_status_cb *, struct afs_status_cb *); 1482 - extern int yfs_fs_store_data(struct afs_operation *, struct address_space *, 1483 - pgoff_t, pgoff_t, unsigned, unsigned, struct afs_status_cb *); 1484 - extern int yfs_fs_setattr(struct afs_operation *, struct iattr *, struct afs_status_cb *); 1485 - extern int yfs_fs_get_volume_status(struct afs_operation *, struct afs_volume_status *); 1486 - extern int yfs_fs_set_lock(struct afs_operation *, afs_lock_type_t, struct afs_status_cb *); 1487 - extern int yfs_fs_extend_lock(struct afs_operation *, struct afs_status_cb *); 1488 - extern int yfs_fs_release_lock(struct afs_operation *, struct afs_status_cb *); 1489 - extern int yfs_fs_fetch_status(struct afs_operation *, struct afs_net *, 1490 - struct afs_fid *, struct afs_status_cb *, 1491 - struct afs_volsync *); 1492 - extern int yfs_fs_inline_bulk_status(struct afs_operation *, struct afs_net *, 1493 - struct afs_fid *, struct afs_status_cb *, 1494 - unsigned int, struct afs_volsync *); 1390 + extern void yfs_fs_fetch_file_status(struct afs_operation *); 1391 + extern void yfs_fs_fetch_data(struct afs_operation *); 1392 + extern void yfs_fs_create_file(struct afs_operation *); 1393 + extern void yfs_fs_make_dir(struct afs_operation *); 1394 + extern void yfs_fs_remove_file2(struct afs_operation *); 1395 + extern void yfs_fs_remove_file(struct afs_operation *); 1396 + extern void yfs_fs_remove_dir(struct afs_operation *); 1397 + extern void yfs_fs_link(struct afs_operation *); 1398 + extern void yfs_fs_symlink(struct afs_operation *); 1399 + extern void yfs_fs_rename(struct afs_operation *); 1400 + extern void yfs_fs_store_data(struct afs_operation *); 1401 + extern void yfs_fs_setattr(struct afs_operation *); 1402 + extern void yfs_fs_get_volume_status(struct afs_operation *); 1403 + extern void yfs_fs_set_lock(struct afs_operation *); 1404 + extern void yfs_fs_extend_lock(struct afs_operation *); 1405 + extern void yfs_fs_release_lock(struct afs_operation *); 1406 + extern void yfs_fs_fetch_status(struct afs_operation *); 1407 + extern void yfs_fs_inline_bulk_status(struct afs_operation *); 1495 1408 1496 1409 struct yfs_acl { 1497 1410 struct afs_acl *acl; /* Dir/file/symlink ACL */ ··· 1492 1429 }; 1493 1430 1494 1431 extern void yfs_free_opaque_acl(struct yfs_acl *); 1495 - extern struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_operation *, struct yfs_acl *, 1496 - struct afs_status_cb *); 1497 - extern int yfs_fs_store_opaque_acl2(struct afs_operation *, const struct afs_acl *, 1498 - struct afs_status_cb *); 1432 + extern void yfs_fs_fetch_opaque_acl(struct afs_operation *); 1433 + extern void yfs_fs_store_opaque_acl2(struct afs_operation *); 1499 1434 1500 1435 /* 1501 1436 * Miscellaneous inline functions. ··· 1511 1450 static inline void afs_check_for_remote_deletion(struct afs_operation *op, 1512 1451 struct afs_vnode *vnode) 1513 1452 { 1514 - if (op->ac.error == -ENOENT) { 1453 + if (op->error == -ENOENT) { 1515 1454 set_bit(AFS_VNODE_DELETED, &vnode->flags); 1516 1455 afs_break_callback(vnode, afs_cb_break_for_deleted); 1517 1456 } 1457 + } 1458 + 1459 + /* 1460 + * Note that a dentry got changed. We need to set d_fsdata to the data version 1461 + * number derived from the result of the operation. It doesn't matter if 1462 + * d_fsdata goes backwards as we'll just revalidate. 1463 + */ 1464 + static inline void afs_update_dentry_version(struct afs_operation *op, 1465 + struct afs_vnode_param *dir_vp, 1466 + struct dentry *dentry) 1467 + { 1468 + if (!op->error) 1469 + dentry->d_fsdata = 1470 + (void *)(unsigned long)dir_vp->scb.status.data_version; 1518 1471 } 1519 1472 1520 1473 static inline int afs_io_error(struct afs_call *call, enum afs_io_error where)
+34 -94
fs/afs/rotate.c
··· 15 15 #include "afs_fs.h" 16 16 17 17 /* 18 - * Begin an operation on the fileserver. 19 - * 20 - * Fileserver operations are serialised on the server by vnode, so we serialise 21 - * them here also using the io_lock. 22 - */ 23 - bool afs_begin_vnode_operation(struct afs_operation *op, struct afs_vnode *vnode, 24 - struct key *key, bool intr) 25 - { 26 - memset(op, 0, sizeof(*op)); 27 - op->vnode = vnode; 28 - op->key = key; 29 - op->ac.error = SHRT_MAX; 30 - op->error = -EDESTADDRREQ; 31 - 32 - if (intr) { 33 - op->flags |= AFS_OPERATION_INTR; 34 - if (mutex_lock_interruptible(&vnode->io_lock) < 0) { 35 - op->error = -EINTR; 36 - op->flags |= AFS_OPERATION_STOP; 37 - return false; 38 - } 39 - } else { 40 - mutex_lock(&vnode->io_lock); 41 - } 42 - 43 - if (vnode->lock_state != AFS_VNODE_LOCK_NONE) 44 - op->flags |= AFS_OPERATION_CUR_ONLY; 45 - return true; 46 - } 47 - 48 - /* 49 18 * Begin iteration through a server list, starting with the vnode's last used 50 19 * server if possible, or the last recorded good server if not. 51 20 */ ··· 24 55 struct afs_cb_interest *cbi; 25 56 int i; 26 57 27 - read_lock(&vnode->volume->servers_lock); 28 - op->server_list = afs_get_serverlist(vnode->volume->servers); 29 - read_unlock(&vnode->volume->servers_lock); 58 + read_lock(&op->volume->servers_lock); 59 + op->server_list = afs_get_serverlist(op->volume->servers); 60 + read_unlock(&op->volume->servers_lock); 30 61 31 62 op->untried = (1UL << op->server_list->nr_servers) - 1; 32 63 op->index = READ_ONCE(op->server_list->preferred); ··· 59 90 vnode->cb_break++; 60 91 write_sequnlock(&vnode->cb_lock); 61 92 62 - afs_put_cb_interest(afs_v2net(vnode), cbi); 93 + afs_put_cb_interest(op->net, cbi); 63 94 cbi = NULL; 64 95 } 65 96 ··· 89 120 */ 90 121 static bool afs_sleep_and_retry(struct afs_operation *op) 91 122 { 92 - if (op->flags & AFS_OPERATION_INTR) { 123 + if (!(op->flags & AFS_OPERATION_UNINTR)) { 93 124 msleep_interruptible(1000); 94 125 if (signal_pending(current)) { 95 126 op->error = -ERESTARTSYS; ··· 110 141 { 111 142 struct afs_addr_list *alist; 112 143 struct afs_server *server; 113 - struct afs_vnode *vnode = op->vnode; 144 + struct afs_vnode *vnode = op->file[0].vnode; 114 145 struct afs_error e; 115 146 u32 rtt; 116 147 int error = op->ac.error, i; ··· 156 187 goto next_server; 157 188 } 158 189 159 - write_lock(&vnode->volume->servers_lock); 190 + write_lock(&op->volume->servers_lock); 160 191 op->server_list->vnovol_mask |= 1 << op->index; 161 - write_unlock(&vnode->volume->servers_lock); 192 + write_unlock(&op->volume->servers_lock); 162 193 163 - set_bit(AFS_VOLUME_NEEDS_UPDATE, &vnode->volume->flags); 164 - error = afs_check_volume_status(vnode->volume, op); 194 + set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); 195 + error = afs_check_volume_status(op->volume, op); 165 196 if (error < 0) 166 197 goto failed_set_error; 167 198 168 - if (test_bit(AFS_VOLUME_DELETED, &vnode->volume->flags)) { 199 + if (test_bit(AFS_VOLUME_DELETED, &op->volume->flags)) { 169 200 op->error = -ENOMEDIUM; 170 201 goto failed; 171 202 } ··· 173 204 /* If the server list didn't change, then assume that 174 205 * it's the fileserver having trouble. 175 206 */ 176 - if (vnode->volume->servers == op->server_list) { 207 + if (op->volume->servers == op->server_list) { 177 208 op->error = -EREMOTEIO; 178 209 goto next_server; 179 210 } ··· 193 224 goto next_server; 194 225 195 226 case VOFFLINE: 196 - if (!test_and_set_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags)) { 197 - afs_busy(vnode->volume, op->ac.abort_code); 198 - clear_bit(AFS_VOLUME_BUSY, &vnode->volume->flags); 227 + if (!test_and_set_bit(AFS_VOLUME_OFFLINE, &op->volume->flags)) { 228 + afs_busy(op->volume, op->ac.abort_code); 229 + clear_bit(AFS_VOLUME_BUSY, &op->volume->flags); 199 230 } 200 231 if (op->flags & AFS_OPERATION_NO_VSLEEP) { 201 232 op->error = -EADV; ··· 217 248 op->error = -EBUSY; 218 249 goto failed; 219 250 } 220 - if (!test_and_set_bit(AFS_VOLUME_BUSY, &vnode->volume->flags)) { 221 - afs_busy(vnode->volume, op->ac.abort_code); 222 - clear_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags); 251 + if (!test_and_set_bit(AFS_VOLUME_BUSY, &op->volume->flags)) { 252 + afs_busy(op->volume, op->ac.abort_code); 253 + clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags); 223 254 } 224 255 busy: 225 256 if (op->flags & AFS_OPERATION_CUR_ONLY) { ··· 248 279 } 249 280 op->flags |= AFS_OPERATION_VMOVED; 250 281 251 - set_bit(AFS_VOLUME_WAIT, &vnode->volume->flags); 252 - set_bit(AFS_VOLUME_NEEDS_UPDATE, &vnode->volume->flags); 253 - error = afs_check_volume_status(vnode->volume, op); 282 + set_bit(AFS_VOLUME_WAIT, &op->volume->flags); 283 + set_bit(AFS_VOLUME_NEEDS_UPDATE, &op->volume->flags); 284 + error = afs_check_volume_status(op->volume, op); 254 285 if (error < 0) 255 286 goto failed_set_error; 256 287 ··· 263 294 * 264 295 * TODO: Retry a few times with sleeps. 265 296 */ 266 - if (vnode->volume->servers == op->server_list) { 297 + if (op->volume->servers == op->server_list) { 267 298 op->error = -ENOMEDIUM; 268 299 goto failed; 269 300 } ··· 271 302 goto restart_from_beginning; 272 303 273 304 default: 274 - clear_bit(AFS_VOLUME_OFFLINE, &vnode->volume->flags); 275 - clear_bit(AFS_VOLUME_BUSY, &vnode->volume->flags); 305 + clear_bit(AFS_VOLUME_OFFLINE, &op->volume->flags); 306 + clear_bit(AFS_VOLUME_BUSY, &op->volume->flags); 276 307 op->error = afs_abort_to_error(op->ac.abort_code); 277 308 goto failed; 278 309 } ··· 301 332 restart_from_beginning: 302 333 _debug("restart"); 303 334 afs_end_cursor(&op->ac); 304 - afs_put_cb_interest(afs_v2net(vnode), op->cbi); 335 + afs_put_cb_interest(op->net, op->cbi); 305 336 op->cbi = NULL; 306 - afs_put_serverlist(afs_v2net(vnode), op->server_list); 337 + afs_put_serverlist(op->net, op->server_list); 307 338 op->server_list = NULL; 308 339 start: 309 340 _debug("start"); 310 341 /* See if we need to do an update of the volume record. Note that the 311 342 * volume may have moved or even have been deleted. 312 343 */ 313 - error = afs_check_volume_status(vnode->volume, op); 344 + error = afs_check_volume_status(op->volume, op); 314 345 if (error < 0) 315 346 goto failed_set_error; 316 347 317 348 if (!afs_start_fs_iteration(op, vnode)) 318 349 goto failed; 319 350 320 - _debug("__ VOL %llx __", vnode->volume->vid); 351 + _debug("__ VOL %llx __", op->volume->vid); 321 352 322 353 pick_server: 323 354 _debug("pick [%lx]", op->untried); ··· 333 364 _debug("cbi %u", op->index); 334 365 if (test_bit(op->index, &op->untried)) 335 366 goto selected_server; 336 - afs_put_cb_interest(afs_v2net(vnode), op->cbi); 367 + afs_put_cb_interest(op->net, op->cbi); 337 368 op->cbi = NULL; 338 369 _debug("nocbi"); 339 370 } ··· 451 482 */ 452 483 bool afs_select_current_fileserver(struct afs_operation *op) 453 484 { 454 - struct afs_vnode *vnode = op->vnode; 455 485 struct afs_cb_interest *cbi; 456 486 struct afs_addr_list *alist; 457 487 int error = op->ac.error; 458 488 459 489 _enter(""); 460 490 461 - cbi = rcu_dereference_protected(vnode->cb_interest, 462 - lockdep_is_held(&vnode->io_lock)); 463 - 464 491 switch (error) { 465 492 case SHRT_MAX: 493 + cbi = op->cbi; 466 494 if (!cbi) { 467 495 op->error = -ESTALE; 468 496 op->flags |= AFS_OPERATION_STOP; 469 497 return false; 470 498 } 471 - 472 - op->cbi = afs_get_cb_interest(cbi); 473 499 474 500 read_lock(&cbi->server->fs_lock); 475 501 alist = rcu_dereference_protected(cbi->server->addresses, ··· 525 561 /* 526 562 * Dump cursor state in the case of the error being EDESTADDRREQ. 527 563 */ 528 - static void afs_dump_edestaddrreq(const struct afs_operation *op) 564 + void afs_dump_edestaddrreq(const struct afs_operation *op) 529 565 { 530 566 static int count; 531 567 int i; ··· 537 573 rcu_read_lock(); 538 574 539 575 pr_notice("EDESTADDR occurred\n"); 540 - pr_notice("FC: cbb=%x cbb2=%x fl=%hx err=%hd\n", 541 - op->cb_break, op->cb_break_2, op->flags, op->error); 576 + pr_notice("FC: cbb=%x cbb2=%x fl=%x err=%hd\n", 577 + op->file[0].cb_break_before, 578 + op->file[1].cb_break_before, op->flags, op->error); 542 579 pr_notice("FC: ut=%lx ix=%d ni=%u\n", 543 580 op->untried, op->index, op->nr_iterations); 544 581 ··· 570 605 op->ac.tried, op->ac.index, op->ac.abort_code, op->ac.error, 571 606 op->ac.responded, op->ac.nr_iterations); 572 607 rcu_read_unlock(); 573 - } 574 - 575 - /* 576 - * Tidy up a filesystem cursor and unlock the vnode. 577 - */ 578 - int afs_end_vnode_operation(struct afs_operation *op) 579 - { 580 - struct afs_net *net = afs_v2net(op->vnode); 581 - 582 - if (op->error == -EDESTADDRREQ || 583 - op->error == -EADDRNOTAVAIL || 584 - op->error == -ENETUNREACH || 585 - op->error == -EHOSTUNREACH) 586 - afs_dump_edestaddrreq(op); 587 - 588 - mutex_unlock(&op->vnode->io_lock); 589 - 590 - afs_end_cursor(&op->ac); 591 - afs_put_cb_interest(net, op->cbi); 592 - afs_put_serverlist(net, op->server_list); 593 - 594 - if (op->error == -ECONNABORTED) 595 - op->error = afs_abort_to_error(op->ac.abort_code); 596 - 597 - return op->error; 598 608 }
+16 -12
fs/afs/rxrpc.c
··· 283 283 struct bio_vec *bv, pgoff_t first, pgoff_t last, 284 284 unsigned offset) 285 285 { 286 + struct afs_operation *op = call->op; 286 287 struct page *pages[AFS_BVEC_MAX]; 287 288 unsigned int nr, n, i, to, bytes = 0; 288 289 289 290 nr = min_t(pgoff_t, last - first + 1, AFS_BVEC_MAX); 290 - n = find_get_pages_contig(call->mapping, first, nr, pages); 291 + n = find_get_pages_contig(op->store.mapping, first, nr, pages); 291 292 ASSERTCMP(n, ==, nr); 292 293 293 294 msg->msg_flags |= MSG_MORE; 294 295 for (i = 0; i < nr; i++) { 295 296 to = PAGE_SIZE; 296 297 if (first + i >= last) { 297 - to = call->last_to; 298 + to = op->store.last_to; 298 299 msg->msg_flags &= ~MSG_MORE; 299 300 } 300 301 bv[i].bv_page = pages[i]; ··· 325 324 */ 326 325 static int afs_send_pages(struct afs_call *call, struct msghdr *msg) 327 326 { 327 + struct afs_operation *op = call->op; 328 328 struct bio_vec bv[AFS_BVEC_MAX]; 329 329 unsigned int bytes, nr, loop, offset; 330 - pgoff_t first = call->first, last = call->last; 330 + pgoff_t first = op->store.first, last = op->store.last; 331 331 int ret; 332 332 333 - offset = call->first_offset; 334 - call->first_offset = 0; 333 + offset = op->store.first_offset; 334 + op->store.first_offset = 0; 335 335 336 336 do { 337 337 afs_load_bvec(call, msg, bv, first, last, offset); ··· 342 340 bytes = msg->msg_iter.count; 343 341 nr = msg->msg_iter.nr_segs; 344 342 345 - ret = rxrpc_kernel_send_data(call->net->socket, call->rxcall, msg, 343 + ret = rxrpc_kernel_send_data(op->net->socket, call->rxcall, msg, 346 344 bytes, afs_notify_end_request_tx); 347 345 for (loop = 0; loop < nr; loop++) 348 346 put_page(bv[loop].bv_page); ··· 352 350 first += nr; 353 351 } while (first <= last); 354 352 355 - trace_afs_sent_pages(call, call->first, last, first, ret); 353 + trace_afs_sent_pages(call, op->store.first, last, first, ret); 356 354 return ret; 357 355 } 358 356 ··· 387 385 */ 388 386 tx_total_len = call->request_size; 389 387 if (call->send_pages) { 390 - if (call->last == call->first) { 391 - tx_total_len += call->last_to - call->first_offset; 388 + struct afs_operation *op = call->op; 389 + 390 + if (op->store.last == op->store.first) { 391 + tx_total_len += op->store.last_to - op->store.first_offset; 392 392 } else { 393 393 /* It looks mathematically like you should be able to 394 394 * combine the following lines with the ones above, but 395 395 * unsigned arithmetic is fun when it wraps... 396 396 */ 397 - tx_total_len += PAGE_SIZE - call->first_offset; 398 - tx_total_len += call->last_to; 399 - tx_total_len += (call->last - call->first - 1) * PAGE_SIZE; 397 + tx_total_len += PAGE_SIZE - op->store.first_offset; 398 + tx_total_len += op->store.last_to; 399 + tx_total_len += (op->store.last - op->store.first - 1) * PAGE_SIZE; 400 400 } 401 401 } 402 402
+21 -16
fs/afs/server.c
··· 424 424 afs_dec_servers_outstanding(net); 425 425 } 426 426 427 - /* 428 - * destroy a dead server 429 - */ 430 - static void afs_destroy_server(struct afs_net *net, struct afs_server *server) 427 + static void afs_give_up_callbacks(struct afs_net *net, struct afs_server *server) 431 428 { 432 429 struct afs_addr_list *alist = rcu_access_pointer(server->addresses); 433 430 struct afs_addr_cursor ac = { ··· 433 436 .error = 0, 434 437 }; 435 438 439 + afs_fs_give_up_all_callbacks(net, server, &ac, NULL); 440 + } 441 + 442 + /* 443 + * destroy a dead server 444 + */ 445 + static void afs_destroy_server(struct afs_net *net, struct afs_server *server) 446 + { 436 447 if (test_bit(AFS_SERVER_FL_MAY_HAVE_CB, &server->flags)) 437 - afs_fs_give_up_all_callbacks(net, server, &ac, NULL); 448 + afs_give_up_callbacks(net, server); 438 449 439 450 afs_put_server(net, server, afs_server_trace_destroy); 440 451 } ··· 576 571 /* 577 572 * Get an update for a server's address list. 578 573 */ 579 - static noinline bool afs_update_server_record(struct afs_operation *fc, struct afs_server *server) 574 + static noinline bool afs_update_server_record(struct afs_operation *op, 575 + struct afs_server *server) 580 576 { 581 577 struct afs_addr_list *alist, *discard; 582 578 ··· 586 580 trace_afs_server(server, atomic_read(&server->ref), atomic_read(&server->active), 587 581 afs_server_trace_update); 588 582 589 - alist = afs_vl_lookup_addrs(fc->vnode->volume->cell, fc->key, 590 - &server->uuid); 583 + alist = afs_vl_lookup_addrs(op->volume->cell, op->key, &server->uuid); 591 584 if (IS_ERR(alist)) { 592 585 if ((PTR_ERR(alist) == -ERESTARTSYS || 593 586 PTR_ERR(alist) == -EINTR) && 594 - !(fc->flags & AFS_OPERATION_INTR) && 587 + (op->flags & AFS_OPERATION_UNINTR) && 595 588 server->addresses) { 596 589 _leave(" = t [intr]"); 597 590 return true; 598 591 } 599 - fc->error = PTR_ERR(alist); 600 - _leave(" = f [%d]", fc->error); 592 + op->error = PTR_ERR(alist); 593 + _leave(" = f [%d]", op->error); 601 594 return false; 602 595 } 603 596 ··· 618 613 /* 619 614 * See if a server's address list needs updating. 620 615 */ 621 - bool afs_check_server_record(struct afs_operation *fc, struct afs_server *server) 616 + bool afs_check_server_record(struct afs_operation *op, struct afs_server *server) 622 617 { 623 618 bool success; 624 619 int ret, retries = 0; ··· 638 633 update: 639 634 if (!test_and_set_bit_lock(AFS_SERVER_FL_UPDATING, &server->flags)) { 640 635 clear_bit(AFS_SERVER_FL_NEEDS_UPDATE, &server->flags); 641 - success = afs_update_server_record(fc, server); 636 + success = afs_update_server_record(op, server); 642 637 clear_bit_unlock(AFS_SERVER_FL_UPDATING, &server->flags); 643 638 wake_up_bit(&server->flags, AFS_SERVER_FL_UPDATING); 644 639 _leave(" = %d", success); ··· 647 642 648 643 wait: 649 644 ret = wait_on_bit(&server->flags, AFS_SERVER_FL_UPDATING, 650 - (fc->flags & AFS_OPERATION_INTR) ? 651 - TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); 645 + (op->flags & AFS_OPERATION_UNINTR) ? 646 + TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE); 652 647 if (ret == -ERESTARTSYS) { 653 - fc->error = ret; 648 + op->error = ret; 654 649 _leave(" = f [intr]"); 655 650 return false; 656 651 }
+34 -43
fs/afs/super.c
··· 373 373 ctx->key = key; 374 374 375 375 if (ctx->volume) { 376 - afs_put_volume(ctx->cell, ctx->volume); 376 + afs_put_volume(ctx->net, ctx->volume); 377 377 ctx->volume = NULL; 378 378 } 379 379 ··· 421 421 static int afs_fill_super(struct super_block *sb, struct afs_fs_context *ctx) 422 422 { 423 423 struct afs_super_info *as = AFS_FS_S(sb); 424 - struct afs_iget_data iget_data; 425 424 struct inode *inode = NULL; 426 425 int ret; 427 426 ··· 445 446 } else { 446 447 sprintf(sb->s_id, "%llu", as->volume->vid); 447 448 afs_activate_volume(as->volume); 448 - iget_data.fid.vid = as->volume->vid; 449 - iget_data.fid.vnode = 1; 450 - iget_data.fid.vnode_hi = 0; 451 - iget_data.fid.unique = 1; 452 - iget_data.cb_v_break = as->volume->cb_v_break; 453 - iget_data.cb_s_break = 0; 454 - inode = afs_iget(sb, ctx->key, &iget_data, NULL, NULL, NULL); 449 + inode = afs_root_iget(sb, ctx->key); 455 450 } 456 451 457 452 if (IS_ERR(inode)) ··· 489 496 as->dyn_root = true; 490 497 } else { 491 498 as->cell = afs_get_cell(ctx->cell); 492 - as->volume = __afs_get_volume(ctx->volume); 499 + as->volume = afs_get_volume(ctx->volume); 493 500 } 494 501 } 495 502 return as; ··· 498 505 static void afs_destroy_sbi(struct afs_super_info *as) 499 506 { 500 507 if (as) { 501 - afs_put_volume(as->cell, as->volume); 502 - afs_put_cell(afs_net(as->net_ns), as->cell); 508 + struct afs_net *net = afs_net(as->net_ns); 509 + afs_put_volume(net, as->volume); 510 + afs_put_cell(net, as->cell); 503 511 put_net(as->net_ns); 504 512 kfree(as); 505 513 } ··· 586 592 struct afs_fs_context *ctx = fc->fs_private; 587 593 588 594 afs_destroy_sbi(fc->s_fs_info); 589 - afs_put_volume(ctx->cell, ctx->volume); 595 + afs_put_volume(ctx->net, ctx->volume); 590 596 afs_put_cell(ctx->net, ctx->cell); 591 597 key_put(ctx->key); 592 598 kfree(ctx); ··· 703 709 atomic_dec(&afs_count_active_inodes); 704 710 } 705 711 712 + static void afs_get_volume_status_success(struct afs_operation *op) 713 + { 714 + struct afs_volume_status *vs = &op->volstatus.vs; 715 + struct kstatfs *buf = op->volstatus.buf; 716 + 717 + if (vs->max_quota == 0) 718 + buf->f_blocks = vs->part_max_blocks; 719 + else 720 + buf->f_blocks = vs->max_quota; 721 + buf->f_bavail = buf->f_bfree = buf->f_blocks - vs->blocks_in_use; 722 + } 723 + 724 + static const struct afs_operation_ops afs_get_volume_status_operation = { 725 + .issue_afs_rpc = afs_fs_get_volume_status, 726 + .issue_yfs_rpc = yfs_fs_get_volume_status, 727 + .success = afs_get_volume_status_success, 728 + }; 729 + 706 730 /* 707 731 * return information about an AFS volume 708 732 */ 709 733 static int afs_statfs(struct dentry *dentry, struct kstatfs *buf) 710 734 { 711 735 struct afs_super_info *as = AFS_FS_S(dentry->d_sb); 712 - struct afs_operation fc; 713 - struct afs_volume_status vs; 736 + struct afs_operation *op; 714 737 struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry)); 715 - struct key *key; 716 - int ret; 717 738 718 739 buf->f_type = dentry->d_sb->s_magic; 719 740 buf->f_bsize = AFS_BLOCK_SIZE; ··· 741 732 return 0; 742 733 } 743 734 744 - key = afs_request_key(vnode->volume->cell); 745 - if (IS_ERR(key)) 746 - return PTR_ERR(key); 735 + op = afs_alloc_operation(NULL, as->volume); 736 + if (IS_ERR(op)) 737 + return PTR_ERR(op); 747 738 748 - ret = -ERESTARTSYS; 749 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 750 - fc.flags |= AFS_OPERATION_NO_VSLEEP; 751 - while (afs_select_fileserver(&fc)) { 752 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 753 - afs_fs_get_volume_status(&fc, &vs); 754 - } 755 - 756 - afs_check_for_remote_deletion(&fc, fc.vnode); 757 - ret = afs_end_vnode_operation(&fc); 758 - } 759 - 760 - key_put(key); 761 - 762 - if (ret == 0) { 763 - if (vs.max_quota == 0) 764 - buf->f_blocks = vs.part_max_blocks; 765 - else 766 - buf->f_blocks = vs.max_quota; 767 - buf->f_bavail = buf->f_bfree = buf->f_blocks - vs.blocks_in_use; 768 - } 769 - 770 - return ret; 739 + afs_op_set_vnode(op, 0, vnode); 740 + op->nr_files = 1; 741 + op->volstatus.buf = buf; 742 + op->ops = &afs_get_volume_status_operation; 743 + return afs_do_sync_operation(op); 771 744 }
+6 -6
fs/afs/volume.c
··· 166 166 /* 167 167 * Drop a reference on a volume record. 168 168 */ 169 - void afs_put_volume(struct afs_cell *cell, struct afs_volume *volume) 169 + void afs_put_volume(struct afs_net *net, struct afs_volume *volume) 170 170 { 171 171 if (volume) { 172 172 _enter("%s", volume->name); 173 173 174 174 if (atomic_dec_and_test(&volume->usage)) 175 - afs_destroy_volume(cell->net, volume); 175 + afs_destroy_volume(net, volume); 176 176 } 177 177 } 178 178 ··· 280 280 /* 281 281 * Make sure the volume record is up to date. 282 282 */ 283 - int afs_check_volume_status(struct afs_volume *volume, struct afs_operation *fc) 283 + int afs_check_volume_status(struct afs_volume *volume, struct afs_operation *op) 284 284 { 285 285 int ret, retries = 0; 286 286 ··· 298 298 update: 299 299 if (!test_and_set_bit_lock(AFS_VOLUME_UPDATING, &volume->flags)) { 300 300 clear_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); 301 - ret = afs_update_volume_status(volume, fc->key); 301 + ret = afs_update_volume_status(volume, op->key); 302 302 if (ret < 0) 303 303 set_bit(AFS_VOLUME_NEEDS_UPDATE, &volume->flags); 304 304 clear_bit_unlock(AFS_VOLUME_WAIT, &volume->flags); ··· 315 315 } 316 316 317 317 ret = wait_on_bit(&volume->flags, AFS_VOLUME_WAIT, 318 - (fc->flags & AFS_OPERATION_INTR) ? 319 - TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); 318 + (op->flags & AFS_OPERATION_UNINTR) ? 319 + TASK_UNINTERRUPTIBLE : TASK_INTERRUPTIBLE); 320 320 if (ret == -ERESTARTSYS) { 321 321 _leave(" = %d", ret); 322 322 return ret;
+94 -62
fs/afs/write.c
··· 349 349 } 350 350 351 351 /* 352 + * Find a key to use for the writeback. We cached the keys used to author the 353 + * writes on the vnode. *_wbk will contain the last writeback key used or NULL 354 + * and we need to start from there if it's set. 355 + */ 356 + static int afs_get_writeback_key(struct afs_vnode *vnode, 357 + struct afs_wb_key **_wbk) 358 + { 359 + struct afs_wb_key *wbk = NULL; 360 + struct list_head *p; 361 + int ret = -ENOKEY, ret2; 362 + 363 + spin_lock(&vnode->wb_lock); 364 + if (*_wbk) 365 + p = (*_wbk)->vnode_link.next; 366 + else 367 + p = vnode->wb_keys.next; 368 + 369 + while (p != &vnode->wb_keys) { 370 + wbk = list_entry(p, struct afs_wb_key, vnode_link); 371 + _debug("wbk %u", key_serial(wbk->key)); 372 + ret2 = key_validate(wbk->key); 373 + if (ret2 == 0) { 374 + refcount_inc(&wbk->usage); 375 + _debug("USE WB KEY %u", key_serial(wbk->key)); 376 + break; 377 + } 378 + 379 + wbk = NULL; 380 + if (ret == -ENOKEY) 381 + ret = ret2; 382 + p = p->next; 383 + } 384 + 385 + spin_unlock(&vnode->wb_lock); 386 + if (*_wbk) 387 + afs_put_wb_key(*_wbk); 388 + *_wbk = wbk; 389 + return 0; 390 + } 391 + 392 + static void afs_store_data_success(struct afs_operation *op) 393 + { 394 + struct afs_vnode *vnode = op->file[0].vnode; 395 + 396 + afs_vnode_commit_status(op, &op->file[0]); 397 + if (op->error == 0) { 398 + afs_pages_written_back(vnode, op->store.first, op->store.last); 399 + afs_stat_v(vnode, n_stores); 400 + atomic_long_add((op->store.last * PAGE_SIZE + op->store.last_to) - 401 + (op->store.first * PAGE_SIZE + op->store.first_offset), 402 + &afs_v2net(vnode)->n_store_bytes); 403 + } 404 + } 405 + 406 + static const struct afs_operation_ops afs_store_data_operation = { 407 + .issue_afs_rpc = afs_fs_store_data, 408 + .issue_yfs_rpc = yfs_fs_store_data, 409 + .success = afs_store_data_success, 410 + }; 411 + 412 + /* 352 413 * write to a file 353 414 */ 354 415 static int afs_store_data(struct address_space *mapping, ··· 417 356 unsigned offset, unsigned to) 418 357 { 419 358 struct afs_vnode *vnode = AFS_FS_I(mapping->host); 420 - struct afs_operation fc; 421 - struct afs_status_cb *scb; 359 + struct afs_operation *op; 422 360 struct afs_wb_key *wbk = NULL; 423 - struct list_head *p; 424 - int ret = -ENOKEY, ret2; 361 + int ret; 425 362 426 363 _enter("%s{%llx:%llu.%u},%lx,%lx,%x,%x", 427 364 vnode->volume->name, ··· 428 369 vnode->fid.unique, 429 370 first, last, offset, to); 430 371 431 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS); 432 - if (!scb) 372 + ret = afs_get_writeback_key(vnode, &wbk); 373 + if (ret) { 374 + _leave(" = %d [no keys]", ret); 375 + return ret; 376 + } 377 + 378 + op = afs_alloc_operation(wbk->key, vnode->volume); 379 + if (IS_ERR(op)) { 380 + afs_put_wb_key(wbk); 433 381 return -ENOMEM; 382 + } 434 383 435 - spin_lock(&vnode->wb_lock); 436 - p = vnode->wb_keys.next; 384 + afs_op_set_vnode(op, 0, vnode); 385 + op->file[0].dv_delta = 1; 386 + op->store.mapping = mapping; 387 + op->store.first = first; 388 + op->store.last = last; 389 + op->store.first_offset = offset; 390 + op->store.last_to = to; 391 + op->ops = &afs_store_data_operation; 437 392 438 - /* Iterate through the list looking for a valid key to use. */ 439 393 try_next_key: 440 - while (p != &vnode->wb_keys) { 441 - wbk = list_entry(p, struct afs_wb_key, vnode_link); 442 - _debug("wbk %u", key_serial(wbk->key)); 443 - ret2 = key_validate(wbk->key); 444 - if (ret2 == 0) 445 - goto found_key; 446 - if (ret == -ENOKEY) 447 - ret = ret2; 448 - p = p->next; 449 - } 394 + afs_begin_vnode_operation(op); 395 + afs_wait_for_operation(op); 450 396 451 - spin_unlock(&vnode->wb_lock); 452 - afs_put_wb_key(wbk); 453 - kfree(scb); 454 - _leave(" = %d [no keys]", ret); 455 - return ret; 456 - 457 - found_key: 458 - refcount_inc(&wbk->usage); 459 - spin_unlock(&vnode->wb_lock); 460 - 461 - _debug("USE WB KEY %u", key_serial(wbk->key)); 462 - 463 - ret = -ERESTARTSYS; 464 - if (afs_begin_vnode_operation(&fc, vnode, wbk->key, false)) { 465 - afs_dataversion_t data_version = vnode->status.data_version + 1; 466 - 467 - while (afs_select_fileserver(&fc)) { 468 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 469 - afs_fs_store_data(&fc, mapping, first, last, offset, to, scb); 470 - } 471 - 472 - afs_check_for_remote_deletion(&fc, vnode); 473 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 474 - &data_version, scb); 475 - if (fc.ac.error == 0) 476 - afs_pages_written_back(vnode, first, last); 477 - ret = afs_end_vnode_operation(&fc); 478 - } 479 - 480 - switch (ret) { 481 - case 0: 482 - afs_stat_v(vnode, n_stores); 483 - atomic_long_add((last * PAGE_SIZE + to) - 484 - (first * PAGE_SIZE + offset), 485 - &afs_v2net(vnode)->n_store_bytes); 486 - break; 397 + switch (op->error) { 487 398 case -EACCES: 488 399 case -EPERM: 489 400 case -ENOKEY: ··· 461 432 case -EKEYREJECTED: 462 433 case -EKEYREVOKED: 463 434 _debug("next"); 464 - spin_lock(&vnode->wb_lock); 465 - p = wbk->vnode_link.next; 466 - afs_put_wb_key(wbk); 467 - goto try_next_key; 435 + 436 + ret = afs_get_writeback_key(vnode, &wbk); 437 + if (ret == 0) { 438 + key_put(op->key); 439 + op->key = key_get(wbk->key); 440 + goto try_next_key; 441 + } 442 + break; 468 443 } 469 444 470 445 afs_put_wb_key(wbk); 471 - kfree(scb); 472 - _leave(" = %d", ret); 473 - return ret; 446 + _leave(" = %d", op->error); 447 + return afs_put_operation(op); 474 448 } 475 449 476 450 /*
+127 -173
fs/afs/xattr.c
··· 35 35 } 36 36 37 37 /* 38 + * Deal with the result of a successful fetch ACL operation. 39 + */ 40 + static void afs_acl_success(struct afs_operation *op) 41 + { 42 + afs_vnode_commit_status(op, &op->file[0]); 43 + } 44 + 45 + static void afs_acl_put(struct afs_operation *op) 46 + { 47 + kfree(op->acl); 48 + } 49 + 50 + static const struct afs_operation_ops afs_fetch_acl_operation = { 51 + .issue_afs_rpc = afs_fs_fetch_acl, 52 + .success = afs_acl_success, 53 + .put = afs_acl_put, 54 + }; 55 + 56 + /* 38 57 * Get a file's ACL. 39 58 */ 40 59 static int afs_xattr_get_acl(const struct xattr_handler *handler, ··· 61 42 struct inode *inode, const char *name, 62 43 void *buffer, size_t size) 63 44 { 64 - struct afs_operation fc; 65 - struct afs_status_cb *scb; 45 + struct afs_operation *op; 66 46 struct afs_vnode *vnode = AFS_FS_I(inode); 67 47 struct afs_acl *acl = NULL; 68 - struct key *key; 69 - int ret = -ENOMEM; 48 + int ret; 70 49 71 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS); 72 - if (!scb) 73 - goto error; 50 + op = afs_alloc_operation(NULL, vnode->volume); 51 + if (IS_ERR(op)) 52 + return -ENOMEM; 74 53 75 - key = afs_request_key(vnode->volume->cell); 76 - if (IS_ERR(key)) { 77 - ret = PTR_ERR(key); 78 - goto error_scb; 79 - } 54 + afs_op_set_vnode(op, 0, vnode); 55 + op->ops = &afs_fetch_acl_operation; 80 56 81 - ret = -ERESTARTSYS; 82 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 83 - afs_dataversion_t data_version = vnode->status.data_version; 84 - 85 - while (afs_select_fileserver(&fc)) { 86 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 87 - acl = afs_fs_fetch_acl(&fc, scb); 88 - } 89 - 90 - afs_check_for_remote_deletion(&fc, fc.vnode); 91 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 92 - &data_version, scb); 93 - ret = afs_end_vnode_operation(&fc); 94 - } 57 + afs_begin_vnode_operation(op); 58 + afs_wait_for_operation(op); 59 + acl = op->acl; 60 + op->acl = NULL; 61 + ret = afs_put_operation(op); 95 62 96 63 if (ret == 0) { 97 64 ret = acl->size; ··· 85 80 if (acl->size <= size) 86 81 memcpy(buffer, acl->data, acl->size); 87 82 else 88 - ret = -ERANGE; 83 + op->error = -ERANGE; 89 84 } 90 - kfree(acl); 91 85 } 92 86 93 - key_put(key); 94 - error_scb: 95 - kfree(scb); 96 - error: 87 + kfree(acl); 97 88 return ret; 98 89 } 90 + 91 + static bool afs_make_acl(struct afs_operation *op, 92 + const void *buffer, size_t size) 93 + { 94 + struct afs_acl *acl; 95 + 96 + acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); 97 + if (!acl) { 98 + afs_op_nomem(op); 99 + return false; 100 + } 101 + 102 + acl->size = size; 103 + memcpy(acl->data, buffer, size); 104 + op->acl = acl; 105 + return true; 106 + } 107 + 108 + static const struct afs_operation_ops afs_store_acl_operation = { 109 + .issue_afs_rpc = afs_fs_store_acl, 110 + .success = afs_acl_success, 111 + .put = afs_acl_put, 112 + }; 99 113 100 114 /* 101 115 * Set a file's AFS3 ACL. ··· 124 100 struct inode *inode, const char *name, 125 101 const void *buffer, size_t size, int flags) 126 102 { 127 - struct afs_operation fc; 128 - struct afs_status_cb *scb; 103 + struct afs_operation *op; 129 104 struct afs_vnode *vnode = AFS_FS_I(inode); 130 - struct afs_acl *acl = NULL; 131 - struct key *key; 132 - int ret = -ENOMEM; 133 105 134 106 if (flags == XATTR_CREATE) 135 107 return -EINVAL; 136 108 137 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS); 138 - if (!scb) 139 - goto error; 109 + op = afs_alloc_operation(NULL, vnode->volume); 110 + if (IS_ERR(op)) 111 + return -ENOMEM; 140 112 141 - acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); 142 - if (!acl) 143 - goto error_scb; 113 + afs_op_set_vnode(op, 0, vnode); 114 + if (!afs_make_acl(op, buffer, size)) 115 + return afs_put_operation(op); 144 116 145 - key = afs_request_key(vnode->volume->cell); 146 - if (IS_ERR(key)) { 147 - ret = PTR_ERR(key); 148 - goto error_acl; 149 - } 150 - 151 - acl->size = size; 152 - memcpy(acl->data, buffer, size); 153 - 154 - ret = -ERESTARTSYS; 155 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 156 - afs_dataversion_t data_version = vnode->status.data_version; 157 - 158 - while (afs_select_fileserver(&fc)) { 159 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 160 - afs_fs_store_acl(&fc, acl, scb); 161 - } 162 - 163 - afs_check_for_remote_deletion(&fc, fc.vnode); 164 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 165 - &data_version, scb); 166 - ret = afs_end_vnode_operation(&fc); 167 - } 168 - 169 - key_put(key); 170 - error_acl: 171 - kfree(acl); 172 - error_scb: 173 - kfree(scb); 174 - error: 175 - return ret; 117 + op->ops = &afs_store_acl_operation; 118 + return afs_do_sync_operation(op); 176 119 } 177 120 178 121 static const struct xattr_handler afs_xattr_afs_acl_handler = { 179 122 .name = "afs.acl", 180 123 .get = afs_xattr_get_acl, 181 124 .set = afs_xattr_set_acl, 125 + }; 126 + 127 + static void yfs_acl_put(struct afs_operation *op) 128 + { 129 + yfs_free_opaque_acl(op->yacl); 130 + } 131 + 132 + static const struct afs_operation_ops yfs_fetch_opaque_acl_operation = { 133 + .issue_yfs_rpc = yfs_fs_fetch_opaque_acl, 134 + .success = afs_acl_success, 135 + /* Don't free op->yacl in .put here */ 182 136 }; 183 137 184 138 /* ··· 167 165 struct inode *inode, const char *name, 168 166 void *buffer, size_t size) 169 167 { 170 - struct afs_operation fc; 171 - struct afs_status_cb *scb; 168 + struct afs_operation *op; 172 169 struct afs_vnode *vnode = AFS_FS_I(inode); 173 170 struct yfs_acl *yacl = NULL; 174 - struct key *key; 175 171 char buf[16], *data; 176 172 int which = 0, dsize, ret = -ENOMEM; 177 173 ··· 193 193 else if (which == 3) 194 194 yacl->flags |= YFS_ACL_WANT_VOL_ACL; 195 195 196 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS); 197 - if (!scb) 196 + op = afs_alloc_operation(NULL, vnode->volume); 197 + if (IS_ERR(op)) 198 198 goto error_yacl; 199 199 200 - key = afs_request_key(vnode->volume->cell); 201 - if (IS_ERR(key)) { 202 - ret = PTR_ERR(key); 203 - goto error_scb; 204 - } 200 + afs_op_set_vnode(op, 0, vnode); 201 + op->yacl = yacl; 202 + op->ops = &yfs_fetch_opaque_acl_operation; 205 203 206 - ret = -ERESTARTSYS; 207 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 208 - afs_dataversion_t data_version = vnode->status.data_version; 204 + afs_begin_vnode_operation(op); 205 + afs_wait_for_operation(op); 206 + ret = afs_put_operation(op); 209 207 210 - while (afs_select_fileserver(&fc)) { 211 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 212 - yfs_fs_fetch_opaque_acl(&fc, yacl, scb); 208 + if (ret == 0) { 209 + switch (which) { 210 + case 0: 211 + data = yacl->acl->data; 212 + dsize = yacl->acl->size; 213 + break; 214 + case 1: 215 + data = buf; 216 + dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag); 217 + break; 218 + case 2: 219 + data = buf; 220 + dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned); 221 + break; 222 + case 3: 223 + data = yacl->vol_acl->data; 224 + dsize = yacl->vol_acl->size; 225 + break; 226 + default: 227 + ret = -EOPNOTSUPP; 228 + goto error_yacl; 213 229 } 214 230 215 - afs_check_for_remote_deletion(&fc, fc.vnode); 216 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 217 - &data_version, scb); 218 - ret = afs_end_vnode_operation(&fc); 219 - } 220 - 221 - if (ret < 0) 222 - goto error_key; 223 - 224 - switch (which) { 225 - case 0: 226 - data = yacl->acl->data; 227 - dsize = yacl->acl->size; 228 - break; 229 - case 1: 230 - data = buf; 231 - dsize = scnprintf(buf, sizeof(buf), "%u", yacl->inherit_flag); 232 - break; 233 - case 2: 234 - data = buf; 235 - dsize = scnprintf(buf, sizeof(buf), "%u", yacl->num_cleaned); 236 - break; 237 - case 3: 238 - data = yacl->vol_acl->data; 239 - dsize = yacl->vol_acl->size; 240 - break; 241 - default: 242 - ret = -EOPNOTSUPP; 243 - goto error_key; 244 - } 245 - 246 - ret = dsize; 247 - if (size > 0) { 248 - if (dsize > size) { 249 - ret = -ERANGE; 250 - goto error_key; 231 + ret = dsize; 232 + if (size > 0) { 233 + if (dsize <= size) 234 + memcpy(buffer, data, dsize); 235 + else 236 + ret = -ERANGE; 251 237 } 252 - memcpy(buffer, data, dsize); 253 238 } 254 239 255 - error_key: 256 - key_put(key); 257 - error_scb: 258 - kfree(scb); 259 240 error_yacl: 260 241 yfs_free_opaque_acl(yacl); 261 242 error: 262 243 return ret; 263 244 } 245 + 246 + static const struct afs_operation_ops yfs_store_opaque_acl2_operation = { 247 + .issue_yfs_rpc = yfs_fs_store_opaque_acl2, 248 + .success = afs_acl_success, 249 + .put = yfs_acl_put, 250 + }; 264 251 265 252 /* 266 253 * Set a file's YFS ACL. ··· 257 270 struct inode *inode, const char *name, 258 271 const void *buffer, size_t size, int flags) 259 272 { 260 - struct afs_operation fc; 261 - struct afs_status_cb *scb; 273 + struct afs_operation *op; 262 274 struct afs_vnode *vnode = AFS_FS_I(inode); 263 - struct afs_acl *acl = NULL; 264 - struct key *key; 265 - int ret = -ENOMEM; 266 275 267 276 if (flags == XATTR_CREATE || 268 277 strcmp(name, "acl") != 0) 269 278 return -EINVAL; 270 279 271 - scb = kzalloc(sizeof(struct afs_status_cb), GFP_NOFS); 272 - if (!scb) 273 - goto error; 280 + op = afs_alloc_operation(NULL, vnode->volume); 281 + if (IS_ERR(op)) 282 + return -ENOMEM; 274 283 275 - acl = kmalloc(sizeof(*acl) + size, GFP_KERNEL); 276 - if (!acl) 277 - goto error_scb; 284 + afs_op_set_vnode(op, 0, vnode); 285 + if (!afs_make_acl(op, buffer, size)) 286 + return afs_put_operation(op); 278 287 279 - acl->size = size; 280 - memcpy(acl->data, buffer, size); 281 - 282 - key = afs_request_key(vnode->volume->cell); 283 - if (IS_ERR(key)) { 284 - ret = PTR_ERR(key); 285 - goto error_acl; 286 - } 287 - 288 - ret = -ERESTARTSYS; 289 - if (afs_begin_vnode_operation(&fc, vnode, key, true)) { 290 - afs_dataversion_t data_version = vnode->status.data_version; 291 - 292 - while (afs_select_fileserver(&fc)) { 293 - fc.cb_break = afs_calc_vnode_cb_break(vnode); 294 - yfs_fs_store_opaque_acl2(&fc, acl, scb); 295 - } 296 - 297 - afs_check_for_remote_deletion(&fc, fc.vnode); 298 - afs_vnode_commit_status(&fc, vnode, fc.cb_break, 299 - &data_version, scb); 300 - ret = afs_end_vnode_operation(&fc); 301 - } 302 - 303 - error_acl: 304 - kfree(acl); 305 - key_put(key); 306 - error_scb: 307 - kfree(scb); 308 - error: 309 - return ret; 288 + op->ops = &yfs_store_opaque_acl2_operation; 289 + return afs_do_sync_operation(op); 310 290 } 311 291 312 292 static const struct xattr_handler afs_xattr_yfs_handler = {
+359 -483
fs/afs/yfsclient.c
··· 17 17 18 18 static const struct afs_fid afs_zero_fid; 19 19 20 - static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi) 21 - { 22 - call->cbi = afs_get_cb_interest(cbi); 23 - } 24 - 25 20 #define xdr_size(x) (sizeof(*x) / sizeof(__be32)) 26 21 27 22 static void xdr_decode_YFSFid(const __be32 **_bp, struct afs_fid *fid) ··· 72 77 } 73 78 74 79 return bp + len / sizeof(__be32); 80 + } 81 + 82 + static __be32 *xdr_encode_name(__be32 *bp, const struct qstr *p) 83 + { 84 + return xdr_encode_string(bp, p->name, p->len); 75 85 } 76 86 77 87 static s64 linux_to_yfs_time(const struct timespec64 *t) ··· 336 336 */ 337 337 static int yfs_deliver_fs_status_cb_and_volsync(struct afs_call *call) 338 338 { 339 + struct afs_operation *op = call->op; 339 340 const __be32 *bp; 340 341 int ret; 341 342 ··· 346 345 347 346 /* unmarshall the reply once we've received all of it */ 348 347 bp = call->buffer; 349 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 350 - xdr_decode_YFSCallBack(&bp, call, call->out_scb); 351 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 348 + xdr_decode_YFSFetchStatus(&bp, call, &op->file[0].scb); 349 + xdr_decode_YFSCallBack(&bp, call, &op->file[0].scb); 350 + xdr_decode_YFSVolSync(&bp, &op->volsync); 352 351 353 352 _leave(" = 0 [done]"); 354 353 return 0; ··· 360 359 */ 361 360 static int yfs_deliver_status_and_volsync(struct afs_call *call) 362 361 { 362 + struct afs_operation *op = call->op; 363 363 const __be32 *bp; 364 364 int ret; 365 365 ··· 369 367 return ret; 370 368 371 369 bp = call->buffer; 372 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 373 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 370 + xdr_decode_YFSFetchStatus(&bp, call, &op->file[0].scb); 371 + xdr_decode_YFSVolSync(&bp, &op->volsync); 374 372 375 373 _leave(" = 0 [done]"); 376 374 return 0; ··· 389 387 /* 390 388 * Fetch the status information for a file. 391 389 */ 392 - int yfs_fs_fetch_file_status(struct afs_operation *fc, struct afs_status_cb *scb, 393 - struct afs_volsync *volsync) 390 + void yfs_fs_fetch_file_status(struct afs_operation *op) 394 391 { 395 - struct afs_vnode *vnode = fc->vnode; 392 + struct afs_vnode_param *vp = &op->file[0]; 396 393 struct afs_call *call; 397 - struct afs_net *net = afs_v2net(vnode); 398 394 __be32 *bp; 399 395 400 396 _enter(",%x,{%llx:%llu},,", 401 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 397 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 402 398 403 - call = afs_alloc_flat_call(net, &yfs_RXYFSFetchStatus_vnode, 399 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchStatus_vnode, 404 400 sizeof(__be32) * 2 + 405 401 sizeof(struct yfs_xdr_YFSFid), 406 402 sizeof(struct yfs_xdr_YFSFetchStatus) + 407 403 sizeof(struct yfs_xdr_YFSCallBack) + 408 404 sizeof(struct yfs_xdr_YFSVolSync)); 409 - if (!call) { 410 - fc->ac.error = -ENOMEM; 411 - return -ENOMEM; 412 - } 413 - 414 - call->key = fc->key; 415 - call->out_scb = scb; 416 - call->out_volsync = volsync; 405 + if (!call) 406 + return afs_op_nomem(op); 417 407 418 408 /* marshall the parameters */ 419 409 bp = call->request; 420 410 bp = xdr_encode_u32(bp, YFSFETCHSTATUS); 421 411 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 422 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 412 + bp = xdr_encode_YFSFid(bp, &vp->fid); 423 413 yfs_check_req(call, bp); 424 414 425 - afs_use_fs_server(call, fc->cbi); 426 - trace_afs_make_fs_call(call, &vnode->fid); 427 - afs_set_fc_call(call, fc); 428 - afs_make_call(&fc->ac, call, GFP_NOFS); 429 - return afs_wait_for_call_to_complete(call, &fc->ac); 415 + trace_afs_make_fs_call(call, &vp->fid); 416 + afs_make_op_call(op, call, GFP_NOFS); 430 417 } 431 418 432 419 /* ··· 423 432 */ 424 433 static int yfs_deliver_fs_fetch_data64(struct afs_call *call) 425 434 { 426 - struct afs_read *req = call->read_request; 435 + struct afs_operation *op = call->op; 436 + struct afs_vnode_param *vp = &op->file[0]; 437 + struct afs_read *req = op->fetch.req; 427 438 const __be32 *bp; 428 439 unsigned int size; 429 440 int ret; ··· 520 527 return ret; 521 528 522 529 bp = call->buffer; 523 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 524 - xdr_decode_YFSCallBack(&bp, call, call->out_scb); 525 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 530 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 531 + xdr_decode_YFSCallBack(&bp, call, &vp->scb); 532 + xdr_decode_YFSVolSync(&bp, &op->volsync); 526 533 527 - req->data_version = call->out_scb->status.data_version; 528 - req->file_size = call->out_scb->status.size; 534 + req->data_version = vp->scb.status.data_version; 535 + req->file_size = vp->scb.status.size; 529 536 530 537 call->unmarshall++; 531 538 /* Fall through */ ··· 549 556 return 0; 550 557 } 551 558 552 - static void yfs_fetch_data_destructor(struct afs_call *call) 553 - { 554 - afs_put_read(call->read_request); 555 - afs_flat_call_destructor(call); 556 - } 557 - 558 559 /* 559 560 * YFS.FetchData64 operation type 560 561 */ ··· 556 569 .name = "YFS.FetchData64", 557 570 .op = yfs_FS_FetchData64, 558 571 .deliver = yfs_deliver_fs_fetch_data64, 559 - .destructor = yfs_fetch_data_destructor, 572 + .destructor = afs_flat_call_destructor, 560 573 }; 561 574 562 575 /* 563 576 * Fetch data from a file. 564 577 */ 565 - int yfs_fs_fetch_data(struct afs_operation *fc, struct afs_status_cb *scb, 566 - struct afs_read *req) 578 + void yfs_fs_fetch_data(struct afs_operation *op) 567 579 { 568 - struct afs_vnode *vnode = fc->vnode; 580 + struct afs_vnode_param *vp = &op->file[0]; 581 + struct afs_read *req = op->fetch.req; 569 582 struct afs_call *call; 570 - struct afs_net *net = afs_v2net(vnode); 571 583 __be32 *bp; 572 584 573 585 _enter(",%x,{%llx:%llu},%llx,%llx", 574 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode, 586 + key_serial(op->key), vp->fid.vid, vp->fid.vnode, 575 587 req->pos, req->len); 576 588 577 - call = afs_alloc_flat_call(net, &yfs_RXYFSFetchData64, 589 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchData64, 578 590 sizeof(__be32) * 2 + 579 591 sizeof(struct yfs_xdr_YFSFid) + 580 592 sizeof(struct yfs_xdr_u64) * 2, ··· 581 595 sizeof(struct yfs_xdr_YFSCallBack) + 582 596 sizeof(struct yfs_xdr_YFSVolSync)); 583 597 if (!call) 584 - return -ENOMEM; 585 - 586 - call->key = fc->key; 587 - call->out_scb = scb; 588 - call->out_volsync = NULL; 589 - call->read_request = afs_get_read(req); 598 + return afs_op_nomem(op); 590 599 591 600 /* marshall the parameters */ 592 601 bp = call->request; 593 602 bp = xdr_encode_u32(bp, YFSFETCHDATA64); 594 603 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 595 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 604 + bp = xdr_encode_YFSFid(bp, &vp->fid); 596 605 bp = xdr_encode_u64(bp, req->pos); 597 606 bp = xdr_encode_u64(bp, req->len); 598 607 yfs_check_req(call, bp); 599 608 600 - afs_use_fs_server(call, fc->cbi); 601 - trace_afs_make_fs_call(call, &vnode->fid); 602 - afs_set_fc_call(call, fc); 603 - afs_make_call(&fc->ac, call, GFP_NOFS); 604 - return afs_wait_for_call_to_complete(call, &fc->ac); 609 + trace_afs_make_fs_call(call, &vp->fid); 610 + afs_make_op_call(op, call, GFP_NOFS); 605 611 } 606 612 607 613 /* ··· 601 623 */ 602 624 static int yfs_deliver_fs_create_vnode(struct afs_call *call) 603 625 { 626 + struct afs_operation *op = call->op; 627 + struct afs_vnode_param *dvp = &op->file[0]; 628 + struct afs_vnode_param *vp = &op->file[1]; 604 629 const __be32 *bp; 605 630 int ret; 606 631 ··· 615 634 616 635 /* unmarshall the reply once we've received all of it */ 617 636 bp = call->buffer; 618 - xdr_decode_YFSFid(&bp, call->out_fid); 619 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 620 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 621 - xdr_decode_YFSCallBack(&bp, call, call->out_scb); 622 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 637 + xdr_decode_YFSFid(&bp, &op->file[1].fid); 638 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 639 + xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb); 640 + xdr_decode_YFSCallBack(&bp, call, &vp->scb); 641 + xdr_decode_YFSVolSync(&bp, &op->volsync); 623 642 624 643 _leave(" = 0 [done]"); 625 644 return 0; ··· 638 657 /* 639 658 * Create a file. 640 659 */ 641 - int yfs_fs_create_file(struct afs_operation *fc, 642 - const char *name, 643 - umode_t mode, 644 - struct afs_status_cb *dvnode_scb, 645 - struct afs_fid *newfid, 646 - struct afs_status_cb *new_scb) 660 + void yfs_fs_create_file(struct afs_operation *op) 647 661 { 648 - struct afs_vnode *dvnode = fc->vnode; 662 + const struct qstr *name = &op->dentry->d_name; 663 + struct afs_vnode_param *dvp = &op->file[0]; 649 664 struct afs_call *call; 650 - struct afs_net *net = afs_v2net(dvnode); 651 - size_t namesz, reqsz, rplsz; 665 + size_t reqsz, rplsz; 652 666 __be32 *bp; 653 667 654 668 _enter(""); 655 669 656 - namesz = strlen(name); 657 670 reqsz = (sizeof(__be32) + 658 671 sizeof(__be32) + 659 672 sizeof(struct yfs_xdr_YFSFid) + 660 - xdr_strlen(namesz) + 673 + xdr_strlen(name->len) + 661 674 sizeof(struct yfs_xdr_YFSStoreStatus) + 662 675 sizeof(__be32)); 663 676 rplsz = (sizeof(struct yfs_xdr_YFSFid) + ··· 660 685 sizeof(struct yfs_xdr_YFSCallBack) + 661 686 sizeof(struct yfs_xdr_YFSVolSync)); 662 687 663 - call = afs_alloc_flat_call(net, &afs_RXFSCreateFile, reqsz, rplsz); 688 + call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile, reqsz, rplsz); 664 689 if (!call) 665 - return -ENOMEM; 666 - 667 - call->key = fc->key; 668 - call->out_dir_scb = dvnode_scb; 669 - call->out_fid = newfid; 670 - call->out_scb = new_scb; 690 + return afs_op_nomem(op); 671 691 672 692 /* marshall the parameters */ 673 693 bp = call->request; 674 694 bp = xdr_encode_u32(bp, YFSCREATEFILE); 675 695 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 676 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 677 - bp = xdr_encode_string(bp, name, namesz); 678 - bp = xdr_encode_YFSStoreStatus_mode(bp, mode); 696 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 697 + bp = xdr_encode_name(bp, name); 698 + bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode); 679 699 bp = xdr_encode_u32(bp, yfs_LockNone); /* ViceLockType */ 680 700 yfs_check_req(call, bp); 681 701 682 - afs_use_fs_server(call, fc->cbi); 683 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 684 - afs_set_fc_call(call, fc); 685 - afs_make_call(&fc->ac, call, GFP_NOFS); 686 - return afs_wait_for_call_to_complete(call, &fc->ac); 702 + trace_afs_make_fs_call1(call, &dvp->fid, name); 703 + afs_make_op_call(op, call, GFP_NOFS); 687 704 } 688 705 689 706 static const struct afs_call_type yfs_RXFSMakeDir = { ··· 688 721 /* 689 722 * Make a directory. 690 723 */ 691 - int yfs_fs_make_dir(struct afs_operation *fc, 692 - const char *name, 693 - umode_t mode, 694 - struct afs_status_cb *dvnode_scb, 695 - struct afs_fid *newfid, 696 - struct afs_status_cb *new_scb) 724 + void yfs_fs_make_dir(struct afs_operation *op) 697 725 { 698 - struct afs_vnode *dvnode = fc->vnode; 726 + const struct qstr *name = &op->dentry->d_name; 727 + struct afs_vnode_param *dvp = &op->file[0]; 699 728 struct afs_call *call; 700 - struct afs_net *net = afs_v2net(dvnode); 701 - size_t namesz, reqsz, rplsz; 729 + size_t reqsz, rplsz; 702 730 __be32 *bp; 703 731 704 732 _enter(""); 705 733 706 - namesz = strlen(name); 707 734 reqsz = (sizeof(__be32) + 708 735 sizeof(struct yfs_xdr_RPCFlags) + 709 736 sizeof(struct yfs_xdr_YFSFid) + 710 - xdr_strlen(namesz) + 737 + xdr_strlen(name->len) + 711 738 sizeof(struct yfs_xdr_YFSStoreStatus)); 712 739 rplsz = (sizeof(struct yfs_xdr_YFSFid) + 713 740 sizeof(struct yfs_xdr_YFSFetchStatus) + ··· 709 748 sizeof(struct yfs_xdr_YFSCallBack) + 710 749 sizeof(struct yfs_xdr_YFSVolSync)); 711 750 712 - call = afs_alloc_flat_call(net, &yfs_RXFSMakeDir, reqsz, rplsz); 751 + call = afs_alloc_flat_call(op->net, &yfs_RXFSMakeDir, reqsz, rplsz); 713 752 if (!call) 714 - return -ENOMEM; 715 - 716 - call->key = fc->key; 717 - call->out_dir_scb = dvnode_scb; 718 - call->out_fid = newfid; 719 - call->out_scb = new_scb; 753 + return afs_op_nomem(op); 720 754 721 755 /* marshall the parameters */ 722 756 bp = call->request; 723 757 bp = xdr_encode_u32(bp, YFSMAKEDIR); 724 758 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 725 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 726 - bp = xdr_encode_string(bp, name, namesz); 727 - bp = xdr_encode_YFSStoreStatus_mode(bp, mode); 759 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 760 + bp = xdr_encode_name(bp, name); 761 + bp = xdr_encode_YFSStoreStatus_mode(bp, op->create.mode); 728 762 yfs_check_req(call, bp); 729 763 730 - afs_use_fs_server(call, fc->cbi); 731 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 732 - afs_set_fc_call(call, fc); 733 - afs_make_call(&fc->ac, call, GFP_NOFS); 734 - return afs_wait_for_call_to_complete(call, &fc->ac); 764 + trace_afs_make_fs_call1(call, &dvp->fid, name); 765 + afs_make_op_call(op, call, GFP_NOFS); 735 766 } 736 767 737 768 /* ··· 731 778 */ 732 779 static int yfs_deliver_fs_remove_file2(struct afs_call *call) 733 780 { 781 + struct afs_operation *op = call->op; 782 + struct afs_vnode_param *dvp = &op->file[0]; 783 + struct afs_vnode_param *vp = &op->file[1]; 734 784 struct afs_fid fid; 735 785 const __be32 *bp; 736 786 int ret; ··· 745 789 return ret; 746 790 747 791 bp = call->buffer; 748 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 792 + xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb); 749 793 xdr_decode_YFSFid(&bp, &fid); 750 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 794 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 751 795 /* Was deleted if vnode->status.abort_code == VNOVNODE. */ 752 796 753 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 797 + xdr_decode_YFSVolSync(&bp, &op->volsync); 754 798 return 0; 799 + } 800 + 801 + static void yfs_done_fs_remove_file2(struct afs_call *call) 802 + { 803 + if (call->error == -ECONNABORTED && 804 + call->abort_code == RX_INVALID_OPERATION) { 805 + set_bit(AFS_SERVER_FL_NO_RM2, &call->server->flags); 806 + call->op->flags |= AFS_OPERATION_DOWNGRADE; 807 + } 755 808 } 756 809 757 810 /* ··· 770 805 .name = "YFS.RemoveFile2", 771 806 .op = yfs_FS_RemoveFile2, 772 807 .deliver = yfs_deliver_fs_remove_file2, 808 + .done = yfs_done_fs_remove_file2, 773 809 .destructor = afs_flat_call_destructor, 774 810 }; 775 811 776 812 /* 777 813 * Remove a file and retrieve new file status. 778 814 */ 779 - int yfs_fs_remove_file2(struct afs_operation *fc, struct afs_vnode *vnode, 780 - const char *name, struct afs_status_cb *dvnode_scb, 781 - struct afs_status_cb *vnode_scb) 815 + void yfs_fs_remove_file2(struct afs_operation *op) 782 816 { 783 - struct afs_vnode *dvnode = fc->vnode; 817 + struct afs_vnode_param *dvp = &op->file[0]; 818 + const struct qstr *name = &op->dentry->d_name; 784 819 struct afs_call *call; 785 - struct afs_net *net = afs_v2net(dvnode); 786 - size_t namesz; 787 820 __be32 *bp; 788 821 789 822 _enter(""); 790 823 791 - namesz = strlen(name); 792 - 793 - call = afs_alloc_flat_call(net, &yfs_RXYFSRemoveFile2, 824 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveFile2, 794 825 sizeof(__be32) + 795 826 sizeof(struct yfs_xdr_RPCFlags) + 796 827 sizeof(struct yfs_xdr_YFSFid) + 797 - xdr_strlen(namesz), 828 + xdr_strlen(name->len), 798 829 sizeof(struct yfs_xdr_YFSFetchStatus) + 799 830 sizeof(struct yfs_xdr_YFSFid) + 800 831 sizeof(struct yfs_xdr_YFSFetchStatus) + 801 832 sizeof(struct yfs_xdr_YFSVolSync)); 802 833 if (!call) 803 - return -ENOMEM; 804 - 805 - call->key = fc->key; 806 - call->out_dir_scb = dvnode_scb; 807 - call->out_scb = vnode_scb; 834 + return afs_op_nomem(op); 808 835 809 836 /* marshall the parameters */ 810 837 bp = call->request; 811 838 bp = xdr_encode_u32(bp, YFSREMOVEFILE2); 812 839 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 813 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 814 - bp = xdr_encode_string(bp, name, namesz); 840 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 841 + bp = xdr_encode_name(bp, name); 815 842 yfs_check_req(call, bp); 816 843 817 - afs_use_fs_server(call, fc->cbi); 818 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 819 - afs_set_fc_call(call, fc); 820 - afs_make_call(&fc->ac, call, GFP_NOFS); 821 - return afs_wait_for_call_to_complete(call, &fc->ac); 844 + trace_afs_make_fs_call1(call, &dvp->fid, name); 845 + afs_make_op_call(op, call, GFP_NOFS); 822 846 } 823 847 824 848 /* ··· 815 861 */ 816 862 static int yfs_deliver_fs_remove(struct afs_call *call) 817 863 { 864 + struct afs_operation *op = call->op; 865 + struct afs_vnode_param *dvp = &op->file[0]; 818 866 const __be32 *bp; 819 867 int ret; 820 868 ··· 827 871 return ret; 828 872 829 873 bp = call->buffer; 830 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 831 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 874 + xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb); 875 + xdr_decode_YFSVolSync(&bp, &op->volsync); 832 876 return 0; 833 877 } 834 878 ··· 842 886 .destructor = afs_flat_call_destructor, 843 887 }; 844 888 889 + /* 890 + * Remove a file. 891 + */ 892 + void yfs_fs_remove_file(struct afs_operation *op) 893 + { 894 + const struct qstr *name = &op->dentry->d_name; 895 + struct afs_vnode_param *dvp = &op->file[0]; 896 + struct afs_call *call; 897 + __be32 *bp; 898 + 899 + _enter(""); 900 + 901 + if (!test_bit(AFS_SERVER_FL_NO_RM2, &op->cbi->server->flags)) 902 + return yfs_fs_remove_file2(op); 903 + 904 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveFile, 905 + sizeof(__be32) + 906 + sizeof(struct yfs_xdr_RPCFlags) + 907 + sizeof(struct yfs_xdr_YFSFid) + 908 + xdr_strlen(name->len), 909 + sizeof(struct yfs_xdr_YFSFetchStatus) + 910 + sizeof(struct yfs_xdr_YFSVolSync)); 911 + if (!call) 912 + return afs_op_nomem(op); 913 + 914 + /* marshall the parameters */ 915 + bp = call->request; 916 + bp = xdr_encode_u32(bp, YFSREMOVEFILE); 917 + bp = xdr_encode_u32(bp, 0); /* RPC flags */ 918 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 919 + bp = xdr_encode_name(bp, name); 920 + yfs_check_req(call, bp); 921 + 922 + trace_afs_make_fs_call1(call, &dvp->fid, name); 923 + afs_make_op_call(op, call, GFP_NOFS); 924 + } 925 + 845 926 static const struct afs_call_type yfs_RXYFSRemoveDir = { 846 927 .name = "YFS.RemoveDir", 847 928 .op = yfs_FS_RemoveDir, ··· 887 894 }; 888 895 889 896 /* 890 - * remove a file or directory 897 + * Remove a directory. 891 898 */ 892 - int yfs_fs_remove(struct afs_operation *fc, struct afs_vnode *vnode, 893 - const char *name, bool isdir, 894 - struct afs_status_cb *dvnode_scb) 899 + void yfs_fs_remove_dir(struct afs_operation *op) 895 900 { 896 - struct afs_vnode *dvnode = fc->vnode; 901 + const struct qstr *name = &op->dentry->d_name; 902 + struct afs_vnode_param *dvp = &op->file[0]; 897 903 struct afs_call *call; 898 - struct afs_net *net = afs_v2net(dvnode); 899 - size_t namesz; 900 904 __be32 *bp; 901 905 902 906 _enter(""); 903 907 904 - namesz = strlen(name); 905 - call = afs_alloc_flat_call( 906 - net, isdir ? &yfs_RXYFSRemoveDir : &yfs_RXYFSRemoveFile, 907 - sizeof(__be32) + 908 - sizeof(struct yfs_xdr_RPCFlags) + 909 - sizeof(struct yfs_xdr_YFSFid) + 910 - xdr_strlen(namesz), 911 - sizeof(struct yfs_xdr_YFSFetchStatus) + 912 - sizeof(struct yfs_xdr_YFSVolSync)); 908 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSRemoveDir, 909 + sizeof(__be32) + 910 + sizeof(struct yfs_xdr_RPCFlags) + 911 + sizeof(struct yfs_xdr_YFSFid) + 912 + xdr_strlen(name->len), 913 + sizeof(struct yfs_xdr_YFSFetchStatus) + 914 + sizeof(struct yfs_xdr_YFSVolSync)); 913 915 if (!call) 914 - return -ENOMEM; 915 - 916 - call->key = fc->key; 917 - call->out_dir_scb = dvnode_scb; 916 + return afs_op_nomem(op); 918 917 919 918 /* marshall the parameters */ 920 919 bp = call->request; 921 - bp = xdr_encode_u32(bp, isdir ? YFSREMOVEDIR : YFSREMOVEFILE); 920 + bp = xdr_encode_u32(bp, YFSREMOVEDIR); 922 921 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 923 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 924 - bp = xdr_encode_string(bp, name, namesz); 922 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 923 + bp = xdr_encode_name(bp, name); 925 924 yfs_check_req(call, bp); 926 925 927 - afs_use_fs_server(call, fc->cbi); 928 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 929 - afs_set_fc_call(call, fc); 930 - afs_make_call(&fc->ac, call, GFP_NOFS); 931 - return afs_wait_for_call_to_complete(call, &fc->ac); 926 + trace_afs_make_fs_call1(call, &dvp->fid, name); 927 + afs_make_op_call(op, call, GFP_NOFS); 932 928 } 933 929 934 930 /* ··· 925 943 */ 926 944 static int yfs_deliver_fs_link(struct afs_call *call) 927 945 { 946 + struct afs_operation *op = call->op; 947 + struct afs_vnode_param *dvp = &op->file[0]; 948 + struct afs_vnode_param *vp = &op->file[1]; 928 949 const __be32 *bp; 929 950 int ret; 930 951 ··· 938 953 return ret; 939 954 940 955 bp = call->buffer; 941 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 942 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 943 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 956 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 957 + xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb); 958 + xdr_decode_YFSVolSync(&bp, &op->volsync); 944 959 _leave(" = 0 [done]"); 945 960 return 0; 946 961 } ··· 958 973 /* 959 974 * Make a hard link. 960 975 */ 961 - int yfs_fs_link(struct afs_operation *fc, struct afs_vnode *vnode, 962 - const char *name, 963 - struct afs_status_cb *dvnode_scb, 964 - struct afs_status_cb *vnode_scb) 976 + void yfs_fs_link(struct afs_operation *op) 965 977 { 966 - struct afs_vnode *dvnode = fc->vnode; 978 + const struct qstr *name = &op->dentry->d_name; 979 + struct afs_vnode_param *dvp = &op->file[0]; 980 + struct afs_vnode_param *vp = &op->file[1]; 967 981 struct afs_call *call; 968 - struct afs_net *net = afs_v2net(vnode); 969 - size_t namesz; 970 982 __be32 *bp; 971 983 972 984 _enter(""); 973 985 974 - namesz = strlen(name); 975 - call = afs_alloc_flat_call(net, &yfs_RXYFSLink, 986 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSLink, 976 987 sizeof(__be32) + 977 988 sizeof(struct yfs_xdr_RPCFlags) + 978 989 sizeof(struct yfs_xdr_YFSFid) + 979 - xdr_strlen(namesz) + 990 + xdr_strlen(name->len) + 980 991 sizeof(struct yfs_xdr_YFSFid), 981 992 sizeof(struct yfs_xdr_YFSFetchStatus) + 982 993 sizeof(struct yfs_xdr_YFSFetchStatus) + 983 994 sizeof(struct yfs_xdr_YFSVolSync)); 984 995 if (!call) 985 - return -ENOMEM; 986 - 987 - call->key = fc->key; 988 - call->out_dir_scb = dvnode_scb; 989 - call->out_scb = vnode_scb; 996 + return afs_op_nomem(op); 990 997 991 998 /* marshall the parameters */ 992 999 bp = call->request; 993 1000 bp = xdr_encode_u32(bp, YFSLINK); 994 1001 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 995 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 996 - bp = xdr_encode_string(bp, name, namesz); 997 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1002 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 1003 + bp = xdr_encode_name(bp, name); 1004 + bp = xdr_encode_YFSFid(bp, &vp->fid); 998 1005 yfs_check_req(call, bp); 999 1006 1000 - afs_use_fs_server(call, fc->cbi); 1001 - trace_afs_make_fs_call1(call, &vnode->fid, name); 1002 - afs_set_fc_call(call, fc); 1003 - afs_make_call(&fc->ac, call, GFP_NOFS); 1004 - return afs_wait_for_call_to_complete(call, &fc->ac); 1007 + trace_afs_make_fs_call1(call, &vp->fid, name); 1008 + afs_make_op_call(op, call, GFP_NOFS); 1005 1009 } 1006 1010 1007 1011 /* ··· 998 1024 */ 999 1025 static int yfs_deliver_fs_symlink(struct afs_call *call) 1000 1026 { 1027 + struct afs_operation *op = call->op; 1028 + struct afs_vnode_param *dvp = &op->file[0]; 1029 + struct afs_vnode_param *vp = &op->file[1]; 1001 1030 const __be32 *bp; 1002 1031 int ret; 1003 1032 ··· 1012 1035 1013 1036 /* unmarshall the reply once we've received all of it */ 1014 1037 bp = call->buffer; 1015 - xdr_decode_YFSFid(&bp, call->out_fid); 1016 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 1017 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 1018 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 1038 + xdr_decode_YFSFid(&bp, &vp->fid); 1039 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 1040 + xdr_decode_YFSFetchStatus(&bp, call, &dvp->scb); 1041 + xdr_decode_YFSVolSync(&bp, &op->volsync); 1019 1042 1020 1043 _leave(" = 0 [done]"); 1021 1044 return 0; ··· 1034 1057 /* 1035 1058 * Create a symbolic link. 1036 1059 */ 1037 - int yfs_fs_symlink(struct afs_operation *fc, 1038 - const char *name, 1039 - const char *contents, 1040 - struct afs_status_cb *dvnode_scb, 1041 - struct afs_fid *newfid, 1042 - struct afs_status_cb *vnode_scb) 1060 + void yfs_fs_symlink(struct afs_operation *op) 1043 1061 { 1044 - struct afs_vnode *dvnode = fc->vnode; 1062 + const struct qstr *name = &op->dentry->d_name; 1063 + struct afs_vnode_param *dvp = &op->file[0]; 1045 1064 struct afs_call *call; 1046 - struct afs_net *net = afs_v2net(dvnode); 1047 - size_t namesz, contents_sz; 1065 + size_t contents_sz; 1048 1066 __be32 *bp; 1049 1067 1050 1068 _enter(""); 1051 1069 1052 - namesz = strlen(name); 1053 - contents_sz = strlen(contents); 1054 - call = afs_alloc_flat_call(net, &yfs_RXYFSSymlink, 1070 + contents_sz = strlen(op->create.symlink); 1071 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSSymlink, 1055 1072 sizeof(__be32) + 1056 1073 sizeof(struct yfs_xdr_RPCFlags) + 1057 1074 sizeof(struct yfs_xdr_YFSFid) + 1058 - xdr_strlen(namesz) + 1075 + xdr_strlen(name->len) + 1059 1076 xdr_strlen(contents_sz) + 1060 1077 sizeof(struct yfs_xdr_YFSStoreStatus), 1061 1078 sizeof(struct yfs_xdr_YFSFid) + ··· 1057 1086 sizeof(struct yfs_xdr_YFSFetchStatus) + 1058 1087 sizeof(struct yfs_xdr_YFSVolSync)); 1059 1088 if (!call) 1060 - return -ENOMEM; 1061 - 1062 - call->key = fc->key; 1063 - call->out_dir_scb = dvnode_scb; 1064 - call->out_fid = newfid; 1065 - call->out_scb = vnode_scb; 1089 + return afs_op_nomem(op); 1066 1090 1067 1091 /* marshall the parameters */ 1068 1092 bp = call->request; 1069 1093 bp = xdr_encode_u32(bp, YFSSYMLINK); 1070 1094 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1071 - bp = xdr_encode_YFSFid(bp, &dvnode->fid); 1072 - bp = xdr_encode_string(bp, name, namesz); 1073 - bp = xdr_encode_string(bp, contents, contents_sz); 1095 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 1096 + bp = xdr_encode_name(bp, name); 1097 + bp = xdr_encode_string(bp, op->create.symlink, contents_sz); 1074 1098 bp = xdr_encode_YFSStoreStatus_mode(bp, S_IRWXUGO); 1075 1099 yfs_check_req(call, bp); 1076 1100 1077 - afs_use_fs_server(call, fc->cbi); 1078 - trace_afs_make_fs_call1(call, &dvnode->fid, name); 1079 - afs_set_fc_call(call, fc); 1080 - afs_make_call(&fc->ac, call, GFP_NOFS); 1081 - return afs_wait_for_call_to_complete(call, &fc->ac); 1101 + trace_afs_make_fs_call1(call, &dvp->fid, name); 1102 + afs_make_op_call(op, call, GFP_NOFS); 1082 1103 } 1083 1104 1084 1105 /* ··· 1078 1115 */ 1079 1116 static int yfs_deliver_fs_rename(struct afs_call *call) 1080 1117 { 1118 + struct afs_operation *op = call->op; 1119 + struct afs_vnode_param *orig_dvp = &op->file[0]; 1120 + struct afs_vnode_param *new_dvp = &op->file[1]; 1081 1121 const __be32 *bp; 1082 1122 int ret; 1083 1123 ··· 1094 1128 /* If the two dirs are the same, we have two copies of the same status 1095 1129 * report, so we just decode it twice. 1096 1130 */ 1097 - xdr_decode_YFSFetchStatus(&bp, call, call->out_dir_scb); 1098 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 1099 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 1131 + xdr_decode_YFSFetchStatus(&bp, call, &orig_dvp->scb); 1132 + xdr_decode_YFSFetchStatus(&bp, call, &new_dvp->scb); 1133 + xdr_decode_YFSVolSync(&bp, &op->volsync); 1100 1134 _leave(" = 0 [done]"); 1101 1135 return 0; 1102 1136 } ··· 1114 1148 /* 1115 1149 * Rename a file or directory. 1116 1150 */ 1117 - int yfs_fs_rename(struct afs_operation *fc, 1118 - const char *orig_name, 1119 - struct afs_vnode *new_dvnode, 1120 - const char *new_name, 1121 - struct afs_status_cb *orig_dvnode_scb, 1122 - struct afs_status_cb *new_dvnode_scb) 1151 + void yfs_fs_rename(struct afs_operation *op) 1123 1152 { 1124 - struct afs_vnode *orig_dvnode = fc->vnode; 1153 + struct afs_vnode_param *orig_dvp = &op->file[0]; 1154 + struct afs_vnode_param *new_dvp = &op->file[1]; 1155 + const struct qstr *orig_name = &op->dentry->d_name; 1156 + const struct qstr *new_name = &op->dentry_2->d_name; 1125 1157 struct afs_call *call; 1126 - struct afs_net *net = afs_v2net(orig_dvnode); 1127 - size_t o_namesz, n_namesz; 1128 1158 __be32 *bp; 1129 1159 1130 1160 _enter(""); 1131 1161 1132 - o_namesz = strlen(orig_name); 1133 - n_namesz = strlen(new_name); 1134 - call = afs_alloc_flat_call(net, &yfs_RXYFSRename, 1162 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSRename, 1135 1163 sizeof(__be32) + 1136 1164 sizeof(struct yfs_xdr_RPCFlags) + 1137 1165 sizeof(struct yfs_xdr_YFSFid) + 1138 - xdr_strlen(o_namesz) + 1166 + xdr_strlen(orig_name->len) + 1139 1167 sizeof(struct yfs_xdr_YFSFid) + 1140 - xdr_strlen(n_namesz), 1168 + xdr_strlen(new_name->len), 1141 1169 sizeof(struct yfs_xdr_YFSFetchStatus) + 1142 1170 sizeof(struct yfs_xdr_YFSFetchStatus) + 1143 1171 sizeof(struct yfs_xdr_YFSVolSync)); 1144 1172 if (!call) 1145 - return -ENOMEM; 1146 - 1147 - call->key = fc->key; 1148 - call->out_dir_scb = orig_dvnode_scb; 1149 - call->out_scb = new_dvnode_scb; 1173 + return afs_op_nomem(op); 1150 1174 1151 1175 /* marshall the parameters */ 1152 1176 bp = call->request; 1153 1177 bp = xdr_encode_u32(bp, YFSRENAME); 1154 1178 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1155 - bp = xdr_encode_YFSFid(bp, &orig_dvnode->fid); 1156 - bp = xdr_encode_string(bp, orig_name, o_namesz); 1157 - bp = xdr_encode_YFSFid(bp, &new_dvnode->fid); 1158 - bp = xdr_encode_string(bp, new_name, n_namesz); 1179 + bp = xdr_encode_YFSFid(bp, &orig_dvp->fid); 1180 + bp = xdr_encode_name(bp, orig_name); 1181 + bp = xdr_encode_YFSFid(bp, &new_dvp->fid); 1182 + bp = xdr_encode_name(bp, new_name); 1159 1183 yfs_check_req(call, bp); 1160 1184 1161 - afs_use_fs_server(call, fc->cbi); 1162 - trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name); 1163 - afs_set_fc_call(call, fc); 1164 - afs_make_call(&fc->ac, call, GFP_NOFS); 1165 - return afs_wait_for_call_to_complete(call, &fc->ac); 1185 + trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name); 1186 + afs_make_op_call(op, call, GFP_NOFS); 1166 1187 } 1167 1188 1168 1189 /* ··· 1165 1212 /* 1166 1213 * Store a set of pages to a large file. 1167 1214 */ 1168 - int yfs_fs_store_data(struct afs_operation *fc, struct address_space *mapping, 1169 - pgoff_t first, pgoff_t last, 1170 - unsigned offset, unsigned to, 1171 - struct afs_status_cb *scb) 1215 + void yfs_fs_store_data(struct afs_operation *op) 1172 1216 { 1173 - struct afs_vnode *vnode = fc->vnode; 1217 + struct afs_vnode_param *vp = &op->file[0]; 1174 1218 struct afs_call *call; 1175 - struct afs_net *net = afs_v2net(vnode); 1176 1219 loff_t size, pos, i_size; 1177 1220 __be32 *bp; 1178 1221 1179 1222 _enter(",%x,{%llx:%llu},,", 1180 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1223 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1181 1224 1182 - size = (loff_t)to - (loff_t)offset; 1183 - if (first != last) 1184 - size += (loff_t)(last - first) << PAGE_SHIFT; 1185 - pos = (loff_t)first << PAGE_SHIFT; 1186 - pos += offset; 1225 + size = (loff_t)op->store.last_to - (loff_t)op->store.first_offset; 1226 + if (op->store.first != op->store.last) 1227 + size += (loff_t)(op->store.last - op->store.first) << PAGE_SHIFT; 1228 + pos = (loff_t)op->store.first << PAGE_SHIFT; 1229 + pos += op->store.first_offset; 1187 1230 1188 - i_size = i_size_read(&vnode->vfs_inode); 1231 + i_size = i_size_read(&vp->vnode->vfs_inode); 1189 1232 if (pos + size > i_size) 1190 1233 i_size = size + pos; 1191 1234 ··· 1189 1240 (unsigned long long)size, (unsigned long long)pos, 1190 1241 (unsigned long long)i_size); 1191 1242 1192 - call = afs_alloc_flat_call(net, &yfs_RXYFSStoreData64, 1243 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64, 1193 1244 sizeof(__be32) + 1194 1245 sizeof(__be32) + 1195 1246 sizeof(struct yfs_xdr_YFSFid) + ··· 1198 1249 sizeof(struct yfs_xdr_YFSFetchStatus) + 1199 1250 sizeof(struct yfs_xdr_YFSVolSync)); 1200 1251 if (!call) 1201 - return -ENOMEM; 1252 + return afs_op_nomem(op); 1202 1253 1203 - call->key = fc->key; 1204 - call->mapping = mapping; 1205 - call->first = first; 1206 - call->last = last; 1207 - call->first_offset = offset; 1208 - call->last_to = to; 1254 + call->key = op->key; 1209 1255 call->send_pages = true; 1210 - call->out_scb = scb; 1211 1256 1212 1257 /* marshall the parameters */ 1213 1258 bp = call->request; 1214 1259 bp = xdr_encode_u32(bp, YFSSTOREDATA64); 1215 1260 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1216 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1217 - bp = xdr_encode_YFSStoreStatus_mtime(bp, &vnode->vfs_inode.i_mtime); 1261 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1262 + bp = xdr_encode_YFSStoreStatus_mtime(bp, &op->mtime); 1218 1263 bp = xdr_encode_u64(bp, pos); 1219 1264 bp = xdr_encode_u64(bp, size); 1220 1265 bp = xdr_encode_u64(bp, i_size); 1221 1266 yfs_check_req(call, bp); 1222 1267 1223 - afs_use_fs_server(call, fc->cbi); 1224 - trace_afs_make_fs_call(call, &vnode->fid); 1225 - afs_set_fc_call(call, fc); 1226 - afs_make_call(&fc->ac, call, GFP_NOFS); 1227 - return afs_wait_for_call_to_complete(call, &fc->ac); 1268 + trace_afs_make_fs_call(call, &vp->fid); 1269 + afs_make_op_call(op, call, GFP_NOFS); 1228 1270 } 1229 1271 1230 1272 /* ··· 1239 1299 * Set the attributes on a file, using YFS.StoreData64 rather than 1240 1300 * YFS.StoreStatus so as to alter the file size also. 1241 1301 */ 1242 - static int yfs_fs_setattr_size(struct afs_operation *fc, struct iattr *attr, 1243 - struct afs_status_cb *scb) 1302 + static void yfs_fs_setattr_size(struct afs_operation *op) 1244 1303 { 1245 - struct afs_vnode *vnode = fc->vnode; 1304 + struct afs_vnode_param *vp = &op->file[0]; 1246 1305 struct afs_call *call; 1247 - struct afs_net *net = afs_v2net(vnode); 1306 + struct iattr *attr = op->setattr.attr; 1248 1307 __be32 *bp; 1249 1308 1250 1309 _enter(",%x,{%llx:%llu},,", 1251 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1310 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1252 1311 1253 - call = afs_alloc_flat_call(net, &yfs_RXYFSStoreData64_as_Status, 1312 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreData64_as_Status, 1254 1313 sizeof(__be32) * 2 + 1255 1314 sizeof(struct yfs_xdr_YFSFid) + 1256 1315 sizeof(struct yfs_xdr_YFSStoreStatus) + ··· 1257 1318 sizeof(struct yfs_xdr_YFSFetchStatus) + 1258 1319 sizeof(struct yfs_xdr_YFSVolSync)); 1259 1320 if (!call) 1260 - return -ENOMEM; 1261 - 1262 - call->key = fc->key; 1263 - call->out_scb = scb; 1321 + return afs_op_nomem(op); 1264 1322 1265 1323 /* marshall the parameters */ 1266 1324 bp = call->request; 1267 1325 bp = xdr_encode_u32(bp, YFSSTOREDATA64); 1268 1326 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1269 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1327 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1270 1328 bp = xdr_encode_YFS_StoreStatus(bp, attr); 1271 1329 bp = xdr_encode_u64(bp, attr->ia_size); /* position of start of write */ 1272 1330 bp = xdr_encode_u64(bp, 0); /* size of write */ 1273 1331 bp = xdr_encode_u64(bp, attr->ia_size); /* new file length */ 1274 1332 yfs_check_req(call, bp); 1275 1333 1276 - afs_use_fs_server(call, fc->cbi); 1277 - trace_afs_make_fs_call(call, &vnode->fid); 1278 - afs_set_fc_call(call, fc); 1279 - afs_make_call(&fc->ac, call, GFP_NOFS); 1280 - return afs_wait_for_call_to_complete(call, &fc->ac); 1334 + trace_afs_make_fs_call(call, &vp->fid); 1335 + afs_make_op_call(op, call, GFP_NOFS); 1281 1336 } 1282 1337 1283 1338 /* 1284 1339 * Set the attributes on a file, using YFS.StoreData64 if there's a change in 1285 1340 * file size, and YFS.StoreStatus otherwise. 1286 1341 */ 1287 - int yfs_fs_setattr(struct afs_operation *fc, struct iattr *attr, 1288 - struct afs_status_cb *scb) 1342 + void yfs_fs_setattr(struct afs_operation *op) 1289 1343 { 1290 - struct afs_vnode *vnode = fc->vnode; 1344 + struct afs_vnode_param *vp = &op->file[0]; 1291 1345 struct afs_call *call; 1292 - struct afs_net *net = afs_v2net(vnode); 1346 + struct iattr *attr = op->setattr.attr; 1293 1347 __be32 *bp; 1294 1348 1295 1349 if (attr->ia_valid & ATTR_SIZE) 1296 - return yfs_fs_setattr_size(fc, attr, scb); 1350 + return yfs_fs_setattr_size(op); 1297 1351 1298 1352 _enter(",%x,{%llx:%llu},,", 1299 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 1353 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1300 1354 1301 - call = afs_alloc_flat_call(net, &yfs_RXYFSStoreStatus, 1355 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreStatus, 1302 1356 sizeof(__be32) * 2 + 1303 1357 sizeof(struct yfs_xdr_YFSFid) + 1304 1358 sizeof(struct yfs_xdr_YFSStoreStatus), 1305 1359 sizeof(struct yfs_xdr_YFSFetchStatus) + 1306 1360 sizeof(struct yfs_xdr_YFSVolSync)); 1307 1361 if (!call) 1308 - return -ENOMEM; 1309 - 1310 - call->key = fc->key; 1311 - call->out_scb = scb; 1362 + return afs_op_nomem(op); 1312 1363 1313 1364 /* marshall the parameters */ 1314 1365 bp = call->request; 1315 1366 bp = xdr_encode_u32(bp, YFSSTORESTATUS); 1316 1367 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1317 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1368 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1318 1369 bp = xdr_encode_YFS_StoreStatus(bp, attr); 1319 1370 yfs_check_req(call, bp); 1320 1371 1321 - afs_use_fs_server(call, fc->cbi); 1322 - trace_afs_make_fs_call(call, &vnode->fid); 1323 - afs_set_fc_call(call, fc); 1324 - afs_make_call(&fc->ac, call, GFP_NOFS); 1325 - return afs_wait_for_call_to_complete(call, &fc->ac); 1372 + trace_afs_make_fs_call(call, &vp->fid); 1373 + afs_make_op_call(op, call, GFP_NOFS); 1326 1374 } 1327 1375 1328 1376 /* ··· 1317 1391 */ 1318 1392 static int yfs_deliver_fs_get_volume_status(struct afs_call *call) 1319 1393 { 1394 + struct afs_operation *op = call->op; 1320 1395 const __be32 *bp; 1321 1396 char *p; 1322 1397 u32 size; ··· 1339 1412 return ret; 1340 1413 1341 1414 bp = call->buffer; 1342 - xdr_decode_YFSFetchVolumeStatus(&bp, call->out_volstatus); 1415 + xdr_decode_YFSFetchVolumeStatus(&bp, &op->volstatus.vs); 1343 1416 call->unmarshall++; 1344 1417 afs_extract_to_tmp(call); 1345 1418 /* Fall through */ ··· 1453 1526 /* 1454 1527 * fetch the status of a volume 1455 1528 */ 1456 - int yfs_fs_get_volume_status(struct afs_operation *fc, 1457 - struct afs_volume_status *vs) 1529 + void yfs_fs_get_volume_status(struct afs_operation *op) 1458 1530 { 1459 - struct afs_vnode *vnode = fc->vnode; 1531 + struct afs_vnode_param *vp = &op->file[0]; 1460 1532 struct afs_call *call; 1461 - struct afs_net *net = afs_v2net(vnode); 1462 1533 __be32 *bp; 1463 1534 1464 1535 _enter(""); 1465 1536 1466 - call = afs_alloc_flat_call(net, &yfs_RXYFSGetVolumeStatus, 1537 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSGetVolumeStatus, 1467 1538 sizeof(__be32) * 2 + 1468 1539 sizeof(struct yfs_xdr_u64), 1469 1540 max_t(size_t, ··· 1469 1544 sizeof(__be32), 1470 1545 AFSOPAQUEMAX + 1)); 1471 1546 if (!call) 1472 - return -ENOMEM; 1473 - 1474 - call->key = fc->key; 1475 - call->out_volstatus = vs; 1547 + return afs_op_nomem(op); 1476 1548 1477 1549 /* marshall the parameters */ 1478 1550 bp = call->request; 1479 1551 bp = xdr_encode_u32(bp, YFSGETVOLUMESTATUS); 1480 1552 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1481 - bp = xdr_encode_u64(bp, vnode->fid.vid); 1553 + bp = xdr_encode_u64(bp, vp->fid.vid); 1482 1554 yfs_check_req(call, bp); 1483 1555 1484 - afs_use_fs_server(call, fc->cbi); 1485 - trace_afs_make_fs_call(call, &vnode->fid); 1486 - afs_set_fc_call(call, fc); 1487 - afs_make_call(&fc->ac, call, GFP_NOFS); 1488 - return afs_wait_for_call_to_complete(call, &fc->ac); 1556 + trace_afs_make_fs_call(call, &vp->fid); 1557 + afs_make_op_call(op, call, GFP_NOFS); 1489 1558 } 1490 1559 1491 1560 /* ··· 1517 1598 /* 1518 1599 * Set a lock on a file 1519 1600 */ 1520 - int yfs_fs_set_lock(struct afs_operation *fc, afs_lock_type_t type, 1521 - struct afs_status_cb *scb) 1601 + void yfs_fs_set_lock(struct afs_operation *op) 1522 1602 { 1523 - struct afs_vnode *vnode = fc->vnode; 1603 + struct afs_vnode_param *vp = &op->file[0]; 1524 1604 struct afs_call *call; 1525 - struct afs_net *net = afs_v2net(vnode); 1526 1605 __be32 *bp; 1527 1606 1528 1607 _enter(""); 1529 1608 1530 - call = afs_alloc_flat_call(net, &yfs_RXYFSSetLock, 1609 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSSetLock, 1531 1610 sizeof(__be32) * 2 + 1532 1611 sizeof(struct yfs_xdr_YFSFid) + 1533 1612 sizeof(__be32), 1534 1613 sizeof(struct yfs_xdr_YFSFetchStatus) + 1535 1614 sizeof(struct yfs_xdr_YFSVolSync)); 1536 1615 if (!call) 1537 - return -ENOMEM; 1538 - 1539 - call->key = fc->key; 1540 - call->lvnode = vnode; 1541 - call->out_scb = scb; 1616 + return afs_op_nomem(op); 1542 1617 1543 1618 /* marshall the parameters */ 1544 1619 bp = call->request; 1545 1620 bp = xdr_encode_u32(bp, YFSSETLOCK); 1546 1621 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1547 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1548 - bp = xdr_encode_u32(bp, type); 1622 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1623 + bp = xdr_encode_u32(bp, op->lock.type); 1549 1624 yfs_check_req(call, bp); 1550 1625 1551 - afs_use_fs_server(call, fc->cbi); 1552 - trace_afs_make_fs_calli(call, &vnode->fid, type); 1553 - afs_set_fc_call(call, fc); 1554 - afs_make_call(&fc->ac, call, GFP_NOFS); 1555 - return afs_wait_for_call_to_complete(call, &fc->ac); 1626 + trace_afs_make_fs_calli(call, &vp->fid, op->lock.type); 1627 + afs_make_op_call(op, call, GFP_NOFS); 1556 1628 } 1557 1629 1558 1630 /* 1559 1631 * extend a lock on a file 1560 1632 */ 1561 - int yfs_fs_extend_lock(struct afs_operation *fc, struct afs_status_cb *scb) 1633 + void yfs_fs_extend_lock(struct afs_operation *op) 1562 1634 { 1563 - struct afs_vnode *vnode = fc->vnode; 1635 + struct afs_vnode_param *vp = &op->file[0]; 1564 1636 struct afs_call *call; 1565 - struct afs_net *net = afs_v2net(vnode); 1566 1637 __be32 *bp; 1567 1638 1568 1639 _enter(""); 1569 1640 1570 - call = afs_alloc_flat_call(net, &yfs_RXYFSExtendLock, 1641 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSExtendLock, 1571 1642 sizeof(__be32) * 2 + 1572 1643 sizeof(struct yfs_xdr_YFSFid), 1573 1644 sizeof(struct yfs_xdr_YFSFetchStatus) + 1574 1645 sizeof(struct yfs_xdr_YFSVolSync)); 1575 1646 if (!call) 1576 - return -ENOMEM; 1577 - 1578 - call->key = fc->key; 1579 - call->lvnode = vnode; 1580 - call->out_scb = scb; 1647 + return afs_op_nomem(op); 1581 1648 1582 1649 /* marshall the parameters */ 1583 1650 bp = call->request; 1584 1651 bp = xdr_encode_u32(bp, YFSEXTENDLOCK); 1585 1652 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1586 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1653 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1587 1654 yfs_check_req(call, bp); 1588 1655 1589 - afs_use_fs_server(call, fc->cbi); 1590 - trace_afs_make_fs_call(call, &vnode->fid); 1591 - afs_set_fc_call(call, fc); 1592 - afs_make_call(&fc->ac, call, GFP_NOFS); 1593 - return afs_wait_for_call_to_complete(call, &fc->ac); 1656 + trace_afs_make_fs_call(call, &vp->fid); 1657 + afs_make_op_call(op, call, GFP_NOFS); 1594 1658 } 1595 1659 1596 1660 /* 1597 1661 * release a lock on a file 1598 1662 */ 1599 - int yfs_fs_release_lock(struct afs_operation *fc, struct afs_status_cb *scb) 1663 + void yfs_fs_release_lock(struct afs_operation *op) 1600 1664 { 1601 - struct afs_vnode *vnode = fc->vnode; 1665 + struct afs_vnode_param *vp = &op->file[0]; 1602 1666 struct afs_call *call; 1603 - struct afs_net *net = afs_v2net(vnode); 1604 1667 __be32 *bp; 1605 1668 1606 1669 _enter(""); 1607 1670 1608 - call = afs_alloc_flat_call(net, &yfs_RXYFSReleaseLock, 1671 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSReleaseLock, 1609 1672 sizeof(__be32) * 2 + 1610 1673 sizeof(struct yfs_xdr_YFSFid), 1611 1674 sizeof(struct yfs_xdr_YFSFetchStatus) + 1612 1675 sizeof(struct yfs_xdr_YFSVolSync)); 1613 1676 if (!call) 1614 - return -ENOMEM; 1615 - 1616 - call->key = fc->key; 1617 - call->lvnode = vnode; 1618 - call->out_scb = scb; 1677 + return afs_op_nomem(op); 1619 1678 1620 1679 /* marshall the parameters */ 1621 1680 bp = call->request; 1622 1681 bp = xdr_encode_u32(bp, YFSRELEASELOCK); 1623 1682 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1624 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 1683 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1625 1684 yfs_check_req(call, bp); 1626 1685 1627 - afs_use_fs_server(call, fc->cbi); 1628 - trace_afs_make_fs_call(call, &vnode->fid); 1629 - afs_set_fc_call(call, fc); 1630 - afs_make_call(&fc->ac, call, GFP_NOFS); 1631 - return afs_wait_for_call_to_complete(call, &fc->ac); 1686 + trace_afs_make_fs_call(call, &vp->fid); 1687 + afs_make_op_call(op, call, GFP_NOFS); 1632 1688 } 1633 1689 1634 1690 /* ··· 1619 1725 /* 1620 1726 * Fetch the status information for a fid without needing a vnode handle. 1621 1727 */ 1622 - int yfs_fs_fetch_status(struct afs_operation *fc, 1623 - struct afs_net *net, 1624 - struct afs_fid *fid, 1625 - struct afs_status_cb *scb, 1626 - struct afs_volsync *volsync) 1728 + void yfs_fs_fetch_status(struct afs_operation *op) 1627 1729 { 1730 + struct afs_vnode_param *vp = &op->file[0]; 1628 1731 struct afs_call *call; 1629 1732 __be32 *bp; 1630 1733 1631 1734 _enter(",%x,{%llx:%llu},,", 1632 - key_serial(fc->key), fid->vid, fid->vnode); 1735 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1633 1736 1634 - call = afs_alloc_flat_call(net, &yfs_RXYFSFetchStatus, 1737 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchStatus, 1635 1738 sizeof(__be32) * 2 + 1636 1739 sizeof(struct yfs_xdr_YFSFid), 1637 1740 sizeof(struct yfs_xdr_YFSFetchStatus) + 1638 1741 sizeof(struct yfs_xdr_YFSCallBack) + 1639 1742 sizeof(struct yfs_xdr_YFSVolSync)); 1640 - if (!call) { 1641 - fc->ac.error = -ENOMEM; 1642 - return -ENOMEM; 1643 - } 1644 - 1645 - call->key = fc->key; 1646 - call->out_scb = scb; 1647 - call->out_volsync = volsync; 1743 + if (!call) 1744 + return afs_op_nomem(op); 1648 1745 1649 1746 /* marshall the parameters */ 1650 1747 bp = call->request; 1651 1748 bp = xdr_encode_u32(bp, YFSFETCHSTATUS); 1652 1749 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1653 - bp = xdr_encode_YFSFid(bp, fid); 1750 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1654 1751 yfs_check_req(call, bp); 1655 1752 1656 - afs_use_fs_server(call, fc->cbi); 1657 - trace_afs_make_fs_call(call, fid); 1658 - afs_set_fc_call(call, fc); 1659 - afs_make_call(&fc->ac, call, GFP_NOFS); 1660 - return afs_wait_for_call_to_complete(call, &fc->ac); 1753 + trace_afs_make_fs_call(call, &vp->fid); 1754 + afs_make_op_call(op, call, GFP_NOFS); 1661 1755 } 1662 1756 1663 1757 /* ··· 1653 1771 */ 1654 1772 static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call) 1655 1773 { 1774 + struct afs_operation *op = call->op; 1656 1775 struct afs_status_cb *scb; 1657 1776 const __be32 *bp; 1658 1777 u32 tmp; ··· 1675 1792 return ret; 1676 1793 1677 1794 tmp = ntohl(call->tmp); 1678 - _debug("status count: %u/%u", tmp, call->count2); 1679 - if (tmp != call->count2) 1795 + _debug("status count: %u/%u", tmp, op->nr_files); 1796 + if (tmp != op->nr_files) 1680 1797 return afs_protocol_error(call, afs_eproto_ibulkst_count); 1681 1798 1682 1799 call->count = 0; ··· 1691 1808 if (ret < 0) 1692 1809 return ret; 1693 1810 1811 + switch (call->count) { 1812 + case 0: 1813 + scb = &op->file[0].scb; 1814 + break; 1815 + case 1: 1816 + scb = &op->file[1].scb; 1817 + break; 1818 + default: 1819 + scb = &op->more_files[call->count - 2].scb; 1820 + break; 1821 + } 1822 + 1694 1823 bp = call->buffer; 1695 - scb = &call->out_scb[call->count]; 1696 1824 xdr_decode_YFSFetchStatus(&bp, call, scb); 1697 1825 1698 1826 call->count++; 1699 - if (call->count < call->count2) 1827 + if (call->count < op->nr_files) 1700 1828 goto more_counts; 1701 1829 1702 1830 call->count = 0; ··· 1724 1830 1725 1831 tmp = ntohl(call->tmp); 1726 1832 _debug("CB count: %u", tmp); 1727 - if (tmp != call->count2) 1833 + if (tmp != op->nr_files) 1728 1834 return afs_protocol_error(call, afs_eproto_ibulkst_cb_count); 1729 1835 call->count = 0; 1730 1836 call->unmarshall++; ··· 1739 1845 return ret; 1740 1846 1741 1847 _debug("unmarshall CB array"); 1848 + switch (call->count) { 1849 + case 0: 1850 + scb = &op->file[0].scb; 1851 + break; 1852 + case 1: 1853 + scb = &op->file[1].scb; 1854 + break; 1855 + default: 1856 + scb = &op->more_files[call->count - 2].scb; 1857 + break; 1858 + } 1859 + 1742 1860 bp = call->buffer; 1743 - scb = &call->out_scb[call->count]; 1744 1861 xdr_decode_YFSCallBack(&bp, call, scb); 1745 1862 call->count++; 1746 - if (call->count < call->count2) 1863 + if (call->count < op->nr_files) 1747 1864 goto more_cbs; 1748 1865 1749 1866 afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSVolSync)); ··· 1767 1862 return ret; 1768 1863 1769 1864 bp = call->buffer; 1770 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 1865 + xdr_decode_YFSVolSync(&bp, &op->volsync); 1771 1866 1772 1867 call->unmarshall++; 1773 1868 /* Fall through */ ··· 1793 1888 /* 1794 1889 * Fetch the status information for up to 1024 files 1795 1890 */ 1796 - int yfs_fs_inline_bulk_status(struct afs_operation *fc, 1797 - struct afs_net *net, 1798 - struct afs_fid *fids, 1799 - struct afs_status_cb *statuses, 1800 - unsigned int nr_fids, 1801 - struct afs_volsync *volsync) 1891 + void yfs_fs_inline_bulk_status(struct afs_operation *op) 1802 1892 { 1893 + struct afs_vnode_param *dvp = &op->file[0]; 1894 + struct afs_vnode_param *vp = &op->file[1]; 1803 1895 struct afs_call *call; 1804 1896 __be32 *bp; 1805 1897 int i; 1806 1898 1807 1899 _enter(",%x,{%llx:%llu},%u", 1808 - key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids); 1900 + key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files); 1809 1901 1810 - call = afs_alloc_flat_call(net, &yfs_RXYFSInlineBulkStatus, 1902 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSInlineBulkStatus, 1811 1903 sizeof(__be32) + 1812 1904 sizeof(__be32) + 1813 1905 sizeof(__be32) + 1814 - sizeof(struct yfs_xdr_YFSFid) * nr_fids, 1906 + sizeof(struct yfs_xdr_YFSFid) * op->nr_files, 1815 1907 sizeof(struct yfs_xdr_YFSFetchStatus)); 1816 - if (!call) { 1817 - fc->ac.error = -ENOMEM; 1818 - return -ENOMEM; 1819 - } 1820 - 1821 - call->key = fc->key; 1822 - call->out_scb = statuses; 1823 - call->out_volsync = volsync; 1824 - call->count2 = nr_fids; 1908 + if (!call) 1909 + return afs_op_nomem(op); 1825 1910 1826 1911 /* marshall the parameters */ 1827 1912 bp = call->request; 1828 1913 bp = xdr_encode_u32(bp, YFSINLINEBULKSTATUS); 1829 1914 bp = xdr_encode_u32(bp, 0); /* RPCFlags */ 1830 - bp = xdr_encode_u32(bp, nr_fids); 1831 - for (i = 0; i < nr_fids; i++) 1832 - bp = xdr_encode_YFSFid(bp, &fids[i]); 1915 + bp = xdr_encode_u32(bp, op->nr_files); 1916 + bp = xdr_encode_YFSFid(bp, &dvp->fid); 1917 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1918 + for (i = 0; i < op->nr_files - 2; i++) 1919 + bp = xdr_encode_YFSFid(bp, &op->more_files[i].fid); 1833 1920 yfs_check_req(call, bp); 1834 1921 1835 - afs_use_fs_server(call, fc->cbi); 1836 - trace_afs_make_fs_call(call, &fids[0]); 1837 - afs_set_fc_call(call, fc); 1838 - afs_make_call(&fc->ac, call, GFP_NOFS); 1839 - return afs_wait_for_call_to_complete(call, &fc->ac); 1922 + trace_afs_make_fs_call(call, &vp->fid); 1923 + afs_make_op_call(op, call, GFP_NOFS); 1840 1924 } 1841 1925 1842 1926 /* ··· 1833 1939 */ 1834 1940 static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call) 1835 1941 { 1836 - struct yfs_acl *yacl = call->out_yacl; 1942 + struct afs_operation *op = call->op; 1943 + struct afs_vnode_param *vp = &op->file[0]; 1944 + struct yfs_acl *yacl = op->yacl; 1837 1945 struct afs_acl *acl; 1838 1946 const __be32 *bp; 1839 1947 unsigned int size; ··· 1925 2029 bp = call->buffer; 1926 2030 yacl->inherit_flag = ntohl(*bp++); 1927 2031 yacl->num_cleaned = ntohl(*bp++); 1928 - xdr_decode_YFSFetchStatus(&bp, call, call->out_scb); 1929 - xdr_decode_YFSVolSync(&bp, call->out_volsync); 2032 + xdr_decode_YFSFetchStatus(&bp, call, &vp->scb); 2033 + xdr_decode_YFSVolSync(&bp, &op->volsync); 1930 2034 1931 2035 call->unmarshall++; 1932 2036 /* Fall through */ ··· 1961 2065 /* 1962 2066 * Fetch the YFS advanced ACLs for a file. 1963 2067 */ 1964 - struct yfs_acl *yfs_fs_fetch_opaque_acl(struct afs_operation *fc, 1965 - struct yfs_acl *yacl, 1966 - struct afs_status_cb *scb) 2068 + void yfs_fs_fetch_opaque_acl(struct afs_operation *op) 1967 2069 { 1968 - struct afs_vnode *vnode = fc->vnode; 2070 + struct afs_vnode_param *vp = &op->file[0]; 1969 2071 struct afs_call *call; 1970 - struct afs_net *net = afs_v2net(vnode); 1971 2072 __be32 *bp; 1972 2073 1973 2074 _enter(",%x,{%llx:%llu},,", 1974 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 2075 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 1975 2076 1976 - call = afs_alloc_flat_call(net, &yfs_RXYFSFetchOpaqueACL, 2077 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSFetchOpaqueACL, 1977 2078 sizeof(__be32) * 2 + 1978 2079 sizeof(struct yfs_xdr_YFSFid), 1979 2080 sizeof(__be32) * 2 + 1980 2081 sizeof(struct yfs_xdr_YFSFetchStatus) + 1981 2082 sizeof(struct yfs_xdr_YFSVolSync)); 1982 - if (!call) { 1983 - fc->ac.error = -ENOMEM; 1984 - return ERR_PTR(-ENOMEM); 1985 - } 1986 - 1987 - call->key = fc->key; 1988 - call->out_yacl = yacl; 1989 - call->out_scb = scb; 1990 - call->out_volsync = NULL; 2083 + if (!call) 2084 + return afs_op_nomem(op); 1991 2085 1992 2086 /* marshall the parameters */ 1993 2087 bp = call->request; 1994 2088 bp = xdr_encode_u32(bp, YFSFETCHOPAQUEACL); 1995 2089 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 1996 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 2090 + bp = xdr_encode_YFSFid(bp, &vp->fid); 1997 2091 yfs_check_req(call, bp); 1998 2092 1999 - afs_use_fs_server(call, fc->cbi); 2000 - trace_afs_make_fs_call(call, &vnode->fid); 2001 - afs_make_call(&fc->ac, call, GFP_KERNEL); 2002 - return (struct yfs_acl *)afs_wait_for_call_to_complete(call, &fc->ac); 2093 + trace_afs_make_fs_call(call, &vp->fid); 2094 + afs_make_op_call(op, call, GFP_KERNEL); 2003 2095 } 2004 2096 2005 2097 /* ··· 2003 2119 /* 2004 2120 * Fetch the YFS ACL for a file. 2005 2121 */ 2006 - int yfs_fs_store_opaque_acl2(struct afs_operation *fc, const struct afs_acl *acl, 2007 - struct afs_status_cb *scb) 2122 + void yfs_fs_store_opaque_acl2(struct afs_operation *op) 2008 2123 { 2009 - struct afs_vnode *vnode = fc->vnode; 2124 + struct afs_vnode_param *vp = &op->file[0]; 2010 2125 struct afs_call *call; 2011 - struct afs_net *net = afs_v2net(vnode); 2126 + struct afs_acl *acl = op->acl; 2012 2127 size_t size; 2013 2128 __be32 *bp; 2014 2129 2015 2130 _enter(",%x,{%llx:%llu},,", 2016 - key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode); 2131 + key_serial(op->key), vp->fid.vid, vp->fid.vnode); 2017 2132 2018 2133 size = round_up(acl->size, 4); 2019 - call = afs_alloc_flat_call(net, &yfs_RXYFSStoreOpaqueACL2, 2134 + call = afs_alloc_flat_call(op->net, &yfs_RXYFSStoreOpaqueACL2, 2020 2135 sizeof(__be32) * 2 + 2021 2136 sizeof(struct yfs_xdr_YFSFid) + 2022 2137 sizeof(__be32) + size, 2023 2138 sizeof(struct yfs_xdr_YFSFetchStatus) + 2024 2139 sizeof(struct yfs_xdr_YFSVolSync)); 2025 - if (!call) { 2026 - fc->ac.error = -ENOMEM; 2027 - return -ENOMEM; 2028 - } 2029 - 2030 - call->key = fc->key; 2031 - call->out_scb = scb; 2032 - call->out_volsync = NULL; 2140 + if (!call) 2141 + return afs_op_nomem(op); 2033 2142 2034 2143 /* marshall the parameters */ 2035 2144 bp = call->request; 2036 2145 bp = xdr_encode_u32(bp, YFSSTOREOPAQUEACL2); 2037 2146 bp = xdr_encode_u32(bp, 0); /* RPC flags */ 2038 - bp = xdr_encode_YFSFid(bp, &vnode->fid); 2147 + bp = xdr_encode_YFSFid(bp, &vp->fid); 2039 2148 bp = xdr_encode_u32(bp, acl->size); 2040 2149 memcpy(bp, acl->data, acl->size); 2041 2150 if (acl->size != size) 2042 2151 memset((void *)bp + acl->size, 0, size - acl->size); 2043 2152 yfs_check_req(call, bp); 2044 2153 2045 - trace_afs_make_fs_call(call, &vnode->fid); 2046 - afs_make_call(&fc->ac, call, GFP_KERNEL); 2047 - return afs_wait_for_call_to_complete(call, &fc->ac); 2154 + trace_afs_make_fs_call(call, &vp->fid); 2155 + afs_make_op_call(op, call, GFP_KERNEL); 2048 2156 }
+8 -11
include/trace/events/afs.h
··· 642 642 643 643 TRACE_EVENT(afs_make_fs_call1, 644 644 TP_PROTO(struct afs_call *call, const struct afs_fid *fid, 645 - const char *name), 645 + const struct qstr *name), 646 646 647 647 TP_ARGS(call, fid, name), 648 648 ··· 654 654 ), 655 655 656 656 TP_fast_assign( 657 - int __len = strlen(name); 658 - __len = min(__len, 23); 657 + unsigned int __len = min_t(unsigned int, name->len, 23); 659 658 __entry->call = call->debug_id; 660 659 __entry->op = call->operation_ID; 661 660 if (fid) { ··· 664 665 __entry->fid.vnode = 0; 665 666 __entry->fid.unique = 0; 666 667 } 667 - memcpy(__entry->name, name, __len); 668 + memcpy(__entry->name, name->name, __len); 668 669 __entry->name[__len] = 0; 669 670 ), 670 671 ··· 679 680 680 681 TRACE_EVENT(afs_make_fs_call2, 681 682 TP_PROTO(struct afs_call *call, const struct afs_fid *fid, 682 - const char *name, const char *name2), 683 + const struct qstr *name, const struct qstr *name2), 683 684 684 685 TP_ARGS(call, fid, name, name2), 685 686 ··· 692 693 ), 693 694 694 695 TP_fast_assign( 695 - int __len = strlen(name); 696 - int __len2 = strlen(name2); 697 - __len = min(__len, 23); 698 - __len2 = min(__len2, 23); 696 + unsigned int __len = min_t(unsigned int, name->len, 23); 697 + unsigned int __len2 = min_t(unsigned int, name2->len, 23); 699 698 __entry->call = call->debug_id; 700 699 __entry->op = call->operation_ID; 701 700 if (fid) { ··· 703 706 __entry->fid.vnode = 0; 704 707 __entry->fid.unique = 0; 705 708 } 706 - memcpy(__entry->name, name, __len); 709 + memcpy(__entry->name, name->name, __len); 707 710 __entry->name[__len] = 0; 708 - memcpy(__entry->name2, name2, __len2); 711 + memcpy(__entry->name2, name2->name, __len2); 709 712 __entry->name2[__len2] = 0; 710 713 ), 711 714