public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stephen C. Tweedie" <sct@redhat.com>
To: Andi Kleen <ak@suse.de>
Cc: Asang K Dani <asang@yahoo.com>,
	linux-kernel@vger.kernel.org, sct@redhat.com,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: generic_file_write code segment in 2.2.18
Date: Thu, 4 Jan 2001 22:42:34 +0000	[thread overview]
Message-ID: <20010104224234.B1290@redhat.com> (raw)
In-Reply-To: <20010104052948.12042.qmail@web2303.mail.yahoo.com> <20010104085137.A18532@gruyere.muc.suse.de>
In-Reply-To: <20010104085137.A18532@gruyere.muc.suse.de>; from ak@suse.de on Thu, Jan 04, 2001 at 08:51:37AM +0100

Hi,

On Thu, Jan 04, 2001 at 08:51:37AM +0100, Andi Kleen wrote:
> On Wed, Jan 03, 2001 at 09:29:48PM -0800, Asang K Dani wrote:
> 
> The code is buggy as far as I can see. copy_from_user doesn't return the 
> number of bytes copied, but the number of bytes not copied when an error
> occurs (or 0 on success).  

But in this case, _any_ non-zero number of bytes copied is a success,
because it indicates that we have dirtied a portion of the page cache.

> Correct would be:
> 
> 	
> --- linux-work/mm/filemap.c-o	Wed Jan  3 17:37:27 2001
>  		dest = (char *) page_address(page) + offset;
>  		if (dest != buf) { /* See comment in update_vm_cache_cond. */
> -			bytes -= copy_from_user(dest, buf, bytes);
> +			if (copy_from_user(dest, buf, bytes))
> +				status = -EFAULT; 
>  			flush_dcache_page(page_address(page));
>  		}
> -		status = -EFAULT;
> -		if (bytes)
> +		if (!status)
>  			status = inode->i_op->updatepage(file, page, offset, bytes, sync);

No, because then you'd be skipping the updatepage() call if we took a
fault mid-copy after copying some data.  That would imply you had
dirtied the page cache without an updatepage().

The current behaviour should just result in a short IO, which should
be fine.

--Stephen
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2001-01-04 22:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-04  5:29 generic_file_write code segment in 2.2.18 Asang K Dani
2001-01-04  7:51 ` Andi Kleen
2001-01-04 22:42   ` Stephen C. Tweedie [this message]
2001-01-04 22:49     ` Andi Kleen
  -- strict thread matches above, loose matches on Subject: below --
2001-01-04 22:58 Asang K Dani
2001-01-04 23:02 ` Andi Kleen
2001-01-04 23:09 Asang K Dani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010104224234.B1290@redhat.com \
    --to=sct@redhat.com \
    --cc=ak@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=asang@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox