Skip to content

Commit 99c21be

Browse files
committed
Merge tag 'vfs-6.15-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull misc vfs updates from Christian Brauner: "Features: - Add CONFIG_DEBUG_VFS infrastucture: - Catch invalid modes in open - Use the new debug macros in inode_set_cached_link() - Use debug-only asserts around fd allocation and install - Place f_ref to 3rd cache line in struct file to resolve false sharing Cleanups: - Start using anon_inode_getfile_fmode() helper in various places - Don't take f_lock during SEEK_CUR if exclusion is guaranteed by f_pos_lock - Add unlikely() to kcmp() - Remove legacy ->remount_fs method from ecryptfs after port to the new mount api - Remove invalidate_inodes() in favour of evict_inodes() - Simplify ep_busy_loopER by removing unused argument - Avoid mmap sem relocks when coredumping with many missing pages - Inline getname() - Inline new_inode_pseudo() and de-staticize alloc_inode() - Dodge an atomic in putname if ref == 1 - Consistently deref the files table with rcu_dereference_raw() - Dedup handling of struct filename init and refcounts bumps - Use wq_has_sleeper() in end_dir_add() - Drop the lock trip around I_NEW wake up in evict() - Load the ->i_sb pointer once in inode_sb_list_{add,del} - Predict not reaching the limit in alloc_empty_file() - Tidy up do_sys_openat2() with likely/unlikely - Call inode_sb_list_add() outside of inode hash lock - Sort out fd allocation vs dup2 race commentary - Turn page_offset() into a wrapper around folio_pos() - Remove locking in exportfs around ->get_parent() call - try_lookup_one_len() does not need any locks in autofs - Fix return type of several functions from long to int in open - Fix return type of several functions from long to int in ioctls Fixes: - Fix watch queue accounting mismatch" * tag 'vfs-6.15-rc1.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (30 commits) fs: sort out fd allocation vs dup2 race commentary, take 2 fs: call inode_sb_list_add() outside of inode hash lock fs: tidy up do_sys_openat2() with likely/unlikely fs: predict not reaching the limit in alloc_empty_file() fs: load the ->i_sb pointer once in inode_sb_list_{add,del} fs: drop the lock trip around I_NEW wake up in evict() fs: use wq_has_sleeper() in end_dir_add() VFS/autofs: try_lookup_one_len() does not need any locks fs: dedup handling of struct filename init and refcounts bumps fs: consistently deref the files table with rcu_dereference_raw() exportfs: remove locking around ->get_parent() call. fs: use debug-only asserts around fd allocation and install fs: dodge an atomic in putname if ref == 1 vfs: Remove invalidate_inodes() ecryptfs: remove NULL remount_fs from super_operations watch_queue: fix pipe accounting mismatch fs: place f_ref to 3rd cache line in struct file to resolve false sharing epoll: simplify ep_busy_loop by removing always 0 argument fs: Turn page_offset() into a wrapper around folio_pos() kcmp: improve performance adding an unlikely hint to task comparisons ...
2 parents c4cff1e + 4dec4f9 commit 99c21be

36 files changed

Lines changed: 339 additions & 258 deletions

File tree

Documentation/filesystems/porting.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,3 +1157,8 @@ in normal case it points into the pathname being looked up.
11571157
NOTE: if you need something like full path from the root of filesystem,
11581158
you are still on your own - this assists with simple cases, but it's not
11591159
magic.
1160+
1161+
---
1162+
1163+
** mandatory **
1164+
invalidate_inodes() is gone use evict_inodes() instead.

