History

introduce fd_file(), convert all accessors to it.

For any changes of struct fd representation we need to turn existing accesses to fields into calls of wrappers. Accesses to struct fd::flags are very few (3 in linux/file.h, 1 in net/socket.c, 3 in fs/overlayfs/file.c and 3 more in explicit initializers). Those can be dealt with in the commit converting to new layout; accesses to struct fd::file are too many for that. This commit converts (almost) all of f.file to fd_file(f). It's not entirely mechanical ('file' is used as a member name more than just in struct fd) and it does not even attempt to distinguish the uses in pointer context from those in boolean context; the latter will be eventually turned into a separate helper (fd_empty()). NOTE: mass conversion to fd_empty(), tempting as it might be, is a bad idea; better do that piecewise in commit that convert from fdget...() to CLASS(...). [conflicts in fs/fhandle.c, kernel/bpf/syscall.c, mm/memcontrol.c caught by git; fs/stat.c one got caught by git grep] [fs/xattr.c conflict]

Al Viro committed 2 years ago

Commit 1da91ea1 parent 840029183 files · +504 −502Browse files

Unified · Split

83 files
  1. arch/alpha/kernel/osf_sys.c +2 −2
  2. arch/arm/kernel/sys_oabi-compat.c +5 −5
  3. arch/powerpc/kvm/book3s_64_vio.c +2 −2
  4. arch/powerpc/kvm/powerpc.c +6 −6
  5. arch/powerpc/platforms/cell/spu_syscalls.c +4 −4
  6. arch/x86/kernel/cpu/sgx/main.c +2 −2
  7. arch/x86/kvm/svm/sev.c +8 −8
  8. drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +4 −4
  9. drivers/gpu/drm/drm_syncobj.c +3 −3
  10. drivers/infiniband/core/ucma.c +3 −3
  11. drivers/infiniband/core/uverbs_cmd.c +4 −4
  12. drivers/media/mc/mc-request.c +3 −3
  13. drivers/media/rc/lirc_dev.c +4 −4
  14. drivers/vfio/group.c +3 −3
  15. drivers/vfio/virqfd.c +3 −3
  16. drivers/virt/acrn/irqfd.c +3 −3
  17. drivers/xen/privcmd.c +5 −5
  18. fs/btrfs/ioctl.c +2 −2
  19. fs/coda/inode.c +2 −2
  20. fs/eventfd.c +2 −2
  21. fs/eventpoll.c +15 −15
  22. fs/ext4/ioctl.c +3 −3
  23. fs/f2fs/file.c +3 −3
  24. fs/fcntl.c +19 −19
  25. fs/fhandle.c +2 −2
  26. fs/fsopen.c +3 −3
  27. fs/fuse/dev.c +3 −3
  28. fs/ioctl.c +15 −15
  29. fs/kernel_read_file.c +2 −2
  30. fs/locks.c +7 −7
  31. fs/namei.c +5 −5
  32. fs/namespace.c +6 −6
  33. fs/notify/fanotify/fanotify_user.c +6 −6
  34. fs/notify/inotify/inotify_user.c +6 −6
  35. fs/ocfs2/cluster/heartbeat.c +3 −3
  36. fs/open.c +12 −12
  37. fs/overlayfs/file.c +20 −20
  38. fs/quota/quota.c +4 −4
  39. fs/read_write.c +59 −59
  40. fs/readdir.c +10 −10
  41. fs/remap_range.c +1 −1
  42. fs/select.c +4 −4
  43. fs/signalfd.c +3 −3
  44. fs/smb/client/ioctl.c +4 −4
  45. fs/splice.c +11 −11
  46. fs/stat.c +4 −4
  47. fs/statfs.c +2 −2
  48. fs/sync.c +7 −7
  49. fs/timerfd.c +4 −4
  50. fs/utimes.c +2 −2
  51. fs/xattr.c +18 −18
  52. fs/xfs/xfs_exchrange.c +2 −2
  53. fs/xfs/xfs_handle.c +2 −2
  54. fs/xfs/xfs_ioctl.c +14 −14
  55. include/linux/cleanup.h +1 −1
  56. include/linux/file.h +4 −2
  57. io_uring/sqpoll.c +5 −5
  58. ipc/mqueue.c +25 −25
  59. kernel/bpf/bpf_inode_storage.c +7 −7
  60. kernel/bpf/btf.c +3 −3
  61. kernel/bpf/syscall.c +21 −21
  62. kernel/bpf/token.c +5 −5
  63. kernel/cgroup/cgroup.c +2 −2
  64. kernel/events/core.c +6 −6
  65. kernel/module/main.c +1 −1
  66. kernel/nsproxy.c +6 −6
  67. kernel/pid.c +5 −5
  68. kernel/signal.c +3 −3
  69. kernel/sys.c +5 −5
  70. kernel/taskstats.c +2 −2
  71. kernel/watch_queue.c +2 −2
  72. mm/fadvise.c +2 −2
  73. mm/filemap.c +3 −3
  74. mm/memcontrol-v1.c +6 −6
  75. mm/readahead.c +5 −5
  76. net/core/net_namespace.c +3 −3
  77. net/socket.c +6 −6
  78. security/integrity/ima/ima_main.c +2 −2
  79. security/landlock/syscalls.c +11 −11
  80. security/loadpin/loadpin.c +2 −2
  81. sound/core/pcm_native.c +3 −3
  82. virt/kvm/eventfd.c +3 −3
  83. virt/kvm/vfio.c +4 −4
