From: Nick Piggin <npiggin@suse.de>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [patch 3/3] fs: fix cont vs deadlock patches
Date: Fri, 1 Dec 2006 03:09:12 +0100 [thread overview]
Message-ID: <20061201020910.GC455@wotan.suse.de> (raw)
In-Reply-To: <87r6vkzinv.fsf@duaron.myhome.or.jp>
On Fri, Dec 01, 2006 at 07:14:28AM +0900, OGAWA Hirofumi wrote:
>
> quick look. Doesn't this break reiserfs? IIRC, the reiserfs is using
> it for another reason. I was also working for this, but I lost the
> thread of this, sorry.
>
> I found some another users (affs, hfs, hfsplus). Those seem have same
> problem, but probably those also can use this...
>
> What do you think?
> --
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
>
>
> Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> ---
>
> fs/buffer.c | 59 +++++++++++++++++---------------------------
> fs/fat/file.c | 2 -
> include/linux/buffer_head.h | 1
> 3 files changed, 24 insertions(+), 38 deletions(-)
>
> diff -puN fs/buffer.c~generic_cont_expand-avoid-zero-size fs/buffer.c
> --- linux-2.6/fs/buffer.c~generic_cont_expand-avoid-zero-size 2006-11-13 01:42:01.000000000 +0900
> +++ linux-2.6-hirofumi/fs/buffer.c 2006-11-13 02:16:20.000000000 +0900
> @@ -2004,18 +2004,24 @@ int block_read_full_page(struct page *pa
> return 0;
> }
>
> -/* utility function for filesystems that need to do work on expanding
> +/*
> + * utility function for filesystems that need to do work on expanding
> * truncates. Uses prepare/commit_write to allow the filesystem to
> * deal with the hole.
> */
> -static int __generic_cont_expand(struct inode *inode, loff_t size,
> - pgoff_t index, unsigned int offset)
> +int generic_cont_expand(struct inode *inode, loff_t size)
> {
> struct address_space *mapping = inode->i_mapping;
> + loff_t pos = inode->i_size;
> struct page *page;
> unsigned long limit;
> + pgoff_t index;
> + unsigned int from, to;
> + void *kaddr;
> int err;
>
> + WARN_ON(pos >= size);
> +
> err = -EFBIG;
> limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
> if (limit != RLIM_INFINITY && size > (loff_t)limit) {
> @@ -2025,11 +2031,18 @@ static int __generic_cont_expand(struct
> if (size > inode->i_sb->s_maxbytes)
> goto out;
>
> + index = (size - 1) >> PAGE_CACHE_SHIFT;
> + to = size - ((loff_t)index << PAGE_CACHE_SHIFT);
> + if (index != (pos >> PAGE_CACHE_SHIFT))
> + from = 0;
> + else
> + from = pos & (PAGE_CACHE_SIZE - 1);
> +
> err = -ENOMEM;
> page = grab_cache_page(mapping, index);
> if (!page)
> goto out;
> - err = mapping->a_ops->prepare_write(NULL, page, offset, offset);
> + err = mapping->a_ops->prepare_write(NULL, page, from, to);
> if (err) {
> /*
> * ->prepare_write() may have instantiated a few blocks
> @@ -2041,7 +2054,12 @@ static int __generic_cont_expand(struct
> goto out;
> }
>
> - err = mapping->a_ops->commit_write(NULL, page, offset, offset);
> + kaddr = kmap_atomic(page, KM_USER0);
> + memset(kaddr + from, 0, to - from);
> + flush_dcache_page(page);
> + kunmap_atomic(kaddr, KM_USER0);
> +
> + err = mapping->a_ops->commit_write(NULL, page, from, to);
So basically this is changing from having prepare_write do all the
zeroing, to zeroing the last page in generic_cont_expand, so that
we don't have to pass a zero-length to prepare_write?
next prev parent reply other threads:[~2006-12-01 2:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-30 7:20 [patch 1/3] mm: pagecache write deadlocks zerolength fix Nick Piggin
2006-11-30 7:22 ` [patch 2/3] mm: pagecache write deadlocks stale holes fix Nick Piggin
2006-11-30 7:22 ` [patch 3/3] fs: fix cont vs deadlock patches Nick Piggin
2006-11-30 11:32 ` Nick Piggin
2006-11-30 22:14 ` OGAWA Hirofumi
2006-12-01 0:27 ` Nick Piggin
2006-12-01 1:11 ` OGAWA Hirofumi
2006-12-01 2:03 ` Nick Piggin
2006-12-01 2:09 ` Nick Piggin [this message]
2006-12-01 3:41 ` OGAWA Hirofumi
2006-12-01 3:47 ` Nick Piggin
2006-12-01 5:08 ` Nick Piggin
2006-12-01 7:21 ` Andrew Morton
2006-12-01 7:53 ` Nick Piggin
2006-12-01 14:50 ` OGAWA Hirofumi
2006-12-01 15:47 ` OGAWA Hirofumi
2006-12-02 0:36 ` Nick Piggin
2006-12-02 7:28 ` [new patch " Nick Piggin
2006-12-02 9:43 ` OGAWA Hirofumi
2006-11-30 7:26 ` [patch 0/3] more buffered write fixes Nick Piggin
2006-11-30 10:15 ` [patch 1/3] mm: pagecache write deadlocks zerolength fix Andreas Schwab
2006-11-30 10:19 ` Nick Piggin
2006-11-30 10:30 ` Andreas Schwab
2006-11-30 11:30 ` Nick Piggin
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=20061201020910.GC455@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@osdl.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).