lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 8 Feb 2007 17:10:01 +0100
From:	Jan Kara <jack@...e.cz>
To:	OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Cc:	linux-kernel@...r.kernel.org
Subject: Re: Direct IO for fat

On Fri 09-02-07 00:44:06, OGAWA Hirofumi wrote:
> Jan Kara <jack@...e.cz> writes:
  Hello,

> >   I've noticed that extending a file using direct IO fails for FAT with
> > EINVAL. It's basically because of the following code in fat_direct_IO():
> >
> > if (rw == WRITE) {
> >         /*
> >          * FIXME: blockdev_direct_IO() doesn't use
> >          * ->prepare_write(),
> >          * so we need to update the ->mmu_private to block
> >          * boundary.
> >          *
> >          * But we must fill the remaining area or hole by nul for
> >          * updating ->mmu_private.
> >          */
> >         loff_t size = offset + iov_length(iov, nr_segs);
> >         if (MSDOS_I(inode)->mmu_private < size)
> >                 return -EINVAL;
> > }
> >
> >   But isn't this check bogus? blockdev_direct_IO writes only to space that
> > is already allocated and stops as soon as it needs to extend the file
> > (further extension is then handled by buffered writes). So it should
> > already do what it needed for FAT. Thanks for an answer in advance.
> 
> 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.

								Honza
> 
> Thanks.
> -- 
> OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
-- 
Jan Kara <jack@...e.cz>
SuSE CR Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