From: Jan Kara <jack@suse.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] fs: Move check for mappings without pages from iterate_bdevs()
Date: Thu, 27 Sep 2012 14:39:21 +0200 [thread overview]
Message-ID: <1348749561-10115-3-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1348749561-10115-1-git-send-email-jack@suse.cz>
Currently, iterate_bdevs() skips block devices without any pages in page
cache. That is fine for current use by sync(2) but may be rather surprising
for possible future users. So move the checks from iterate_bdevs() to
callback functions used by sync(2).
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/block_dev.c | 3 +--
fs/sync.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 220391c..ad31709 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1727,8 +1727,7 @@ void iterate_bdevs(void (*func)(struct block_device *, void *), void *arg)
* With i_lock we can safely check bdev isn't freeing and
* grab our reference.
*/
- if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW) ||
- inode->i_mapping->nrpages == 0) {
+ if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) {
spin_unlock(&inode->i_lock);
continue;
}
diff --git a/fs/sync.c b/fs/sync.c
index eb8722d..536a272 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -81,12 +81,20 @@ static void sync_fs_one_sb(struct super_block *sb, void *arg)
static void fdatawrite_one_bdev(struct block_device *bdev, void *arg)
{
- filemap_fdatawrite(bdev->bd_inode->i_mapping);
+ struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+ if (mapping->nrpages == 0)
+ return;
+ filemap_fdatawrite(mapping);
}
static void fdatawait_one_bdev(struct block_device *bdev, void *arg)
{
- filemap_fdatawait(bdev->bd_inode->i_mapping);
+ struct address_space *mapping = bdev->bd_inode->i_mapping;
+
+ if (mapping->nrpages == 0)
+ return;
+ filemap_fdatawait(mapping);
}
/*
--
1.7.1
prev parent reply other threads:[~2012-09-27 12:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-27 12:39 [PATCH 0/2] iterate_bdevs() cleanups Jan Kara
2012-09-27 12:39 ` [PATCH 1/2] fs: Change iterate_bdevs() to iterate over all_bdevs list instead of blockdev_superblock Jan Kara
2012-09-27 12:39 ` Jan Kara [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=1348749561-10115-3-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).