linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhangjun <openzhangj@gmail.com>
To: Richard Weinberger <richard@nod.at>, linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	hsiangkao@mail.ru, kirill.shutemov@linux.intel.com,
	stable@vger.kernel.org
Subject: Re: [PATCH] ubifs: Get/put page when changing PG_private
Date: Sun, 16 Dec 2018 04:38:42 +0800	[thread overview]
Message-ID: <9d539def-2042-9a2e-1251-c3f03d3d616c@gmail.com> (raw)
In-Reply-To: <20181215150130.19381-1-richard@nod.at>

On 2018/12/15 下午11:01, Richard Weinberger wrote:
> The page migration code assumes that a page with PG_private
> set has its page count elevated by 1.
> UBIFS never did this and therefore the migration code was unable
> to migrate some pages owned by UBIFS.
> The lead to situations where the CMA memory allocator failed to
> allocate memory.
>
> Fix this by using get/put_page when changing PG_private.
>
> Cc: <stable@vger.kernel.org>
> Cc: zhangjun <openzhangj@gmail.com>
> Fixes: 4ac1c17b2044 ("UBIFS: Implement ->migratepage()")
> Reported-by: zhangjun <openzhangj@gmail.com>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> zhangjun,
>
> Please give this patch a try!
>
> Thanks,
> //richard
> ---
>   fs/ubifs/file.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 1b78f2e09218..abe940d0767c 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -582,6 +582,7 @@ static int ubifs_write_end(struct file *file, struct address_space *mapping,
>   	}
>   
>   	if (!PagePrivate(page)) {
> +		get_page(page);
>   		SetPagePrivate(page);
>   		atomic_long_inc(&c->dirty_pg_cnt);
>   		__set_page_dirty_nobuffers(page);
> @@ -959,6 +960,7 @@ static int do_writepage(struct page *page, int len)
>   	atomic_long_dec(&c->dirty_pg_cnt);
>   	ClearPagePrivate(page);
>   	ClearPageChecked(page);
> +	put_page(page);
>   
>   	kunmap(page);
>   	unlock_page(page);
> @@ -1318,6 +1320,7 @@ static void ubifs_invalidatepage(struct page *page, unsigned int offset,
>   	atomic_long_dec(&c->dirty_pg_cnt);
>   	ClearPagePrivate(page);
>   	ClearPageChecked(page);
> +	put_page(page);
>   }
>   
>   int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
> @@ -1487,6 +1490,8 @@ static int ubifs_migrate_page(struct address_space *mapping,
>   
>   	if (PagePrivate(page)) {
>   		ClearPagePrivate(page);
> +		put_page(page);
> +		get_page(newpage);
>   		SetPagePrivate(newpage);
>   	}
>   
> @@ -1513,6 +1518,7 @@ static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags)
>   	ubifs_assert(c, 0);
>   	ClearPagePrivate(page);
>   	ClearPageChecked(page);
> +	put_page(page);
>   	return 1;
>   }
>   
> @@ -1582,6 +1588,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
>   	else {
>   		if (!PageChecked(page))
>   			ubifs_convert_page_budget(c);
> +		get_page(page);
>   		SetPagePrivate(page);
>   		atomic_long_inc(&c->dirty_pg_cnt);
>   		__set_page_dirty_nobuffers(page);

Hello Richard

After adding your patch,my test did not go wrong.
I think it is ok now.

thanks
//zhangjun

  reply	other threads:[~2018-12-15 20:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-15 15:01 [PATCH] ubifs: Get/put page when changing PG_private Richard Weinberger
2018-12-15 20:38 ` zhangjun [this message]
2018-12-17 10:59 ` Kirill A. Shutemov
2018-12-17 11:32   ` Richard Weinberger
2018-12-21  8:56 ` Richard Weinberger
2018-12-21 10:35   ` Kirill A. Shutemov
2018-12-25  2:42   ` zhangjun
2018-12-25 21:08     ` Richard Weinberger

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=9d539def-2042-9a2e-1251-c3f03d3d616c@gmail.com \
    --to=openzhangj@gmail.com \
    --cc=hsiangkao@mail.ru \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=stable@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).