From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@fb.com>
Cc: David Howells <dhowells@redhat.com>, Tejun Heo <tj@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-mtd@lists.infradead.org, linux-nfs@vger.kernel.org,
ceph-devel@vger.kernel.org
Subject: [PATCH 02/12] fs: kill BDI_CAP_SWAP_BACKED
Date: Thu, 8 Jan 2015 18:45:23 +0100 [thread overview]
Message-ID: <1420739133-27514-3-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1420739133-27514-1-git-send-email-hch@lst.de>
This bdi flag isn't too useful - we can determine that a vma is backed by
either swap or shmem trivially in the caller.
This also allows removing the backing_dev_info instaces for swap and shmem
in favor of noop_backing_dev_info.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/backing-dev.h | 13 -------------
mm/madvise.c | 19 +++++++++++--------
mm/shmem.c | 25 +++++++------------------
mm/swap.c | 2 --
mm/swap_state.c | 7 +------
5 files changed, 19 insertions(+), 47 deletions(-)
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index 5da6012..e936cea 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -238,8 +238,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
* BDI_CAP_WRITE_MAP: Can be mapped for writing
* BDI_CAP_EXEC_MAP: Can be mapped for execution
*
- * BDI_CAP_SWAP_BACKED: Count shmem/tmpfs objects as swap-backed.
- *
* BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
*/
#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
@@ -250,7 +248,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
#define BDI_CAP_WRITE_MAP 0x00000020
#define BDI_CAP_EXEC_MAP 0x00000040
#define BDI_CAP_NO_ACCT_WB 0x00000080
-#define BDI_CAP_SWAP_BACKED 0x00000100
#define BDI_CAP_STABLE_WRITES 0x00000200
#define BDI_CAP_STRICTLIMIT 0x00000400
@@ -329,11 +326,6 @@ static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
BDI_CAP_NO_WRITEBACK));
}
-static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
-{
- return bdi->capabilities & BDI_CAP_SWAP_BACKED;
-}
-
static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
{
return bdi_cap_writeback_dirty(mapping->backing_dev_info);
@@ -344,11 +336,6 @@ static inline bool mapping_cap_account_dirty(struct address_space *mapping)
return bdi_cap_account_dirty(mapping->backing_dev_info);
}
-static inline bool mapping_cap_swap_backed(struct address_space *mapping)
-{
- return bdi_cap_swap_backed(mapping->backing_dev_info);
-}
-
static inline int bdi_sched_wait(void *word)
{
schedule();
diff --git a/mm/madvise.c b/mm/madvise.c
index a271adc..073b41a 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -222,19 +222,22 @@ static long madvise_willneed(struct vm_area_struct *vma,
struct file *file = vma->vm_file;
#ifdef CONFIG_SWAP
- if (!file || mapping_cap_swap_backed(file->f_mapping)) {
+ if (!file) {
*prev = vma;
- if (!file)
- force_swapin_readahead(vma, start, end);
- else
- force_shm_swapin_readahead(vma, start, end,
- file->f_mapping);
+ force_swapin_readahead(vma, start, end);
return 0;
}
-#endif
-
+
+ if (shmem_mapping(file->f_mapping)) {
+ *prev = vma;
+ force_shm_swapin_readahead(vma, start, end,
+ file->f_mapping);
+ return 0;
+ }
+#else
if (!file)
return -EBADF;
+#endif
if (file->f_mapping->a_ops->get_xip_mem) {
/* no bad return value, but ignore advice */
diff --git a/mm/shmem.c b/mm/shmem.c
index 73ba1df..1b77eaf 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -191,11 +191,6 @@ static const struct inode_operations shmem_dir_inode_operations;
static const struct inode_operations shmem_special_inode_operations;
static const struct vm_operations_struct shmem_vm_ops;
-static struct backing_dev_info shmem_backing_dev_info __read_mostly = {
- .ra_pages = 0, /* No readahead */
- .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED,
-};
-
static LIST_HEAD(shmem_swaplist);
static DEFINE_MUTEX(shmem_swaplist_mutex);
@@ -765,11 +760,11 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
goto redirty;
/*
- * shmem_backing_dev_info's capabilities prevent regular writeback or
- * sync from ever calling shmem_writepage; but a stacking filesystem
- * might use ->writepage of its underlying filesystem, in which case
- * tmpfs should write out to swap only in response to memory pressure,
- * and not for the writeback threads or sync.
+ * Our capabilities prevent regular writeback or sync from ever calling
+ * shmem_writepage; but a stacking filesystem might use ->writepage of
+ * its underlying filesystem, in which case tmpfs should write out to
+ * swap only in response to memory pressure, and not for the writeback
+ * threads or sync.
*/
if (!wbc->for_reclaim) {
WARN_ON_ONCE(1); /* Still happens? Tell us about it! */
@@ -1415,7 +1410,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
inode->i_ino = get_next_ino();
inode_init_owner(inode, dir, mode);
inode->i_blocks = 0;
- inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
+ inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
inode->i_generation = get_seconds();
info = SHMEM_I(inode);
@@ -1461,7 +1456,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
bool shmem_mapping(struct address_space *mapping)
{
- return mapping->backing_dev_info == &shmem_backing_dev_info;
+ return mapping->host->i_sb->s_op == &shmem_ops;
}
#ifdef CONFIG_TMPFS
@@ -3226,10 +3221,6 @@ int __init shmem_init(void)
if (shmem_inode_cachep)
return 0;
- error = bdi_init(&shmem_backing_dev_info);
- if (error)
- goto out4;
-
error = shmem_init_inodecache();
if (error)
goto out3;
@@ -3253,8 +3244,6 @@ out1:
out2:
shmem_destroy_inodecache();
out3:
- bdi_destroy(&shmem_backing_dev_info);
-out4:
shm_mnt = ERR_PTR(error);
return error;
}
diff --git a/mm/swap.c b/mm/swap.c
index 8a12b33..4e0109a 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -1138,8 +1138,6 @@ void __init swap_setup(void)
#ifdef CONFIG_SWAP
int i;
- if (bdi_init(swapper_spaces[0].backing_dev_info))
- panic("Failed to init swap bdi");
for (i = 0; i < MAX_SWAPFILES; i++) {
spin_lock_init(&swapper_spaces[i].tree_lock);
INIT_LIST_HEAD(&swapper_spaces[i].i_mmap_nonlinear);
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 9711342..1c137b6 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -32,17 +32,12 @@ static const struct address_space_operations swap_aops = {
#endif
};
-static struct backing_dev_info swap_backing_dev_info = {
- .name = "swap",
- .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED,
-};
-
struct address_space swapper_spaces[MAX_SWAPFILES] = {
[0 ... MAX_SWAPFILES - 1] = {
.page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN),
.i_mmap_writable = ATOMIC_INIT(0),
.a_ops = &swap_aops,
- .backing_dev_info = &swap_backing_dev_info,
+ .backing_dev_info = &noop_backing_dev_info,
}
};
--
1.9.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-01-08 17:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-08 17:45 backing_dev_info cleanups & lifetime rule fixes Christoph Hellwig
2015-01-08 17:45 ` [PATCH 01/12] fs: deduplicate noop_backing_dev_info Christoph Hellwig
2015-01-11 17:00 ` Tejun Heo
2015-01-08 17:45 ` Christoph Hellwig [this message]
2015-01-11 17:05 ` [PATCH 02/12] fs: kill BDI_CAP_SWAP_BACKED Tejun Heo
2015-01-08 17:45 ` [PATCH 03/12] fs: introduce f_op->mmap_capabilities for nommu mmap support Christoph Hellwig
2015-01-11 17:24 ` Tejun Heo
2015-01-08 17:45 ` [PATCH 04/12] block_dev: only write bdev inode on close Christoph Hellwig
2015-01-11 17:32 ` Tejun Heo
2015-01-12 12:33 ` Christoph Hellwig
[not found] ` <1420739133-27514-1-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-08 17:45 ` [PATCH 05/12] block_dev: get bdev inode bdi directly from the block device Christoph Hellwig
2015-01-11 17:40 ` Tejun Heo
2015-01-08 17:45 ` [PATCH 09/12] ceph: remove call to bdi_unregister Christoph Hellwig
2015-01-08 17:45 ` [PATCH 06/12] nilfs2: set up s_bdi like the generic mount_bdev code Christoph Hellwig
2015-01-11 17:41 ` Tejun Heo
2015-01-08 17:45 ` [PATCH 07/12] fs: export inode_to_bdi and use it in favor of mapping->backing_dev_info Christoph Hellwig
[not found] ` <1420739133-27514-8-git-send-email-hch-jcswGhMUV9g@public.gmane.org>
2015-01-11 18:16 ` Tejun Heo
2015-01-12 12:36 ` Christoph Hellwig
2015-01-08 17:45 ` [PATCH 08/12] fs: remove mapping->backing_dev_info Christoph Hellwig
2015-01-11 18:20 ` Tejun Heo
2015-01-08 17:45 ` [PATCH 10/12] nfs: don't call bdi_unregister Christoph Hellwig
2015-01-08 17:45 ` [PATCH 11/12] fs: don't reassign dirty inodes to default_backing_dev_info Christoph Hellwig
2015-01-11 18:33 ` Tejun Heo
2015-01-08 17:45 ` [PATCH 12/12] fs: remove default_backing_dev_info Christoph Hellwig
2015-01-11 18:39 ` Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2015-01-14 9:42 backing_dev_info cleanups & lifetime rule fixes V2 Christoph Hellwig
2015-01-14 9:42 ` [PATCH 02/12] fs: kill BDI_CAP_SWAP_BACKED Christoph Hellwig
2015-01-14 12:47 ` Jan Kara
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=1420739133-27514-3-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@fb.com \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=tj@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).