All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Dmitriy Monakhov <dmonakhov@openvz.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: nobh_truncate_page question
Date: Wed, 7 Feb 2007 18:11:03 -0800	[thread overview]
Message-ID: <20070207181103.b24923f5.akpm@linux-foundation.org> (raw)
In-Reply-To: <87iredh9jd.fsf@sw.ru>

On Thu, 08 Feb 2007 01:45:10 +0300
Dmitriy Monakhov <dmonakhov@openvz.org> wrote:

> Could some one please explain me what's happens with nobh_truncate_page?
> 
> int nobh_truncate_page(struct address_space *mapping, loff_t from)
> {
> ........
>  if ((offset & (blocksize - 1)) == 0)
>                 goto out;
> 
>         ret = -ENOMEM;
>         page = grab_cache_page(mapping, index);
>         if (!page)
>                 goto out;
> 
>         to = (offset + blocksize) & ~(blocksize - 1);
>         ret = a_ops->prepare_write(NULL, page, offset, to);
> <<<<< This prepare_write() not balanced by appropriate commit_write()
> <<<<< Currently this not is fatal because this function used only
> <<<<< by ext2 and jfs witch  unbalanced prepare/commit operations
> <<<<< not painful.  

See that comment at the top of nobh_truncate_page()?

>         if (ret == 0) {
>                 kaddr = kmap_atomic(page, KM_USER0);
>                 memset(kaddr + offset, 0, PAGE_CACHE_SIZE - offset);
>                 flush_dcache_page(page);
>                 kunmap_atomic(kaddr, KM_USER0);
>                 set_page_dirty(page);
>         }
>         unlock_page(page);
>         page_cache_release(page);
> out:
>         return ret;
> }
> 
> But we can't just call commit_write after all job done because this result in
> i_size increasing till block end. Where are two possible solutions:
> a) Call ->commit_write() and then restore i_size to old value.
> b) Leave code as it is now, but add warning comment about prepare/commit
>    balance violation.

It just happens that nobh_prepare_write() does all the things which
nobh_truncate_page() wants done.

If you need to change nobh_prepare_write(), you'll need to change
nobh_truncate_page().

Or something.  You haven't told us what you're trying to do.

      reply	other threads:[~2007-02-08  2:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-07 22:45 nobh_truncate_page question Dmitriy Monakhov
2007-02-08  2:11 ` Andrew Morton [this message]

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=20070207181103.b24923f5.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dmonakhov@openvz.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.