mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Remove f_error field from struct file
@ 2005-06-06 20:55 Christoph Lameter
  2005-06-06 21:11 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Lameter @ 2005-06-06 20:55 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

To my surpise I found that the f_error field defined for struct file is
never set to any error value. Its just checked in a couple of places. But
why check if it never becomes != 0?

The following patch removes the f_error field and all checks of f_error.

Signed-off-by: Christoph Lameter <christoph@lameter.com>

Index: linux-2.6.12-rc5/fs/nfs/direct.c
===================================================================
--- linux-2.6.12-rc5.orig/fs/nfs/direct.c	2005-06-06 20:43:34.000000000 +0000
+++ linux-2.6.12-rc5/fs/nfs/direct.c	2005-06-06 20:43:51.000000000 +0000
@@ -751,11 +751,6 @@
 	retval = -EFAULT;
 	if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len))
 		goto out;
-        if (file->f_error) {
-                retval = file->f_error;
-                file->f_error = 0;
-                goto out;
-        }
 	retval = -EFBIG;
 	if (limit != RLIM_INFINITY) {
 		if (pos >= limit) {
Index: linux-2.6.12-rc5/include/linux/fs.h
===================================================================
--- linux-2.6.12-rc5.orig/include/linux/fs.h	2005-06-06 20:43:34.000000000 +0000
+++ linux-2.6.12-rc5/include/linux/fs.h	2005-06-06 20:43:51.000000000 +0000
@@ -581,7 +581,6 @@
 	atomic_t		f_count;
 	unsigned int 		f_flags;
 	mode_t			f_mode;
-	int			f_error;
 	loff_t			f_pos;
 	struct fown_struct	f_owner;
 	unsigned int		f_uid, f_gid;
Index: linux-2.6.12-rc5/fs/open.c
===================================================================
--- linux-2.6.12-rc5.orig/fs/open.c	2005-06-06 20:43:34.000000000 +0000
+++ linux-2.6.12-rc5/fs/open.c	2005-06-06 20:43:51.000000000 +0000
@@ -980,23 +980,15 @@
  */
 int filp_close(struct file *filp, fl_owner_t id)
 {
-	int retval;
-
-	/* Report and clear outstanding errors */
-	retval = filp->f_error;
-	if (retval)
-		filp->f_error = 0;
+	int retval = 0;
 
 	if (!file_count(filp)) {
 		printk(KERN_ERR "VFS: Close: file count is 0\n");
-		return retval;
+		return 0;
 	}
 
-	if (filp->f_op && filp->f_op->flush) {
-		int err = filp->f_op->flush(filp);
-		if (!retval)
-			retval = err;
-	}
+	if (filp->f_op && filp->f_op->flush)
+		retval = filp->f_op->flush(filp);
 
 	dnotify_flush(filp, id);
 	locks_remove_posix(filp, id);
Index: linux-2.6.12-rc5/mm/filemap.c
===================================================================
--- linux-2.6.12-rc5.orig/mm/filemap.c	2005-06-06 20:43:34.000000000 +0000
+++ linux-2.6.12-rc5/mm/filemap.c	2005-06-06 20:43:51.000000000 +0000
@@ -1827,12 +1827,6 @@
         if (unlikely(*pos < 0))
                 return -EINVAL;
 
-        if (unlikely(file->f_error)) {
-                int err = file->f_error;
-                file->f_error = 0;
-                return err;
-        }
-
 	if (!isblk) {
 		/* FIXME: this is for backwards compatibility with 2.4 */
 		if (file->f_flags & O_APPEND)


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

* Re: [PATCH] Remove f_error field from struct file
  2005-06-06 20:55 [PATCH] Remove f_error field from struct file Christoph Lameter
@ 2005-06-06 21:11 ` Trond Myklebust
  0 siblings, 0 replies; 2+ messages in thread
From: Trond Myklebust @ 2005-06-06 21:11 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: linux-kernel, akpm

må den 06.06.2005 Klokka 13:55 (-0700) skreiv Christoph Lameter:
> To my surpise I found that the f_error field defined for struct file is
> never set to any error value. Its just checked in a couple of places. But
> why check if it never becomes != 0?
> 
> The following patch removes the f_error field and all checks of f_error.
> 
> Signed-off-by: Christoph Lameter <christoph@lameter.com>

ACK...

f_error was introduced for NFS, and made sense when we were guaranteed
always to have a file pointer around when write errors occurred. Since
then, we have (for various reasons) had to introduce the
nfs_open_context in order to track the file read/write state, and it
made sense to move our f_error tracking there too.

Cheers,
  Trond

> Index: linux-2.6.12-rc5/fs/nfs/direct.c
> ===================================================================
> --- linux-2.6.12-rc5.orig/fs/nfs/direct.c	2005-06-06 20:43:34.000000000 +0000
> +++ linux-2.6.12-rc5/fs/nfs/direct.c	2005-06-06 20:43:51.000000000 +0000
> @@ -751,11 +751,6 @@
>  	retval = -EFAULT;
>  	if (!access_ok(VERIFY_READ, iov.iov_base, iov.iov_len))
>  		goto out;
> -        if (file->f_error) {
> -                retval = file->f_error;
> -                file->f_error = 0;
> -                goto out;
> -        }
>  	retval = -EFBIG;
>  	if (limit != RLIM_INFINITY) {
>  		if (pos >= limit) {
> Index: linux-2.6.12-rc5/include/linux/fs.h
> ===================================================================
> --- linux-2.6.12-rc5.orig/include/linux/fs.h	2005-06-06 20:43:34.000000000 +0000
> +++ linux-2.6.12-rc5/include/linux/fs.h	2005-06-06 20:43:51.000000000 +0000
> @@ -581,7 +581,6 @@
>  	atomic_t		f_count;
>  	unsigned int 		f_flags;
>  	mode_t			f_mode;
> -	int			f_error;
>  	loff_t			f_pos;
>  	struct fown_struct	f_owner;
>  	unsigned int		f_uid, f_gid;
> Index: linux-2.6.12-rc5/fs/open.c
> ===================================================================
> --- linux-2.6.12-rc5.orig/fs/open.c	2005-06-06 20:43:34.000000000 +0000
> +++ linux-2.6.12-rc5/fs/open.c	2005-06-06 20:43:51.000000000 +0000
> @@ -980,23 +980,15 @@
>   */
>  int filp_close(struct file *filp, fl_owner_t id)
>  {
> -	int retval;
> -
> -	/* Report and clear outstanding errors */
> -	retval = filp->f_error;
> -	if (retval)
> -		filp->f_error = 0;
> +	int retval = 0;
>  
>  	if (!file_count(filp)) {
>  		printk(KERN_ERR "VFS: Close: file count is 0\n");
> -		return retval;
> +		return 0;
>  	}
>  
> -	if (filp->f_op && filp->f_op->flush) {
> -		int err = filp->f_op->flush(filp);
> -		if (!retval)
> -			retval = err;
> -	}
> +	if (filp->f_op && filp->f_op->flush)
> +		retval = filp->f_op->flush(filp);
>  
>  	dnotify_flush(filp, id);
>  	locks_remove_posix(filp, id);
> Index: linux-2.6.12-rc5/mm/filemap.c
> ===================================================================
> --- linux-2.6.12-rc5.orig/mm/filemap.c	2005-06-06 20:43:34.000000000 +0000
> +++ linux-2.6.12-rc5/mm/filemap.c	2005-06-06 20:43:51.000000000 +0000
> @@ -1827,12 +1827,6 @@
>          if (unlikely(*pos < 0))
>                  return -EINVAL;
>  
> -        if (unlikely(file->f_error)) {
> -                int err = file->f_error;
> -                file->f_error = 0;
> -                return err;
> -        }
> -
>  	if (!isblk) {
>  		/* FIXME: this is for backwards compatibility with 2.4 */
>  		if (file->f_flags & O_APPEND)
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


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

end of thread, other threads:[~2005-06-06 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-06 20:55 [PATCH] Remove f_error field from struct file Christoph Lameter
2005-06-06 21:11 ` Trond Myklebust

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

all inboxes | Powered by JetHome®