From: hujianyang <hujianyang@huawei.com>
To: Artem Bityutskiy <dedekind1@gmail.com>, <adrian.hunter@intel.com>
Cc: Laurence Withers <lwithers@guralp.com>,
linux-mtd <linux-mtd@lists.infradead.org>
Subject: [PATCH v2] UBIFS: Fix assert failed in ubifs_set_page_dirty
Date: Wed, 30 Apr 2014 14:06:06 +0800 [thread overview]
Message-ID: <536092CE.2090209@huawei.com> (raw)
In-Reply-To: <535B7B96.9030008@huawei.com>
Hi, all
Basing on the perious mail, I would like to show a clear figure
about the race I have found.
Thread A (mmap) Thread B (fsync)
->__do_fault ->write_cache_pages
-> ubifs_page_mkwrite
-> budget_space
-> lock_page
-> release/convert_page_budget
-> SetPagePrivate
-> TestSetPageDirty
-> unlock_page
-> lock_page
-> TestClearPageDirty
-> ubifs_writepage
-> do_writepage
-> release_budget
-> ClearPagePrivate
-> unlock_page
-> !(ret & VM_FAULT_LOCKED)
-> lock_page
-> set_page_dirty
-> ubifs_set_page_dirty
-> TestSetPageDirty (set page dirty without budgeting)
-> unlock_page
According to this situation, my v2 fix returns from page_mkwrite
without performing unlock_page. We return VM_FAULT_LOCKED instead
of just return 0. After doing this, the race above will not happen.
Signed-off-by: hujianyang <hujianyang@huawei.com>
---
fs/ubifs/file.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 4f34dba..f7d48a0 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1525,8 +1525,7 @@ static int ubifs_vm_page_mkwrite(struct vm_area_struct *vma,
}
wait_for_stable_page(page);
- unlock_page(page);
- return 0;
+ return VM_FAULT_LOCKED;
out_unlock:
unlock_page(page);
--
1.8.5.5
next prev parent reply other threads:[~2014-04-30 6:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-26 9:25 [PATCH RFC] UBIFS: Fix assert failed in ubifs_set_page_dirty hujianyang
2014-04-30 6:06 ` hujianyang [this message]
2014-04-30 12:18 ` [PATCH v2] " Laurence Withers
2014-04-30 13:48 ` Dolev Raviv
2014-05-04 6:38 ` hujianyang
2014-05-04 11:54 ` Dolev Raviv
2014-05-05 7:07 ` Artem Bityutskiy
2014-05-05 11:50 ` Laurence Withers
2014-05-05 7:02 ` Artem Bityutskiy
2014-05-05 7:16 ` Artem Bityutskiy
2014-05-05 7:30 ` hujianyang
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=536092CE.2090209@huawei.com \
--to=hujianyang@huawei.com \
--cc=adrian.hunter@intel.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
--cc=lwithers@guralp.com \
/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.