Skip to content

Commit 97b713b

Browse files
Christoph Hellwigaxboe
Christoph Hellwig
authored andcommitted
fs: kill BDI_CAP_SWAP_BACKED
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 <[email protected]> Reviewed-by: Tejun Heo <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent a7a2c68 commit 97b713b

File tree

5 files changed

+18
-46
lines changed

5 files changed

+18
-46
lines changed

include/linux/backing-dev.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
238238
* BDI_CAP_WRITE_MAP: Can be mapped for writing
239239
* BDI_CAP_EXEC_MAP: Can be mapped for execution
240240
*
241-
* BDI_CAP_SWAP_BACKED: Count shmem/tmpfs objects as swap-backed.
242-
*
243241
* BDI_CAP_STRICTLIMIT: Keep number of dirty pages below bdi threshold.
244242
*/
245243
#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);
250248
#define BDI_CAP_WRITE_MAP 0x00000020
251249
#define BDI_CAP_EXEC_MAP 0x00000040
252250
#define BDI_CAP_NO_ACCT_WB 0x00000080
253-
#define BDI_CAP_SWAP_BACKED 0x00000100
254251
#define BDI_CAP_STABLE_WRITES 0x00000200
255252
#define BDI_CAP_STRICTLIMIT 0x00000400
256253

@@ -329,11 +326,6 @@ static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
329326
BDI_CAP_NO_WRITEBACK));
330327
}
331328

332-
static inline bool bdi_cap_swap_backed(struct backing_dev_info *bdi)
333-
{
334-
return bdi->capabilities & BDI_CAP_SWAP_BACKED;
335-
}
336-
337329
static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
338330
{
339331
return bdi_cap_writeback_dirty(mapping->backing_dev_info);
@@ -344,11 +336,6 @@ static inline bool mapping_cap_account_dirty(struct address_space *mapping)
344336
return bdi_cap_account_dirty(mapping->backing_dev_info);
345337
}
346338

347-
static inline bool mapping_cap_swap_backed(struct address_space *mapping)
348-
{
349-
return bdi_cap_swap_backed(mapping->backing_dev_info);
350-
}
351-
352339
static inline int bdi_sched_wait(void *word)
353340
{
354341
schedule();

mm/madvise.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,22 @@ static long madvise_willneed(struct vm_area_struct *vma,
222222
struct file *file = vma->vm_file;
223223

224224
#ifdef CONFIG_SWAP
225-
if (!file || mapping_cap_swap_backed(file->f_mapping)) {
225+
if (!file) {
226226
*prev = vma;
227-
if (!file)
228-
force_swapin_readahead(vma, start, end);
229-
else
230-
force_shm_swapin_readahead(vma, start, end,
231-
file->f_mapping);
227+
force_swapin_readahead(vma, start, end);
232228
return 0;
233229
}
234-
#endif
235230

231+
if (shmem_mapping(file->f_mapping)) {
232+
*prev = vma;
233+
force_shm_swapin_readahead(vma, start, end,
234+
file->f_mapping);
235+
return 0;
236+
}
237+
#else
236238
if (!file)
237239
return -EBADF;
240+
#endif
238241

239242
if (file->f_mapping->a_ops->get_xip_mem) {
240243
/* no bad return value, but ignore advice */

mm/shmem.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ static const struct inode_operations shmem_dir_inode_operations;
191191
static const struct inode_operations shmem_special_inode_operations;
192192
static const struct vm_operations_struct shmem_vm_ops;
193193

194-
static struct backing_dev_info shmem_backing_dev_info __read_mostly = {
195-
.ra_pages = 0, /* No readahead */
196-
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED,
197-
};
198-
199194
static LIST_HEAD(shmem_swaplist);
200195
static DEFINE_MUTEX(shmem_swaplist_mutex);
201196

@@ -765,11 +760,11 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
765760
goto redirty;
766761

767762
/*
768-
* shmem_backing_dev_info's capabilities prevent regular writeback or
769-
* sync from ever calling shmem_writepage; but a stacking filesystem
770-
* might use ->writepage of its underlying filesystem, in which case
771-
* tmpfs should write out to swap only in response to memory pressure,
772-
* and not for the writeback threads or sync.
763+
* Our capabilities prevent regular writeback or sync from ever calling
764+
* shmem_writepage; but a stacking filesystem might use ->writepage of
765+
* its underlying filesystem, in which case tmpfs should write out to
766+
* swap only in response to memory pressure, and not for the writeback
767+
* threads or sync.
773768
*/
774769
if (!wbc->for_reclaim) {
775770
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
14151410
inode->i_ino = get_next_ino();
14161411
inode_init_owner(inode, dir, mode);
14171412
inode->i_blocks = 0;
1418-
inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
1413+
inode->i_mapping->backing_dev_info = &noop_backing_dev_info;
14191414
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
14201415
inode->i_generation = get_seconds();
14211416
info = SHMEM_I(inode);
@@ -1461,7 +1456,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
14611456

14621457
bool shmem_mapping(struct address_space *mapping)
14631458
{
1464-
return mapping->backing_dev_info == &shmem_backing_dev_info;
1459+
return mapping->host->i_sb->s_op == &shmem_ops;
14651460
}
14661461

14671462
#ifdef CONFIG_TMPFS
@@ -3226,10 +3221,6 @@ int __init shmem_init(void)
32263221
if (shmem_inode_cachep)
32273222
return 0;
32283223

3229-
error = bdi_init(&shmem_backing_dev_info);
3230-
if (error)
3231-
goto out4;
3232-
32333224
error = shmem_init_inodecache();
32343225
if (error)
32353226
goto out3;
@@ -3253,8 +3244,6 @@ int __init shmem_init(void)
32533244
out2:
32543245
shmem_destroy_inodecache();
32553246
out3:
3256-
bdi_destroy(&shmem_backing_dev_info);
3257-
out4:
32583247
shm_mnt = ERR_PTR(error);
32593248
return error;
32603249
}

mm/swap.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,6 @@ void __init swap_setup(void)
11381138
#ifdef CONFIG_SWAP
11391139
int i;
11401140

1141-
if (bdi_init(swapper_spaces[0].backing_dev_info))
1142-
panic("Failed to init swap bdi");
11431141
for (i = 0; i < MAX_SWAPFILES; i++) {
11441142
spin_lock_init(&swapper_spaces[i].tree_lock);
11451143
INIT_LIST_HEAD(&swapper_spaces[i].i_mmap_nonlinear);

mm/swap_state.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,12 @@ static const struct address_space_operations swap_aops = {
3232
#endif
3333
};
3434

35-
static struct backing_dev_info swap_backing_dev_info = {
36-
.name = "swap",
37-
.capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK | BDI_CAP_SWAP_BACKED,
38-
};
39-
4035
struct address_space swapper_spaces[MAX_SWAPFILES] = {
4136
[0 ... MAX_SWAPFILES - 1] = {
4237
.page_tree = RADIX_TREE_INIT(GFP_ATOMIC|__GFP_NOWARN),
4338
.i_mmap_writable = ATOMIC_INIT(0),
4439
.a_ops = &swap_aops,
45-
.backing_dev_info = &swap_backing_dev_info,
40+
.backing_dev_info = &noop_backing_dev_info,
4641
}
4742
};
4843

0 commit comments

Comments
 (0)