From: Dmitriy Monakhov <dmonakhov@sw.ru>
To: Nick Piggin <npiggin@suse.de>
Cc: Linux Filesystems <linux-fsdevel@vger.kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Mark Fasheh <mark.fasheh@oracle.com>
Subject: Re: [patch 2/5] fs: introduce new aops and infrastructure
Date: Thu, 15 Mar 2007 12:44:37 +0300 [thread overview]
Message-ID: <87bqiuzvqy.fsf@sw.ru> (raw)
In-Reply-To: <20070314112540.13798.97719.sendpatchset@linux.site> (Nick Piggin's message of "Wed, 14 Mar 2007 14:38:22 +0100 (CET)")
Nick Piggin <npiggin@suse.de> writes:
> Index: linux-2.6/fs/splice.c
> ===================================================================
> --- linux-2.6.orig/fs/splice.c
> +++ linux-2.6/fs/splice.c
> @@ -559,7 +559,7 @@ static int pipe_to_file(struct pipe_inod
> struct address_space *mapping = file->f_mapping;
> unsigned int offset, this_len;
> struct page *page;
> - pgoff_t index;
> + void *fsdata;
> int ret;
>
> /*
> @@ -569,13 +569,13 @@ static int pipe_to_file(struct pipe_inod
> if (unlikely(ret))
> return ret;
>
> - index = sd->pos >> PAGE_CACHE_SHIFT;
> offset = sd->pos & ~PAGE_CACHE_MASK;
>
> this_len = sd->len;
> if (this_len + offset > PAGE_CACHE_SIZE)
> this_len = PAGE_CACHE_SIZE - offset;
>
> +#if 0
> /*
> * Reuse buf page, if SPLICE_F_MOVE is set and we are doing a full
> * page.
> @@ -587,86 +587,11 @@ static int pipe_to_file(struct pipe_inod
> * locked on successful return.
> */
> if (buf->ops->steal(pipe, buf))
> - goto find_page;
> +#endif
One more note. It's looks like you just disabled all fancy zero copy logic.
Off corse this is just rfc patchset.
But i think where is fundamental problem with it:
Previous logic was following:
1)splice code responsible for: stealing(if possible) and loking the page
2)prepare_write() code responsible for: do fs speciffic stuff
But with new write_begin() logic all steps (grubbing, locking, preparing)
happened internaly inside write_begin() witch doesn't even know about what
kind of data will be copied between write_begin/write_end.
So fancy zero copy logic is impossible :(
I think this can be solved somehow, but i dont know yet, how can this be done
without implementing it inside begin_write().
>
> - page = buf->page;
> - if (add_to_page_cache(page, mapping, index, GFP_KERNEL)) {
> - unlock_page(page);
> - goto find_page;
> - }
> -
> - page_cache_get(page);
> -
> - if (!(buf->flags & PIPE_BUF_FLAG_LRU))
> - lru_cache_add(page);
> - } else {
> -find_page:
> - page = find_lock_page(mapping, index);
> - if (!page) {
> - ret = -ENOMEM;
> - page = page_cache_alloc_cold(mapping);
> - if (unlikely(!page))
> - goto out_ret;
> -
> - /*
> - * This will also lock the page
> - */
> - ret = add_to_page_cache_lru(page, mapping, index,
> - GFP_KERNEL);
> - if (unlikely(ret))
> - goto out;
> - }
> -
> - /*
> - * We get here with the page locked. If the page is also
> - * uptodate, we don't need to do more. If it isn't, we
> - * may need to bring it in if we are not going to overwrite
> - * the full page.
> - */
> - if (!PageUptodate(page)) {
> - if (this_len < PAGE_CACHE_SIZE) {
> - ret = mapping->a_ops->readpage(file, page);
> - if (unlikely(ret))
> - goto out;
> -
> - lock_page(page);
> -
> - if (!PageUptodate(page)) {
> - /*
> - * Page got invalidated, repeat.
> - */
> - if (!page->mapping) {
> - unlock_page(page);
> - page_cache_release(page);
> - goto find_page;
> - }
> - ret = -EIO;
> - goto out;
> - }
> - } else
> - SetPageUptodate(page);
> - }
> - }
> -
> - ret = mapping->a_ops->prepare_write(file, page, offset, offset+this_len);
> - if (unlikely(ret)) {
> - loff_t isize = i_size_read(mapping->host);
> -
> - if (ret != AOP_TRUNCATED_PAGE)
> - unlock_page(page);
> - page_cache_release(page);
> - if (ret == AOP_TRUNCATED_PAGE)
> - goto find_page;
> -
> - /*
> - * prepare_write() may have instantiated a few blocks
> - * outside i_size. Trim these off again.
> - */
> - if (sd->pos + this_len > isize)
> - vmtruncate(mapping->host, isize);
> -
> - goto out_ret;
> - }
> + ret = pagecache_write_begin(file, mapping, sd->pos, sd->len, 0, &page, &fsdata);
> + if (unlikely(ret))
> + goto out;
>
> if (buf->page != page) {
> /*
> @@ -676,28 +601,13 @@ find_page:
> char *dst = kmap_atomic(page, KM_USER1);
>
> memcpy(dst + offset, src + buf->offset, this_len);
> - flush_dcache_page(page);
> kunmap_atomic(dst, KM_USER1);
> buf->ops->unmap(pipe, buf, src);
> }
>
> - ret = mapping->a_ops->commit_write(file, page, offset, offset+this_len);
> - if (!ret) {
> - /*
> - * Return the number of bytes written and mark page as
> - * accessed, we are now done!
> - */
> - ret = this_len;
> - mark_page_accessed(page);
> - balance_dirty_pages_ratelimited(mapping);
> - } else if (ret == AOP_TRUNCATED_PAGE) {
> - page_cache_release(page);
> - goto find_page;
> - }
> + ret = pagecache_write_end(file, mapping, sd->pos, sd->len, sd->len, page, fsdata);
> +
> out:
> - page_cache_release(page);
> - unlock_page(page);
> -out_ret:
> return ret;
> }
>
next prev parent reply other threads:[~2007-03-15 9:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-14 13:38 [patch 1/5] fs: add an iovec iterator Nick Piggin
2007-03-14 13:38 ` [patch 2/5] fs: introduce new aops and infrastructure Nick Piggin
2007-03-14 21:28 ` Dmitriy Monakhov
2007-03-15 3:55 ` Nick Piggin
[not found] ` <200703142246.27167.m.kozlowski@tuxland.pl>
2007-03-15 3:58 ` Nick Piggin
2007-03-15 4:13 ` Mark Fasheh
2007-03-15 4:36 ` Nick Piggin
2007-03-15 6:11 ` Mark Fasheh
2007-03-15 6:23 ` Joel Becker
2007-03-15 8:04 ` Nick Piggin
2007-03-15 16:24 ` Steven Whitehouse
2007-03-15 20:06 ` Trond Myklebust
2007-03-15 20:44 ` Mark Fasheh
2007-03-15 9:44 ` Dmitriy Monakhov [this message]
2007-03-15 10:04 ` Nick Piggin
2007-03-14 13:38 ` [patch 3/5] fs: convert some simple filesystems Nick Piggin
2007-03-14 13:38 ` [patch 4/5] ext2: convert to new aops Nick Piggin
2007-03-14 13:38 ` [patch 5/5] ext3: " Nick Piggin
2007-03-14 13:51 ` [patch 1/5] fs: add an iovec iterator 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=87bqiuzvqy.fsf@sw.ru \
--to=dmonakhov@sw.ru \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.fasheh@oracle.com \
--cc=npiggin@suse.de \
/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).