aboutsummaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorGravatar Christian Brauner <brauner@kernel.org> 2024-03-28 13:27:24 +0100
committerGravatar Christian Brauner <brauner@kernel.org> 2024-04-07 13:49:02 +0200
commit210a03c9d51aa0e6e6f06980116e3256da8d4c48 (patch)
tree04084320e97c4e3991b2ea3d36959f5651893e67 /mm
parentfs: Annotate struct file_handle with __counted_by() and use struct_size() (diff)
downloadlinux-210a03c9d51aa0e6e6f06980116e3256da8d4c48.tar.gz
linux-210a03c9d51aa0e6e6f06980116e3256da8d4c48.tar.bz2
linux-210a03c9d51aa0e6e6f06980116e3256da8d4c48.zip
fs: claw back a few FMODE_* bits
There's a bunch of flags that are purely based on what the file operations support while also never being conditionally set or unset. IOW, they're not subject to change for individual files. Imho, such flags don't need to live in f_mode they might as well live in the fops structs itself. And the fops struct already has that lonely mmap_supported_flags member. We might as well turn that into a generic fop_flags member and move a few flags from FMODE_* space into FOP_* space. That gets us four FMODE_* bits back and the ability for new static flags that are about file ops to not have to live in FMODE_* space but in their own FOP_* space. It's not the most beautiful thing ever but it gets the job done. Yes, there'll be an additional pointer chase but hopefully that won't matter for these flags. I suspect there's a few more we can move into there and that we can also redirect a bunch of new flag suggestions that follow this pattern into the fop_flags field instead of f_mode. Link: https://lore.kernel.org/r/20240328-gewendet-spargel-aa60a030ef74@brauner Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mmap.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index 6dbda99a47da..3490af70f259 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1294,7 +1294,9 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
if (!file_mmap_ok(file, inode, pgoff, len))
return -EOVERFLOW;
- flags_mask = LEGACY_MAP_MASK | file->f_op->mmap_supported_flags;
+ flags_mask = LEGACY_MAP_MASK;
+ if (file->f_op->fop_flags & FOP_MMAP_SYNC)
+ flags_mask |= MAP_SYNC;
switch (flags & MAP_TYPE) {
case MAP_SHARED: