File descriptors are a per-process resource. The same descriptor
in different processes can refer to different files. find_file()
incorrectly assumed that file descriptors are globally unique.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes ZFS issue #386
typedef struct vn_file {
int f_fd; /* linux fd for lookup */
+ struct task_struct *f_task; /* linux task this fd belongs to */
struct file *f_file; /* linux file struct */
atomic_t f_ref; /* ref count */
kmutex_t f_lock; /* struct lock */
ASSERT(spin_is_locked(&vn_file_lock));
list_for_each_entry(fp, &vn_file_list, f_list) {
- if (fd == fp->f_fd) {
+ if (fd == fp->f_fd && fp->f_task == current) {
ASSERT(atomic_read(&fp->f_ref) != 0);
return fp;
}
mutex_enter(&fp->f_lock);
fp->f_fd = fd;
+ fp->f_task = current;
fp->f_offset = 0;
atomic_inc(&fp->f_ref);