From: "qufuping" <qufuping@ercist.iscas.ac.cn>
To: fs <fs@ercist.iscas.ac.cn>, vs@namesys.com
Cc: reiserfs-list <reiserfs-list@namesys.com>,
Hans Reiser <reiser@namesys.com>,
iscas-linaccident <iscas-linaccident@intellilink.co.jp>
Subject: Re: [iscas-linaccident 55] Re: [PATCH] ReiserFS file.c several bug-fix
Date: Thu, 23 Jun 2005 19:54:03 +0800 [thread overview]
Message-ID: <004a01c577ea$474e65e0$de024dd2@coolq> (raw)
In-Reply-To: 1119518209.3816.58.camel@tribesman.namesys.com
----- Original Message -----
From: "Vladimir Saveliev" <vs@namesys.com>
To: "fs" <fs@ercist.iscas.ac.cn>
Cc: "reiserfs-list" <reiserfs-list@namesys.com>; "Hans Reiser" <reiser@namesys.com>; "iscas-linaccident" <iscas-linaccident@intellilink.co.jp>
Sent: Thursday, June 23, 2005 5:16 PM
Subject: [iscas-linaccident 55] Re: [PATCH] ReiserFS file.c several bug-fix
> Hello
>
> On Thu, 2005-06-23 at 23:27, fs wrote:
> > Related FS:
> > ReiserFS
> >
> > Related Files:
> > fs/reiserfs/file.c
> >
> > Bug description:
> > Make a ReiserFS partition in USB storage HDD, create a test file
> > with enough size.
> > Write a program, do: open(O_SYNC/O_DSYNC) - read - close. After each
> > operation, pause for a while, such as 3s. Between open and read, unlug
> > the USB wire. open returns zero-filled buffer, no error returns.
> >
> Open returns not buffer buf opened file descriptor or -1. Please
> describe your test more carefully.
>
Sorry to use the wrong template. :(
Bug description:
Make a ReiserFS partition in USB storage HDD, create a test file,
for example, 64K.
Write a program, do: open(O_SYNC or O_DSYNC) - write(no need to use lseek)
- close. After each operation, pause for a while, such as 3s. Between open
and write, unplug the USB wire. write returns no error.
> > Bug analysis:
> > reiserfs_file_write will claim some blocks, commit the I/O request,
>
> So, you said: open(O_SYNC/O_DSYNC) - read - close. Where does write come
> from?
>
> > if O_SYNC and O_DSYNC is used, it will
> > if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
> > res = generic_osync_inode(inode, file->f_mapping,
> > OSYNC_METADATA|OSYNC_DATA);
> > The question is, if I/O error occurs,
> > res = reiserfs_allocate_blocks_for_region fails with -EIO, so
> > it will exit the loop, no I/O request, no page marked as dirty.
> > If run generic_osync_inode, it returns 0(no dirty page), res will be
> > overwritten from -EIO to 0, thus no error report.
> >
> > Also, reiserfs_file_write contains a serious bug, see here
> > blocks_to_allocate = reiserfs_prepare_file_region_for_write
> > (inode, pos, num_pages, write_bytes, prepared_pages);
> > Here blocks_to_allocate is defined as size_t, i.e. unsigned int, but
> > reiserfs_prepare_file_region_for_write is declared as int, so sometimes
> > it will return -EIO, -ENOENT, etc, take a look at this line
> > if ( blocks_to_allocate < 0 ) { <- This will never happen
> > res = blocks_to_allocate;
> > reiserfs_release_claimed_blocks(inode->i_sb,
> > num_pages << (PAGE_CACHE_SHIFT - inode->i_blkbits));
> > break;
> > }
> > Way around:
> > 1) if already_written is zero, don't do generic_osync_inode
> > 2) tell the result of reiserfs_prepare_file_region_for_write with IS_ERR
> > macro or cast it to size_t
> >
> > Signed-off-by: Qu Fuping<fs@ercist.iscas.ac.cn>
> >
> > Patch:
> > diff -uNp linux-2.6.12/fs/reiserfs/file.c
> > linux-2.6.12-new/fs/reiserfs/file.c
> >
> >
>
>
prev parent reply other threads:[~2005-06-23 11:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-23 19:27 [PATCH] ReiserFS file.c several bug-fix fs
2005-06-23 9:16 ` Vladimir Saveliev
2005-06-23 11:54 ` qufuping [this message]
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='004a01c577ea$474e65e0$de024dd2@coolq' \
--to=qufuping@ercist.iscas.ac.cn \
--cc=fs@ercist.iscas.ac.cn \
--cc=iscas-linaccident@intellilink.co.jp \
--cc=reiser@namesys.com \
--cc=reiserfs-list@namesys.com \
--cc=vs@namesys.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.