arch/arm64/kernel/elfcore.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ static int mte_dump_tag_range(struct coredump_params *cprm,
2727
int ret = 1;
2828
unsigned long addr;
2929
void *tags = NULL;
30+
int locked = 0;
3031

3132
for (addr = start; addr < start + len; addr += PAGE_SIZE) {
32-
struct page *page = get_dump_page(addr);
33+
struct page *page = get_dump_page(addr, &locked);
3334

3435
/*
3536
* get_dump_page() returns NULL when encountering an empty

arch/powerpc/platforms/pseries/papr-vpd.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,13 @@ static long papr_vpd_create_handle(struct papr_location_code __user *ulc)
482482
goto free_blob;
483483
}
484484

485-
file = anon_inode_getfile("[papr-vpd]", &papr_vpd_handle_ops,
486-
(void *)blob, O_RDONLY);
485+
file = anon_inode_getfile_fmode("[papr-vpd]", &papr_vpd_handle_ops,
486+
(void *)blob, O_RDONLY,
487+
FMODE_LSEEK | FMODE_PREAD);
487488
if (IS_ERR(file)) {
488489
err = PTR_ERR(file);
489490
goto put_fd;
490491
}
491-
492-
file->f_mode |= FMODE_LSEEK | FMODE_PREAD;
493492
fd_install(fd, file);
494493
return fd;
495494
put_fd:

drivers/vfio/group.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,12 @@ static struct file *vfio_device_open_file(struct vfio_device *device)
266266
if (ret)
267267
goto err_free;
268268

269-
/*
270-
* We can't use anon_inode_getfd() because we need to modify
271-
* the f_mode flags directly to allow more than just ioctls
272-
*/
273-
filep = anon_inode_getfile("[vfio-device]", &vfio_device_fops,
274-
df, O_RDWR);
269+
filep = anon_inode_getfile_fmode("[vfio-device]", &vfio_device_fops,
270+
df, O_RDWR, FMODE_PREAD | FMODE_PWRITE);
275271
if (IS_ERR(filep)) {
276272
ret = PTR_ERR(filep);
277273
goto err_close_device;
278274
}
279-
280-
/*
281-
* TODO: add an anon_inode interface to do this.
282-
* Appears to be missing by lack of need rather than
283-
* explicitly prevented. Now there's need.
284-
*/
285-
filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);
286-
287275
/*
288276
* Use the pseudo fs inode on the device to link all mmaps
289277
* to the same address space, allowing us to unmap all vmas

fs/autofs/dev-ioctl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ static int autofs_dev_ioctl_timeout(struct file *fp,
442442
sbi->exp_timeout = timeout * HZ;
443443
} else {
444444
struct dentry *base = fp->f_path.dentry;
445-
struct inode *inode = base->d_inode;
446445
int path_len = param->size - AUTOFS_DEV_IOCTL_SIZE - 1;
447446
struct dentry *dentry;
448447
struct autofs_info *ino;
@@ -460,9 +459,7 @@ static int autofs_dev_ioctl_timeout(struct file *fp,
460459
"the parent autofs mount timeout which could "
461460
"prevent shutdown\n");
462461

463-
inode_lock_shared(inode);
464462
dentry = try_lookup_one_len(param->path, base, path_len);
465-
inode_unlock_shared(inode);
466463
if (IS_ERR_OR_NULL(dentry))
467464
return dentry ? PTR_ERR(dentry) : -ENOENT;
468465
ino = autofs_dentry_ino(dentry);

fs/cachefiles/ondemand.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ static int cachefiles_ondemand_get_fd(struct cachefiles_req *req,
317317
goto err_free_id;
318318
}
319319

320-
anon_file->file = anon_inode_getfile("[cachefiles]",
321-
&cachefiles_ondemand_fd_fops, object, O_WRONLY);
320+
anon_file->file = anon_inode_getfile_fmode("[cachefiles]",
321+
&cachefiles_ondemand_fd_fops, object,
322+
O_WRONLY, FMODE_PWRITE | FMODE_LSEEK);
322323
if (IS_ERR(anon_file->file)) {
323324
ret = PTR_ERR(anon_file->file);
324325
goto err_put_fd;
@@ -333,8 +334,6 @@ static int cachefiles_ondemand_get_fd(struct cachefiles_req *req,
333334
goto err_put_file;
334335
}
335336

336-
anon_file->file->f_mode |= FMODE_PWRITE | FMODE_LSEEK;
337-
338337
load = (void *)req->msg.data;
339338
load->fd = anon_file->fd;
340339
object->ondemand->ondemand_id = object_id;

fs/coredump.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -926,36 +926,62 @@ int dump_user_range(struct coredump_params *cprm, unsigned long start,
926926
{
927927
unsigned long addr;
928928
struct page *dump_page;
929+
int locked, ret;
929930

930931
dump_page = dump_page_alloc();
931932
if (!dump_page)
932933
return 0;
933934

935+
ret = 0;
936+
locked = 0;
934937
for (addr = start; addr < start + len; addr += PAGE_SIZE) {
935938
struct page *page;
936939

940+
if (!locked) {
941+
if (mmap_read_lock_killable(current->mm))
942+
goto out;
943+
locked = 1;
944+
}
945+
937946
/*
938947
* To avoid having to allocate page tables for virtual address
939948
* ranges that have never been used yet, and also to make it
940949
* easy to generate sparse core files, use a helper that returns
941950
* NULL when encountering an empty page table entry that would
942951
* otherwise have been filled with the zero page.
943952
*/
944-
page = get_dump_page(addr);
953+
page = get_dump_page(addr, &locked);
945954
if (page) {
955+
if (locked) {
956+
mmap_read_unlock(current->mm);
957+
locked = 0;
958+
}
946959
int stop = !dump_emit_page(cprm, dump_page_copy(page, dump_page));
947960
put_page(page);
948-
if (stop) {
949-
dump_page_free(dump_page);
950-
return 0;
951-
}
961+
if (stop)
962+
goto out;
952963
} else {
953964
dump_skip(cprm, PAGE_SIZE);
954965
}
966+
967+
if (dump_interrupted())
968+
goto out;
969+
970+
if (!need_resched())
971+
continue;
972+
if (locked) {
973+
mmap_read_unlock(current->mm);
974+
locked = 0;
975+
}
955976
cond_resched();
956977
}
978+
ret = 1;
979+
out:
980+
if (locked)
981+
mmap_read_unlock(current->mm);
982+
957983
dump_page_free(dump_page);
958-
return 1;
984+
return ret;
959985
}
960986
#endif
961987

