misc stuff that should've been pushed in the last window
Subsystems (8)
Al Viro
maintainerPATCH 1/1 misc stuff that should've been pushed in the last window
Several patches that missed for-next (some - for more than
one cycle). This stuff is ingit://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git #work.misc and if nobody objects, to -next it goes. Not going to be rebased...
Individual patches in followups. Please, review.
3 descriptor-related cleanups, then a couple of patches eliminating 'inode' argument of kernel_file_open() and do_dentry_open() resp., then Miklos' removal of call_{read,write}_iter() from back last August.
Al Viro
maintainerPATCH 1/6 close_on_exec(): pass files_struct instead of fdtable
both callers are happier that way...
--- fs/file.c | 5 +---- fs/proc/fd.c | 4 +--- include/linux/fdtable.h | 10 +++++----- 3 files changed, 7 insertions(+), 12 deletions(-)
fs/file.c +1 -4
@@ -1219,12 +1219,9 @@ void set_close_on_exec(unsigned int fd, int flag)bool get_close_on_exec (unsigned int fd) { -struct files_struct *files = current->files; -struct fdtable *fdt;bool res;rcu_read_lock (); - fdt =files_fdtable (files); - res =close_on_exec (fd, fdt); + res =close_on_exec (fd, current->files);rcu_read_unlock ();return res; }
fs/proc/fd.c +1 -3
@@ -39,10 +39,8 @@ static int seq_show(struct seq_file *m, void *v)spin_lock (&files->file_lock); file =files_lookup_fd_locked (files, fd);if (file) { -struct fdtable *fdt =files_fdtable (files); - f_flags = file->f_flags; -if (close_on_exec (fd, fdt)) +if (close_on_exec (fd, files)) f_flags |=O_CLOEXEC ;get_file (file);
include/linux/fdtable.h +5 -5
@@ -33,11 +33,6 @@ struct fdtable {struct rcu_head rcu; }; -static inline bool close_on_exec (unsigned int fd,const struct fdtable *fdt) -{ -return test_bit (fd, fdt->close_on_exec); -} -static inline bool fd_is_open (unsigned int fd,const struct fdtable *fdt) {return test_bit (fd, fdt->open_fds);
@@ -107,6 +102,11 @@ struct file *lookup_fdget_rcu(unsigned int fd);struct file *task_lookup_fdget_rcu (struct task_struct *task,unsigned int fd);struct file *task_lookup_next_fdget_rcu (struct task_struct *task,unsigned int *fd); +static inline bool close_on_exec (unsigned int fd,const struct files_struct *files) +{ +return test_bit (fd,files_fdtable (files)->close_on_exec); +} +struct task_struct ;void put_files_struct (struct files_struct *fs);
Signature · 1 line
2.39.2
Re: [PATCH 1/6] close_on_exec(): pass files_struct instead of fdtable
Quoted 4 lines · Al Viro
both callers are happier that way...
Signed-off-by Al Viro <[email protected]>---
Looks good to me,
Al Viro
maintainerPATCH 2/6 fd_is_open(): move to fs/file.c
In reply to Al Virono users outside that...
--- fs/file.c | 5 +++++ include/linux/fdtable.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/file.c +5 -0
@@ -271,6 +271,11 @@ static inline void __clear_open_fd(unsigned int fd, struct fdtable *fdt)__clear_bit (fd /BITS_PER_LONG , fdt->full_fds_bits); } +static inline bool fd_is_open (unsigned int fd,const struct fdtable *fdt) +{ +return test_bit (fd, fdt->open_fds); +} +static unsigned int count_open_files (struct fdtable *fdt) {unsigned int size = fdt->max_fds;
include/linux/fdtable.h +0 -5
@@ -33,11 +33,6 @@ struct fdtable {struct rcu_head rcu; }; -static inline bool fd_is_open (unsigned int fd,const struct fdtable *fdt) -{ -return test_bit (fd, fdt->open_fds); -} -/* * Open file table structure */
Signature · 1 line
2.39.2
Re: [PATCH 2/6] fd_is_open(): move to fs/file.c
Quoted 4 lines · Al Viro
no users outside that...
Signed-off-by Al Viro <[email protected]>---
Al Viro
maintainerPATCH 3/6 get_file_rcu(): no need to check for NULL separately
In reply to Al ViroIS_ERR(NULL) is false and IS_ERR() already comes with unlikely()...
--- fs/file.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/file.c +2 -7
@@ -920,13 +920,8 @@ struct file *get_file_rcu(struct file __rcu **f)struct file __rcu *file; file =__get_file_rcu (f); -if (unlikely (!file)) -return NULL ; - -if (unlikely (IS_ERR (file))) -continue ; - -return file; +if (!IS_ERR (file)) +return file; } }EXPORT_SYMBOL_GPL (get_file_rcu);
Signature · 1 line
2.39.2
Re: [PATCH 3/6] get_file_rcu(): no need to check for NULL separately
Quoted 4 lines · Al Viro
IS_ERR(NULL)is false andIS_ERR()already comes withunlikely()...Signed-off-by Al Viro <[email protected]>---
Looks good to me,
Al Viro
maintainerPATCH 4/6 kernel_file_open(): get rid of inode argument
In reply to Al Viroalways equal to ->dentry->d_inode of the path argument these days.
--- fs/cachefiles/namei.c | 3 +-- fs/open.c | 5 ++--- fs/overlayfs/util.c | 2 +- include/linux/fs.h | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-)
fs/cachefiles/namei.c +1 -2
@@ -563,8 +563,7 @@ static bool cachefiles_open_file(struct cachefiles_object *object,*/ path.mnt = cache->mnt; path.dentry = dentry; - file =kernel_file_open (&path,O_RDWR |O_LARGEFILE |O_DIRECT , -d_backing_inode (dentry), cache->cache_cred); + file =kernel_file_open (&path,O_RDWR |O_LARGEFILE |O_DIRECT , cache->cache_cred);if (IS_ERR (file)) { trace_cachefiles_vfs_error(object, d_backing_inode(dentry), PTR_ERR(file),
fs/open.c +2 -3
@@ -1155,7 +1155,6 @@ EXPORT_SYMBOL(dentry_create);* kernel_file_open - open a file for kernel internal use * @path: path of the file to open * @flags: open flags -* @inode: the inode * @cred: credentials for open * * Open a file for use by in-kernel consumers. The file is not accounted
@@ -1165,7 +1164,7 @@ EXPORT_SYMBOL(dentry_create);* Return: Opened file on success, an error pointer on failure. */ struct file *kernel_file_open (const struct path *path,int flags, -struct inode *inode,const struct cred *cred) +const struct cred *cred) {struct file *f;int error;
@@ -1175,7 +1174,7 @@ struct file *kernel_file_open(const struct path *path, int flags,return f; f->f_path = *path; - error =do_dentry_open (f, inode,NULL ); + error =do_dentry_open (f,d_inode (path->dentry),NULL );if (error) {fput (f); f =ERR_PTR (error);
fs/overlayfs/util.c +1 -1
@@ -1376,7 +1376,7 @@ int ovl_ensure_verity_loaded(struct path *datapath)* If this inode was not yet opened, the verity info hasn't been * loaded yet, so we need to do that here to force it into memory. */ - filp =kernel_file_open (datapath,O_RDONLY , inode,current_cred ()); + filp =kernel_file_open (datapath,O_RDONLY ,current_cred ());if (IS_ERR (filp))return PTR_ERR (filp);fput (filp);
include/linux/fs.h +1 -1
@@ -1906,7 +1906,7 @@ struct file *kernel_tmpfile_open(struct mnt_idmap *idmap, umode_t mode, int open_flag, const struct cred *cred);struct file *kernel_file_open (const struct path *path,int flags, -struct inode *inode,const struct cred *cred); +const struct cred *cred); int vfs_mkobj(struct dentry *, umode_t, int (*f)(struct dentry *, umode_t, void *),
Signature · 1 line
2.39.2
Re: [PATCH 4/6] kernel_file_open(): get rid of inode argument
Quoted 5 lines · Al Viro
always equal to ->dentry->d_inode of the path argument these days.
Signed-off-by Al Viro <[email protected]>---
Looks good to me,
Al Viro
maintainerPATCH 5/6 do_dentry_open(): kill inode argument
In reply to Al Viroshould've been done as soon as overlayfs stopped messing with fake paths...
--- fs/open.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/open.c +4 -4
@@ -902,10 +902,10 @@ static inline int file_get_write_access(struct file *f) }static int do_dentry_open (struct file *f, -struct inode *inode,int (*open)(struct inode *,struct file *)) {static const struct file_operations empty_fops = {}; +struct inode *inode = f->f_path.dentry->d_inode;int error;path_get (&f->f_path);
@@ -1047,7 +1047,7 @@ int finish_open(struct file *file, struct dentry *dentry,BUG_ON (file->f_mode &FMODE_OPENED );/* once it's opened, it's opened */ file->f_path.dentry = dentry; -return do_dentry_open (file,d_backing_inode (dentry), open); +return do_dentry_open (file, open); }EXPORT_SYMBOL (finish_open);
@@ -1086,7 +1086,7 @@ EXPORT_SYMBOL(file_path);int vfs_open (const struct path *path,struct file *file) { file->f_path = *path; -return do_dentry_open (file,d_backing_inode (path->dentry),NULL ); +return do_dentry_open (file,NULL ); } struct file *dentry_open(const struct path *path, int flags,
@@ -1174,7 +1174,7 @@ struct file *kernel_file_open(const struct path *path, int flags,return f; f->f_path = *path; - error =do_dentry_open (f,d_inode (path->dentry),NULL ); + error =do_dentry_open (f,NULL );if (error) {fput (f); f =ERR_PTR (error);
Signature · 1 line
2.39.2
Re: [PATCH 5/6] do_dentry_open(): kill inode argument
Quoted 5 lines · Al Viro
should've been done as soon as overlayfs stopped messing with fake paths...
Signed-off-by Al Viro <[email protected]>---
Looks good to me,
Al Viro
maintainerPATCH 6/6 remove call_{read,write}_iter() functions
In reply to Al ViroFrom d8c77afeb9912f5eca06f53cbed7fc618c71b46b Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <[email protected]>
Date: Mon, 28 Aug 2023 17:13:18 +0200
Subject: [PATCH 6/6] remove call_{read,write}_iter() functions
These have no clear purpose. This is effectively a revert of commit bb7462b6fd64 ("vfs: use helpers for calling f_op->{read,write}_iter()").
The patch was created with the help of a coccinelle script.
--- drivers/block/loop.c | 4 ++-- drivers/target/target_core_file.c | 4 ++-- fs/aio.c | 4 ++-- fs/read_write.c | 12 ++++++------ fs/splice.c | 4 ++-- include/linux/fs.h | 12 ------------ io_uring/rw.c | 4 ++-- 7 files changed, 16 insertions(+), 28 deletions(-)
drivers/block/loop.c +2 -2
@@ -445,9 +445,9 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, cmd->iocb.ki_ioprio =IOPRIO_PRIO_VALUE (IOPRIO_CLASS_NONE ,0 );if (rw ==ITER_SOURCE ) - ret =call_write_iter (file, &cmd->iocb, &iter); + ret = file->f_op->write_iter (&cmd->iocb, &iter);else - ret =call_read_iter (file, &cmd->iocb, &iter); + ret = file->f_op->read_iter (&cmd->iocb, &iter);lo_rw_aio_do_completion (cmd);
drivers/target/target_core_file.c +2 -2
@@ -299,9 +299,9 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, aio_cmd->iocb.ki_flags |=IOCB_DSYNC ;if (is_write) - ret =call_write_iter (file, &aio_cmd->iocb, &iter); + ret = file->f_op->write_iter (&aio_cmd->iocb, &iter);else - ret =call_read_iter (file, &aio_cmd->iocb, &iter); + ret = file->f_op->read_iter (&aio_cmd->iocb, &iter);if (ret != -EIOCBQUEUED )cmd_rw_aio_complete (&aio_cmd->iocb, ret);
fs/aio.c +2 -2
@@ -1605,7 +1605,7 @@ static int aio_read(struct kiocb *req, const struct iocb *iocb,return ret; ret =rw_verify_area (READ , file, &req->ki_pos,iov_iter_count (&iter));if (!ret) -aio_rw_done (req,call_read_iter (file, req, &iter)); +aio_rw_done (req, file->f_op->read_iter (req, &iter));kfree (iovec);return ret; }
@@ -1636,7 +1636,7 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,if (S_ISREG (file_inode (file)->i_mode))kiocb_start_write (req); req->ki_flags |=IOCB_WRITE ; -aio_rw_done (req,call_write_iter (file, req, &iter)); +aio_rw_done (req, file->f_op->write_iter (req, &iter)); }kfree (iovec);return ret;
fs/read_write.c +6 -6
@@ -392,7 +392,7 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo kiocb.ki_pos = (ppos ? *ppos :0 );iov_iter_ubuf (&iter,ITER_DEST , buf, len); - ret =call_read_iter (filp, &kiocb, &iter); + ret = filp->f_op->read_iter (&kiocb, &iter);BUG_ON (ret == -EIOCBQUEUED );if (ppos) *ppos = kiocb.ki_pos;
@@ -494,7 +494,7 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t kiocb.ki_pos = (ppos ? *ppos :0 );iov_iter_ubuf (&iter,ITER_SOURCE , (void __user *)buf, len); - ret =call_write_iter (filp, &kiocb, &iter); + ret = filp->f_op->write_iter (&kiocb, &iter);BUG_ON (ret == -EIOCBQUEUED );if (ret >0 && ppos) *ppos = kiocb.ki_pos;
@@ -736,9 +736,9 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, kiocb.ki_pos = (ppos ? *ppos :0 );if (type ==READ ) - ret =call_read_iter (filp, &kiocb, iter); + ret = filp->f_op->read_iter (&kiocb, iter);else - ret =call_write_iter (filp, &kiocb, iter); + ret = filp->f_op->write_iter (&kiocb, iter);BUG_ON (ret == -EIOCBQUEUED );if (ppos) *ppos = kiocb.ki_pos;
@@ -799,7 +799,7 @@ ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb,if (ret <0 )return ret; - ret =call_read_iter (file, iocb, iter); + ret = file->f_op->read_iter (iocb, iter); out:if (ret >=0 )fsnotify_access (file);
@@ -860,7 +860,7 @@ ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb,return ret;kiocb_start_write (iocb); - ret =call_write_iter (file, iocb, iter); + ret = file->f_op->write_iter (iocb, iter);if (ret != -EIOCBQUEUED )kiocb_end_write (iocb);if (ret >0 )
fs/splice.c +2 -2
@@ -362,7 +362,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos,iov_iter_bvec (&to,ITER_DEST , bv, npages, len);init_sync_kiocb (&kiocb, in); kiocb.ki_pos = *ppos; - ret =call_read_iter (in, &kiocb, &to); + ret = in->f_op->read_iter (&kiocb, &to);if (ret >0 ) { keep =DIV_ROUND_UP (ret,PAGE_SIZE );
@@ -740,7 +740,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,iov_iter_bvec (&from,ITER_SOURCE , array, n, sd.total_len - left);init_sync_kiocb (&kiocb, out); kiocb.ki_pos = sd.pos; - ret =call_write_iter (out, &kiocb, &from); + ret = out->f_op->write_iter (&kiocb, &from); sd.pos = kiocb.ki_pos;if (ret <=0 )break ;
include/linux/fs.h +0 -12
@@ -2096,18 +2096,6 @@ struct inode_operations {struct offset_ctx *(*get_offset_ctx)(struct inode *inode); }____cacheline_aligned ; -static inline ssize_t call_read_iter (struct file *file,struct kiocb *kio, -struct iov_iter *iter) -{ -return file->f_op->read_iter (kio, iter); -} - -static inline ssize_t call_write_iter (struct file *file,struct kiocb *kio, -struct iov_iter *iter) -{ -return file->f_op->write_iter (kio, iter); -} -static inline int call_mmap (struct file *file,struct vm_area_struct *vma) {return file->f_op->mmap (file, vma);
io_uring/rw.c +2 -2
@@ -701,7 +701,7 @@ static inline int io_iter_do_read(struct io_rw *rw, struct iov_iter *iter)struct file *file = rw->kiocb.ki_filp;if (likely (file->f_op->read_iter)) -return call_read_iter (file, &rw->kiocb, iter); +return file->f_op->read_iter (&rw->kiocb, iter);else if (file->f_op->read)return loop_rw_iter (READ , rw, iter);else
@@ -1047,7 +1047,7 @@ int io_write(struct io_kiocb *req, unsigned int issue_flags) kiocb->ki_flags |=IOCB_WRITE ;if (likely (req->file->f_op->write_iter)) - ret2 =call_write_iter (req->file, kiocb, &s->iter); + ret2 = req->file->f_op->write_iter (kiocb, &s->iter);else if (req->file->f_op->write) ret2 =loop_rw_iter (WRITE , rw, &s->iter);else
Signature · 1 line
2.39.2
Re: [PATCH 6/6] remove call_{read,write}_iter() functions
Quoted 8 lines · Al Viro
From
d8c77afeb9912f5eca06f53cbed7fc618c71b46bMon Sep 17 00:00:00 2001
From: Miklos Szeredi <[email protected]>
Date: Mon, 28 Aug 2023 17:13:18 +0200
Subject: [PATCH 6/6] remove call_{read,write}_iter() functionsThese have no clear purpose. This is effectively a revert of commit
bb7462b6fd64("vfs: use helpers for calling f_op->{read,write}_iter()").
Quoted 6 lines
The patch was created with the help of a coccinelle script.
Fixes bb7462b6fd64 ("vfs: use helpers for calling f_op->{read,write}_iter()")Signed-off-by Miklos Szeredi <[email protected]>Signed-off-by Al Viro <[email protected]>---
Looks good to me,