LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Direct IO for fat
Date: Thu, 8 Feb 2007 18:35:16 +0100	[thread overview]
Message-ID: <20070208173515.GB3780@duck.suse.cz> (raw)
In-Reply-To: <87wt2sd2m8.fsf@duaron.myhome.or.jp>

On Fri 09-02-07 01:40:31, OGAWA Hirofumi wrote:
> Jan Kara <jack@suse.cz> writes:
> 
> >> FAT has to fill the hole completely, but DIO doesn't seems to do.
> >> 
> >> e.g.
> >>         fd = open("file", O_WRONLY | O_CREAT | O_TRUNC);
> >>         write(fd, buf, 512);
> >>         lseek(fd, 10000, SEEK_SET);
> >>         write(fd, buf, 512);
> >> 
> >> We need to allocate the blocks on 512 ~ 10000, and fill it with zero.
> >> However, I think DIO doesn't fill it. If I'm missing something, please
> >> let me know, I'll kill that check.
> >   I know. DIO doesn't do it. But the point is that if blockdev_direct_IO
> > finds out it should allocate new blocks, it exits without allocating them.
> > Then in __generic_file_aio_write_nolock() if we find out that we did not
> > write everything in generic_file_direct_write(), we just call
> > generic_file_buffered_write() to write the unwritten part.
> >   Hence, in case you describe above, the second write() finds out that
> > block is not allocated and eventually everything falls back to calling
> > generic_file_buffered_write() which calls prepare_write() and everything is
> > happy.
> 
> I see. But sorry, I can't see where is preventing it... Finally, I
> think we do the following on second write(2).
> 
> This is write, so create == 1, and ->lock_type == DIO_LOCKING,
> and dio->block_in_file > ->i_size, so DIO callback fat_get_block() with
> create == 1.
  I think you misread the code - see below.

> Then fat_get_block() seems to allocate block without fill hole,
> because it can't know caller is prepre_write or not...
> Well, anyway I'll test it on weekend. Thanks.
> 
> -> blockdev_direct_IO()
>   -> direct_io_worker()
>     -> do_direct_IO()
>       -> get_more_blocks()
> 
> 		create = dio->rw & WRITE;
  Here, create == 1.

> 		if (dio->lock_type == DIO_LOCKING) {
> 			if (dio->block_in_file < (i_size_read(dio->inode) >>
> 							dio->blkbits))
> 				create = 0;
  But here create was reset back to 0 - exactly because
dio->block_in_file > i_size...

									Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

  reply	other threads:[~2007-02-08 17:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08 11:28 Jan Kara
2007-02-08 15:44 ` OGAWA Hirofumi
2007-02-08 16:10   ` Jan Kara
2007-02-08 16:40     ` OGAWA Hirofumi
2007-02-08 17:35       ` Jan Kara [this message]
2007-02-08 18:41         ` Jan Kara
2007-02-08 19:53           ` OGAWA Hirofumi
2007-02-09  7:19             ` Jan Kara
2007-02-09 13:42               ` OGAWA Hirofumi

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=20070208173515.GB3780@duck.suse.cz \
    --to=jack@suse.cz \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: Direct IO for fat' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).