Skip to content

Commit 371d217

Browse files
jankaraJens Axboe
authored andcommitted
char: Mark /dev/zero and /dev/kmem as not capable of writeback
These devices don't do any writeback but their device inodes still can get dirty so mark bdi appropriately so that bdi code does the right thing and files inodes to lists of bdi carrying the device inodes. Cc: stable@kernel.org Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
1 parent 976e48f commit 371d217

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/char/mem.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,11 @@ static const struct file_operations zero_fops = {
788788
/*
789789
* capabilities for /dev/zero
790790
* - permits private mappings, "copies" are taken of the source of zeros
791+
* - no writeback happens
791792
*/
792793
static struct backing_dev_info zero_bdi = {
793794
.name = "char/mem",
794-
.capabilities = BDI_CAP_MAP_COPY,
795+
.capabilities = BDI_CAP_MAP_COPY | BDI_CAP_NO_ACCT_AND_WRITEBACK,
795796
};
796797

797798
static const struct file_operations full_fops = {

‎fs/char_dev.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ struct backing_dev_info directly_mappable_cdev_bdi = {
4040
#endif
4141
/* permit direct mmap, for read, write or exec */
4242
BDI_CAP_MAP_DIRECT |
43-
BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP),
43+
BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP |
44+
/* no writeback happens */
45+
BDI_CAP_NO_ACCT_AND_WRITEBACK),
4446
};
4547

4648
static struct kobj_map *cdev_map;

0 commit comments

Comments
 (0)