fs/dcache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2480,7 +2480,8 @@ static inline void end_dir_add(struct inode *dir, unsigned int n,
24802480
{
24812481
smp_store_release(&dir->i_dir_seq, n + 2);
24822482
preempt_enable_nested();
2483-
wake_up_all(d_wait);
2483+
if (wq_has_sleeper(d_wait))
2484+
wake_up_all(d_wait);
24842485
}
24852486

24862487
static void d_wait_lookup(struct dentry *dentry)

fs/ecryptfs/super.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ const struct super_operations ecryptfs_sops = {
172172
.destroy_inode = ecryptfs_destroy_inode,
173173
.free_inode = ecryptfs_free_inode,
174174
.statfs = ecryptfs_statfs,
175-
.remount_fs = NULL,
176175
.evict_inode = ecryptfs_evict_inode,
177176
.show_options = ecryptfs_show_options
178177
};

fs/eventfd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,13 @@ static int do_eventfd(unsigned int count, int flags)
406406
if (fd < 0)
407407
goto err;
408408

409-
file = anon_inode_getfile("[eventfd]", &eventfd_fops, ctx, flags);
409+
file = anon_inode_getfile_fmode("[eventfd]", &eventfd_fops,
410+
ctx, flags, FMODE_NOWAIT);
410411
if (IS_ERR(file)) {
411412
put_unused_fd(fd);
412413
fd = PTR_ERR(file);
413414
goto err;
414415
}
415-
416-
file->f_mode |= FMODE_NOWAIT;
417416
fd_install(fd, file);
418417
return fd;
419418
err:

0 commit comments

Comments
 (0)