public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: fs <fs@ercist.iscas.ac.cn>
Cc: viro@parcelfarce.linux.theplanet.co.uk,
	linux-fsdevel@vger.kernel.org,
	iscas-linaccident@intellilink.co.jp,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] VFS mmap wrong behavior when I/O failure occurs
Date: Wed, 11 May 2005 01:19:16 -0700	[thread overview]
Message-ID: <20050511011916.611486e7.akpm@osdl.org> (raw)
In-Reply-To: <1115837231.3599.55.camel@CoolQ>

fs <fs@ercist.iscas.ac.cn> wrote:
>
> --- linux-2.6.11.8-orig/fs/buffer.c     2005-05-11 14:41:03.000000000
>  -0400

Your email client wordwrapped the patch.  Please fix it.

>  +++ linux-2.6.11.8/fs/buffer.c  2005-05-11 14:38:55.000000000 -0400
>  @@ -2105,7 +2105,6 @@ int block_read_full_page(struct page *pa
>                                  memset(kaddr + i * blocksize, 0,
>  blocksize);
>                                  flush_dcache_page(page);
>                                  kunmap_atomic(kaddr, KM_USER0);
>  -                               set_buffer_uptodate(bh);
>                                  continue;
>                          }
>                          /*

This patch will break the kernel's regular handling of file holes -
!buffer_mapped() means that there was no disk mapping for this buffer: it
sits over a hole in the file.  Zeroing out the buffer and marking it
uptodate is correct behaviour.

You probably want something like this:

--- 25/fs/buffer.c~a	2005-05-11 01:15:13.000000000 -0700
+++ 25-akpm/fs/buffer.c	2005-05-11 01:16:39.000000000 -0700
@@ -2094,9 +2094,12 @@ int block_read_full_page(struct page *pa
 			continue;
 
 		if (!buffer_mapped(bh)) {
+			int err = 0;
+
 			fully_mapped = 0;
 			if (iblock < lblock) {
-				if (get_block(inode, iblock, bh, 0))
+				err = get_block(inode, iblock, bh, 0);
+				if (err)
 					SetPageError(page);
 			}
 			if (!buffer_mapped(bh)) {
@@ -2104,7 +2107,8 @@ int block_read_full_page(struct page *pa
 				memset(kaddr + i * blocksize, 0, blocksize);
 				flush_dcache_page(page);
 				kunmap_atomic(kaddr, KM_USER0);
-				set_buffer_uptodate(bh);
+				if (!err)
+					set_buffer_uptodate(bh);
 				continue;
 			}
 			/*
_



  reply	other threads:[~2005-05-11  8:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-11 18:47 [PATCH] VFS mmap wrong behavior when I/O failure occurs fs
2005-05-11  8:19 ` Andrew Morton [this message]
2005-05-11 20:31   ` fs

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=20050511011916.611486e7.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=fs@ercist.iscas.ac.cn \
    --cc=iscas-linaccident@intellilink.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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