public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/4] vfs: trivial cleanups
@ 2008-07-30 13:08 Miklos Szeredi
  2008-07-30 13:08 ` [patch 1/4] splice: fix comment Miklos Szeredi
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Miklos Szeredi @ 2008-07-30 13:08 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-fsdevel, linux-kernel

Again, either 2.6.27 or .28, I don't really know which is more
appropriate at this time...

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 1/4] splice: fix comment
  2008-07-30 13:08 [patch 0/4] vfs: trivial cleanups Miklos Szeredi
@ 2008-07-30 13:08 ` Miklos Szeredi
  2008-07-30 13:08 ` [patch 2/4] vfs: filp is never NULL in do_generic_file_read() Miklos Szeredi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Miklos Szeredi @ 2008-07-30 13:08 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-fsdevel, linux-kernel

[-- Attachment #1: splice_fix_comment.patch --]
[-- Type: text/plain, Size: 687 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

Clearing SPLICE_F_NONBLOCK means: block.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/splice.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c	2008-07-30 13:52:35.000000000 +0200
+++ linux-2.6/fs/splice.c	2008-07-30 13:52:40.000000000 +0200
@@ -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;
 

--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 2/4] vfs: filp is never NULL in do_generic_file_read()
  2008-07-30 13:08 [patch 0/4] vfs: trivial cleanups Miklos Szeredi
  2008-07-30 13:08 ` [patch 1/4] splice: fix comment Miklos Szeredi
@ 2008-07-30 13:08 ` Miklos Szeredi
  2008-07-31  7:19   ` KOSAKI Motohiro
  2008-07-30 13:08 ` [patch 3/4] vfs: remove unused nameidata argument of may_create() Miklos Szeredi
  2008-07-30 13:08 ` [patch 4/4] vfs: create file_truncate() helper Miklos Szeredi
  3 siblings, 1 reply; 7+ messages in thread
From: Miklos Szeredi @ 2008-07-30 13:08 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-fsdevel, linux-kernel

[-- Attachment #1: do_generic_file_read_cleanup.patch --]
[-- Type: text/plain, Size: 679 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

...so remove bogus "if (filp)".

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 mm/filemap.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/mm/filemap.c	2008-07-30 13:52:39.000000000 +0200
@@ -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,

--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 3/4] vfs: remove unused nameidata argument of may_create()
  2008-07-30 13:08 [patch 0/4] vfs: trivial cleanups Miklos Szeredi
  2008-07-30 13:08 ` [patch 1/4] splice: fix comment Miklos Szeredi
  2008-07-30 13:08 ` [patch 2/4] vfs: filp is never NULL in do_generic_file_read() Miklos Szeredi
@ 2008-07-30 13:08 ` Miklos Szeredi
  2008-07-30 13:08 ` [patch 4/4] vfs: create file_truncate() helper Miklos Szeredi
  3 siblings, 0 replies; 7+ messages in thread
From: Miklos Szeredi @ 2008-07-30 13:08 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-fsdevel, linux-kernel

[-- Attachment #1: may_create_remove_nameidata.patch --]
[-- Type: text/plain, Size: 2347 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/namei.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Index: linux-2.6/fs/namei.c
===================================================================
--- linux-2.6.orig/fs/namei.c	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/fs/namei.c	2008-07-30 13:52:40.000000000 +0200
@@ -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, st
 int 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 __u
 
 int 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, st
 		return 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)

--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [patch 4/4] vfs: create file_truncate() helper
  2008-07-30 13:08 [patch 0/4] vfs: trivial cleanups Miklos Szeredi
                   ` (2 preceding siblings ...)
  2008-07-30 13:08 ` [patch 3/4] vfs: remove unused nameidata argument of may_create() Miklos Szeredi
@ 2008-07-30 13:08 ` Miklos Szeredi
  3 siblings, 0 replies; 7+ messages in thread
From: Miklos Szeredi @ 2008-07-30 13:08 UTC (permalink / raw)
  To: viro; +Cc: akpm, linux-fsdevel, linux-kernel

[-- Attachment #1: vfs-create-file_truncate-helper.patch --]
[-- Type: text/plain, Size: 4050 bytes --]

From: Miklos Szeredi <mszeredi@suse.cz>

...and add kerneldoc comment to it and to do_truncate().

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 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(-)

Index: linux-2.6/fs/exec.c
===================================================================
--- linux-2.6.orig/fs/exec.c	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/fs/exec.c	2008-07-30 13:52:39.000000000 +0200
@@ -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);
Index: linux-2.6/fs/open.c
===================================================================
--- linux-2.6.orig/fs/open.c	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/fs/open.c	2008-07-30 13:52:39.000000000 +0200
@@ -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, l
 	return 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 char 
 static 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 in
 	if (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:
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/include/linux/fs.h	2008-07-30 13:52:39.000000000 +0200
@@ -1614,6 +1614,8 @@ static inline int break_lease(struct ino
 
 extern 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);
Index: linux-2.6/mm/tiny-shmem.c
===================================================================
--- linux-2.6.orig/mm/tiny-shmem.c	2008-07-30 13:52:36.000000000 +0200
+++ linux-2.6/mm/tiny-shmem.c	2008-07-30 13:52:39.000000000 +0200
@@ -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;
 

--

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 2/4] vfs: filp is never NULL in do_generic_file_read()
  2008-07-30 13:08 ` [patch 2/4] vfs: filp is never NULL in do_generic_file_read() Miklos Szeredi
@ 2008-07-31  7:19   ` KOSAKI Motohiro
  2008-07-31  7:30     ` Li Zefan
  0 siblings, 1 reply; 7+ messages in thread
From: KOSAKI Motohiro @ 2008-07-31  7:19 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: kosaki.motohiro, viro, akpm, linux-fsdevel, linux-kernel

>  	*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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [patch 2/4] vfs: filp is never NULL in do_generic_file_read()
  2008-07-31  7:19   ` KOSAKI Motohiro
@ 2008-07-31  7:30     ` Li Zefan
  0 siblings, 0 replies; 7+ messages in thread
From: Li Zefan @ 2008-07-31  7:30 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: Miklos Szeredi, viro, akpm, linux-fsdevel, linux-kernel

KOSAKI Motohiro wrote:
>>  	*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?
> 

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-07-31  7:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-30 13:08 [patch 0/4] vfs: trivial cleanups Miklos Szeredi
2008-07-30 13:08 ` [patch 1/4] splice: fix comment Miklos Szeredi
2008-07-30 13:08 ` [patch 2/4] vfs: filp is never NULL in do_generic_file_read() Miklos Szeredi
2008-07-31  7:19   ` KOSAKI Motohiro
2008-07-31  7:30     ` Li Zefan
2008-07-30 13:08 ` [patch 3/4] vfs: remove unused nameidata argument of may_create() Miklos Szeredi
2008-07-30 13:08 ` [patch 4/4] vfs: create file_truncate() helper Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox