vfs: trivial cleanups
Subsystems (4)
cover vfs: trivial cleanups
Again, either 2.6.27 or .28, I don't really know which is more appropriate at this time...
Thanks,
Miklos
PATCH 1/4 splice: fix comment
From: Miklos Szeredi <[email protected]>
Clearing SPLICE_F_NONBLOCK means: block.
--- fs/splice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/splice.c +1 -1
@@ -987,7 +987,7 @@ ssize_t splice_direct_to_actor(struct fi flags = sd->flags;/* -* Don't block on output, we have to drain the direct pipe. +* Block on output, we have to drain the direct pipe. */ sd->flags &= ~SPLICE_F_NONBLOCK ;
--
PATCH 2/4 vfs: filp is never NULL in do_generic_file_read()
In reply to Miklos SzerediFrom: Miklos Szeredi <[email protected]>
...so remove bogus "if (filp)".
--- mm/filemap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/filemap.c +1 -2
@@ -1186,8 +1186,7 @@ out: ra->prev_pos |= prev_offset; *ppos = ((loff_t )index <<PAGE_CACHE_SHIFT ) + offset; -if (filp) -file_accessed (filp); +file_accessed (filp); } int file_read_actor(read_descriptor_t *desc, struct page *page,
--
Re: [patch 2/4] vfs: filp is never NULL in do_generic_file_read()
mm/filemap.c out: · line 1192
Quoted 7 lines
mm/filemap.c +1
-2*ppos = ((loff_t )index <<PAGE_CACHE_SHIFT ) + offset; -if (filp) -file_accessed (filp); +file_accessed (filp); } int file_read_actor(read_descriptor_t *desc, struct page *page,
if filp is never NULL, BUG_ON is better?
Re: [patch 2/4] vfs: filp is never NULL in do_generic_file_read()
Quoted 10 lines · KOSAKI Motohiro
mm/filemap.c out: · line 1192
Quoted 7 lines
mm/filemap.c +1
-2*ppos = ((loff_t )index <<PAGE_CACHE_SHIFT ) + offset; -if (filp) -file_accessed (filp); +file_accessed (filp); } int file_read_actor(read_descriptor_t *desc, struct page *page,if filp is never NULL,
BUG_ONis better?
static inline void file_accessed(struct file *file)
{
if (!(file->f_flags & O_NOATIME))
...
}So if filp is NULL, we'll get a noisy NULL dereference bug immediately, so BUG_ON() is not needed.
PATCH 3/4 vfs: remove unused nameidata argument of may_create()
In reply to Miklos SzerediFrom: Miklos Szeredi <[email protected]>
--- fs/namei.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/namei.c +7 -8
@@ -1431,8 +1431,7 @@ static int may_delete(struct inode *dir,* 3. We should have write and exec permissions on dir * 4. We can't do it if dir is immutable (done in permission()) */ -static inline int may_create (struct inode *dir,struct dentry *child, -struct nameidata *nd) +static inline int may_create (struct inode *dir,struct dentry *child) {if (child->d_inode)return -EEXIST ;
@@ -1504,7 +1503,7 @@ void unlock_rename(struct dentry *p1, stint vfs_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd) { -int error =may_create (dir, dentry, nd); +int error =may_create (dir, dentry);if (error)return error;
@@ -1948,7 +1947,7 @@ EXPORT_SYMBOL_GPL(lookup_create);int vfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) { -int error =may_create (dir, dentry,NULL ); +int error =may_create (dir, dentry);if (error)return error;
@@ -2049,7 +2048,7 @@ asmlinkage long sys_mknod(const char __uint vfs_mkdir (struct inode *dir,struct dentry *dentry,int mode) { -int error =may_create (dir, dentry,NULL ); +int error =may_create (dir, dentry);if (error)return error;
@@ -2316,7 +2315,7 @@ asmlinkage long sys_unlink(const char __int vfs_symlink (struct inode *dir,struct dentry *dentry,const char *oldname) { -int error =may_create (dir, dentry,NULL ); +int error =may_create (dir, dentry);if (error)return error;
@@ -2386,7 +2385,7 @@ int vfs_link(struct dentry *old_dentry,if (!inode)return -ENOENT ; - error =may_create (dir, new_dentry,NULL ); + error =may_create (dir, new_dentry);if (error)return error;
@@ -2595,7 +2594,7 @@ int vfs_rename(struct inode *old_dir, streturn error;if (!new_dentry->d_inode) - error =may_create (new_dir, new_dentry,NULL ); + error =may_create (new_dir, new_dentry);else error =may_delete (new_dir, new_dentry, is_dir);if (error)
--
PATCH 4/4 vfs: create file_truncate() helper
In reply to Miklos SzerediFrom: Miklos Szeredi <[email protected]>
...and add kerneldoc comment to it and to do_truncate().
--- fs/exec.c | 2 +- fs/open.c | 24 ++++++++++++++++++++---- include/linux/fs.h | 2 ++ mm/tiny-shmem.c | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-)
fs/exec.c +1 -1
@@ -1827,7 +1827,7 @@ int do_coredump(long signr, int exit_cod goto close_fail;if (!file->f_op->write) goto close_fail; -if (!ispipe &&do_truncate (file->f_path.dentry,0 ,0 , file) !=0 ) +if (!ispipe &&file_truncate (file,0 ,0 ) !=0 ) goto close_fail; retval = binfmt->core_dump (signr, regs, file, core_limit);
fs/open.c +20 -4
@@ -197,6 +197,13 @@ out:return error; } +/* +* do_truncate - truncate (or extend) an inode +* @dentry: the dentry to truncate +* @length: the new length +* @time_attrs: file times to be updated (e.g. ATTR_MTIME|ATTR_CTIME) +* @filp: an open file or NULL (see file_truncate() as well) +*/ int do_truncate (struct dentry *dentry,loff_t length,unsigned int time_attrs,struct file *filp) {
@@ -223,6 +230,17 @@ int do_truncate(struct dentry *dentry, lreturn err; } +/* +* file_truncate - truncate (or extend) an open file +* @filp: the open file +* @length: the new length +* @time_attrs: file times to be updated (e.g. ATTR_MTIME|ATTR_CTIME) +*/ +int file_truncate (struct file *filp,loff_t length,unsigned int time_attrs) +{ +return do_truncate (filp->f_path.dentry, length, time_attrs, filp); +} +static long do_sys_truncate (const char __user *pathname,loff_t length) {struct path path;
@@ -296,7 +314,6 @@ asmlinkage long sys_truncate(const charstatic long do_sys_ftruncate (unsigned int fd,loff_t length,int small) {struct inode * inode; -struct dentry *dentry;struct file * file;int error;
@@ -312,8 +329,7 @@ static long do_sys_ftruncate(unsigned inif (file->f_flags &O_LARGEFILE ) small =0 ; - dentry = file->f_path.dentry; - inode = dentry->d_inode; + inode = file->f_path.dentry->d_inode; error = -EINVAL ;if (!S_ISREG (inode->i_mode) || !(file->f_mode &FMODE_WRITE )) goto out_putf;
@@ -329,7 +345,7 @@ static long do_sys_ftruncate(unsigned in error =locks_verify_truncate (inode, file, length);if (!error) - error =do_truncate (dentry, length,ATTR_MTIME |ATTR_CTIME , file); + error =file_truncate (file, length,ATTR_MTIME |ATTR_CTIME ); out_putf:fput (file); out:
include/linux/fs.h +2 -0
@@ -1614,6 +1614,8 @@ static inline int break_lease(struct inoextern int do_truncate (struct dentry *,loff_t start,unsigned int time_attrs,struct file *filp); +extern int file_truncate (struct file *filp,loff_t start, +unsigned int time_attrs);extern long do_sys_open (int dfd,const char __user *filename,int flags,int mode);extern struct file *filp_open (const char *,int ,int );
mm/tiny-shmem.c +1 -1
@@ -80,7 +80,7 @@ struct file *shmem_file_setup(char *name inode->i_nlink =0 ;/* It is unlinked */ /* notify everyone as to the change of file size */ - error =do_truncate (dentry, size,0 , file); + error =file_truncate (file, size,0 );if (error <0 ) goto close_file;
--