arch/alpha/kernel/osf_sys.c+2−2
@@ -160,10 +160,10 @@ SYSCALL_DEFINE4(osf_getdirentries, unsigned int, fd, · 159 unmodified lines
160160 .count = count
161161 };
162162
163− if (!arg.file)
163+ if (!fd_file(arg))
164164 return -EBADF;
165165
166− error = iterate_dir(arg.file, &buf.ctx);
166+ error = iterate_dir(fd_file(arg), &buf.ctx);
167167 if (error >= 0)
168168 error = buf.error;
169169 if (count != buf.count)
arch/arm/kernel/sys_oabi-compat.c+5−5
@@ -239,19 +239,19 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 238 unmodified lines
239239 struct flock64 flock;
240240 long err = -EBADF;
241241
242− if (!f.file)
242+ if (!fd_file(f))
243243 goto out;
244244
245245 switch (cmd) {
246246 case F_GETLK64:
247247 case F_OFD_GETLK:
248− err = security_file_fcntl(f.file, cmd, arg);
248+ err = security_file_fcntl(fd_file(f), cmd, arg);
249249 if (err)
250250 break;
251251 err = get_oabi_flock(&flock, argp);
252252 if (err)
253253 break;
254− err = fcntl_getlk64(f.file, cmd, &flock);
254+ err = fcntl_getlk64(fd_file(f), cmd, &flock);
255255 if (!err)
256256 err = put_oabi_flock(&flock, argp);
257257 break;
@@ -259,13 +259,13 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, · 1 unmodified line
259259 case F_SETLKW64:
260260 case F_OFD_SETLK:
261261 case F_OFD_SETLKW:
262− err = security_file_fcntl(f.file, cmd, arg);
262+ err = security_file_fcntl(fd_file(f), cmd, arg);
263263 if (err)
264264 break;
265265 err = get_oabi_flock(&flock, argp);
266266 if (err)
267267 break;
268− err = fcntl_setlk64(fd, f.file, cmd, &flock);
268+ err = fcntl_setlk64(fd, fd_file(f), cmd, &flock);
269269 break;
270270 default:
271271 err = sys_fcntl64(fd, cmd, arg);
arch/powerpc/kvm/book3s_64_vio.c+2−2
@@ -118,12 +118,12 @@ long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd, · 117 unmodified lines
118118 struct fd f;
119119
120120 f = fdget(tablefd);
121− if (!f.file)
121+ if (!fd_file(f))
122122 return -EBADF;
123123
124124 rcu_read_lock();
125125 list_for_each_entry_rcu(stt, &kvm->arch.spapr_tce_tables, list) {
126− if (stt == f.file->private_data) {
126+ if (stt == fd_file(f)->private_data) {
127127 found = true;
128128 break;
129129 }
arch/powerpc/kvm/powerpc.c+6−6
@@ -1938,11 +1938,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 1937 unmodified lines
19381938
19391939 r = -EBADF;
19401940 f = fdget(cap->args[0]);
1941− if (!f.file)
1941+ if (!fd_file(f))
19421942 break;
19431943
19441944 r = -EPERM;
1945− dev = kvm_device_from_filp(f.file);
1945+ dev = kvm_device_from_filp(fd_file(f));
19461946 if (dev)
19471947 r = kvmppc_mpic_connect_vcpu(dev, vcpu, cap->args[1]);
19481948
@@ -1957,11 +1957,11 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 8 unmodified lines
19571957
19581958 r = -EBADF;
19591959 f = fdget(cap->args[0]);
1960− if (!f.file)
1960+ if (!fd_file(f))
19611961 break;
19621962
19631963 r = -EPERM;
1964− dev = kvm_device_from_filp(f.file);
1964+ dev = kvm_device_from_filp(fd_file(f));
19651965 if (dev) {
19661966 if (xics_on_xive())
19671967 r = kvmppc_xive_connect_vcpu(dev, vcpu, cap->args[1]);
@@ -1980,7 +1980,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 12 unmodified lines
19801980
19811981 r = -EBADF;
19821982 f = fdget(cap->args[0]);
1983− if (!f.file)
1983+ if (!fd_file(f))
19841984 break;
19851985
19861986 r = -ENXIO;
@@ -1990,7 +1990,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, · 3 unmodified lines
19901990 }
19911991
19921992 r = -EPERM;
1993− dev = kvm_device_from_filp(f.file);
1993+ dev = kvm_device_from_filp(fd_file(f));
19941994 if (dev)
19951995 r = kvmppc_xive_native_connect_vcpu(dev, vcpu,
19961996 cap->args[1]);
arch/powerpc/platforms/cell/spu_syscalls.c+4−4
@@ -66,8 +66,8 @@ SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags, · 65 unmodified lines
6666 if (flags & SPU_CREATE_AFFINITY_SPU) {
6767 struct fd neighbor = fdget(neighbor_fd);
6868 ret = -EBADF;
69− if (neighbor.file) {
70− ret = calls->create_thread(name, flags, mode, neighbor.file);
69+ if (fd_file(neighbor)) {
70+ ret = calls->create_thread(name, flags, mode, fd_file(neighbor));
7171 fdput(neighbor);
7272 }
7373 } else
@@ -89,8 +89,8 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus) · 15 unmodified lines
8989
9090 ret = -EBADF;
9191 arg = fdget(fd);
92− if (arg.file) {
93− ret = calls->spu_run(arg.file, unpc, ustatus);
92+ if (fd_file(arg)) {
93+ ret = calls->spu_run(fd_file(arg), unpc, ustatus);
9494 fdput(arg);
9595 }
9696
arch/x86/kernel/cpu/sgx/main.c+2−2
@@ -895,10 +895,10 @@ int sgx_set_attribute(unsigned long *allowed_attributes, · 894 unmodified lines
895895 {
896896 struct fd f = fdget(attribute_fd);
897897
898− if (!f.file)
898+ if (!fd_file(f))
899899 return -EINVAL;
900900
901− if (f.file->f_op != &sgx_provision_fops) {
901+ if (fd_file(f)->f_op != &sgx_provision_fops) {
902902 fdput(f);
903903 return -EINVAL;
904904 }
arch/x86/kvm/svm/sev.c+8−8
@@ -534,10 +534,10 @@ static int __sev_issue_cmd(int fd, int id, void *data, int *error) · 533 unmodified lines
534534 int ret;
535535
536536 f = fdget(fd);
537− if (!f.file)
537+ if (!fd_file(f))
538538 return -EBADF;
539539
540− ret = sev_issue_cmd_external_user(f.file, id, data, error);
540+ ret = sev_issue_cmd_external_user(fd_file(f), id, data, error);
541541
542542 fdput(f);
543543 return ret;
@@ -2078,15 +2078,15 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) · 1534 unmodified lines
20782078 bool charged = false;
20792079 int ret;
20802080
2081− if (!f.file)
2081+ if (!fd_file(f))
20822082 return -EBADF;
20832083
2084− if (!file_is_kvm(f.file)) {
2084+ if (!file_is_kvm(fd_file(f))) {
20852085 ret = -EBADF;
20862086 goto out_fput;
20872087 }
20882088
2089− source_kvm = f.file->private_data;
2089+ source_kvm = fd_file(f)->private_data;
20902090 ret = sev_lock_two_vms(kvm, source_kvm);
20912091 if (ret)
20922092 goto out_fput;
@@ -2801,15 +2801,15 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) · 708 unmodified lines
28012801 struct kvm_sev_info *source_sev, *mirror_sev;
28022802 int ret;
28032803
2804− if (!f.file)
2804+ if (!fd_file(f))
28052805 return -EBADF;
28062806
2807− if (!file_is_kvm(f.file)) {
2807+ if (!file_is_kvm(fd_file(f))) {
28082808 ret = -EBADF;
28092809 goto e_source_fput;
28102810 }
28112811
2812− source_kvm = f.file->private_data;
2812+ source_kvm = fd_file(f)->private_data;
28132813 ret = sev_lock_two_vms(kvm, source_kvm);
28142814 if (ret)
28152815 goto e_source_fput;
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c+4−4
@@ -43,10 +43,10 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, · 42 unmodified lines
4343 uint32_t id;
4444 int r;
4545
46− if (!f.file)
46+ if (!fd_file(f))
4747 return -EINVAL;
4848
49− r = amdgpu_file_to_fpriv(f.file, &fpriv);
49+ r = amdgpu_file_to_fpriv(fd_file(f), &fpriv);
5050 if (r) {
5151 fdput(f);
5252 return r;
@@ -72,10 +72,10 @@ static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev, · 19 unmodified lines
7272 struct amdgpu_ctx *ctx;
7373 int r;
7474
75− if (!f.file)
75+ if (!fd_file(f))
7676 return -EINVAL;
7777
78− r = amdgpu_file_to_fpriv(f.file, &fpriv);
78+ r = amdgpu_file_to_fpriv(fd_file(f), &fpriv);
7979 if (r) {
8080 fdput(f);
8181 return r;
drivers/gpu/drm/drm_syncobj.c+3−3
@@ -715,16 +715,16 @@ static int drm_syncobj_fd_to_handle(struct drm_file *file_private, · 714 unmodified lines
715715 struct fd f = fdget(fd);
716716 int ret;
717717
718− if (!f.file)
718+ if (!fd_file(f))
719719 return -EINVAL;
720720
721− if (f.file->f_op != &drm_syncobj_file_fops) {
721+ if (fd_file(f)->f_op != &drm_syncobj_file_fops) {
722722 fdput(f);
723723 return -EINVAL;
724724 }
725725
726726 /* take a reference to put in the idr */
727− syncobj = f.file->private_data;
727+ syncobj = fd_file(f)->private_data;
728728 drm_syncobj_get(syncobj);
729729
730730 idr_preload(GFP_KERNEL);
drivers/infiniband/core/ucma.c+3−3
@@ -1624,13 +1624,13 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file, · 1623 unmodified lines
16241624
16251625 /* Get current fd to protect against it being closed */
16261626 f = fdget(cmd.fd);
1627− if (!f.file)
1627+ if (!fd_file(f))
16281628 return -ENOENT;
1629− if (f.file->f_op != &ucma_fops) {
1629+ if (fd_file(f)->f_op != &ucma_fops) {
16301630 ret = -EINVAL;
16311631 goto file_put;
16321632 }
1633− cur_file = f.file->private_data;
1633+ cur_file = fd_file(f)->private_data;
16341634
16351635 /* Validate current fd and prevent destruction of id. */
16361636 ctx = ucma_get_ctx(cur_file, cmd.id);
drivers/infiniband/core/uverbs_cmd.c+4−4
@@ -584,12 +584,12 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 583 unmodified lines
584584 if (cmd.fd != -1) {
585585 /* search for file descriptor */
586586 f = fdget(cmd.fd);
587− if (!f.file) {
587+ if (!fd_file(f)) {
588588 ret = -EBADF;
589589 goto err_tree_mutex_unlock;
590590 }
591591
592− inode = file_inode(f.file);
592+ inode = file_inode(fd_file(f));
593593 xrcd = find_xrcd(ibudev, inode);
594594 if (!xrcd && !(cmd.oflags & O_CREAT)) {
595595 /* no file descriptor. Need CREATE flag */
@@ -632,7 +632,7 @@ static int ib_uverbs_open_xrcd(struct uverbs_attr_bundle *attrs) · 36 unmodified lines
632632 atomic_inc(&xrcd->usecnt);
633633 }
634634
635− if (f.file)
635+ if (fd_file(f))
636636 fdput(f);
637637
638638 mutex_unlock(&ibudev->xrcd_tree_mutex);
@@ -648,7 +648,7 @@ err: · 9 unmodified lines
648648 uobj_alloc_abort(&obj->uobject, attrs);
649649
650650 err_tree_mutex_unlock:
651− if (f.file)
651+ if (fd_file(f))
652652 fdput(f);
653653
654654 mutex_unlock(&ibudev->xrcd_tree_mutex);
drivers/media/mc/mc-request.c+3−3
@@ -254,12 +254,12 @@ media_request_get_by_fd(struct media_device *mdev, int request_fd) · 253 unmodified lines
254254 return ERR_PTR(-EBADR);
255255
256256 f = fdget(request_fd);
257− if (!f.file)
257+ if (!fd_file(f))
258258 goto err_no_req_fd;
259259
260− if (f.file->f_op != &request_fops)
260+ if (fd_file(f)->f_op != &request_fops)
261261 goto err_fput;
262− req = f.file->private_data;
262+ req = fd_file(f)->private_data;
263263 if (req->mdev != mdev)
264264 goto err_fput;
265265
drivers/media/rc/lirc_dev.c+4−4
@@ -820,20 +820,20 @@ struct rc_dev *rc_dev_get_from_fd(int fd, bool write) · 819 unmodified lines
820820 struct lirc_fh *fh;
821821 struct rc_dev *dev;
822822
823− if (!f.file)
823+ if (!fd_file(f))
824824 return ERR_PTR(-EBADF);
825825
826− if (f.file->f_op != &lirc_fops) {
826+ if (fd_file(f)->f_op != &lirc_fops) {
827827 fdput(f);
828828 return ERR_PTR(-EINVAL);
829829 }
830830
831− if (write && !(f.file->f_mode & FMODE_WRITE)) {
831+ if (write && !(fd_file(f)->f_mode & FMODE_WRITE)) {
832832 fdput(f);
833833 return ERR_PTR(-EPERM);
834834 }
835835
836− fh = f.file->private_data;
836+ fh = fd_file(f)->private_data;
837837 dev = fh->rc;
838838
839839 get_device(&dev->dev);
drivers/vfio/group.c+3−3
@@ -112,7 +112,7 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, · 111 unmodified lines
112112 return -EFAULT;
113113
114114 f = fdget(fd);
115− if (!f.file)
115+ if (!fd_file(f))
116116 return -EBADF;
117117
118118 mutex_lock(&group->group_lock);
@@ -125,13 +125,13 @@ static int vfio_group_ioctl_set_container(struct vfio_group *group, · 6 unmodified lines
125125 goto out_unlock;
126126 }
127127
128− container = vfio_container_from_file(f.file);
128+ container = vfio_container_from_file(fd_file(f));
129129 if (container) {
130130 ret = vfio_container_attach_group(container, group);
131131 goto out_unlock;
132132 }
133133
134− iommufd = iommufd_ctx_from_file(f.file);
134+ iommufd = iommufd_ctx_from_file(fd_file(f));
135135 if (!IS_ERR(iommufd)) {
136136 if (IS_ENABLED(CONFIG_VFIO_NOIOMMU) &&
137137 group->type == VFIO_NO_IOMMU)
drivers/vfio/virqfd.c+3−3
@@ -134,12 +134,12 @@ int vfio_virqfd_enable(void *opaque, · 133 unmodified lines
134134 INIT_WORK(&virqfd->flush_inject, virqfd_flush_inject);
135135
136136 irqfd = fdget(fd);
137− if (!irqfd.file) {
137+ if (!fd_file(irqfd)) {
138138 ret = -EBADF;
139139 goto err_fd;
140140 }
141141
142− ctx = eventfd_ctx_fileget(irqfd.file);
142+ ctx = eventfd_ctx_fileget(fd_file(irqfd));
143143 if (IS_ERR(ctx)) {
144144 ret = PTR_ERR(ctx);
145145 goto err_ctx;
@@ -171,7 +171,7 @@ int vfio_virqfd_enable(void *opaque, · 25 unmodified lines
171171 init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup);
172172 init_poll_funcptr(&virqfd->pt, virqfd_ptable_queue_proc);
173173
174− events = vfs_poll(irqfd.file, &virqfd->pt);
174+ events = vfs_poll(fd_file(irqfd), &virqfd->pt);
175175
176176 /*
177177 * Check if there was an event already pending on the eventfd
drivers/virt/acrn/irqfd.c+3−3
@@ -125,12 +125,12 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args) · 124 unmodified lines
125125 INIT_WORK(&irqfd->shutdown, hsm_irqfd_shutdown_work);
126126
127127 f = fdget(args->fd);
128− if (!f.file) {
128+ if (!fd_file(f)) {
129129 ret = -EBADF;
130130 goto out;
131131 }
132132
133− eventfd = eventfd_ctx_fileget(f.file);
133+ eventfd = eventfd_ctx_fileget(fd_file(f));
134134 if (IS_ERR(eventfd)) {
135135 ret = PTR_ERR(eventfd);
136136 goto fail;
@@ -157,7 +157,7 @@ static int acrn_irqfd_assign(struct acrn_vm *vm, struct acrn_irqfd *args) · 20 unmodified lines
157157 mutex_unlock(&vm->irqfds_lock);
158158
159159 /* Check the pending event in this stage */
160− events = vfs_poll(f.file, &irqfd->pt);
160+ events = vfs_poll(fd_file(f), &irqfd->pt);
161161
162162 if (events & EPOLLIN)
163163 acrn_irqfd_inject(irqfd);
drivers/xen/privcmd.c+5−5
@@ -959,12 +959,12 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 958 unmodified lines
959959 INIT_WORK(&kirqfd->shutdown, irqfd_shutdown);
960960
961961 f = fdget(irqfd->fd);
962− if (!f.file) {
962+ if (!fd_file(f)) {
963963 ret = -EBADF;
964964 goto error_kfree;
965965 }
966966
967− kirqfd->eventfd = eventfd_ctx_fileget(f.file);
967+ kirqfd->eventfd = eventfd_ctx_fileget(fd_file(f));
968968 if (IS_ERR(kirqfd->eventfd)) {
969969 ret = PTR_ERR(kirqfd->eventfd);
970970 goto error_fd_put;
@@ -995,7 +995,7 @@ static int privcmd_irqfd_assign(struct privcmd_irqfd *irqfd) · 24 unmodified lines
995995 * Check if there was an event already pending on the eventfd before we
996996 * registered, and trigger it as if we didn't miss it.
997997 */
998− events = vfs_poll(f.file, &kirqfd->pt);
998+ events = vfs_poll(fd_file(f), &kirqfd->pt);
999999 if (events & EPOLLIN)
10001000 irqfd_inject(kirqfd);
10011001
@@ -1345,12 +1345,12 @@ static int privcmd_ioeventfd_assign(struct privcmd_ioeventfd *ioeventfd) · 343 unmodified lines
13451345 return -ENOMEM;
13461346
13471347 f = fdget(ioeventfd->event_fd);
1348− if (!f.file) {
1348+ if (!fd_file(f)) {
13491349 ret = -EBADF;
13501350 goto error_kfree;
13511351 }
13521352
1353− kioeventfd->eventfd = eventfd_ctx_fileget(f.file);
1353+ kioeventfd->eventfd = eventfd_ctx_fileget(fd_file(f));
13541354 fdput(f);
13551355
13561356 if (IS_ERR(kioeventfd->eventfd)) {
fs/btrfs/ioctl.c+2−2
@@ -1312,12 +1312,12 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, · 1311 unmodified lines
13121312 } else {
13131313 struct fd src = fdget(fd);
13141314 struct inode *src_inode;
1315− if (!src.file) {
1315+ if (!fd_file(src)) {
13161316 ret = -EINVAL;
13171317 goto out_drop_write;
13181318 }
13191319
1320− src_inode = file_inode(src.file);
1320+ src_inode = file_inode(fd_file(src));
13211321 if (src_inode->i_sb != file_inode(file)->i_sb) {
13221322 btrfs_info(BTRFS_I(file_inode(file))->root->fs_info,
13231323 "Snapshot src from another FS");
fs/coda/inode.c+2−2
@@ -127,9 +127,9 @@ static int coda_parse_fd(struct fs_context *fc, int fd) · 126 unmodified lines
127127 int idx;
128128
129129 f = fdget(fd);
130− if (!f.file)
130+ if (!fd_file(f))
131131 return -EBADF;
132− inode = file_inode(f.file);
132+ inode = file_inode(fd_file(f));
133133 if (!S_ISCHR(inode->i_mode) || imajor(inode) != CODA_PSDEV_MAJOR) {
134134 fdput(f);
135135 return invalf(fc, "code: Not coda psdev");
fs/eventfd.c+2−2
@@ -349,9 +349,9 @@ struct eventfd_ctx *eventfd_ctx_fdget(int fd) · 348 unmodified lines
349349 {
350350 struct eventfd_ctx *ctx;
351351 struct fd f = fdget(fd);
352− if (!f.file)
352+ if (!fd_file(f))
353353 return ERR_PTR(-EBADF);
354− ctx = eventfd_ctx_fileget(f.file);
354+ ctx = eventfd_ctx_fileget(fd_file(f));
355355 fdput(f);
356356 return ctx;
357357 }
fs/eventpoll.c+15−15
@@ -2266,17 +2266,17 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2265 unmodified lines
22662266
22672267 error = -EBADF;
22682268 f = fdget(epfd);
2269− if (!f.file)
2269+ if (!fd_file(f))
22702270 goto error_return;
22712271
22722272 /* Get the "struct file *" for the target file */
22732273 tf = fdget(fd);
2274− if (!tf.file)
2274+ if (!fd_file(tf))
22752275 goto error_fput;
22762276
22772277 /* The target file descriptor must support poll */
22782278 error = -EPERM;
2279− if (!file_can_poll(tf.file))
2279+ if (!file_can_poll(fd_file(tf)))
22802280 goto error_tgt_fput;
22812281
22822282 /* Check if EPOLLWAKEUP is allowed */
@@ -2289,7 +2289,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 6 unmodified lines
22892289 * adding an epoll file descriptor inside itself.
22902290 */
22912291 error = -EINVAL;
2292− if (f.file == tf.file || !is_file_epoll(f.file))
2292+ if (fd_file(f) == fd_file(tf) || !is_file_epoll(fd_file(f)))
22932293 goto error_tgt_fput;
22942294
22952295 /*
@@ -2300,7 +2300,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 4 unmodified lines
23002300 if (ep_op_has_event(op) && (epds->events & EPOLLEXCLUSIVE)) {
23012301 if (op == EPOLL_CTL_MOD)
23022302 goto error_tgt_fput;
2303− if (op == EPOLL_CTL_ADD && (is_file_epoll(tf.file) ||
2303+ if (op == EPOLL_CTL_ADD && (is_file_epoll(fd_file(tf)) ||
23042304 (epds->events & ~EPOLLEXCLUSIVE_OK_BITS)))
23052305 goto error_tgt_fput;
23062306 }
@@ -2309,7 +2309,7 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 2 unmodified lines
23092309 * At this point it is safe to assume that the "private_data" contains
23102310 * our own data structure.
23112311 */
2312− ep = f.file->private_data;
2312+ ep = fd_file(f)->private_data;
23132313
23142314 /*
23152315 * When we insert an epoll file descriptor inside another epoll file
@@ -2330,16 +2330,16 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 14 unmodified lines
23302330 if (error)
23312331 goto error_tgt_fput;
23322332 if (op == EPOLL_CTL_ADD) {
2333− if (READ_ONCE(f.file->f_ep) || ep->gen == loop_check_gen ||
2334− is_file_epoll(tf.file)) {
2333+ if (READ_ONCE(fd_file(f)->f_ep) || ep->gen == loop_check_gen ||
2334+ is_file_epoll(fd_file(tf))) {
23352335 mutex_unlock(&ep->mtx);
23362336 error = epoll_mutex_lock(&epnested_mutex, 0, nonblock);
23372337 if (error)
23382338 goto error_tgt_fput;
23392339 loop_check_gen++;
23402340 full_check = 1;
2341− if (is_file_epoll(tf.file)) {
2342− tep = tf.file->private_data;
2341+ if (is_file_epoll(fd_file(tf))) {
2342+ tep = fd_file(tf)->private_data;
23432343 error = -ELOOP;
23442344 if (ep_loop_check(ep, tep) != 0)
23452345 goto error_tgt_fput;
@@ -2355,14 +2355,14 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds, · 9 unmodified lines
23552355 * above, we can be sure to be able to use the item looked up by
23562356 * ep_find() till we release the mutex.
23572357 */
2358− epi = ep_find(ep, tf.file, fd);
2358+ epi = ep_find(ep, fd_file(tf), fd);
23592359
23602360 error = -EINVAL;
23612361 switch (op) {
23622362 case EPOLL_CTL_ADD:
23632363 if (!epi) {
23642364 epds->events |= EPOLLERR | EPOLLHUP;
2365− error = ep_insert(ep, epds, tf.file, fd, full_check);
2365+ error = ep_insert(ep, epds, fd_file(tf), fd, full_check);
23662366 } else
23672367 error = -EEXIST;
23682368 break;
@@ -2443,7 +2443,7 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 74 unmodified lines
24432443
24442444 /* Get the "struct file *" for the eventpoll file */
24452445 f = fdget(epfd);
2446− if (!f.file)
2446+ if (!fd_file(f))
24472447 return -EBADF;
24482448
24492449 /*
@@ -2451,14 +2451,14 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events, · 1 unmodified line
24512451 * the user passed to us _is_ an eventpoll file.
24522452 */
24532453 error = -EINVAL;
2454− if (!is_file_epoll(f.file))
2454+ if (!is_file_epoll(fd_file(f)))
24552455 goto error_fput;
24562456
24572457 /*
24582458 * At this point it is safe to assume that the "private_data" contains
24592459 * our own data structure.
24602460 */
2461− ep = f.file->private_data;
2461+ ep = fd_file(f)->private_data;
24622462
24632463 /* Time to fish for events ... */
24642464 error = ep_poll(ep, events, maxevents, to);
fs/ext4/ioctl.c+3−3
@@ -1343,10 +1343,10 @@ group_extend_out: · 1342 unmodified lines
13431343 me.moved_len = 0;
13441344
13451345 donor = fdget(me.donor_fd);
1346− if (!donor.file)
1346+ if (!fd_file(donor))
13471347 return -EBADF;
13481348
1349− if (!(donor.file->f_mode & FMODE_WRITE)) {
1349+ if (!(fd_file(donor)->f_mode & FMODE_WRITE)) {
13501350 err = -EBADF;
13511351 goto mext_out;
13521352 }
@@ -1367,7 +1367,7 @@ group_extend_out: · 14 unmodified lines
13671367 if (err)
13681368 goto mext_out;
13691369
1370− err = ext4_move_extents(filp, donor.file, me.orig_start,
1370+ err = ext4_move_extents(filp, fd_file(donor), me.orig_start,
13711371 me.donor_start, me.len, &me.moved_len);
13721372 mnt_drop_write_file(filp);
13731373
fs/f2fs/file.c+3−3
@@ -3014,10 +3014,10 @@ static int __f2fs_ioc_move_range(struct file *filp, · 3013 unmodified lines
30143014 return -EBADF;
30153015
30163016 dst = fdget(range->dst_fd);
3017− if (!dst.file)
3017+ if (!fd_file(dst))
30183018 return -EBADF;
30193019
3020− if (!(dst.file->f_mode & FMODE_WRITE)) {
3020+ if (!(fd_file(dst)->f_mode & FMODE_WRITE)) {
30213021 err = -EBADF;
30223022 goto err_out;
30233023 }
@@ -3026,7 +3026,7 @@ static int __f2fs_ioc_move_range(struct file *filp, · 2 unmodified lines
30263026 if (err)
30273027 goto err_out;
30283028
3029− err = f2fs_move_file_range(filp, range->pos_in, dst.file,
3029+ err = f2fs_move_file_range(filp, range->pos_in, fd_file(dst),
30303030 range->pos_out, range->len);
30313031
30323032 mnt_drop_write_file(filp);
fs/fcntl.c+19−19
@@ -340,7 +340,7 @@ static long f_dupfd_query(int fd, struct file *filp) · 339 unmodified lines
340340 * overkill, but given our lockless file pointer lookup, the
341341 * alternatives are complicated.
342342 */
343− return f.file == filp;
343+ return fd_file(f) == filp;
344344 }
345345
346346 static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
@@ -479,17 +479,17 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 132 unmodified lines
479479 struct fd f = fdget_raw(fd);
480480 long err = -EBADF;
481481
482− if (!f.file)
482+ if (!fd_file(f))
483483 goto out;
484484
485− if (unlikely(f.file->f_mode & FMODE_PATH)) {
485+ if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) {
486486 if (!check_fcntl_cmd(cmd))
487487 goto out1;
488488 }
489489
490− err = security_file_fcntl(f.file, cmd, arg);
490+ err = security_file_fcntl(fd_file(f), cmd, arg);
491491 if (!err)
492− err = do_fcntl(fd, cmd, arg, f.file);
492+ err = do_fcntl(fd, cmd, arg, fd_file(f));
493493
494494 out1:
495495 fdput(f);
@@ -506,15 +506,15 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 10 unmodified lines
506506 struct flock64 flock;
507507 long err = -EBADF;
508508
509− if (!f.file)
509+ if (!fd_file(f))
510510 goto out;
511511
512− if (unlikely(f.file->f_mode & FMODE_PATH)) {
512+ if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) {
513513 if (!check_fcntl_cmd(cmd))
514514 goto out1;
515515 }
516516
517− err = security_file_fcntl(f.file, cmd, arg);
517+ err = security_file_fcntl(fd_file(f), cmd, arg);
518518 if (err)
519519 goto out1;
520520
@@ -524,7 +524,7 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 3 unmodified lines
524524 err = -EFAULT;
525525 if (copy_from_user(&flock, argp, sizeof(flock)))
526526 break;
527− err = fcntl_getlk64(f.file, cmd, &flock);
527+ err = fcntl_getlk64(fd_file(f), cmd, &flock);
528528 if (!err && copy_to_user(argp, &flock, sizeof(flock)))
529529 err = -EFAULT;
530530 break;
@@ -535,10 +535,10 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, · 4 unmodified lines
535535 err = -EFAULT;
536536 if (copy_from_user(&flock, argp, sizeof(flock)))
537537 break;
538− err = fcntl_setlk64(fd, f.file, cmd, &flock);
538+ err = fcntl_setlk64(fd, fd_file(f), cmd, &flock);
539539 break;
540540 default:
541− err = do_fcntl(fd, cmd, arg, f.file);
541+ err = do_fcntl(fd, cmd, arg, fd_file(f));
542542 break;
543543 }
544544 out1:
@@ -643,15 +643,15 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 98 unmodified lines
643643 struct flock flock;
644644 long err = -EBADF;
645645
646− if (!f.file)
646+ if (!fd_file(f))
647647 return err;
648648
649− if (unlikely(f.file->f_mode & FMODE_PATH)) {
649+ if (unlikely(fd_file(f)->f_mode & FMODE_PATH)) {
650650 if (!check_fcntl_cmd(cmd))
651651 goto out_put;
652652 }
653653
654− err = security_file_fcntl(f.file, cmd, arg);
654+ err = security_file_fcntl(fd_file(f), cmd, arg);
655655 if (err)
656656 goto out_put;
657657
@@ -660,7 +660,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines
660660 err = get_compat_flock(&flock, compat_ptr(arg));
661661 if (err)
662662 break;
663− err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
663+ err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock);
664664 if (err)
665665 break;
666666 err = fixup_compat_flock(&flock);
@@ -672,7 +672,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 5 unmodified lines
672672 err = get_compat_flock64(&flock, compat_ptr(arg));
673673 if (err)
674674 break;
675− err = fcntl_getlk(f.file, convert_fcntl_cmd(cmd), &flock);
675+ err = fcntl_getlk(fd_file(f), convert_fcntl_cmd(cmd), &flock);
676676 if (!err)
677677 err = put_compat_flock64(&flock, compat_ptr(arg));
678678 break;
@@ -681,7 +681,7 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines
681681 err = get_compat_flock(&flock, compat_ptr(arg));
682682 if (err)
683683 break;
684− err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock);
684+ err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock);
685685 break;
686686 case F_SETLK64:
687687 case F_SETLKW64:
@@ -690,10 +690,10 @@ static long do_compat_fcntl64(unsigned int fd, unsigned int cmd, · 2 unmodified lines
690690 err = get_compat_flock64(&flock, compat_ptr(arg));
691691 if (err)
692692 break;
693− err = fcntl_setlk(fd, f.file, convert_fcntl_cmd(cmd), &flock);
693+ err = fcntl_setlk(fd, fd_file(f), convert_fcntl_cmd(cmd), &flock);
694694 break;
695695 default:
696− err = do_fcntl(fd, cmd, arg, f.file);
696+ err = do_fcntl(fd, cmd, arg, fd_file(f));
697697 break;
698698 }
699699 out_put:
fs/fhandle.c+2−2
@@ -125,9 +125,9 @@ static int get_path_from_fd(int fd, struct path *root) · 124 unmodified lines
125125 spin_unlock(&fs->lock);
126126 } else {
127127 struct fd f = fdget(fd);
128− if (!f.file)
128+ if (!fd_file(f))
129129 return -EBADF;
130− *root = f.file->f_path;
130+ *root = fd_file(f)->f_path;
131131 path_get(root);
132132 fdput(f);
133133 }
fs/fsopen.c+3−3
@@ -394,13 +394,13 @@ SYSCALL_DEFINE5(fsconfig, · 393 unmodified lines
394394 }
395395
396396 f = fdget(fd);
397− if (!f.file)
397+ if (!fd_file(f))
398398 return -EBADF;
399399 ret = -EINVAL;
400− if (f.file->f_op != &fscontext_fops)
400+ if (fd_file(f)->f_op != &fscontext_fops)
401401 goto out_f;
402402
403− fc = f.file->private_data;
403+ fc = fd_file(f)->private_data;
404404 if (fc->ops == &legacy_fs_context_ops) {
405405 switch (cmd) {
406406 case FSCONFIG_SET_BINARY:
fs/fuse/dev.c+3−3
@@ -2321,15 +2321,15 @@ static long fuse_dev_ioctl_clone(struct file *file, __u32 __user *argp) · 2320 unmodified lines
23212321 return -EFAULT;
23222322
23232323 f = fdget(oldfd);
2324− if (!f.file)
2324+ if (!fd_file(f))
23252325 return -EINVAL;
23262326
23272327 /*
23282328 * Check against file->f_op because CUSE
23292329 * uses the same ioctl handler.
23302330 */
2331− if (f.file->f_op == file->f_op)
2332− fud = fuse_get_dev(f.file);
2331+ if (fd_file(f)->f_op == file->f_op)
2332+ fud = fuse_get_dev(fd_file(f));
23332333
23342334 res = -EINVAL;
23352335 if (fud) {
fs/ioctl.c+15−15
@@ -235,9 +235,9 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, · 234 unmodified lines
235235 loff_t cloned;
236236 int ret;
237237
238− if (!src_file.file)
238+ if (!fd_file(src_file))
239239 return -EBADF;
240− cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff,
240+ cloned = vfs_clone_file_range(fd_file(src_file), off, dst_file, destoff,
241241 olen, 0);
242242 if (cloned < 0)
243243 ret = cloned;
@@ -895,16 +895,16 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) · 651 unmodified lines
895895 struct fd f = fdget(fd);
896896 int error;
897897
898− if (!f.file)
898+ if (!fd_file(f))
899899 return -EBADF;
900900
901− error = security_file_ioctl(f.file, cmd, arg);
901+ error = security_file_ioctl(fd_file(f), cmd, arg);
902902 if (error)
903903 goto out;
904904
905− error = do_vfs_ioctl(f.file, fd, cmd, arg);
905+ error = do_vfs_ioctl(fd_file(f), fd, cmd, arg);
906906 if (error == -ENOIOCTLCMD)
907− error = vfs_ioctl(f.file, cmd, arg);
907+ error = vfs_ioctl(fd_file(f), cmd, arg);
908908
909909 out:
910910 fdput(f);
@@ -953,32 +953,32 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 42 unmodified lines
953953 struct fd f = fdget(fd);
954954 int error;
955955
956− if (!f.file)
956+ if (!fd_file(f))
957957 return -EBADF;
958958
959− error = security_file_ioctl_compat(f.file, cmd, arg);
959+ error = security_file_ioctl_compat(fd_file(f), cmd, arg);
960960 if (error)
961961 goto out;
962962
963963 switch (cmd) {
964964 /* FICLONE takes an int argument, so don't use compat_ptr() */
965965 case FICLONE:
966− error = ioctl_file_clone(f.file, arg, 0, 0, 0);
966+ error = ioctl_file_clone(fd_file(f), arg, 0, 0, 0);
967967 break;
968968
969969 #if defined(CONFIG_X86_64)
970970 /* these get messy on amd64 due to alignment differences */
971971 case FS_IOC_RESVSP_32:
972972 case FS_IOC_RESVSP64_32:
973− error = compat_ioctl_preallocate(f.file, 0, compat_ptr(arg));
973+ error = compat_ioctl_preallocate(fd_file(f), 0, compat_ptr(arg));
974974 break;
975975 case FS_IOC_UNRESVSP_32:
976976 case FS_IOC_UNRESVSP64_32:
977− error = compat_ioctl_preallocate(f.file, FALLOC_FL_PUNCH_HOLE,
977+ error = compat_ioctl_preallocate(fd_file(f), FALLOC_FL_PUNCH_HOLE,
978978 compat_ptr(arg));
979979 break;
980980 case FS_IOC_ZERO_RANGE_32:
981− error = compat_ioctl_preallocate(f.file, FALLOC_FL_ZERO_RANGE,
981+ error = compat_ioctl_preallocate(fd_file(f), FALLOC_FL_ZERO_RANGE,
982982 compat_ptr(arg));
983983 break;
984984 #endif
@@ -998,13 +998,13 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, · 13 unmodified lines
998998 * argument.
999999 */
10001000 default:
1001− error = do_vfs_ioctl(f.file, fd, cmd,
1001+ error = do_vfs_ioctl(fd_file(f), fd, cmd,
10021002 (unsigned long)compat_ptr(arg));
10031003 if (error != -ENOIOCTLCMD)
10041004 break;
10051005
1006− if (f.file->f_op->compat_ioctl)
1007− error = f.file->f_op->compat_ioctl(f.file, cmd, arg);
1006+ if (fd_file(f)->f_op->compat_ioctl)
1007+ error = fd_file(f)->f_op->compat_ioctl(fd_file(f), cmd, arg);
10081008 if (error == -ENOIOCTLCMD)
10091009 error = -ENOTTY;
10101010 break;
fs/kernel_read_file.c+2−2
@@ -178,10 +178,10 @@ ssize_t kernel_read_file_from_fd(int fd, loff_t offset, void **buf, · 177 unmodified lines
178178 struct fd f = fdget(fd);
179179 ssize_t ret = -EBADF;
180180
181− if (!f.file || !(f.file->f_mode & FMODE_READ))
181+ if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ))
182182 goto out;
183183
184− ret = kernel_read_file(f.file, offset, buf, buf_size, file_size, id);
184+ ret = kernel_read_file(fd_file(f), offset, buf, buf_size, file_size, id);
185185 out:
186186 fdput(f);
187187 return ret;
fs/locks.c+7−7
@@ -2153,15 +2153,15 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 2152 unmodified lines
21532153
21542154 error = -EBADF;
21552155 f = fdget(fd);
2156− if (!f.file)
2156+ if (!fd_file(f))
21572157 return error;
21582158
2159− if (type != F_UNLCK && !(f.file->f_mode & (FMODE_READ | FMODE_WRITE)))
2159+ if (type != F_UNLCK && !(fd_file(f)->f_mode & (FMODE_READ | FMODE_WRITE)))
21602160 goto out_putf;
21612161
2162− flock_make_lock(f.file, &fl, type);
2162+ flock_make_lock(fd_file(f), &fl, type);
21632163
2164− error = security_file_lock(f.file, fl.c.flc_type);
2164+ error = security_file_lock(fd_file(f), fl.c.flc_type);
21652165 if (error)
21662166 goto out_putf;
21672167
@@ -2169,12 +2169,12 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) · 1 unmodified line
21692169 if (can_sleep)
21702170 fl.c.flc_flags |= FL_SLEEP;
21712171
2172− if (f.file->f_op->flock)
2173− error = f.file->f_op->flock(f.file,
2172+ if (fd_file(f)->f_op->flock)
2173+ error = fd_file(f)->f_op->flock(fd_file(f),
21742174 (can_sleep) ? F_SETLKW : F_SETLK,
21752175 &fl);
21762176 else
2177− error = locks_lock_file_wait(f.file, &fl);
2177+ error = locks_lock_file_wait(fd_file(f), &fl);
21782178
21792179 locks_release_private(&fl);
21802180 out_putf:
fs/namei.c+5−5
@@ -2492,25 +2492,25 @@ static const char *path_init(struct nameidata *nd, unsigned flags) · 2491 unmodified lines
24922492 struct fd f = fdget_raw(nd->dfd);
24932493 struct dentry *dentry;
24942494
2495− if (!f.file)
2495+ if (!fd_file(f))
24962496 return ERR_PTR(-EBADF);
24972497
24982498 if (flags & LOOKUP_LINKAT_EMPTY) {
2499− if (f.file->f_cred != current_cred() &&
2500− !ns_capable(f.file->f_cred->user_ns, CAP_DAC_READ_SEARCH)) {
2499+ if (fd_file(f)->f_cred != current_cred() &&
2500+ !ns_capable(fd_file(f)->f_cred->user_ns, CAP_DAC_READ_SEARCH)) {
25012501 fdput(f);
25022502 return ERR_PTR(-ENOENT);
25032503 }
25042504 }
25052505
2506− dentry = f.file->f_path.dentry;
2506+ dentry = fd_file(f)->f_path.dentry;
25072507
25082508 if (*s && unlikely(!d_can_lookup(dentry))) {
25092509 fdput(f);
25102510 return ERR_PTR(-ENOTDIR);
25112511 }
25122512
2513− nd->path = f.file->f_path;
2513+ nd->path = fd_file(f)->f_path;
25142514 if (flags & LOOKUP_RCU) {
25152515 nd->inode = nd->path.dentry->d_inode;
25162516 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
fs/namespace.c+6−6
@@ -4099,14 +4099,14 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, · 4098 unmodified lines
40994099 }
41004100
41014101 f = fdget(fs_fd);
4102− if (!f.file)
4102+ if (!fd_file(f))
41034103 return -EBADF;
41044104
41054105 ret = -EINVAL;
4106− if (f.file->f_op != &fscontext_fops)
4106+ if (fd_file(f)->f_op != &fscontext_fops)
41074107 goto err_fsfd;
41084108
4109− fc = f.file->private_data;
4109+ fc = fd_file(f)->private_data;
41104110
41114111 ret = mutex_lock_interruptible(&fc->uapi_mutex);
41124112 if (ret < 0)
@@ -4649,15 +4649,15 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize, · 536 unmodified lines
46494649 return -EINVAL;
46504650
46514651 f = fdget(attr->userns_fd);
4652− if (!f.file)
4652+ if (!fd_file(f))
46534653 return -EBADF;
46544654
4655− if (!proc_ns_file(f.file)) {
4655+ if (!proc_ns_file(fd_file(f))) {
46564656 err = -EINVAL;
46574657 goto out_fput;
46584658 }
46594659
4660− ns = get_proc_ns(file_inode(f.file));
4660+ ns = get_proc_ns(file_inode(fd_file(f)));
46614661 if (ns->ops->type != CLONE_NEWUSER) {
46624662 err = -EINVAL;
46634663 goto out_fput;
fs/notify/fanotify/fanotify_user.c+6−6
@@ -1006,17 +1006,17 @@ static int fanotify_find_path(int dfd, const char __user *filename, · 1005 unmodified lines
10061006 struct fd f = fdget(dfd);
10071007
10081008 ret = -EBADF;
1009− if (!f.file)
1009+ if (!fd_file(f))
10101010 goto out;
10111011
10121012 ret = -ENOTDIR;
10131013 if ((flags & FAN_MARK_ONLYDIR) &&
1014− !(S_ISDIR(file_inode(f.file)->i_mode))) {
1014+ !(S_ISDIR(file_inode(fd_file(f))->i_mode))) {
10151015 fdput(f);
10161016 goto out;
10171017 }
10181018
1019− *path = f.file->f_path;
1019+ *path = fd_file(f)->f_path;
10201020 path_get(path);
10211021 fdput(f);
10221022 } else {
@@ -1753,14 +1753,14 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, · 730 unmodified lines
17531753 }
17541754
17551755 f = fdget(fanotify_fd);
1756− if (unlikely(!f.file))
1756+ if (unlikely(!fd_file(f)))
17571757 return -EBADF;
17581758
17591759 /* verify that this is indeed an fanotify instance */
17601760 ret = -EINVAL;
1761− if (unlikely(f.file->f_op != &fanotify_fops))
1761+ if (unlikely(fd_file(f)->f_op != &fanotify_fops))
17621762 goto fput_and_out;
1763− group = f.file->private_data;
1763+ group = fd_file(f)->private_data;
17641764
17651765 /*
17661766 * An unprivileged user is not allowed to setup mount nor filesystem
fs/notify/inotify/inotify_user.c+6−6
@@ -753,7 +753,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 752 unmodified lines
753753 return -EINVAL;
754754
755755 f = fdget(fd);
756− if (unlikely(!f.file))
756+ if (unlikely(!fd_file(f)))
757757 return -EBADF;
758758
759759 /* IN_MASK_ADD and IN_MASK_CREATE don't make sense together */
@@ -763,7 +763,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 3 unmodified lines
763763 }
764764
765765 /* verify that this is indeed an inotify instance */
766− if (unlikely(f.file->f_op != &inotify_fops)) {
766+ if (unlikely(fd_file(f)->f_op != &inotify_fops)) {
767767 ret = -EINVAL;
768768 goto fput_and_out;
769769 }
@@ -780,7 +780,7 @@ SYSCALL_DEFINE3(inotify_add_watch, int, fd, const char __user *, pathname, · 10 unmodified lines
780780
781781 /* inode held in place by reference to path; group by fget on fd */
782782 inode = path.dentry->d_inode;
783− group = f.file->private_data;
783+ group = fd_file(f)->private_data;
784784
785785 /* create/update an inode mark */
786786 ret = inotify_update_watch(group, inode, mask);
@@ -798,14 +798,14 @@ SYSCALL_DEFINE2(inotify_rm_watch, int, fd, __s32, wd) · 11 unmodified lines
798798 int ret = -EINVAL;
799799
800800 f = fdget(fd);
801− if (unlikely(!f.file))
801+ if (unlikely(!fd_file(f)))
802802 return -EBADF;
803803
804804 /* verify that this is indeed an inotify instance */
805− if (unlikely(f.file->f_op != &inotify_fops))
805+ if (unlikely(fd_file(f)->f_op != &inotify_fops))
806806 goto out;
807807
808− group = f.file->private_data;
808+ group = fd_file(f)->private_data;
809809
810810 i_mark = inotify_idr_find(group, wd);
811811 if (unlikely(!i_mark))
fs/ocfs2/cluster/heartbeat.c+3−3
@@ -1785,17 +1785,17 @@ static ssize_t o2hb_region_dev_store(struct config_item *item, · 1784 unmodified lines
17851785 goto out;
17861786
17871787 f = fdget(fd);
1788− if (f.file == NULL)
1788+ if (fd_file(f) == NULL)
17891789 goto out;
17901790
17911791 if (reg->hr_blocks == 0 || reg->hr_start_block == 0 ||
17921792 reg->hr_block_bytes == 0)
17931793 goto out2;
17941794
1795− if (!S_ISBLK(f.file->f_mapping->host->i_mode))
1795+ if (!S_ISBLK(fd_file(f)->f_mapping->host->i_mode))
17961796 goto out2;
17971797
1798− reg->hr_bdev_file = bdev_file_open_by_dev(f.file->f_mapping->host->i_rdev,
1798+ reg->hr_bdev_file = bdev_file_open_by_dev(fd_file(f)->f_mapping->host->i_rdev,
17991799 BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, NULL);
18001800 if (IS_ERR(reg->hr_bdev_file)) {
18011801 ret = PTR_ERR(reg->hr_bdev_file);
fs/open.c+12−12
@@ -193,10 +193,10 @@ long do_sys_ftruncate(unsigned int fd, loff_t length, int small) · 192 unmodified lines
193193 if (length < 0)
194194 return -EINVAL;
195195 f = fdget(fd);
196− if (!f.file)
196+ if (!fd_file(f))
197197 return -EBADF;
198198
199− error = do_ftruncate(f.file, length, small);
199+ error = do_ftruncate(fd_file(f), length, small);
200200
201201 fdput(f);
202202 return error;
@@ -353,8 +353,8 @@ int ksys_fallocate(int fd, int mode, loff_t offset, loff_t len) · 150 unmodified lines
353353 struct fd f = fdget(fd);
354354 int error = -EBADF;
355355
356− if (f.file) {
357− error = vfs_fallocate(f.file, mode, offset, len);
356+ if (fd_file(f)) {
357+ error = vfs_fallocate(fd_file(f), mode, offset, len);
358358 fdput(f);
359359 }
360360 return error;
@@ -585,16 +585,16 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd) · 224 unmodified lines
585585 int error;
586586
587587 error = -EBADF;
588− if (!f.file)
588+ if (!fd_file(f))
589589 goto out;
590590
591591 error = -ENOTDIR;
592− if (!d_can_lookup(f.file->f_path.dentry))
592+ if (!d_can_lookup(fd_file(f)->f_path.dentry))
593593 goto out_putf;
594594
595− error = file_permission(f.file, MAY_EXEC | MAY_CHDIR);
595+ error = file_permission(fd_file(f), MAY_EXEC | MAY_CHDIR);
596596 if (!error)
597− set_fs_pwd(current->fs, &f.file->f_path);
597+ set_fs_pwd(current->fs, &fd_file(f)->f_path);
598598 out_putf:
599599 fdput(f);
600600 out:
@@ -675,8 +675,8 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode) · 74 unmodified lines
675675 struct fd f = fdget(fd);
676676 int err = -EBADF;
677677
678− if (f.file) {
679− err = vfs_fchmod(f.file, mode);
678+ if (fd_file(f)) {
679+ err = vfs_fchmod(fd_file(f), mode);
680680 fdput(f);
681681 }
682682 return err;
@@ -869,8 +869,8 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group) · 186 unmodified lines
869869 struct fd f = fdget(fd);
870870 int error = -EBADF;
871871
872− if (f.file) {
873− error = vfs_fchown(f.file, user, group);
872+ if (fd_file(f)) {
873+ error = vfs_fchown(fd_file(f), user, group);
874874 fdput(f);
875875 }
876876 return error;
fs/overlayfs/file.c+20−20
@@ -209,13 +209,13 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) · 208 unmodified lines
209209 * files, so we use the real file to perform seeks.
210210 */
211211 ovl_inode_lock(inode);
212− real.file->f_pos = file->f_pos;
212+ fd_file(real)->f_pos = file->f_pos;
213213
214214 old_cred = ovl_override_creds(inode->i_sb);
215− ret = vfs_llseek(real.file, offset, whence);
215+ ret = vfs_llseek(fd_file(real), offset, whence);
216216 revert_creds(old_cred);
217217
218− file->f_pos = real.file->f_pos;
218+ file->f_pos = fd_file(real)->f_pos;
219219 ovl_inode_unlock(inode);
220220
221221 fdput(real);
@@ -275,7 +275,7 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) · 53 unmodified lines
275275 if (ret)
276276 return ret;
277277
278− ret = backing_file_read_iter(real.file, iter, iocb, iocb->ki_flags,
278+ ret = backing_file_read_iter(fd_file(real), iter, iocb, iocb->ki_flags,
279279 &ctx);
280280 fdput(real);
281281
@@ -314,7 +314,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) · 32 unmodified lines
314314 * this property in case it is set by the issuer.
315315 */
316316 ifl &= ~IOCB_DIO_CALLER_COMP;
317− ret = backing_file_write_iter(real.file, iter, iocb, ifl, &ctx);
317+ ret = backing_file_write_iter(fd_file(real), iter, iocb, ifl, &ctx);
318318 fdput(real);
319319
320320 out_unlock:
@@ -339,7 +339,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 18 unmodified lines
339339 if (ret)
340340 return ret;
341341
342− ret = backing_file_splice_read(real.file, ppos, pipe, len, flags, &ctx);
342+ ret = backing_file_splice_read(fd_file(real), ppos, pipe, len, flags, &ctx);
343343 fdput(real);
344344
345345 return ret;
@@ -348,7 +348,7 @@ static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, · 2 unmodified lines
348348 /*
349349 * Calling iter_file_splice_write() directly from overlay's f_op may deadlock
350350 * due to lock order inversion between pipe->mutex in iter_file_splice_write()
351− * and file_start_write(real.file) in ovl_write_iter().
351+ * and file_start_write(fd_file(real)) in ovl_write_iter().
352352 *
353353 * So do everything ovl_write_iter() does and call iter_file_splice_write() on
354354 * the real file.
@@ -373,7 +373,7 @@ static ssize_t ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, · 18 unmodified lines
373373 if (ret)
374374 goto out_unlock;
375375
376− ret = backing_file_splice_write(pipe, real.file, ppos, len, flags, &ctx);
376+ ret = backing_file_splice_write(pipe, fd_file(real), ppos, len, flags, &ctx);
377377 fdput(real);
378378
379379 out_unlock:
@@ -397,9 +397,9 @@ static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) · 17 unmodified lines
397397 return ret;
398398
399399 /* Don't sync lower file for fear of receiving EROFS error */
400− if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) {
400+ if (file_inode(fd_file(real)) == ovl_inode_upper(file_inode(file))) {
401401 old_cred = ovl_override_creds(file_inode(file)->i_sb);
402− ret = vfs_fsync_range(real.file, start, end, datasync);
402+ ret = vfs_fsync_range(fd_file(real), start, end, datasync);
403403 revert_creds(old_cred);
404404 }
405405
@@ -439,7 +439,7 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len · 33 unmodified lines
439439 goto out_unlock;
440440
441441 old_cred = ovl_override_creds(file_inode(file)->i_sb);
442− ret = vfs_fallocate(real.file, mode, offset, len);
442+ ret = vfs_fallocate(fd_file(real), mode, offset, len);
443443 revert_creds(old_cred);
444444
445445 /* Update size */
@@ -464,7 +464,7 @@ static int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) · 18 unmodified lines
464464 return ret;
465465
466466 old_cred = ovl_override_creds(file_inode(file)->i_sb);
467− ret = vfs_fadvise(real.file, offset, len, advice);
467+ ret = vfs_fadvise(fd_file(real), offset, len, advice);
468468 revert_creds(old_cred);
469469
470470 fdput(real);
@@ -509,18 +509,18 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, · 38 unmodified lines
509509 old_cred = ovl_override_creds(file_inode(file_out)->i_sb);
510510 switch (op) {
511511 case OVL_COPY:
512− ret = vfs_copy_file_range(real_in.file, pos_in,
513− real_out.file, pos_out, len, flags);
512+ ret = vfs_copy_file_range(fd_file(real_in), pos_in,
513+ fd_file(real_out), pos_out, len, flags);
514514 break;
515515
516516 case OVL_CLONE:
517− ret = vfs_clone_file_range(real_in.file, pos_in,
518− real_out.file, pos_out, len, flags);
517+ ret = vfs_clone_file_range(fd_file(real_in), pos_in,
518+ fd_file(real_out), pos_out, len, flags);
519519 break;
520520
521521 case OVL_DEDUPE:
522− ret = vfs_dedupe_file_range_one(real_in.file, pos_in,
523− real_out.file, pos_out, len,
522+ ret = vfs_dedupe_file_range_one(fd_file(real_in), pos_in,
523+ fd_file(real_out), pos_out, len,
524524 flags);
525525 break;
526526 }
@@ -583,9 +583,9 @@ static int ovl_flush(struct file *file, fl_owner_t id) · 56 unmodified lines
583583 if (err)
584584 return err;
585585
586− if (real.file->f_op->flush) {
586+ if (fd_file(real)->f_op->flush) {
587587 old_cred = ovl_override_creds(file_inode(file)->i_sb);
588− err = real.file->f_op->flush(real.file, id);
588+ err = fd_file(real)->f_op->flush(fd_file(real), id);
589589 revert_creds(old_cred);
590590 }
591591 fdput(real);
fs/quota/quota.c+4−4
@@ -980,7 +980,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 979 unmodified lines
980980 int ret;
981981
982982 f = fdget_raw(fd);
983− if (!f.file)
983+ if (!fd_file(f))
984984 return -EBADF;
985985
986986 ret = -EINVAL;
@@ -988,12 +988,12 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 1 unmodified line
988988 goto out;
989989
990990 if (quotactl_cmd_write(cmds)) {
991− ret = mnt_want_write(f.file->f_path.mnt);
991+ ret = mnt_want_write(fd_file(f)->f_path.mnt);
992992 if (ret)
993993 goto out;
994994 }
995995
996− sb = f.file->f_path.mnt->mnt_sb;
996+ sb = fd_file(f)->f_path.mnt->mnt_sb;
997997 if (quotactl_cmd_onoff(cmds))
998998 down_write(&sb->s_umount);
999999 else
@@ -1007,7 +1007,7 @@ SYSCALL_DEFINE4(quotactl_fd, unsigned int, fd, unsigned int, cmd, · 7 unmodified lines
10071007 up_read(&sb->s_umount);
10081008
10091009 if (quotactl_cmd_write(cmds))
1010− mnt_drop_write(f.file->f_path.mnt);
1010+ mnt_drop_write(fd_file(f)->f_path.mnt);
10111011 out:
10121012 fdput(f);
10131013 return ret;
fs/read_write.c+59−59
@@ -294,12 +294,12 @@ static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence) · 293 unmodified lines
294294 {
295295 off_t retval;
296296 struct fd f = fdget_pos(fd);
297− if (!f.file)
297+ if (!fd_file(f))
298298 return -EBADF;
299299
300300 retval = -EINVAL;
301301 if (whence <= SEEK_MAX) {
302− loff_t res = vfs_llseek(f.file, offset, whence);
302+ loff_t res = vfs_llseek(fd_file(f), offset, whence);
303303 retval = res;
304304 if (res != (loff_t)retval)
305305 retval = -EOVERFLOW; /* LFS: should only happen on 32 bit platforms */
@@ -330,14 +330,14 @@ SYSCALL_DEFINE5(llseek, unsigned int, fd, unsigned long, offset_high, · 24 unmodified lines
330330 struct fd f = fdget_pos(fd);
331331 loff_t offset;
332332
333− if (!f.file)
333+ if (!fd_file(f))
334334 return -EBADF;
335335
336336 retval = -EINVAL;
337337 if (whence > SEEK_MAX)
338338 goto out_putf;
339339
340− offset = vfs_llseek(f.file, ((loff_t) offset_high << 32) | offset_low,
340+ offset = vfs_llseek(fd_file(f), ((loff_t) offset_high << 32) | offset_low,
341341 whence);
342342
343343 retval = (int)offset;
@@ -610,15 +610,15 @@ ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count) · 266 unmodified lines
610610 struct fd f = fdget_pos(fd);
611611 ssize_t ret = -EBADF;
612612
613− if (f.file) {
614− loff_t pos, *ppos = file_ppos(f.file);
613+ if (fd_file(f)) {
614+ loff_t pos, *ppos = file_ppos(fd_file(f));
615615 if (ppos) {
616616 pos = *ppos;
617617 ppos = &pos;
618618 }
619− ret = vfs_read(f.file, buf, count, ppos);
619+ ret = vfs_read(fd_file(f), buf, count, ppos);
620620 if (ret >= 0 && ppos)
621− f.file->f_pos = pos;
621+ fd_file(f)->f_pos = pos;
622622 fdput_pos(f);
623623 }
624624 return ret;
@@ -634,15 +634,15 @@ ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count) · 9 unmodified lines
634634 struct fd f = fdget_pos(fd);
635635 ssize_t ret = -EBADF;
636636
637− if (f.file) {
638− loff_t pos, *ppos = file_ppos(f.file);
637+ if (fd_file(f)) {
638+ loff_t pos, *ppos = file_ppos(fd_file(f));
639639 if (ppos) {
640640 pos = *ppos;
641641 ppos = &pos;
642642 }
643− ret = vfs_write(f.file, buf, count, ppos);
643+ ret = vfs_write(fd_file(f), buf, count, ppos);
644644 if (ret >= 0 && ppos)
645− f.file->f_pos = pos;
645+ fd_file(f)->f_pos = pos;
646646 fdput_pos(f);
647647 }
648648
@@ -665,10 +665,10 @@ ssize_t ksys_pread64(unsigned int fd, char __user *buf, size_t count, · 16 unmodified lines
665665 return -EINVAL;
666666
667667 f = fdget(fd);
668− if (f.file) {
668+ if (fd_file(f)) {
669669 ret = -ESPIPE;
670− if (f.file->f_mode & FMODE_PREAD)
671− ret = vfs_read(f.file, buf, count, &pos);
670+ if (fd_file(f)->f_mode & FMODE_PREAD)
671+ ret = vfs_read(fd_file(f), buf, count, &pos);
672672 fdput(f);
673673 }
674674
@@ -699,10 +699,10 @@ ssize_t ksys_pwrite64(unsigned int fd, const char __user *buf, · 24 unmodified lines
699699 return -EINVAL;
700700
701701 f = fdget(fd);
702− if (f.file) {
702+ if (fd_file(f)) {
703703 ret = -ESPIPE;
704− if (f.file->f_mode & FMODE_PWRITE)
705− ret = vfs_write(f.file, buf, count, &pos);
704+ if (fd_file(f)->f_mode & FMODE_PWRITE)
705+ ret = vfs_write(fd_file(f), buf, count, &pos);
706706 fdput(f);
707707 }
708708
@@ -985,15 +985,15 @@ static ssize_t do_readv(unsigned long fd, const struct iovec __user *vec, · 276 unmodified lines
985985 struct fd f = fdget_pos(fd);
986986 ssize_t ret = -EBADF;
987987
988− if (f.file) {
989− loff_t pos, *ppos = file_ppos(f.file);
988+ if (fd_file(f)) {
989+ loff_t pos, *ppos = file_ppos(fd_file(f));
990990 if (ppos) {
991991 pos = *ppos;
992992 ppos = &pos;
993993 }
994− ret = vfs_readv(f.file, vec, vlen, ppos, flags);
994+ ret = vfs_readv(fd_file(f), vec, vlen, ppos, flags);
995995 if (ret >= 0 && ppos)
996− f.file->f_pos = pos;
996+ fd_file(f)->f_pos = pos;
997997 fdput_pos(f);
998998 }
999999
@@ -1009,15 +1009,15 @@ static ssize_t do_writev(unsigned long fd, const struct iovec __user *vec, · 9 unmodified lines
10091009 struct fd f = fdget_pos(fd);
10101010 ssize_t ret = -EBADF;
10111011
1012− if (f.file) {
1013− loff_t pos, *ppos = file_ppos(f.file);
1012+ if (fd_file(f)) {
1013+ loff_t pos, *ppos = file_ppos(fd_file(f));
10141014 if (ppos) {
10151015 pos = *ppos;
10161016 ppos = &pos;
10171017 }
1018− ret = vfs_writev(f.file, vec, vlen, ppos, flags);
1018+ ret = vfs_writev(fd_file(f), vec, vlen, ppos, flags);
10191019 if (ret >= 0 && ppos)
1020− f.file->f_pos = pos;
1020+ fd_file(f)->f_pos = pos;
10211021 fdput_pos(f);
10221022 }
10231023
@@ -1043,10 +1043,10 @@ static ssize_t do_preadv(unsigned long fd, const struct iovec __user *vec, · 19 unmodified lines
10431043 return -EINVAL;
10441044
10451045 f = fdget(fd);
1046− if (f.file) {
1046+ if (fd_file(f)) {
10471047 ret = -ESPIPE;
1048− if (f.file->f_mode & FMODE_PREAD)
1049− ret = vfs_readv(f.file, vec, vlen, &pos, flags);
1048+ if (fd_file(f)->f_mode & FMODE_PREAD)
1049+ ret = vfs_readv(fd_file(f), vec, vlen, &pos, flags);
10501050 fdput(f);
10511051 }
10521052
@@ -1066,10 +1066,10 @@ static ssize_t do_pwritev(unsigned long fd, const struct iovec __user *vec, · 13 unmodified lines
10661066 return -EINVAL;
10671067
10681068 f = fdget(fd);
1069− if (f.file) {
1069+ if (fd_file(f)) {
10701070 ret = -ESPIPE;
1071− if (f.file->f_mode & FMODE_PWRITE)
1072− ret = vfs_writev(f.file, vec, vlen, &pos, flags);
1071+ if (fd_file(f)->f_mode & FMODE_PWRITE)
1072+ ret = vfs_writev(fd_file(f), vec, vlen, &pos, flags);
10731073 fdput(f);
10741074 }
10751075
@@ -1235,19 +1235,19 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 159 unmodified lines
12351235 */
12361236 retval = -EBADF;
12371237 in = fdget(in_fd);
1238− if (!in.file)
1238+ if (!fd_file(in))
12391239 goto out;
1240− if (!(in.file->f_mode & FMODE_READ))
1240+ if (!(fd_file(in)->f_mode & FMODE_READ))
12411241 goto fput_in;
12421242 retval = -ESPIPE;
12431243 if (!ppos) {
1244− pos = in.file->f_pos;
1244+ pos = fd_file(in)->f_pos;
12451245 } else {
12461246 pos = *ppos;
1247− if (!(in.file->f_mode & FMODE_PREAD))
1247+ if (!(fd_file(in)->f_mode & FMODE_PREAD))
12481248 goto fput_in;
12491249 }
1250− retval = rw_verify_area(READ, in.file, &pos, count);
1250+ retval = rw_verify_area(READ, fd_file(in), &pos, count);
12511251 if (retval < 0)
12521252 goto fput_in;
12531253 if (count > MAX_RW_COUNT)
@@ -1258,13 +1258,13 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 4 unmodified lines
12581258 */
12591259 retval = -EBADF;
12601260 out = fdget(out_fd);
1261− if (!out.file)
1261+ if (!fd_file(out))
12621262 goto fput_in;
1263− if (!(out.file->f_mode & FMODE_WRITE))
1263+ if (!(fd_file(out)->f_mode & FMODE_WRITE))
12641264 goto fput_out;
1265− in_inode = file_inode(in.file);
1266− out_inode = file_inode(out.file);
1267− out_pos = out.file->f_pos;
1265+ in_inode = file_inode(fd_file(in));
1266+ out_inode = file_inode(fd_file(out));
1267+ out_pos = fd_file(out)->f_pos;
12681268
12691269 if (!max)
12701270 max = min(in_inode->i_sb->s_maxbytes, out_inode->i_sb->s_maxbytes);
@@ -1284,33 +1284,33 @@ static ssize_t do_sendfile(int out_fd, int in_fd, loff_t *ppos, · 13 unmodified lines
12841284 * and the application is arguably buggy if it doesn't expect
12851285 * EAGAIN on a non-blocking file descriptor.
12861286 */
1287− if (in.file->f_flags & O_NONBLOCK)
1287+ if (fd_file(in)->f_flags & O_NONBLOCK)
12881288 fl = SPLICE_F_NONBLOCK;
12891289 #endif
1290− opipe = get_pipe_info(out.file, true);
1290+ opipe = get_pipe_info(fd_file(out), true);
12911291 if (!opipe) {
1292− retval = rw_verify_area(WRITE, out.file, &out_pos, count);
1292+ retval = rw_verify_area(WRITE, fd_file(out), &out_pos, count);
12931293 if (retval < 0)
12941294 goto fput_out;
1295− retval = do_splice_direct(in.file, &pos, out.file, &out_pos,
1295+ retval = do_splice_direct(fd_file(in), &pos, fd_file(out), &out_pos,
12961296 count, fl);
12971297 } else {
1298− if (out.file->f_flags & O_NONBLOCK)
1298+ if (fd_file(out)->f_flags & O_NONBLOCK)
12991299 fl |= SPLICE_F_NONBLOCK;
13001300
1301− retval = splice_file_to_pipe(in.file, opipe, &pos, count, fl);
1301+ retval = splice_file_to_pipe(fd_file(in), opipe, &pos, count, fl);
13021302 }
13031303
13041304 if (retval > 0) {
13051305 add_rchar(current, retval);
13061306 add_wchar(current, retval);
1307− fsnotify_access(in.file);
1308− fsnotify_modify(out.file);
1309− out.file->f_pos = out_pos;
1307+ fsnotify_access(fd_file(in));
1308+ fsnotify_modify(fd_file(out));
1309+ fd_file(out)->f_pos = out_pos;
13101310 if (ppos)
13111311 *ppos = pos;
13121312 else
1313− in.file->f_pos = pos;
1313+ fd_file(in)->f_pos = pos;
13141314 }
13151315
13161316 inc_syscr(current);
@@ -1583,11 +1583,11 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 266 unmodified lines
15831583 ssize_t ret = -EBADF;
15841584
15851585 f_in = fdget(fd_in);
1586− if (!f_in.file)
1586+ if (!fd_file(f_in))
15871587 goto out2;
15881588
15891589 f_out = fdget(fd_out);
1590− if (!f_out.file)
1590+ if (!fd_file(f_out))
15911591 goto out1;
15921592
15931593 ret = -EFAULT;
@@ -1595,21 +1595,21 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 1 unmodified line
15951595 if (copy_from_user(&pos_in, off_in, sizeof(loff_t)))
15961596 goto out;
15971597 } else {
1598− pos_in = f_in.file->f_pos;
1598+ pos_in = fd_file(f_in)->f_pos;
15991599 }
16001600
16011601 if (off_out) {
16021602 if (copy_from_user(&pos_out, off_out, sizeof(loff_t)))
16031603 goto out;
16041604 } else {
1605− pos_out = f_out.file->f_pos;
1605+ pos_out = fd_file(f_out)->f_pos;
16061606 }
16071607
16081608 ret = -EINVAL;
16091609 if (flags != 0)
16101610 goto out;
16111611
1612− ret = vfs_copy_file_range(f_in.file, pos_in, f_out.file, pos_out, len,
1612+ ret = vfs_copy_file_range(fd_file(f_in), pos_in, fd_file(f_out), pos_out, len,
16131613 flags);
16141614 if (ret > 0) {
16151615 pos_in += ret;
@@ -1619,14 +1619,14 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, · 3 unmodified lines
16191619 if (copy_to_user(off_in, &pos_in, sizeof(loff_t)))
16201620 ret = -EFAULT;
16211621 } else {
1622− f_in.file->f_pos = pos_in;
1622+ fd_file(f_in)->f_pos = pos_in;
16231623 }
16241624
16251625 if (off_out) {
16261626 if (copy_to_user(off_out, &pos_out, sizeof(loff_t)))
16271627 ret = -EFAULT;
16281628 } else {
1629− f_out.file->f_pos = pos_out;
1629+ fd_file(f_out)->f_pos = pos_out;
16301630 }
16311631 }
16321632
fs/readdir.c+10−10
@@ -225,10 +225,10 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 224 unmodified lines
225225 .dirent = dirent
226226 };
227227
228− if (!f.file)
228+ if (!fd_file(f))
229229 return -EBADF;
230230
231− error = iterate_dir(f.file, &buf.ctx);
231+ error = iterate_dir(fd_file(f), &buf.ctx);
232232 if (buf.result)
233233 error = buf.result;
234234
@@ -318,10 +318,10 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd, · 83 unmodified lines
318318 int error;
319319
320320 f = fdget_pos(fd);
321− if (!f.file)
321+ if (!fd_file(f))
322322 return -EBADF;
323323
324− error = iterate_dir(f.file, &buf.ctx);
324+ error = iterate_dir(fd_file(f), &buf.ctx);
325325 if (error >= 0)
326326 error = buf.error;
327327 if (buf.prev_reclen) {
@@ -401,10 +401,10 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd, · 73 unmodified lines
401401 int error;
402402
403403 f = fdget_pos(fd);
404− if (!f.file)
404+ if (!fd_file(f))
405405 return -EBADF;
406406
407− error = iterate_dir(f.file, &buf.ctx);
407+ error = iterate_dir(fd_file(f), &buf.ctx);
408408 if (error >= 0)
409409 error = buf.error;
410410 if (buf.prev_reclen) {
@@ -483,10 +483,10 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, · 72 unmodified lines
483483 .dirent = dirent
484484 };
485485
486− if (!f.file)
486+ if (!fd_file(f))
487487 return -EBADF;
488488
489− error = iterate_dir(f.file, &buf.ctx);
489+ error = iterate_dir(fd_file(f), &buf.ctx);
490490 if (buf.result)
491491 error = buf.result;
492492
@@ -569,10 +569,10 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, · 76 unmodified lines
569569 int error;
570570
571571 f = fdget_pos(fd);
572− if (!f.file)
572+ if (!fd_file(f))
573573 return -EBADF;
574574
575− error = iterate_dir(f.file, &buf.ctx);
575+ error = iterate_dir(fd_file(f), &buf.ctx);
576576 if (error >= 0)
577577 error = buf.error;
578578 if (buf.prev_reclen) {
fs/remap_range.c+1−1
@@ -537,7 +537,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) · 536 unmodified lines
537537
538538 for (i = 0, info = same->info; i < count; i++, info++) {
539539 struct fd dst_fd = fdget(info->dest_fd);
540− struct file *dst_file = dst_fd.file;
540+ struct file *dst_file = fd_file(dst_fd);
541541
542542 if (!dst_file) {
543543 info->status = -EBADF;
fs/select.c+4−4
@@ -532,10 +532,10 @@ static noinline_for_stack int do_select(int n, fd_set_bits *fds, struct timespec · 531 unmodified lines
532532 continue;
533533 mask = EPOLLNVAL;
534534 f = fdget(i);
535− if (f.file) {
535+ if (fd_file(f)) {
536536 wait_key_set(wait, in, out, bit,
537537 busy_flag);
538− mask = vfs_poll(f.file, wait);
538+ mask = vfs_poll(fd_file(f), wait);
539539
540540 fdput(f);
541541 }
@@ -864,13 +864,13 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, · 322 unmodified lines
864864 goto out;
865865 mask = EPOLLNVAL;
866866 f = fdget(fd);
867− if (!f.file)
867+ if (!fd_file(f))
868868 goto out;
869869
870870 /* userland u16 ->events contains POLL... bitmap */
871871 filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP;
872872 pwait->_key = filter | busy_flag;
873− mask = vfs_poll(f.file, pwait);
873+ mask = vfs_poll(fd_file(f), pwait);
874874 if (mask & busy_flag)
875875 *can_busy_poll = true;
876876 mask &= filter; /* Mask out unneeded events. */
fs/signalfd.c+3−3
@@ -289,10 +289,10 @@ static int do_signalfd4(int ufd, sigset_t *mask, int flags) · 288 unmodified lines
289289 fd_install(ufd, file);
290290 } else {
291291 struct fd f = fdget(ufd);
292− if (!f.file)
292+ if (!fd_file(f))
293293 return -EBADF;
294− ctx = f.file->private_data;
295− if (f.file->f_op != &signalfd_fops) {
294+ ctx = fd_file(f)->private_data;
295+ if (fd_file(f)->f_op != &signalfd_fops) {
296296 fdput(f);
297297 return -EINVAL;
298298 }
fs/smb/client/ioctl.c+4−4
@@ -90,23 +90,23 @@ static long cifs_ioctl_copychunk(unsigned int xid, struct file *dst_file, · 89 unmodified lines
9090 }
9191
9292 src_file = fdget(srcfd);
93− if (!src_file.file) {
93+ if (!fd_file(src_file)) {
9494 rc = -EBADF;
9595 goto out_drop_write;
9696 }
9797
98− if (src_file.file->f_op->unlocked_ioctl != cifs_ioctl) {
98+ if (fd_file(src_file)->f_op->unlocked_ioctl != cifs_ioctl) {
9999 rc = -EBADF;
100100 cifs_dbg(VFS, "src file seems to be from a different filesystem type\n");
101101 goto out_fput;
102102 }
103103
104− src_inode = file_inode(src_file.file);
104+ src_inode = file_inode(fd_file(src_file));
105105 rc = -EINVAL;
106106 if (S_ISDIR(src_inode->i_mode))
107107 goto out_fput;
108108
109− rc = cifs_file_copychunk_range(xid, src_file.file, 0, dst_file, 0,
109+ rc = cifs_file_copychunk_range(xid, fd_file(src_file), 0, dst_file, 0,
110110 src_inode->i_size, 0);
111111 if (rc > 0)
112112 rc = 0;
fs/splice.c+11−11
@@ -1566,11 +1566,11 @@ static ssize_t vmsplice_to_pipe(struct file *file, struct iov_iter *iter, · 1565 unmodified lines
15661566
15671567 static int vmsplice_type(struct fd f, int *type)
15681568 {
1569− if (!f.file)
1569+ if (!fd_file(f))
15701570 return -EBADF;
1571− if (f.file->f_mode & FMODE_WRITE) {
1571+ if (fd_file(f)->f_mode & FMODE_WRITE) {
15721572 *type = ITER_SOURCE;
1573− } else if (f.file->f_mode & FMODE_READ) {
1573+ } else if (fd_file(f)->f_mode & FMODE_READ) {
15741574 *type = ITER_DEST;
15751575 } else {
15761576 fdput(f);
@@ -1621,9 +1621,9 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov, · 44 unmodified lines
16211621 if (!iov_iter_count(&iter))
16221622 error = 0;
16231623 else if (type == ITER_SOURCE)
1624− error = vmsplice_to_pipe(f.file, &iter, flags);
1624+ error = vmsplice_to_pipe(fd_file(f), &iter, flags);
16251625 else
1626− error = vmsplice_to_user(f.file, &iter, flags);
1626+ error = vmsplice_to_user(fd_file(f), &iter, flags);
16271627
16281628 kfree(iov);
16291629 out_fdput:
@@ -1646,10 +1646,10 @@ SYSCALL_DEFINE6(splice, int, fd_in, loff_t __user *, off_in, · 16 unmodified lines
16461646
16471647 error = -EBADF;
16481648 in = fdget(fd_in);
1649− if (in.file) {
1649+ if (fd_file(in)) {
16501650 out = fdget(fd_out);
1651− if (out.file) {
1652− error = __do_splice(in.file, off_in, out.file, off_out,
1651+ if (fd_file(out)) {
1652+ error = __do_splice(fd_file(in), off_in, fd_file(out), off_out,
16531653 len, flags);
16541654 fdput(out);
16551655 }
@@ -2016,10 +2016,10 @@ SYSCALL_DEFINE4(tee, int, fdin, int, fdout, size_t, len, unsigned int, flags) · 360 unmodified lines
20162016
20172017 error = -EBADF;
20182018 in = fdget(fdin);
2019− if (in.file) {
2019+ if (fd_file(in)) {
20202020 out = fdget(fdout);
2021− if (out.file) {
2022− error = do_tee(in.file, out.file, len, flags);
2021+ if (fd_file(out)) {
2022+ error = do_tee(fd_file(in), fd_file(out), len, flags);
20232023 fdput(out);
20242024 }
20252025 fdput(in);
fs/stat.c+4−4
@@ -224,9 +224,9 @@ int vfs_fstat(int fd, struct kstat *stat) · 223 unmodified lines
224224 int error;
225225
226226 f = fdget_raw(fd);
227− if (!f.file)
227+ if (!fd_file(f))
228228 return -EBADF;
229− error = vfs_getattr(&f.file->f_path, stat, STATX_BASIC_STATS, 0);
229+ error = vfs_getattr(&fd_file(f)->f_path, stat, STATX_BASIC_STATS, 0);
230230 fdput(f);
231231 return error;
232232 }
@@ -277,9 +277,9 @@ static int vfs_statx_fd(int fd, int flags, struct kstat *stat, · 44 unmodified lines
277277 u32 request_mask)
278278 {
279279 CLASS(fd_raw, f)(fd);
280− if (!f.file)
280+ if (!fd_file(f))
281281 return -EBADF;
282− return vfs_statx_path(&f.file->f_path, flags, stat, request_mask);
282+ return vfs_statx_path(&fd_file(f)->f_path, flags, stat, request_mask);
283283 }
284284
285285 /**
fs/statfs.c+2−2
@@ -116,8 +116,8 @@ int fd_statfs(int fd, struct kstatfs *st) · 115 unmodified lines
116116 {
117117 struct fd f = fdget_raw(fd);
118118 int error = -EBADF;
119− if (f.file) {
120− error = vfs_statfs(&f.file->f_path, st);
119+ if (fd_file(f)) {
120+ error = vfs_statfs(&fd_file(f)->f_path, st);
121121 fdput(f);
122122 }
123123 return error;
fs/sync.c+7−7
@@ -152,15 +152,15 @@ SYSCALL_DEFINE1(syncfs, int, fd) · 151 unmodified lines
152152 struct super_block *sb;
153153 int ret, ret2;
154154
155− if (!f.file)
155+ if (!fd_file(f))
156156 return -EBADF;
157− sb = f.file->f_path.dentry->d_sb;
157+ sb = fd_file(f)->f_path.dentry->d_sb;
158158
159159 down_read(&sb->s_umount);
160160 ret = sync_filesystem(sb);
161161 up_read(&sb->s_umount);
162162
163− ret2 = errseq_check_and_advance(&sb->s_wb_err, &f.file->f_sb_err);
163+ ret2 = errseq_check_and_advance(&sb->s_wb_err, &fd_file(f)->f_sb_err);
164164
165165 fdput(f);
166166 return ret ? ret : ret2;
@@ -208,8 +208,8 @@ static int do_fsync(unsigned int fd, int datasync) · 41 unmodified lines
208208 struct fd f = fdget(fd);
209209 int ret = -EBADF;
210210
211− if (f.file) {
212− ret = vfs_fsync(f.file, datasync);
211+ if (fd_file(f)) {
212+ ret = vfs_fsync(fd_file(f), datasync);
213213 fdput(f);
214214 }
215215 return ret;
@@ -360,8 +360,8 @@ int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, · 144 unmodified lines
360360
361361 ret = -EBADF;
362362 f = fdget(fd);
363− if (f.file)
364− ret = sync_file_range(f.file, offset, nbytes, flags);
363+ if (fd_file(f))
364+ ret = sync_file_range(fd_file(f), offset, nbytes, flags);
365365
366366 fdput(f);
367367 return ret;
fs/timerfd.c+4−4
@@ -397,9 +397,9 @@ static const struct file_operations timerfd_fops = { · 396 unmodified lines
397397 static int timerfd_fget(int fd, struct fd *p)
398398 {
399399 struct fd f = fdget(fd);
400− if (!f.file)
400+ if (!fd_file(f))
401401 return -EBADF;
402− if (f.file->f_op != &timerfd_fops) {
402+ if (fd_file(f)->f_op != &timerfd_fops) {
403403 fdput(f);
404404 return -EINVAL;
405405 }
@@ -482,7 +482,7 @@ static int do_timerfd_settime(int ufd, int flags, · 76 unmodified lines
482482 ret = timerfd_fget(ufd, &f);
483483 if (ret)
484484 return ret;
485− ctx = f.file->private_data;
485+ ctx = fd_file(f)->private_data;
486486
487487 if (isalarm(ctx) && !capable(CAP_WAKE_ALARM)) {
488488 fdput(f);
@@ -546,7 +546,7 @@ static int do_timerfd_gettime(int ufd, struct itimerspec64 *t) · 57 unmodified lines
546546 int ret = timerfd_fget(ufd, &f);
547547 if (ret)
548548 return ret;
549− ctx = f.file->private_data;
549+ ctx = fd_file(f)->private_data;
550550
551551 spin_lock_irq(&ctx->wqh.lock);
552552 if (ctx->expired && ctx->tintv) {
fs/utimes.c+2−2
@@ -115,9 +115,9 @@ static int do_utimes_fd(int fd, struct timespec64 *times, int flags) · 114 unmodified lines
115115 return -EINVAL;
116116
117117 f = fdget(fd);
118− if (!f.file)
118+ if (!fd_file(f))
119119 return -EBADF;
120− error = vfs_utimes(&f.file->f_path, times);
120+ error = vfs_utimes(&fd_file(f)->f_path, times);
121121 fdput(f);
122122 return error;
123123 }
fs/xattr.c+18−18
@@ -697,19 +697,19 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, · 696 unmodified lines
697697 int error;
698698
699699 CLASS(fd, f)(fd);
700− if (!f.file)
700+ if (!fd_file(f))
701701 return -EBADF;
702702
703− audit_file(f.file);
703+ audit_file(fd_file(f));
704704 error = setxattr_copy(name, &ctx);
705705 if (error)
706706 return error;
707707
708− error = mnt_want_write_file(f.file);
708+ error = mnt_want_write_file(fd_file(f));
709709 if (!error) {
710− error = do_setxattr(file_mnt_idmap(f.file),
711− f.file->f_path.dentry, &ctx);
712− mnt_drop_write_file(f.file);
710+ error = do_setxattr(file_mnt_idmap(fd_file(f)),
711+ fd_file(f)->f_path.dentry, &ctx);
712+ mnt_drop_write_file(fd_file(f));
713713 }
714714 kvfree(ctx.kvalue);
715715 return error;
@@ -812,10 +812,10 @@ SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, · 96 unmodified lines
812812 struct fd f = fdget(fd);
813813 ssize_t error = -EBADF;
814814
815− if (!f.file)
815+ if (!fd_file(f))
816816 return error;
817− audit_file(f.file);
818− error = getxattr(file_mnt_idmap(f.file), f.file->f_path.dentry,
817+ audit_file(fd_file(f));
818+ error = getxattr(file_mnt_idmap(fd_file(f)), fd_file(f)->f_path.dentry,
819819 name, value, size);
820820 fdput(f);
821821 return error;
@@ -888,10 +888,10 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) · 66 unmodified lines
888888 struct fd f = fdget(fd);
889889 ssize_t error = -EBADF;
890890
891− if (!f.file)
891+ if (!fd_file(f))
892892 return error;
893− audit_file(f.file);
894− error = listxattr(f.file->f_path.dentry, list, size);
893+ audit_file(fd_file(f));
894+ error = listxattr(fd_file(f)->f_path.dentry, list, size);
895895 fdput(f);
896896 return error;
897897 }
@@ -954,9 +954,9 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 56 unmodified lines
954954 char kname[XATTR_NAME_MAX + 1];
955955 int error = -EBADF;
956956
957− if (!f.file)
957+ if (!fd_file(f))
958958 return error;
959− audit_file(f.file);
959+ audit_file(fd_file(f));
960960
961961 error = strncpy_from_user(kname, name, sizeof(kname));
962962 if (error == 0 || error == sizeof(kname))
@@ -964,11 +964,11 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) · 1 unmodified line
964964 if (error < 0)
965965 return error;
966966
967− error = mnt_want_write_file(f.file);
967+ error = mnt_want_write_file(fd_file(f));
968968 if (!error) {
969− error = removexattr(file_mnt_idmap(f.file),
970− f.file->f_path.dentry, kname);
971− mnt_drop_write_file(f.file);
969+ error = removexattr(file_mnt_idmap(fd_file(f)),
970+ fd_file(f)->f_path.dentry, kname);
971+ mnt_drop_write_file(fd_file(f));
972972 }
973973 fdput(f);
974974 return error;
fs/xfs/xfs_exchrange.c+2−2
@@ -794,9 +794,9 @@ xfs_ioc_exchange_range( · 793 unmodified lines
794794 fxr.flags = args.flags;
795795
796796 file1 = fdget(args.file1_fd);
797− if (!file1.file)
797+ if (!fd_file(file1))
798798 return -EBADF;
799− fxr.file1 = file1.file;
799+ fxr.file1 = fd_file(file1);
800800
801801 error = xfs_exchange_range(&fxr);
802802 fdput(file1);
fs/xfs/xfs_handle.c+2−2
@@ -92,9 +92,9 @@ xfs_find_handle( · 91 unmodified lines
9292
9393 if (cmd == XFS_IOC_FD_TO_HANDLE) {
9494 f = fdget(hreq->fd);
95− if (!f.file)
95+ if (!fd_file(f))
9696 return -EBADF;
97− inode = file_inode(f.file);
97+ inode = file_inode(fd_file(f));
9898 } else {
9999 error = user_path_at(AT_FDCWD, hreq->path, 0, &path);
100100 if (error)
fs/xfs/xfs_ioctl.c+14−14
@@ -1005,33 +1005,33 @@ xfs_ioc_swapext( · 1004 unmodified lines
10051005
10061006 /* Pull information for the target fd */
10071007 f = fdget((int)sxp->sx_fdtarget);
1008− if (!f.file) {
1008+ if (!fd_file(f)) {
10091009 error = -EINVAL;
10101010 goto out;
10111011 }
10121012
1013− if (!(f.file->f_mode & FMODE_WRITE) ||
1014− !(f.file->f_mode & FMODE_READ) ||
1015− (f.file->f_flags & O_APPEND)) {
1013+ if (!(fd_file(f)->f_mode & FMODE_WRITE) ||
1014+ !(fd_file(f)->f_mode & FMODE_READ) ||
1015+ (fd_file(f)->f_flags & O_APPEND)) {
10161016 error = -EBADF;
10171017 goto out_put_file;
10181018 }
10191019
10201020 tmp = fdget((int)sxp->sx_fdtmp);
1021− if (!tmp.file) {
1021+ if (!fd_file(tmp)) {
10221022 error = -EINVAL;
10231023 goto out_put_file;
10241024 }
10251025
1026− if (!(tmp.file->f_mode & FMODE_WRITE) ||
1027− !(tmp.file->f_mode & FMODE_READ) ||
1028− (tmp.file->f_flags & O_APPEND)) {
1026+ if (!(fd_file(tmp)->f_mode & FMODE_WRITE) ||
1027+ !(fd_file(tmp)->f_mode & FMODE_READ) ||
1028+ (fd_file(tmp)->f_flags & O_APPEND)) {
10291029 error = -EBADF;
10301030 goto out_put_tmp_file;
10311031 }
10321032
1033− if (IS_SWAPFILE(file_inode(f.file)) ||
1034− IS_SWAPFILE(file_inode(tmp.file))) {
1033+ if (IS_SWAPFILE(file_inode(fd_file(f))) ||
1034+ IS_SWAPFILE(file_inode(fd_file(tmp)))) {
10351035 error = -EINVAL;
10361036 goto out_put_tmp_file;
10371037 }
@@ -1041,14 +1041,14 @@ xfs_ioc_swapext( · 3 unmodified lines
10411041 * before we cast and access them as XFS structures as we have no
10421042 * control over what the user passes us here.
10431043 */
1044− if (f.file->f_op != &xfs_file_operations ||
1045− tmp.file->f_op != &xfs_file_operations) {
1044+ if (fd_file(f)->f_op != &xfs_file_operations ||
1045+ fd_file(tmp)->f_op != &xfs_file_operations) {
10461046 error = -EINVAL;
10471047 goto out_put_tmp_file;
10481048 }
10491049
1050− ip = XFS_I(file_inode(f.file));
1051− tip = XFS_I(file_inode(tmp.file));
1050+ ip = XFS_I(file_inode(fd_file(f)));
1051+ tip = XFS_I(file_inode(fd_file(tmp)));
10521052
10531053 if (ip->i_mount != tip->i_mount) {
10541054 error = -EINVAL;
include/linux/cleanup.h+1−1
@@ -98,7 +98,7 @@ const volatile void * __must_check_fn(const volatile void *val) · 97 unmodified lines
9898 * DEFINE_CLASS(fdget, struct fd, fdput(_T), fdget(fd), int fd)
9999 *
100100 * CLASS(fdget, f)(fd);
101− * if (!f.file)
101+ * if (!fd_file(f))
102102 * return -EBADF;
103103 *
104104 * // use 'f' without concern
include/linux/file.h+4−2
@@ -42,10 +42,12 @@ struct fd { · 41 unmodified lines
4242 #define FDPUT_FPUT 1
4343 #define FDPUT_POS_UNLOCK 2
4444
45+#define fd_file(f) ((f).file)
46+
4547 static inline void fdput(struct fd fd)
4648 {
4749 if (fd.flags & FDPUT_FPUT)
48− fput(fd.file);
50+ fput(fd_file(fd));
4951 }
5052
5153 extern struct file *fget(unsigned int fd);
@@ -79,7 +81,7 @@ static inline struct fd fdget_pos(int fd) · 27 unmodified lines
7981 static inline void fdput_pos(struct fd f)
8082 {
8183 if (f.flags & FDPUT_POS_UNLOCK)
82− __f_unlock_pos(f.file);
84+ __f_unlock_pos(fd_file(f));
8385 fdput(f);
8486 }
8587
io_uring/sqpoll.c+5−5
@@ -108,14 +108,14 @@ static struct io_sq_data *io_attach_sq_data(struct io_uring_params *p) · 107 unmodified lines
108108 struct fd f;
109109
110110 f = fdget(p->wq_fd);
111− if (!f.file)
111+ if (!fd_file(f))
112112 return ERR_PTR(-ENXIO);
113− if (!io_is_uring_fops(f.file)) {
113+ if (!io_is_uring_fops(fd_file(f))) {
114114 fdput(f);
115115 return ERR_PTR(-EINVAL);
116116 }
117117
118− ctx_attach = f.file->private_data;
118+ ctx_attach = fd_file(f)->private_data;
119119 sqd = ctx_attach->sq_data;
120120 if (!sqd) {
121121 fdput(f);
@@ -418,9 +418,9 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx, · 296 unmodified lines
418418 struct fd f;
419419
420420 f = fdget(p->wq_fd);
421− if (!f.file)
421+ if (!fd_file(f))
422422 return -ENXIO;
423− if (!io_is_uring_fops(f.file)) {
423+ if (!io_is_uring_fops(fd_file(f))) {
424424 fdput(f);
425425 return -EINVAL;
426426 }
ipc/mqueue.c+25−25
@@ -1085,20 +1085,20 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, · 1084 unmodified lines
10851085 audit_mq_sendrecv(mqdes, msg_len, msg_prio, ts);
10861086
10871087 f = fdget(mqdes);
1088− if (unlikely(!f.file)) {
1088+ if (unlikely(!fd_file(f))) {
10891089 ret = -EBADF;
10901090 goto out;
10911091 }
10921092
1093− inode = file_inode(f.file);
1094− if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1093+ inode = file_inode(fd_file(f));
1094+ if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) {
10951095 ret = -EBADF;
10961096 goto out_fput;
10971097 }
10981098 info = MQUEUE_I(inode);
1099− audit_file(f.file);
1099+ audit_file(fd_file(f));
11001100
1101− if (unlikely(!(f.file->f_mode & FMODE_WRITE))) {
1101+ if (unlikely(!(fd_file(f)->f_mode & FMODE_WRITE))) {
11021102 ret = -EBADF;
11031103 goto out_fput;
11041104 }
@@ -1138,7 +1138,7 @@ static int do_mq_timedsend(mqd_t mqdes, const char __user *u_msg_ptr, · 33 unmodified lines
11381138 }
11391139
11401140 if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) {
1141− if (f.file->f_flags & O_NONBLOCK) {
1141+ if (fd_file(f)->f_flags & O_NONBLOCK) {
11421142 ret = -EAGAIN;
11431143 } else {
11441144 wait.task = current;
@@ -1199,20 +1199,20 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr, · 54 unmodified lines
11991199 audit_mq_sendrecv(mqdes, msg_len, 0, ts);
12001200
12011201 f = fdget(mqdes);
1202− if (unlikely(!f.file)) {
1202+ if (unlikely(!fd_file(f))) {
12031203 ret = -EBADF;
12041204 goto out;
12051205 }
12061206
1207− inode = file_inode(f.file);
1208− if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1207+ inode = file_inode(fd_file(f));
1208+ if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) {
12091209 ret = -EBADF;
12101210 goto out_fput;
12111211 }
12121212 info = MQUEUE_I(inode);
1213− audit_file(f.file);
1213+ audit_file(fd_file(f));
12141214
1215− if (unlikely(!(f.file->f_mode & FMODE_READ))) {
1215+ if (unlikely(!(fd_file(f)->f_mode & FMODE_READ))) {
12161216 ret = -EBADF;
12171217 goto out_fput;
12181218 }
@@ -1242,7 +1242,7 @@ static int do_mq_timedreceive(mqd_t mqdes, char __user *u_msg_ptr, · 23 unmodified lines
12421242 }
12431243
12441244 if (info->attr.mq_curmsgs == 0) {
1245− if (f.file->f_flags & O_NONBLOCK) {
1245+ if (fd_file(f)->f_flags & O_NONBLOCK) {
12461246 spin_unlock(&info->lock);
12471247 ret = -EAGAIN;
12481248 } else {
@@ -1356,11 +1356,11 @@ static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification) · 107 unmodified lines
13561356 /* and attach it to the socket */
13571357 retry:
13581358 f = fdget(notification->sigev_signo);
1359− if (!f.file) {
1359+ if (!fd_file(f)) {
13601360 ret = -EBADF;
13611361 goto out;
13621362 }
1363− sock = netlink_getsockbyfilp(f.file);
1363+ sock = netlink_getsockbyfilp(fd_file(f));
13641364 fdput(f);
13651365 if (IS_ERR(sock)) {
13661366 ret = PTR_ERR(sock);
@@ -1379,13 +1379,13 @@ retry: · 12 unmodified lines
13791379 }
13801380
13811381 f = fdget(mqdes);
1382− if (!f.file) {
1382+ if (!fd_file(f)) {
13831383 ret = -EBADF;
13841384 goto out;
13851385 }
13861386
1387− inode = file_inode(f.file);
1388− if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1387+ inode = file_inode(fd_file(f));
1388+ if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) {
13891389 ret = -EBADF;
13901390 goto out_fput;
13911391 }
@@ -1460,31 +1460,31 @@ static int do_mq_getsetattr(int mqdes, struct mq_attr *new, struct mq_attr *old) · 68 unmodified lines
14601460 return -EINVAL;
14611461
14621462 f = fdget(mqdes);
1463− if (!f.file)
1463+ if (!fd_file(f))
14641464 return -EBADF;
14651465
1466− if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1466+ if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) {
14671467 fdput(f);
14681468 return -EBADF;
14691469 }
14701470
1471− inode = file_inode(f.file);
1471+ inode = file_inode(fd_file(f));
14721472 info = MQUEUE_I(inode);
14731473
14741474 spin_lock(&info->lock);
14751475
14761476 if (old) {
14771477 *old = info->attr;
1478− old->mq_flags = f.file->f_flags & O_NONBLOCK;
1478+ old->mq_flags = fd_file(f)->f_flags & O_NONBLOCK;
14791479 }
14801480 if (new) {
14811481 audit_mq_getsetattr(mqdes, new);
1482− spin_lock(&f.file->f_lock);
1482+ spin_lock(&fd_file(f)->f_lock);
14831483 if (new->mq_flags & O_NONBLOCK)
1484− f.file->f_flags |= O_NONBLOCK;
1484+ fd_file(f)->f_flags |= O_NONBLOCK;
14851485 else
1486− f.file->f_flags &= ~O_NONBLOCK;
1487− spin_unlock(&f.file->f_lock);
1486+ fd_file(f)->f_flags &= ~O_NONBLOCK;
1487+ spin_unlock(&fd_file(f)->f_lock);
14881488
14891489 inode_set_atime_to_ts(inode, inode_set_ctime_current(inode));
14901490 }
kernel/bpf/bpf_inode_storage.c+7−7
@@ -80,10 +80,10 @@ static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key) · 79 unmodified lines
8080 struct bpf_local_storage_data *sdata;
8181 struct fd f = fdget_raw(*(int *)key);
8282
83− if (!f.file)
83+ if (!fd_file(f))
8484 return ERR_PTR(-EBADF);
8585
86− sdata = inode_storage_lookup(file_inode(f.file), map, true);
86+ sdata = inode_storage_lookup(file_inode(fd_file(f)), map, true);
8787 fdput(f);
8888 return sdata ? sdata->data : NULL;
8989 }
@@ -94,14 +94,14 @@ static long bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key, · 4 unmodified lines
9494 struct bpf_local_storage_data *sdata;
9595 struct fd f = fdget_raw(*(int *)key);
9696
97− if (!f.file)
97+ if (!fd_file(f))
9898 return -EBADF;
99− if (!inode_storage_ptr(file_inode(f.file))) {
99+ if (!inode_storage_ptr(file_inode(fd_file(f)))) {
100100 fdput(f);
101101 return -EBADF;
102102 }
103103
104− sdata = bpf_local_storage_update(file_inode(f.file),
104+ sdata = bpf_local_storage_update(file_inode(fd_file(f)),
105105 (struct bpf_local_storage_map *)map,
106106 value, map_flags, GFP_ATOMIC);
107107 fdput(f);
@@ -126,10 +126,10 @@ static long bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key) · 18 unmodified lines
126126 struct fd f = fdget_raw(*(int *)key);
127127 int err;
128128
129− if (!f.file)
129+ if (!fd_file(f))
130130 return -EBADF;
131131
132− err = inode_storage_delete(file_inode(f.file), map);
132+ err = inode_storage_delete(file_inode(fd_file(f)), map);
133133 fdput(f);
134134 return err;
135135 }
kernel/bpf/btf.c+3−3
@@ -7677,15 +7677,15 @@ struct btf *btf_get_by_fd(int fd) · 7676 unmodified lines
76777677
76787678 f = fdget(fd);
76797679
7680− if (!f.file)
7680+ if (!fd_file(f))
76817681 return ERR_PTR(-EBADF);
76827682
7683− if (f.file->f_op != &btf_fops) {
7683+ if (fd_file(f)->f_op != &btf_fops) {
76847684 fdput(f);
76857685 return ERR_PTR(-EINVAL);
76867686 }
76877687
7688− btf = f.file->private_data;
7688+ btf = fd_file(f)->private_data;
76897689 refcount_inc(&btf->refcnt);
76907690 fdput(f);
76917691
kernel/bpf/syscall.c+21−21
@@ -829,7 +829,7 @@ static int bpf_map_release(struct inode *inode, struct file *filp) · 828 unmodified lines
829829
830830 static fmode_t map_get_sys_perms(struct bpf_map *map, struct fd f)
831831 {
832− fmode_t mode = f.file->f_mode;
832+ fmode_t mode = fd_file(f)->f_mode;
833833
834834 /* Our file permissions may have been overridden by global
835835 * map permissions facing syscall side.
@@ -1423,14 +1423,14 @@ put_token: · 587 unmodified lines
14231423 */
14241424 struct bpf_map *__bpf_map_get(struct fd f)
14251425 {
1426− if (!f.file)
1426+ if (!fd_file(f))
14271427 return ERR_PTR(-EBADF);
1428− if (f.file->f_op != &bpf_map_fops) {
1428+ if (fd_file(f)->f_op != &bpf_map_fops) {
14291429 fdput(f);
14301430 return ERR_PTR(-EINVAL);
14311431 }
14321432
1433− return f.file->private_data;
1433+ return fd_file(f)->private_data;
14341434 }
14351435
14361436 void bpf_map_inc(struct bpf_map *map)
@@ -1651,7 +1651,7 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr) · 214 unmodified lines
16511651 goto free_key;
16521652 }
16531653
1654− err = bpf_map_update_value(map, f.file, key, value, attr->flags);
1654+ err = bpf_map_update_value(map, fd_file(f), key, value, attr->flags);
16551655 if (!err)
16561656 maybe_wait_bpf_programs(map);
16571657
@@ -2409,14 +2409,14 @@ int bpf_prog_new_fd(struct bpf_prog *prog) · 751 unmodified lines
24092409
24102410 static struct bpf_prog *____bpf_prog_get(struct fd f)
24112411 {
2412− if (!f.file)
2412+ if (!fd_file(f))
24132413 return ERR_PTR(-EBADF);
2414− if (f.file->f_op != &bpf_prog_fops) {
2414+ if (fd_file(f)->f_op != &bpf_prog_fops) {
24152415 fdput(f);
24162416 return ERR_PTR(-EINVAL);
24172417 }
24182418
2419− return f.file->private_data;
2419+ return fd_file(f)->private_data;
24202420 }
24212421
24222422 void bpf_prog_add(struct bpf_prog *prog, int i)
@@ -3259,14 +3259,14 @@ struct bpf_link *bpf_link_get_from_fd(u32 ufd) · 836 unmodified lines
32593259 struct fd f = fdget(ufd);
32603260 struct bpf_link *link;
32613261
3262− if (!f.file)
3262+ if (!fd_file(f))
32633263 return ERR_PTR(-EBADF);
3264− if (f.file->f_op != &bpf_link_fops && f.file->f_op != &bpf_link_fops_poll) {
3264+ if (fd_file(f)->f_op != &bpf_link_fops && fd_file(f)->f_op != &bpf_link_fops_poll) {
32653265 fdput(f);
32663266 return ERR_PTR(-EINVAL);
32673267 }
32683268
3269− link = f.file->private_data;
3269+ link = fd_file(f)->private_data;
32703270 bpf_link_inc(link);
32713271 fdput(f);
32723272
@@ -4982,19 +4982,19 @@ static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, · 1709 unmodified lines
49824982 return -EINVAL;
49834983
49844984 f = fdget(ufd);
4985− if (!f.file)
4985+ if (!fd_file(f))
49864986 return -EBADFD;
49874987
4988− if (f.file->f_op == &bpf_prog_fops)
4989− err = bpf_prog_get_info_by_fd(f.file, f.file->private_data, attr,
4988+ if (fd_file(f)->f_op == &bpf_prog_fops)
4989+ err = bpf_prog_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr,
49904990 uattr);
4991− else if (f.file->f_op == &bpf_map_fops)
4992− err = bpf_map_get_info_by_fd(f.file, f.file->private_data, attr,
4991+ else if (fd_file(f)->f_op == &bpf_map_fops)
4992+ err = bpf_map_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr,
49934993 uattr);
4994− else if (f.file->f_op == &btf_fops)
4995− err = bpf_btf_get_info_by_fd(f.file, f.file->private_data, attr, uattr);
4996− else if (f.file->f_op == &bpf_link_fops || f.file->f_op == &bpf_link_fops_poll)
4997− err = bpf_link_get_info_by_fd(f.file, f.file->private_data,
4994+ else if (fd_file(f)->f_op == &btf_fops)
4995+ err = bpf_btf_get_info_by_fd(fd_file(f), fd_file(f)->private_data, attr, uattr);
4996+ else if (fd_file(f)->f_op == &bpf_link_fops || fd_file(f)->f_op == &bpf_link_fops_poll)
4997+ err = bpf_link_get_info_by_fd(fd_file(f), fd_file(f)->private_data,
49984998 attr, uattr);
49994999 else
50005000 err = -EINVAL;
@@ -5215,7 +5215,7 @@ static int bpf_map_do_batch(const union bpf_attr *attr, · 214 unmodified lines
52155215 else if (cmd == BPF_MAP_LOOKUP_AND_DELETE_BATCH)
52165216 BPF_DO_BATCH(map->ops->map_lookup_and_delete_batch, map, attr, uattr);
52175217 else if (cmd == BPF_MAP_UPDATE_BATCH)
5218− BPF_DO_BATCH(map->ops->map_update_batch, map, f.file, attr, uattr);
5218+ BPF_DO_BATCH(map->ops->map_update_batch, map, fd_file(f), attr, uattr);
52195219 else
52205220 BPF_DO_BATCH(map->ops->map_delete_batch, map, attr, uattr);
52215221 err_put:
kernel/bpf/token.c+5−5
@@ -122,10 +122,10 @@ int bpf_token_create(union bpf_attr *attr) · 121 unmodified lines
122122 int err, fd;
123123
124124 f = fdget(attr->token_create.bpffs_fd);
125− if (!f.file)
125+ if (!fd_file(f))
126126 return -EBADF;
127127
128− path = f.file->f_path;
128+ path = fd_file(f)->f_path;
129129 path_get(&path);
130130 fdput(f);
131131
@@ -235,14 +235,14 @@ struct bpf_token *bpf_token_get_from_fd(u32 ufd) · 103 unmodified lines
235235 struct fd f = fdget(ufd);
236236 struct bpf_token *token;
237237
238− if (!f.file)
238+ if (!fd_file(f))
239239 return ERR_PTR(-EBADF);
240− if (f.file->f_op != &bpf_token_fops) {
240+ if (fd_file(f)->f_op != &bpf_token_fops) {
241241 fdput(f);
242242 return ERR_PTR(-EINVAL);
243243 }
244244
245− token = f.file->private_data;
245+ token = fd_file(f)->private_data;
246246 bpf_token_inc(token);
247247 fdput(f);
248248
kernel/cgroup/cgroup.c+2−2
@@ -6901,10 +6901,10 @@ struct cgroup *cgroup_v1v2_get_from_fd(int fd) · 6900 unmodified lines
69016901 {
69026902 struct cgroup *cgrp;
69036903 struct fd f = fdget_raw(fd);
6904− if (!f.file)
6904+ if (!fd_file(f))
69056905 return ERR_PTR(-EBADF);
69066906
6907− cgrp = cgroup_v1v2_get_from_file(f.file);
6907+ cgrp = cgroup_v1v2_get_from_file(fd_file(f));
69086908 fdput(f);
69096909 return cgrp;
69106910 }
kernel/events/core.c+6−6
@@ -933,10 +933,10 @@ static inline int perf_cgroup_connect(int fd, struct perf_event *event, · 932 unmodified lines
933933 struct fd f = fdget(fd);
934934 int ret = 0;
935935
936− if (!f.file)
936+ if (!fd_file(f))
937937 return -EBADF;
938938
939− css = css_tryget_online_from_dir(f.file->f_path.dentry,
939+ css = css_tryget_online_from_dir(fd_file(f)->f_path.dentry,
940940 &perf_event_cgrp_subsys);
941941 if (IS_ERR(css)) {
942942 ret = PTR_ERR(css);
@@ -5898,10 +5898,10 @@ static const struct file_operations perf_fops; · 4955 unmodified lines
58985898 static inline int perf_fget_light(int fd, struct fd *p)
58995899 {
59005900 struct fd f = fdget(fd);
5901− if (!f.file)
5901+ if (!fd_file(f))
59025902 return -EBADF;
59035903
5904− if (f.file->f_op != &perf_fops) {
5904+ if (fd_file(f)->f_op != &perf_fops) {
59055905 fdput(f);
59065906 return -EBADF;
59075907 }
@@ -5961,7 +5961,7 @@ static long _perf_ioctl(struct perf_event *event, unsigned int cmd, unsigned lon · 53 unmodified lines
59615961 ret = perf_fget_light(arg, &output);
59625962 if (ret)
59635963 return ret;
5964− output_event = output.file->private_data;
5964+ output_event = fd_file(output)->private_data;
59655965 ret = perf_event_set_output(event, output_event);
59665966 fdput(output);
59675967 } else {
@@ -12549,7 +12549,7 @@ SYSCALL_DEFINE5(perf_event_open, · 6581 unmodified lines
1254912549 err = perf_fget_light(group_fd, &group);
1255012550 if (err)
1255112551 goto err_fd;
12552− group_leader = group.file->private_data;
12552+ group_leader = fd_file(group)->private_data;
1255312553 if (flags & PERF_FLAG_FD_OUTPUT)
1255412554 output_event = group_leader;
1255512555 if (flags & PERF_FLAG_FD_NO_GROUP)
kernel/module/main.c+1−1
@@ -3211,7 +3211,7 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) · 3210 unmodified lines
32113211 return -EINVAL;
32123212
32133213 f = fdget(fd);
3214− err = idempotent_init_module(f.file, uargs, flags);
3214+ err = idempotent_init_module(fd_file(f), uargs, flags);
32153215 fdput(f);
32163216 return err;
32173217 }
kernel/nsproxy.c+6−6
@@ -550,15 +550,15 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 549 unmodified lines
550550 struct nsset nsset = {};
551551 int err = 0;
552552
553− if (!f.file)
553+ if (!fd_file(f))
554554 return -EBADF;
555555
556− if (proc_ns_file(f.file)) {
557− ns = get_proc_ns(file_inode(f.file));
556+ if (proc_ns_file(fd_file(f))) {
557+ ns = get_proc_ns(file_inode(fd_file(f)));
558558 if (flags && (ns->ops->type != flags))
559559 err = -EINVAL;
560560 flags = ns->ops->type;
561− } else if (!IS_ERR(pidfd_pid(f.file))) {
561+ } else if (!IS_ERR(pidfd_pid(fd_file(f)))) {
562562 err = check_setns_flags(flags);
563563 } else {
564564 err = -EINVAL;
@@ -570,10 +570,10 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags) · 5 unmodified lines
570570 if (err)
571571 goto out;
572572
573− if (proc_ns_file(f.file))
573+ if (proc_ns_file(fd_file(f)))
574574 err = validate_ns(&nsset, ns);
575575 else
576− err = validate_nsset(&nsset, pidfd_pid(f.file));
576+ err = validate_nsset(&nsset, pidfd_pid(fd_file(f)));
577577 if (!err) {
578578 commit_nsset(&nsset);
579579 perf_event_namespaces(current);
kernel/pid.c+5−5
@@ -540,13 +540,13 @@ struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags) · 539 unmodified lines
540540 struct pid *pid;
541541
542542 f = fdget(fd);
543− if (!f.file)
543+ if (!fd_file(f))
544544 return ERR_PTR(-EBADF);
545545
546− pid = pidfd_pid(f.file);
546+ pid = pidfd_pid(fd_file(f));
547547 if (!IS_ERR(pid)) {
548548 get_pid(pid);
549− *flags = f.file->f_flags;
549+ *flags = fd_file(f)->f_flags;
550550 }
551551
552552 fdput(f);
@@ -755,10 +755,10 @@ SYSCALL_DEFINE3(pidfd_getfd, int, pidfd, int, fd, · 202 unmodified lines
755755 return -EINVAL;
756756
757757 f = fdget(pidfd);
758− if (!f.file)
758+ if (!fd_file(f))
759759 return -EBADF;
760760
761− pid = pidfd_pid(f.file);
761+ pid = pidfd_pid(fd_file(f));
762762 if (IS_ERR(pid))
763763 ret = PTR_ERR(pid);
764764 else
kernel/signal.c+3−3
@@ -3922,11 +3922,11 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 3921 unmodified lines
39223922 return -EINVAL;
39233923
39243924 f = fdget(pidfd);
3925− if (!f.file)
3925+ if (!fd_file(f))
39263926 return -EBADF;
39273927
39283928 /* Is this a pidfd? */
3929− pid = pidfd_to_pid(f.file);
3929+ pid = pidfd_to_pid(fd_file(f));
39303930 if (IS_ERR(pid)) {
39313931 ret = PTR_ERR(pid);
39323932 goto err;
@@ -3939,7 +3939,7 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, · 6 unmodified lines
39393939 switch (flags) {
39403940 case 0:
39413941 /* Infer scope from the type of pidfd. */
3942− if (f.file->f_flags & PIDFD_THREAD)
3942+ if (fd_file(f)->f_flags & PIDFD_THREAD)
39433943 type = PIDTYPE_PID;
39443944 else
39453945 type = PIDTYPE_TGID;
kernel/sys.c+5−5
@@ -1916,10 +1916,10 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) · 1915 unmodified lines
19161916 int err;
19171917
19181918 exe = fdget(fd);
1919− if (!exe.file)
1919+ if (!fd_file(exe))
19201920 return -EBADF;
19211921
1922− inode = file_inode(exe.file);
1922+ inode = file_inode(fd_file(exe));
19231923
19241924 /*
19251925 * Because the original mm->exe_file points to executable file, make
@@ -1927,14 +1927,14 @@ static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd) · 1 unmodified line
19271927 * overall picture.
19281928 */
19291929 err = -EACCES;
1930− if (!S_ISREG(inode->i_mode) || path_noexec(&exe.file->f_path))
1930+ if (!S_ISREG(inode->i_mode) || path_noexec(&fd_file(exe)->f_path))
19311931 goto exit;
19321932
1933− err = file_permission(exe.file, MAY_EXEC);
1933+ err = file_permission(fd_file(exe), MAY_EXEC);
19341934 if (err)
19351935 goto exit;
19361936
1937− err = replace_mm_exe_file(mm, exe.file);
1937+ err = replace_mm_exe_file(mm, fd_file(exe));
19381938 exit:
19391939 fdput(exe);
19401940 return err;
kernel/taskstats.c+2−2
@@ -419,7 +419,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) · 418 unmodified lines
419419
420420 fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]);
421421 f = fdget(fd);
422− if (!f.file)
422+ if (!fd_file(f))
423423 return 0;
424424
425425 size = nla_total_size(sizeof(struct cgroupstats));
@@ -440,7 +440,7 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info) · 14 unmodified lines
440440 stats = nla_data(na);
441441 memset(stats, 0, sizeof(*stats));
442442
443− rc = cgroupstats_build(stats, f.file->f_path.dentry);
443+ rc = cgroupstats_build(stats, fd_file(f)->f_path.dentry);
444444 if (rc < 0) {
445445 nlmsg_free(rep_skb);
446446 goto err;
kernel/watch_queue.c+2−2
@@ -666,8 +666,8 @@ struct watch_queue *get_watch_queue(int fd) · 665 unmodified lines
666666 struct fd f;
667667
668668 f = fdget(fd);
669− if (f.file) {
670− pipe = get_pipe_info(f.file, false);
669+ if (fd_file(f)) {
670+ pipe = get_pipe_info(fd_file(f), false);
671671 if (pipe && pipe->watch_queue) {
672672 wqueue = pipe->watch_queue;
673673 kref_get(&wqueue->usage);
mm/fadvise.c+2−2
@@ -193,10 +193,10 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) · 192 unmodified lines
193193 struct fd f = fdget(fd);
194194 int ret;
195195
196− if (!f.file)
196+ if (!fd_file(f))
197197 return -EBADF;
198198
199− ret = vfs_fadvise(f.file, offset, len, advice);
199+ ret = vfs_fadvise(fd_file(f), offset, len, advice);
200200
201201 fdput(f);
202202 return ret;
mm/filemap.c+3−3
@@ -4393,7 +4393,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 4392 unmodified lines
43934393 struct cachestat cs;
43944394 pgoff_t first_index, last_index;
43954395
4396− if (!f.file)
4396+ if (!fd_file(f))
43974397 return -EBADF;
43984398
43994399 if (copy_from_user(&csr, cstat_range,
@@ -4403,7 +4403,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 3 unmodified lines
44034403 }
44044404
44054405 /* hugetlbfs is not supported */
4406− if (is_file_hugepages(f.file)) {
4406+ if (is_file_hugepages(fd_file(f))) {
44074407 fdput(f);
44084408 return -EOPNOTSUPP;
44094409 }
@@ -4417,7 +4417,7 @@ SYSCALL_DEFINE4(cachestat, unsigned int, fd, · 7 unmodified lines
44174417 last_index =
44184418 csr.len == 0 ? ULONG_MAX : (csr.off + csr.len - 1) >> PAGE_SHIFT;
44194419 memset(&cs, 0, sizeof(struct cachestat));
4420− mapping = f.file->f_mapping;
4420+ mapping = fd_file(f)->f_mapping;
44214421 filemap_cachestat(mapping, first_index, last_index, &cs);
44224422 fdput(f);
44234423
mm/memcontrol-v1.c+6−6
@@ -1857,26 +1857,26 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1856 unmodified lines
18571857 INIT_WORK(&event->remove, memcg_event_remove);
18581858
18591859 efile = fdget(efd);
1860− if (!efile.file) {
1860+ if (!fd_file(efile)) {
18611861 ret = -EBADF;
18621862 goto out_kfree;
18631863 }
18641864
1865− event->eventfd = eventfd_ctx_fileget(efile.file);
1865+ event->eventfd = eventfd_ctx_fileget(fd_file(efile));
18661866 if (IS_ERR(event->eventfd)) {
18671867 ret = PTR_ERR(event->eventfd);
18681868 goto out_put_efile;
18691869 }
18701870
18711871 cfile = fdget(cfd);
1872− if (!cfile.file) {
1872+ if (!fd_file(cfile)) {
18731873 ret = -EBADF;
18741874 goto out_put_eventfd;
18751875 }
18761876
18771877 /* the process need read permission on control file */
18781878 /* AV: shouldn't we check that it's been opened for read instead? */
1879− ret = file_permission(cfile.file, MAY_READ);
1879+ ret = file_permission(fd_file(cfile), MAY_READ);
18801880 if (ret < 0)
18811881 goto out_put_cfile;
18821882
@@ -1884,7 +1884,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 1 unmodified line
18841884 * The control file must be a regular cgroup1 file. As a regular cgroup
18851885 * file can't be renamed, it's safe to access its name afterwards.
18861886 */
1887− cdentry = cfile.file->f_path.dentry;
1887+ cdentry = fd_file(cfile)->f_path.dentry;
18881888 if (cdentry->d_sb->s_type != &cgroup_fs_type || !d_is_reg(cdentry)) {
18891889 ret = -EINVAL;
18901890 goto out_put_cfile;
@@ -1936,7 +1936,7 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, · 45 unmodified lines
19361936 if (ret)
19371937 goto out_put_css;
19381938
1939− vfs_poll(efile.file, &event->pt);
1939+ vfs_poll(fd_file(efile), &event->pt);
19401940
19411941 spin_lock_irq(&memcg->event_list_lock);
19421942 list_add(&event->list, &memcg->event_list);
mm/readahead.c+5−5
@@ -646,7 +646,7 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 645 unmodified lines
646646
647647 ret = -EBADF;
648648 f = fdget(fd);
649− if (!f.file || !(f.file->f_mode & FMODE_READ))
649+ if (!fd_file(f) || !(fd_file(f)->f_mode & FMODE_READ))
650650 goto out;
651651
652652 /*
@@ -655,12 +655,12 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) · 2 unmodified lines
655655 * on this file, then we must return -EINVAL.
656656 */
657657 ret = -EINVAL;
658− if (!f.file->f_mapping || !f.file->f_mapping->a_ops ||
659− (!S_ISREG(file_inode(f.file)->i_mode) &&
660− !S_ISBLK(file_inode(f.file)->i_mode)))
658+ if (!fd_file(f)->f_mapping || !fd_file(f)->f_mapping->a_ops ||
659+ (!S_ISREG(file_inode(fd_file(f))->i_mode) &&
660+ !S_ISBLK(file_inode(fd_file(f))->i_mode)))
661661 goto out;
662662
663− ret = vfs_fadvise(f.file, offset, count, POSIX_FADV_WILLNEED);
663+ ret = vfs_fadvise(fd_file(f), offset, count, POSIX_FADV_WILLNEED);
664664 out:
665665 fdput(f);
666666 return ret;
net/core/net_namespace.c+3−3
@@ -711,11 +711,11 @@ struct net *get_net_ns_by_fd(int fd) · 710 unmodified lines
711711 struct fd f = fdget(fd);
712712 struct net *net = ERR_PTR(-EINVAL);
713713
714− if (!f.file)
714+ if (!fd_file(f))
715715 return ERR_PTR(-EBADF);
716716
717− if (proc_ns_file(f.file)) {
718− struct ns_common *ns = get_proc_ns(file_inode(f.file));
717+ if (proc_ns_file(fd_file(f))) {
718+ struct ns_common *ns = get_proc_ns(file_inode(fd_file(f)));
719719 if (ns->ops == &netns_operations)
720720 net = get_net(container_of(ns, struct net, ns));
721721 }
net/socket.c+6−6
@@ -556,8 +556,8 @@ static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed) · 555 unmodified lines
556556 struct socket *sock;
557557
558558 *err = -EBADF;
559− if (f.file) {
560− sock = sock_from_file(f.file);
559+ if (fd_file(f)) {
560+ sock = sock_from_file(fd_file(f));
561561 if (likely(sock)) {
562562 *fput_needed = f.flags & FDPUT_FPUT;
563563 return sock;
@@ -2008,8 +2008,8 @@ int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr, · 1444 unmodified lines
20082008 struct fd f;
20092009
20102010 f = fdget(fd);
2011− if (f.file) {
2012− ret = __sys_accept4_file(f.file, upeer_sockaddr,
2011+ if (fd_file(f)) {
2012+ ret = __sys_accept4_file(fd_file(f), upeer_sockaddr,
20132013 upeer_addrlen, flags);
20142014 fdput(f);
20152015 }
@@ -2070,12 +2070,12 @@ int __sys_connect(int fd, struct sockaddr __user *uservaddr, int addrlen) · 54 unmodified lines
20702070 struct fd f;
20712071
20722072 f = fdget(fd);
2073− if (f.file) {
2073+ if (fd_file(f)) {
20742074 struct sockaddr_storage address;
20752075
20762076 ret = move_addr_to_kernel(uservaddr, addrlen, &address);
20772077 if (!ret)
2078− ret = __sys_connect_file(f.file, &address, addrlen, 0);
2078+ ret = __sys_connect_file(fd_file(f), &address, addrlen, 0);
20792079 fdput(f);
20802080 }
20812081
security/integrity/ima/ima_main.c+2−2
@@ -1068,10 +1068,10 @@ void ima_kexec_cmdline(int kernel_fd, const void *buf, int size) · 1067 unmodified lines
10681068 return;
10691069
10701070 f = fdget(kernel_fd);
1071− if (!f.file)
1071+ if (!fd_file(f))
10721072 return;
10731073
1074− process_buffer_measurement(file_mnt_idmap(f.file), file_inode(f.file),
1074+ process_buffer_measurement(file_mnt_idmap(fd_file(f)), file_inode(fd_file(f)),
10751075 buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0,
10761076 NULL, false, NULL, 0);
10771077 fdput(f);
security/landlock/syscalls.c+11−11
@@ -238,19 +238,19 @@ static struct landlock_ruleset *get_ruleset_from_fd(const int fd, · 237 unmodified lines
238238 struct landlock_ruleset *ruleset;
239239
240240 ruleset_f = fdget(fd);
241− if (!ruleset_f.file)
241+ if (!fd_file(ruleset_f))
242242 return ERR_PTR(-EBADF);
243243
244244 /* Checks FD type and access right. */
245− if (ruleset_f.file->f_op != &ruleset_fops) {
245+ if (fd_file(ruleset_f)->f_op != &ruleset_fops) {
246246 ruleset = ERR_PTR(-EBADFD);
247247 goto out_fdput;
248248 }
249− if (!(ruleset_f.file->f_mode & mode)) {
249+ if (!(fd_file(ruleset_f)->f_mode & mode)) {
250250 ruleset = ERR_PTR(-EPERM);
251251 goto out_fdput;
252252 }
253− ruleset = ruleset_f.file->private_data;
253+ ruleset = fd_file(ruleset_f)->private_data;
254254 if (WARN_ON_ONCE(ruleset->num_layers != 1)) {
255255 ruleset = ERR_PTR(-EINVAL);
256256 goto out_fdput;
@@ -277,22 +277,22 @@ static int get_path_from_fd(const s32 fd, struct path *const path) · 20 unmodified lines
277277
278278 /* Handles O_PATH. */
279279 f = fdget_raw(fd);
280− if (!f.file)
280+ if (!fd_file(f))
281281 return -EBADF;
282282 /*
283283 * Forbids ruleset FDs, internal filesystems (e.g. nsfs), including
284284 * pseudo filesystems that will never be mountable (e.g. sockfs,
285285 * pipefs).
286286 */
287− if ((f.file->f_op == &ruleset_fops) ||
288− (f.file->f_path.mnt->mnt_flags & MNT_INTERNAL) ||
289− (f.file->f_path.dentry->d_sb->s_flags & SB_NOUSER) ||
290− d_is_negative(f.file->f_path.dentry) ||
291− IS_PRIVATE(d_backing_inode(f.file->f_path.dentry))) {
287+ if ((fd_file(f)->f_op == &ruleset_fops) ||
288+ (fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) ||
289+ (fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) ||
290+ d_is_negative(fd_file(f)->f_path.dentry) ||
291+ IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry))) {
292292 err = -EBADFD;
293293 goto out_fdput;
294294 }
295− *path = f.file->f_path;
295+ *path = fd_file(f)->f_path;
296296 path_get(path);
297297
298298 out_fdput:
security/loadpin/loadpin.c+2−2
@@ -296,7 +296,7 @@ static int read_trusted_verity_root_digests(unsigned int fd) · 295 unmodified lines
296296 return -EPERM;
297297
298298 f = fdget(fd);
299− if (!f.file)
299+ if (!fd_file(f))
300300 return -EINVAL;
301301
302302 data = kzalloc(SZ_4K, GFP_KERNEL);
@@ -305,7 +305,7 @@ static int read_trusted_verity_root_digests(unsigned int fd) · 2 unmodified lines
305305 goto err;
306306 }
307307
308− rc = kernel_read_file(f.file, 0, (void **)&data, SZ_4K - 1, NULL, READING_POLICY);
308+ rc = kernel_read_file(fd_file(f), 0, (void **)&data, SZ_4K - 1, NULL, READING_POLICY);
309309 if (rc < 0)
310310 goto err;
311311
sound/core/pcm_native.c+3−3
@@ -2250,12 +2250,12 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) · 2249 unmodified lines
22502250 bool nonatomic = substream->pcm->nonatomic;
22512251 CLASS(fd, f)(fd);
22522252
2253− if (!f.file)
2253+ if (!fd_file(f))
22542254 return -EBADFD;
2255− if (!is_pcm_file(f.file))
2255+ if (!is_pcm_file(fd_file(f)))
22562256 return -EBADFD;
22572257
2258− pcm_file = f.file->private_data;
2258+ pcm_file = fd_file(f)->private_data;
22592259 substream1 = pcm_file->substream;
22602260
22612261 if (substream == substream1)
virt/kvm/eventfd.c+3−3
@@ -327,12 +327,12 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 326 unmodified lines
327327 seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock);
328328
329329 f = fdget(args->fd);
330− if (!f.file) {
330+ if (!fd_file(f)) {
331331 ret = -EBADF;
332332 goto out;
333333 }
334334
335− eventfd = eventfd_ctx_fileget(f.file);
335+ eventfd = eventfd_ctx_fileget(fd_file(f));
336336 if (IS_ERR(eventfd)) {
337337 ret = PTR_ERR(eventfd);
338338 goto fail;
@@ -419,7 +419,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) · 80 unmodified lines
419419 * Check if there was an event already pending on the eventfd
420420 * before we registered, and trigger it as if we didn't miss it.
421421 */
422− events = vfs_poll(f.file, &irqfd->pt);
422+ events = vfs_poll(fd_file(f), &irqfd->pt);
423423
424424 if (events & EPOLLIN)
425425 schedule_work(&irqfd->inject);
virt/kvm/vfio.c+4−4
@@ -194,7 +194,7 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd) · 193 unmodified lines
194194 int ret;
195195
196196 f = fdget(fd);
197− if (!f.file)
197+ if (!fd_file(f))
198198 return -EBADF;
199199
200200 ret = -ENOENT;
@@ -202,7 +202,7 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd) · 1 unmodified line
202202 mutex_lock(&kv->lock);
203203
204204 list_for_each_entry(kvf, &kv->file_list, node) {
205− if (kvf->file != f.file)
205+ if (kvf->file != fd_file(f))
206206 continue;
207207
208208 list_del(&kvf->node);
@@ -240,7 +240,7 @@ static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev, · 31 unmodified lines
240240 return -EFAULT;
241241
242242 f = fdget(param.groupfd);
243− if (!f.file)
243+ if (!fd_file(f))
244244 return -EBADF;
245245
246246 ret = -ENOENT;
@@ -248,7 +248,7 @@ static int kvm_vfio_file_set_spapr_tce(struct kvm_device *dev, · 1 unmodified line
248248 mutex_lock(&kv->lock);
249249
250250 list_for_each_entry(kvf, &kv->file_list, node) {
251− if (kvf->file != f.file)
251+ if (kvf->file != fd_file(f))
252252 continue;
253253
254254 if (!kvf->iommu_group) {