Messages in this thread Patch in this message | | | Date | Mon, 7 Nov 2005 20:19:34 -0800 | From | Andrew Morton <> | Subject | Re: [PATCH 7/6] fat: Support a truncate() for expanding size |
| |
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> wrote: > > Andrew Morton <akpm@osdl.org> writes: > > > OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> wrote: > >> > >> +static int fat_cont_expand(struct inode *inode, loff_t size) > > > > Is it not possible to extend generic_cont_expand() so that fatfs can use it? > > The generic_cont_expand() is too generic.
But can it be fixed??
> If "size" is block boundary, generic_cont_expand() expands the > ->i_size to "size + 1", after it, the caller of it will truncate to > "size" by vmtruncate().
Something like this?
--- devel/fs/buffer.c~a 2005-11-07 20:17:49.000000000 -0800 +++ devel-akpm/fs/buffer.c 2005-11-07 20:18:59.000000000 -0800 @@ -2160,7 +2160,7 @@ int block_read_full_page(struct page *pa * truncates. Uses prepare/commit_write to allow the filesystem to * deal with the hole. */ -int generic_cont_expand(struct inode *inode, loff_t size) +static int __generic_cont_expand(struct inode *inode, loff_t size, int dont_do_that) { struct address_space *mapping = inode->i_mapping; struct page *page; @@ -2182,9 +2182,8 @@ int generic_cont_expand(struct inode *in ** skip the prepare. make sure we never send an offset for the start ** of a block */ - if ((offset & (inode->i_sb->s_blocksize - 1)) == 0) { + if (!dont_do_that && (offset & (inode->i_sb->s_blocksize - 1)) == 0) offset++; - } index = size >> PAGE_CACHE_SHIFT; err = -ENOMEM; page = grab_cache_page(mapping, index); @@ -2202,6 +2201,16 @@ out: return err; } +int generic_cont_expand(struct inode *inode, loff_t size) +{ + return __generic_cont_expand(inode, size, 0); +} + +int generic_cont_expand_dont_do_that(struct inode *inode, loff_t size) +{ + return __generic_cont_expand(inode, size, 1); +} + /* * For moronic filesystems that do not allow holes in file. * We may have to extend the file. _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |