From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Anton Salikhmetov <salikhmetov@gmail.com>
Cc: inux-mm@kvack.org, jakob@unthought.net,
linux-kernel@vger.kernel.org, valdis.kletnieks@vt.edu,
riel@redhat.com, ksm@42.dk, staubach@redhat.com,
jesper.juhl@gmail.com, torvalds@linux-foundation.org,
akpm@linux-foundation.org, protasnb@gmail.com, miklos@szeredi.hu
Subject: Re: [PATCH 2/2] Updating ctime and mtime at syncing
Date: Tue, 15 Jan 2008 17:35:11 +0100 [thread overview]
Message-ID: <1200414911.26045.32.camel@twins> (raw)
In-Reply-To: <1200412978699-git-send-email-salikhmetov@gmail.com>
On Tue, 2008-01-15 at 19:02 +0300, Anton Salikhmetov wrote:
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 3d3848f..53d0e34 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -997,35 +997,39 @@ int __set_page_dirty_no_writeback(struct page *page)
> */
> int __set_page_dirty_nobuffers(struct page *page)
> {
> - if (!TestSetPageDirty(page)) {
> - struct address_space *mapping = page_mapping(page);
> - struct address_space *mapping2;
> + struct address_space *mapping = page_mapping(page);
> + struct address_space *mapping2;
>
> - if (!mapping)
> - return 1;
> + if (!mapping)
> + return 1;
>
> - write_lock_irq(&mapping->tree_lock);
> - mapping2 = page_mapping(page);
> - if (mapping2) { /* Race with truncate? */
> - BUG_ON(mapping2 != mapping);
> - WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
> - if (mapping_cap_account_dirty(mapping)) {
> - __inc_zone_page_state(page, NR_FILE_DIRTY);
> - __inc_bdi_stat(mapping->backing_dev_info,
> - BDI_RECLAIMABLE);
> - task_io_account_write(PAGE_CACHE_SIZE);
> - }
> - radix_tree_tag_set(&mapping->page_tree,
> - page_index(page), PAGECACHE_TAG_DIRTY);
> - }
> - write_unlock_irq(&mapping->tree_lock);
> - if (mapping->host) {
> - /* !PageAnon && !swapper_space */
> - __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
> + mapping->mtime = CURRENT_TIME;
> + set_bit(AS_MCTIME, &mapping->flags);
This seems vulnerable to the race we have against truncate, handled by
the mapping2 magic below. Do we care?
> +
> + if (TestSetPageDirty(page))
> + return 0;
> +
> + write_lock_irq(&mapping->tree_lock);
> + mapping2 = page_mapping(page);
> + if (mapping2) {
> + /* Race with truncate? */
> + BUG_ON(mapping2 != mapping);
> + WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
> + if (mapping_cap_account_dirty(mapping)) {
> + __inc_zone_page_state(page, NR_FILE_DIRTY);
> + __inc_bdi_stat(mapping->backing_dev_info,
> + BDI_RECLAIMABLE);
> + task_io_account_write(PAGE_CACHE_SIZE);
> }
> - return 1;
> + radix_tree_tag_set(&mapping->page_tree,
> + page_index(page), PAGECACHE_TAG_DIRTY);
> }
> - return 0;
> + write_unlock_irq(&mapping->tree_lock);
> +
> + if (mapping->host)
> + __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
> +
> + return 1;
> }
> EXPORT_SYMBOL(__set_page_dirty_nobuffers);
>
next prev parent reply other threads:[~2008-01-15 16:35 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-15 16:02 [PATCH 0/2] Updating ctime and mtime for memory-mapped files [try #4] Anton Salikhmetov
2008-01-15 16:02 ` [PATCH 1/2] Massive code cleanup of sys_msync() Anton Salikhmetov
2008-01-15 17:57 ` Christoph Hellwig
2008-01-15 19:02 ` Anton Salikhmetov
2008-01-15 19:10 ` Randy Dunlap
2008-01-15 19:26 ` Anton Salikhmetov
2008-01-15 19:28 ` Peter Zijlstra
2008-01-15 19:32 ` Christoph Hellwig
2008-01-15 20:12 ` Anton Salikhmetov
2008-01-15 20:46 ` Matt Mackall
2008-01-15 21:06 ` Randy Dunlap
2008-01-15 16:02 ` [PATCH 2/2] Updating ctime and mtime at syncing Anton Salikhmetov
2008-01-15 16:35 ` Peter Zijlstra [this message]
2008-01-15 17:18 ` Anton Salikhmetov
2008-01-15 19:30 ` Peter Zijlstra
2008-01-15 18:04 ` Christoph Hellwig
2008-01-15 19:04 ` Anton Salikhmetov
2008-01-15 20:27 ` [PATCH 0/2] Updating ctime and mtime for memory-mapped files [try #4] Miklos Szeredi
2008-01-15 20:32 ` Peter Zijlstra
2008-01-15 20:40 ` Miklos Szeredi
2008-01-15 22:15 ` Anton Salikhmetov
-- strict thread matches above, loose matches on Subject: below --
2008-01-13 4:39 [PATCH 0/2] yet another attempt to fix the ctime and mtime issue Anton Salikhmetov
2008-01-13 4:39 ` [PATCH 2/2] updating ctime and mtime at syncing Anton Salikhmetov
2008-01-13 4:59 ` Rik van Riel
2008-01-14 11:08 ` Miklos Szeredi
2008-01-14 11:15 ` Miklos Szeredi
2008-01-14 12:25 ` Anton Salikhmetov
2008-01-14 12:22 ` Anton Salikhmetov
2008-01-14 13:14 ` Miklos Szeredi
2008-01-14 13:35 ` Peter Zijlstra
2008-01-14 13:39 ` Peter Zijlstra
2008-01-14 13:45 ` Miklos Szeredi
2008-01-14 13:47 ` Miklos Szeredi
2008-01-14 14:17 ` Anton Salikhmetov
2008-01-15 9:53 ` Miklos Szeredi
2008-01-15 10:46 ` Anton Salikhmetov
2008-01-14 18:59 ` Anton Salikhmetov
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=1200414911.26045.32.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=inux-mm@kvack.org \
--cc=jakob@unthought.net \
--cc=jesper.juhl@gmail.com \
--cc=ksm@42.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=protasnb@gmail.com \
--cc=riel@redhat.com \
--cc=salikhmetov@gmail.com \
--cc=staubach@redhat.com \
--cc=torvalds@linux-foundation.org \
--cc=valdis.kletnieks@vt.edu \
/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